55 views
# Upgrading to linux-current and debugging of ## How to boot RockPro64 from u-boot console To get out of desaster in case my production system brakes when attempting to use a newer kernel I need to be able to boot the old kernel from the u-boot console. The boot process can be reconstructed from /boot/boot.cmd. For Armbian Debian Bookworm it looks like this ### booting of emmc, but mounting harddrives as root device ``` setenv rootdev "/dev/mmcblk0p1" setenv verbosity "1" setenv console "both" setenv rootfstype "ext4" load mmc 0:1 0x800800 /boot/armbianEnv.txt # replace the 139 on the following line with the # filesize output by 'load' env import -t 0x800800 139 part uuid mmc 0:1 partuuid setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${ver bosity} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}" ls mmc 0:1 /boot # get the dtb directory, **uInitrd** and the vmlinuz # from the output to use with the following 'load' commands load mmc 0:1 0x02080000 /boot/vmlinuz-4.4.213-legacy-rockchip64 load mmc 0:1 0x06000000 /boot/uInitrd-4.4.213-legacy-rockchip64 load mmc 0:1 0x01f00000 /boot/dtb-4.4.213-legacy-rockchip64/rockchip/rk3399-rockpro64.dtb booti 0x02080000 0x06000000 0x01f00000 ``` ### using scsi only ``` # initialize pci bus pci enum # show devices on pci pci # scan for scsi devices scsi reset # get partition table scsi part # find boot files ls scsi 0:1 /boot # start loding stuff like shown above ``` ## reboot tests for PCIe improvements ### debian dmesg and restart Show dmesg on serial console after boot, wait 20 seconds, and shutdown for the next powercylce: ``` root:~# cat /root/bin/dmesg_and_shutdown.sh #!/bin/bash dmesg > /dev/ttyS2 echo "Will shutdown in 20 seconds - to stop me call 'pkill dmesg_and_shut'" > /dev/ttyS2 sleep 20 echo "shutdown -h" > /dev/ttyS2 shutdown -h now root:~# crontab -l @reboot /root/bin/dmesg_and_shutdown.sh ``` ### Powercycle the board Using a Sonoff Powr2 flashed with [ESP Easy](https://github.com/letscontrolit/ESPEasy) (mega-20210503) to switch the powersupply off and on again: Rule Set 1: ``` On System#Boot do gpio,12,0 gpio,13,1 endon On button#button_state do if [blue_led#blue_led_state]=1 gpio,13,0 timerSet,1,2 else gpio,13,1 gpio,12,1 timerSet,1,0 timerSet,2,0 endif endon On Rules#Timer=1 do gpio,12,0 timerSet,2,1 endon On Rules#Timer=2 do gpio,12,1 timerSet,1,2 endon ``` Pressing the button toggles between: * blue led off, timers disabled, relay on permanently * blue led on, timers switch the relay off for 5 seconds, on for 120 seconds and then repeat ### result The resulting log is taken from the serial console on a second machine running `minicom`. To split the logfile into one individual boot per file I used `csplit ../filename.log '/U-Boot TPL 2023.07+dfsg-1/' '{*}'`. To look into the many logfiles I decided to diff all of them agains one of them and filter out what I'd say is unimportant to find the ones that do have significant differences easier: ``` #!/bin/bash GREP1='Received client request to flush runtime journal|SerialNumber: fe380000.usb|Wireless Keyboard/Mouse|^\d+ bytes read in \d+ ms \(|^ ([\d,]+| {11,})\s+[\d,]+\s+\w+_\w+$' PERLRE='s/^\[[\s\d.]{12}\] (.+)/$1/; s/\d+ MB\/sec//; s/^(usb usb\d:|^hub \d-|^usb \d-)//; s/clock to 2025.*$//' GREP2='^raid\|^.hci-platform\|^fan53555-regulator\|^mmc2: \|^ SerialNumber: fe3c0000.usb\|^systemd\[1\]' for F in reboot-logs/xx*; do echo -e "\n============== diff reboot-logs/xx01 $F\n" diff -W110 --suppress-common-lines -yibB \ <(grep -vaP "$GREP1" reboot-logs/xx01 | perl -pe"$PERLRE" | grep -av "$GREP2") \ <(grep -vaP "$GREP1" $F | perl -pe"$PERLRE" | grep -av "$GREP2") done ``` Looking at the diffs I found that `xx44` and `xx76` seemed to contain failed boots. Some other of the logfiles with bigger differences I symlinked to the main dircetory for further reference: ``` $ ls -l insgesamt 5212 -rw-r--r-- 1 cvogel cvogel 65704 28. Feb 19:09 8mfO.dtb -rwxr-xr-x 1 cvogel cvogel 694 2. Mär 14:44 diff_logs.sh -rw-r--r-- 1 cvogel cvogel 47 2. Mär 14:54 README.md drwxr-xr-x 2 cvogel cvogel 4096 2. Mär 12:26 reboot-logs -rw-r--r-- 2 cvogel cvogel 5248712 2. Mär 00:30 rockpro64-DeLockSATA-dietpiKernel-dtbPatched-dmesg-shutdown-powercycle.log lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:46 xx06 -> reboot-logs/xx06 lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:49 xx39 -> reboot-logs/xx39 lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:49 xx44 -> reboot-logs/xx44 lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:50 xx54 -> reboot-logs/xx54 lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:52 xx67 -> reboot-logs/xx67 lrwxrwxrwx 1 cvogel cvogel 16 2. Mär 14:53 xx76 -> reboot-logs/xx76 ``` I uploaded an archive with these files: https://lufi.z9.de/r/0Mx0mWJkce#NSkHC1kDDpVFmnJJwzRCR+UGB3n+9yW2DF7jB/f4Iog= (available until 2026-03-01)