sipeed / LicheeRV-Nano-Build

LicheeRV-Nano-Build
110 stars 41 forks source link

Can only boot once with licheervnano-alpine-musl-openrc-20240206-0802.img #5

Open smartass opened 9 months ago

smartass commented 9 months ago

I am using licheervnano-alpine-musl-openrc-20240206-0802.img on LicheeRV-Nano-E. It boots okay when I flash the sdcard, but after reboot or poweroff it fails to start up again.

I don't possess a serial cable, so it's hard to debug this. However, after looking at the image I discovered that /etc/local.d/aaa_boot_setup.start runs

cp -arv /mnt/etc/* /etc/
rm -rf /mnt/etc/*
/etc/init.d/S01modload start
/etc/init.d/S04usbdev start

I then started moving the files from /mnt/etc to /etc one by one and rebooting until I was able to reproduce the problem. I believe the culprit is mnt/etc/inittab.

I can fix this myself, but I thought to let you know about this problem. Please let me know if you need any help -- I really like this SBC and I would love to help out with code, documentation, testing, whatever.

zhoujustin commented 9 months ago

I also found this problems. The sulotion is add

::sysinit:/sbin/openrc sysinit ::sysinit:/sbin/openrc boot ::wait:/sbin/openrc default

after the comment Startup the system. Good luck!

smartass commented 9 months ago

@zhoujustin Thanks, but that's not enough -- none of the S01modload / S02hostname / S03ethmac / S04usbdev services will be started even if you update inittab as you suggest. It won't give you any benefits over the default, working /etc/inittab file.

The bigger issue is that /mnt/etc/init.d/S01modload and the rest are SysV init scripts. Alpine Linux uses OpenRC (openrc is even mentioned in the image filename). For OpenRC to start any of these services, they must look like this:

licheervnano:~# cat /etc/init.d/S02lo
#!/sbin/openrc-run

start() {
    printf "start loopback: "
    ifconfig lo up
    ifconfig lo 127.0.0.1
    echo "OK"
}

stop() {
    ifconfig lo down
}

Note the different shebang plus the mandatory start() function.

Currently even after the files get moved from /mnt/etc/init.d/ to /etc/init.d/, they won't be started no matter which run level you add them to.

Moreover, /sys should be mounted for S02hostname and others to work at all.

Here's a working /etc/inittab:

::sysinit:/bin/mount -a
::sysinit:/bin/mount -o remount,rw /
::sysinit:/sbin/swapon -a
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -t sysfs sysfs /sys

::sysinit:/sbin/openrc sysinit
::sysinit:/sbin/openrc boot
::wait:/sbin/openrc default

# https://patchwork.ozlabs.org/project/buildroot/patch/20180404180935.15185-2-joerg.krause@embedded.rocks/
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

console::respawn:/sbin/getty -L console 115200 vt100
ttyGS0::respawn:/sbin/getty -L ttyGS0 115200 vt100

::shutdown:/sbin/openrc shutdown

I am surprised the licheervnano-alpine-musl-openrc-20240206-0802.img image was published at all -- I don't think it's ready for most users.

zhoujustin commented 9 months ago

@zhoujustin Thanks, but that's not enough -- none of the S01modload / S02hostname / S03ethmac / S04usbdev services will be started even if you update inittab as you suggest. It won't give you any benefits over the default, working /etc/inittab file.

The bigger issue is that /mnt/etc/init.d/S01modload and the rest are SysV init scripts. Alpine Linux uses OpenRC (openrc is even mentioned in the image filename). For OpenRC to start any of these services, they must look like this:

licheervnano:~# cat /etc/init.d/S02lo
#!/sbin/openrc-run

start() {
    printf "start loopback: "
    ifconfig lo up
    ifconfig lo 127.0.0.1
    echo "OK"
}

stop() {
    ifconfig lo down
}

Note the different shebang plus the mandatory start() function.

Currently even after the files get moved from /mnt/etc/init.d/ to /etc/init.d/, they won't be started no matter which run level you add them to.

Moreover, /sys should be mounted for S02hostname and others to work at all.

Here's a working /etc/inittab:

::sysinit:/bin/mount -a
::sysinit:/bin/mount -o remount,rw /
::sysinit:/sbin/swapon -a
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -t sysfs sysfs /sys

::sysinit:/sbin/openrc sysinit
::sysinit:/sbin/openrc boot
::wait:/sbin/openrc default

# https://patchwork.ozlabs.org/project/buildroot/patch/20180404180935.15185-2-joerg.krause@embedded.rocks/
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

console::respawn:/sbin/getty -L console 115200 vt100
ttyGS0::respawn:/sbin/getty -L ttyGS0 115200 vt100

::shutdown:/sbin/openrc shutdown

I am surprised the licheervnano-alpine-musl-openrc-20240206-0802.img image was published at all -- I don't think it's ready for most users.

I think it's a demo version. The openrc managed the wlan0 by networking service, So the file S02lo was not importent! I solve the reboot issue by add the content as I mentioned! And rc-update del networking and readd the networking by rc-update -u add networking. The WiFi can configed on the boot. Mentioned the option -u, It will be redepend the relationship of the serivces.

wtarreau commented 9 months ago

Same here, the default provided image from 20240226 boots, gets an IP address and responds to ping, but doesn' t have sshd running nor a tty enabled. I'm surprised such a totally useless image was released at all!

wtarreau commented 9 months ago

Ah, and since the config is provided in a squashfs, you can't even easily adjust it without extracting, modifying, regenerating.