Repository navigation
Fix boot and shutdown issues on a Miyoo Flip with BaseOS/Add BaseOS support to Flip - #1881
Conversation
|
We don't officially support BaseOS, but I have been looking into adding it. I'll take a look at this. |
|
Thanks. For context, only one of the three fixes is BaseOS-specific. The swap fix applies to all devices, the card left dirty on each device, BaseOS just began to check it on start so it became hard to ignore. The chroot mount_muOS.sh fails on Miyoo Flip stock too. Only the overlay image rebuild is BaseOS-related. Maybe it is better to split the PR, i just found them all while searching the issue with 'repairing cd' and thought to submit them together. |
|
if something ends up being Spruce-specific we can probably merge. Worst case I'll just ask you to split it to a separate PR later. |
|
I can split them now and keep only the BaseOS-specific fix in this PR, so the common fixes are not blocked. The more I think about it, the more logical that seems. |
|
I might just push everything here together - as long as the commits are separate it's easy to tell what is what |
|
Yes, the commits are fully separate and each message describes what it does. I also commented the less obvious things in the code. |
|
Hardware notes from testing this PR on a Miyoo Flip running BaseOS-my355 1.1.0 (two cards), a stock Flip, and an RG35XX SP on BaseOS 1.4.0. The PR's three commits were tested on top of a local branch that adds the rest of the BaseOS support (rebased on Development e06f4b3). Each shutdown below went through spruce's own reboot ( This PR's commits
Found along the way (coming as separate commits on top)
For BaseOS-my355 (@apommel), optional, since spruce now shields its session
|
Moved from AnbernicXXCommon.sh to utils/baseos_session_shield.sh; it now takes the inittab session path. The XX shim it writes is byte-identical.
Flip.cfg flags BaseOS and reads the card from /proc/mounts (mmcblk1p1 is U-Boot there); skip vendor fw/UI/services; shield frontend-session twice.
The Flip uses Flip.cfg's SD_DEV, not mmcblk1p1 (BaseOS U-Boot); an empty device now means unsupported instead of a grep that matches every mount.
BaseOS 1.3.0 renamed /sbin/nextui-session to /sbin/frontend-session, so the shutdown shield matched nothing on current images; shield both names.
Strict path: unmount by mountinfo parentage incl. card-backed loops, detach them, catch mappings by device, and re-run under a static busybox if the shell maps the card.
A failed clean umount listed no holder on the XX line; the errno says why.
Strict path: this process's own card fds are closed (10 and up included), process roots are swept, and the dump names stage 2 itself and processes stuck exiting.
bind_glibc.sh and bind-new-libmali.sh bind only over names that exist (BaseOS-my355 lacks libanl.so.1, among others) and log the skipped names on one line.
baseos_fw_needs_update serves XX and the BaseOS Flip; each cfg names its BaseOS project. The updater takes any BaseOS device, and checks a release without SHA256SUMS by GitHub's digest.
On the BaseOS Flip even a static /bin/sh runs out of the /usr overlay whose upper is a card loop (loop2 pinned in V1/V2). The failure dump now lists every live process with exe and cwd.
busybox takes its applet from argv[1] only when named busybox, so the stage-2 re-run never fired (V2b). The shim now runs and sleeps from /tmp too: started from /usr it pinned the overlay.
The strict sweep matched only paths under "$SD_MOUNTPOINT/", so a daemon with cwd exactly at the mount point survived and kept it busy (XX X4, Flip V3b). The dump skips kernel threads.
Stock Flip: /data -> userdata, a card bind, so stage 2 logged onto the card and pinned it itself. Key lines also go to /dev/kmsg, which console-ramoops keeps across a warm reboot.
device_init sets printk to 3, so level-4 lines never reached the console that console-ramoops records (.94 S2 kept none).
Flip.cfg sources FlipBaseOS.cfg and Flip.sh ends by sourcing FlipBaseOS.sh, which replaces whole functions; stock Flip.sh keeps the vendor code plus two hooks. PLATFORM stays Flip.
platform/*.cfg names platforms (only *Common.cfg is partial), so the layer is now platform/baseos/my355.cfg + device_functions/baseos/my355.sh. No behaviour change.
|
Thanks for the work there and the detailed feedback. Here's what I can do on BaseOS side for the next version:
With that, you should be able to remove the session shim if you remove the card unmount. The session restart happens because you unmount the card during shutdown, and BaseOS does not know it's shutting down so attempts to start it again. With the new rcK, SpruceOS no longer needs to unmount the card itself and it can just call poweroff/reboot, and BaseOS would do the full shutdown cleanly. You can also keep the shim, and it should work fine. I have made a quick beta with those changes, you can make some tests with it: |
Its rcK turns swap off, detaches the /usr overlay and unmounts the card (1.2.0-beta.1), so a plain power-off skips stage 2; 1.1.0 and USB export keep it.
A version like 1.2.0-beta.1 blocked every offer; it now compares by its x.y.z and counts as older than the release of the same number.
…he file A SHA256SUMS without the asset passed unchecked; baseos-my355 ships one from 1.2.0, and older releases still have only the GitHub digest.
|
Tested on a Miyoo Flip with BaseOS-my355 1.2.0-beta.1 and a swap file on the SD card. Spruce's reboot, power-off, and a plain reboot (rcK only) all left the card clean. The overlay and lib binds work too. Everything looks good. |
On 1.2.0-beta.1 it offered releases/latest (1.1.0), which BaseOS refuses at boot. Both now use baseos_version_older: x.y.z first, a pre-release before its release.
GitHub serves release files by a 302; curl -sf without -L saved it as an empty file (rc 0), so the SHA256SUMS check never ran. The downloader follows it, with its TLS retry.
The log line now shows which sum was checked, so a report proves a real comparison.
A child exiting ends the busybox shell's own sleep at once: after a USB session the 10 s grace for init lasted 0.4 s and reboot -f preempted BaseOS's rcK. Forcing is logged to kmsg.
A process holding a file through spruce's /usr overlay shows no card path, so the sweep missed it and USB export was refused; fdinfo mnt_id (and exe/cwd opened here) now link it.
unmount_all lazily detaches the busy /usr overlay, which leaves mountinfo, so stage 2 saw only the card (flip-91 B2: nothing found). Stage 1 now exports SPRUCE_CARD_MNT_IDS first; quiet skips.
…r1881/push The baseosUpdate.sh and firmwareUpdate.sh conflicts take Development's side (REPO and the finish message by BASEOS_TARGET); the digest fallback, redirect-following SHA256SUMS fetch, pre-release ordering and the stage 1/2 unmount changes are kept.
baseos_repo (helperFunctions) feeds the update check and baseosUpdate.sh, replacing the cfgs' BASEOS_REPO and BASEOS_UPDATE_FINISH; TARGET_BASEOS_VERSION stays in Flip.cfg. Stock Flip.sh drops its BaseOS branch (pre-releases never offered): the my355 layer replaces it.
Each pass names its victims (pid:comm) even when the umount then succeeds: B2/B3 on flip-91 unmounted cleanly at 0 retries and nothing recorded which holders the sweep took.
Changes:
fsck("REPAIRING SD CARD", ~14 s) on every boot. Applies to all devices.mkfs.ext4on older BaseOS versions remained empty, leaving/usr/lib32unavailable.mount_muOS.shcall from the Flip's 32-bit chroot, where it always failed.Tested on a Miyoo Flip running BaseOS 1.1.0.