1#!/bin/sh
2
3# This script replaces the default busybox init process to avoid having that
4# process staying alive and sleeping in the background, (uselessly) consuming
5# precious memory.
6
7# Mount procfs and sysfs
8/bin/mount -t proc proc /proc
9/bin/mount -t sysfs sysfs /sys
10
11# When the kernel is directly booted, devtmpfs is not automatically mounted.
12# Manually mount it if needed.
13devmnt=$(mount | grep -c devtmpfs)
14if [ ${devmnt} -eq 0 ]; then
15    /bin/mount -t devtmpfs devtmpfs /dev
16fi
17
18# Use the /dev/console device node from devtmpfs if possible to not
19# confuse glibc's ttyname_r().
20# This may fail (E.G. booted with console=), and errors from exec will
21# terminate the shell, so use a subshell for the test
22if (exec 0</dev/console) 2>/dev/null; then
23    exec 0</dev/console
24    exec 1>/dev/console
25    exec 2>/dev/console
26fi
27
28# Clear memory to reduce page fragmentation
29echo 3 > /proc/sys/vm/drop_caches
30
31# Print a fun logo :)
32echo "          __  _"
33echo "         / / (_) ____   _   _ __  __"
34echo "        / /  | ||  _ \\ | | | |\\ \\/ /"
35echo "       / /___| || | | || |_| | >  < "
36echo "      /_____/|_||_| |_| \\____|/_/\\_\\"
37echo "    64-bits RISC-V Kendryte K210 NOMMU"
38echo ""
39
40# Finally, let's start an interactive shell
41exec /bin/sh
42