Hi,
tl:dr I can boot Debian Bookworm on my Sheevaplug from USB but need some help flashing the NAND and booting from there.
I have a Sheevaplug Dev Kit from 2009 (?).
For many years it ran a host of static and WordPress websites, booting from an MMC.
It was retired a few years ago in favour of a RasPi4 with an SSD.
I have decided to bring it back to life and use it as a DNS server, VPN and for PiHole.
I have the Debian Bookworm uImage and uInitrd files from here:
https://ftp.debian.org/debian/dists/bookworm/main/installer-armel/current/images/kirkwood/netboot/marvell/sheevaplug/
My u-boot is from here:
https://forum.doozan.com/read.php?3,12381
These files are on my tftp server and the only changes to the u-boot were to add the tftp and machine settings.
I have created a Debian Bookworm USB from the above and can boot from it.
However I am a bit stuck on copying the files to NAND and getting it to boot from there.
These are the steps I have taken, with the terminal responses.
I'm not sure whether my process is at fault or I am doing something else wrong.
Most of the following came from the instructions here:
http://web.archive.org/web/20101011142054/https://www.plugcomputer.org/plugwiki/index.php/Installing_Debian_To_Flash#Convert_internal_flash_root_partition_to_UBIFS
Boot to working Debian from USB
~~~~~~~~~~~~~~~~~~~~~~~~~~
Plug in and power up
Interrupt autoboot
setenv bootargs_console console=ttyS0,115200
setenv bootcmd_usb 'usb start; ext2load usb 0:1 0x00800000 /uImage; ext2load usb 0:1 0x01100000 /uInitrd'
setenv bootcmd 'setenv bootargs ${bootargs_console}; run bootcmd_usb; bootm 0x00800000 0x01100000'
run bootcmd
Login
~~~~
login
su
Install mtd-utils
~~~~~~~~~~~
Add in the modprobe
~~~~~~~~~~~~~~~~
Format internal flash root partition to UBIFS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Backup fstab
~~~~~~~~~~
Change fstab
~~~~~~~~~~~
Replace with:
/dev/root / ubifs defaults,noatime,rw 0 0
tmpfs /var/run tmpfs size=1M,rw,nosuid,mode=0755 0 0
tmpfs /var/lock tmpfs size=1M,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
Clone USB rootfs to NAND
~~~~~~~~~~~~~~~~~~~~~
Restore fstab
~~~~~~~~~~
Reboot
~~~~~~
Interrupt autoboot
Flash the kernel
~~~~~~~~~~~~
Set the envars if not already done
Erase the old kernel
Write the new kernel into NAND flash
Set the env variables
~~~~~~~~~~~~~~~~
This is where it hangs.
So I'm not sure what I've done wrong.
It boots and works from the USB, so are my envvars wrong or did I bungle the flashing process ?
Any help, guidance or advice would be much appreciated.
(I'm not particularly attached to getting the above process working, I'd like to be able to boot from NAND so will happily follow any alternative routes to achieving this.)
tl:dr I can boot Debian Bookworm on my Sheevaplug from USB but need some help flashing the NAND and booting from there.
I have a Sheevaplug Dev Kit from 2009 (?).
For many years it ran a host of static and WordPress websites, booting from an MMC.
It was retired a few years ago in favour of a RasPi4 with an SSD.
I have decided to bring it back to life and use it as a DNS server, VPN and for PiHole.
I have the Debian Bookworm uImage and uInitrd files from here:
https://ftp.debian.org/debian/dists/bookworm/main/installer-armel/current/images/kirkwood/netboot/marvell/sheevaplug/
My u-boot is from here:
https://forum.doozan.com/read.php?3,12381
These files are on my tftp server and the only changes to the u-boot were to add the tftp and machine settings.
I have created a Debian Bookworm USB from the above and can boot from it.
However I am a bit stuck on copying the files to NAND and getting it to boot from there.
These are the steps I have taken, with the terminal responses.
I'm not sure whether my process is at fault or I am doing something else wrong.
Most of the following came from the instructions here:
http://web.archive.org/web/20101011142054/https://www.plugcomputer.org/plugwiki/index.php/Installing_Debian_To_Flash#Convert_internal_flash_root_partition_to_UBIFS
Boot to working Debian from USB
~~~~~~~~~~~~~~~~~~~~~~~~~~
Plug in and power up
Interrupt autoboot
setenv bootargs_console console=ttyS0,115200
setenv bootcmd_usb 'usb start; ext2load usb 0:1 0x00800000 /uImage; ext2load usb 0:1 0x01100000 /uInitrd'
setenv bootcmd 'setenv bootargs ${bootargs_console}; run bootcmd_usb; bootm 0x00800000 0x01100000'
run bootcmd
Login
~~~~
login
su
Install mtd-utils
~~~~~~~~~~~
apt-get install mtd-utils
root@sheevaplug:~# apt-get install mtd-utils Reading package lists... Done Building dependency tree... Done Reading state information... Done mtd-utils is already the newest version (1:2.1.5-1). mtd-utils set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@sheevaplug:~#
Add in the modprobe
~~~~~~~~~~~~~~~~
/usr/sbin/modprobe ubi
Format internal flash root partition to UBIFS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/sbin/ubiformat /dev/mtd2 -s 512
root@sheevaplug:~# /usr/sbin/ubiformat /dev/mtd2 -s 512 ubiformat: mtd2 (nand), size 531628032 bytes (507.0 MiB), 4056 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes libscan: scanning eraseblock 4055 -- 100 % complete ubiformat: 4055 eraseblocks have valid erase counter, mean value is 1 ubiformat: 1 bad eraseblocks found, numbers: 2854 ubiformat: formatting eraseblock 4055 -- 100 % complete root@sheevaplug:~#
/usr/sbin/ubiattach /dev/ubi_ctrl -m 2
root@sheevaplug:~# /usr/sbin/ubiattach /dev/ubi_ctrl -m 2 [ 183.188203] ubi0: attaching mtd2 [ 183.819624] ubi0: scanning is finished [ 183.848784] ubi0: attached mtd2 (name "root", size 507 MiB) [ 183.854457] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes [ 183.861403] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512 [ 183.868155] ubi0: VID header offset: 512 (aligned 512), data offset: 2048 [ 183.875011] ubi0: good PEBs: 4055, bad PEBs: 1, corrupted PEBs: 0 [ 183.881158] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128 [ 183.888437] ubi0: max/mean erase counter: 5/2, WL threshold: 4096, image sequence number: 728050822 [ 183.897554] ubi0: available PEBs: 3972, total reserved PEBs: 83, PEBs reserved for bad PEB handling: 79 [ 183.907057] ubi0: background thread "ubi_bgt0d" started, PID 334 UBI device number 0, total 4055 LEBs (523192320 bytes, 498.9 MiB), available 3972 LEBs (512483328 bytes, 488.7 MiB), LEB size 129024 bytes (126.0 KiB) root@sheevaplug:~#
/usr/sbin/ubimkvol /dev/ubi0 -N rootfs -m
root@sheevaplug:~# /usr/sbin/ubimkvol /dev/ubi0 -N rootfs -m Set volume size to 512483328 Volume ID 0, size 3972 LEBs (512483328 bytes, 488.7 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1 root@sheevaplug:~#
mount -t ubifs ubi0:rootfs /mnt
root@sheevaplug:~# mount -t ubifs ubi0:rootfs /mnt [ 233.439620] UBIFS (ubi0:0): default file-system created [ 233.446912] UBIFS (ubi0:0): Mounting in unauthenticated mode [ 233.478930] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 360 [ 233.542937] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs" [ 233.550425] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes [ 233.560431] UBIFS (ubi0:0): FS size: 510418944 bytes (486 MiB, 3956 LEBs), max 3972 LEBs, journal size 25546752 bytes (24 MiB, 198 LEBs) [ 233.572786] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB) [ 233.579454] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 2BA446B8-3BF9-44E2-AAA0-7A29202B3F5A, small LPT model mount: (hint) your fstab has been modified, but systemd still uses the old version; use 'systemctl daemon-reload' to reload. mount: (hint) your fstab has been modified, but systemd still uses the old version; use 'systemctl daemon-reload' to reload. root@sheevaplug:~#
Backup fstab
~~~~~~~~~~
cp /etc/fstab /etc/fstab.bak
Change fstab
~~~~~~~~~~~
nano /etc/fstab
Replace with:
/dev/root / ubifs defaults,noatime,rw 0 0
tmpfs /var/run tmpfs size=1M,rw,nosuid,mode=0755 0 0
tmpfs /var/lock tmpfs size=1M,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
nano /etc/fstab # <file system> <mount point> <type> <options> <dump> <pass> /dev/root / ubifs defaults,noatime,rw 0 0 tmpfs /var/run tmpfs size=1M,rw,nosuid,mode=0755 0 0 tmpfs /var/lock tmpfs size=1M,rw,noexec,nosuid,nodev,mode=1777 0 0 tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
Clone USB rootfs to NAND
~~~~~~~~~~~~~~~~~~~~~
mkdir /tmp/rootfs
mount -o bind / /tmp/rootfs/
cd /tmp/rootfs
sync
cp -a . /mnt/
root@sheevaplug:/tmp/rootfs# cp -a . /mnt/ [ 1102.885700] usb 1-1: reset high-speed USB device number 2 using orion-ehci [ 1103.067693] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK cmd_age=0s [ 1103.077024] sd 0:0:0:0: [sda] tag#0 CDB: Read(10) 28 00 00 18 e6 78 00 00 08 00 [ 1103.084434] I/O error, dev sda, sector 1631864 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2 cp: preserving permissions for ‘/mnt/./var/log/journal/75e30cfb7de24a1aa004fabd2a8a8a68/system@000605c9542dfb52-1ac8dc41d880b815.journal~’: Operation not supported cp: preserving permissions for ‘/mnt/./var/log/journal/75e30cfb7de24a1aa004fabd2a8a8a68/system.journal’: Operation not supported cp: preserving permissions for ‘/mnt/./var/log/journal/75e30cfb7de24a1aa004fabd2a8a8a68/user-1000.journal’: Operation not supported cp: preserving permissions for ‘/mnt/./var/log/journal/75e30cfb7de24a1aa004fabd2a8a8a68’: Operation not supported cp: preserving permissions for ‘/mnt/./var/log/journal’: Operation not supported root@sheevaplug:/tmp/rootfs#
Restore fstab
~~~~~~~~~~
cp /etc/fstab.bak /etc/fstab
Reboot
~~~~~~
systemctl reboot
Interrupt autoboot
Flash the kernel
~~~~~~~~~~~~
Set the envars if not already done
setenv serverip 192.168.0.205 #Host setenv ipaddr 192.168.0.201 #Sheevaplug setenv ethaddr 00:50:43:01:63:EA setenv macaddr 00:50:43:01:63:EA saveenv tftpboot 0x00800000 uImage
Erase the old kernel
nand erase 0x100000 0x400000
Write the new kernel into NAND flash
nand write 0x800000 0x100000 0x400000
Set the env variables
~~~~~~~~~~~~~~~~
setenv bootargs_ubi console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs setenv bootcmd_nand_read nand read 0x800000 0x100000 0x400000 setenv bootcmd 'setenv bootargs $(bootargs_ubi); run bootcmd_nand_read; bootm 0x800000' saveenv boot
Sheevaplug> boot NAND read: device 0 offset 0x100000, size 0x400000 4194304 bytes read: OK ## Booting kernel from Legacy Image at 00800000 ... Image Name: Debian kernel Created: 2023-10-01 22:16:20 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2634776 Bytes = 2.5 MiB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK Loading Kernel Image ... OK Starting kernel ...
This is where it hangs.
So I'm not sure what I've done wrong.
It boots and works from the USB, so are my envvars wrong or did I bungle the flashing process ?
Any help, guidance or advice would be much appreciated.
(I'm not particularly attached to getting the above process working, I'd like to be able to boot from NAND so will happily follow any alternative routes to achieving this.)
Sheevaplug> printenv arcNumber=2097 baudrate=115200 bootargs_ubi=console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs bootcmd=setenv bootargs $(bootargs_ubi); run bootcmd_nand_read; bootm 0x800000 bootcmd_exec=run load_uimage; if run load_initrd; then if run load_dtb; then bootm $load_uimage_addr $load_initrd_addr $load_dtb_addr; else bootm $load_uimage_addr $load_initrd_addr; fi; else if run load_dtb; then bootm $load_uimage_addr - $load_dtb_addr; else bootm $load_uimage_addr; fi; fi bootcmd_nand_read=nand read 0x800000 0x100000 0x400000 bootcmd_uenv=run uenv_load; if test $uenv_loaded -eq 1; then run uenv_import; fi bootdelay=10 bootdev=usb console=ttyS0,115200 device=0:1 devices=usb ide mmc disks=0 1 2 3 dtb_file=/boot/dts/kirkwood-sheevaplug.dtb ethact=egiga0 ethaddr=00:50:43:01:63:EA if_netconsole=ping $serverip ipaddr=192.168.0.201 led_error=orange blinking led_exit=green off led_init=green blinking load_dtb=echo loading DTB $dtb_file ...; load $bootdev $device $load_dtb_addr $dtb_file load_dtb_addr=0x1c00000 load_initrd=echo loading uInitrd ...; load $bootdev $device $load_initrd_addr /boot/uInitrd load_initrd_addr=0x1100000 load_uimage=echo loading uImage ...; load $bootdev $device $load_uimage_addr /boot/uImage load_uimage_addr=0x800000 macaddr=00:50:43:01:63:EA mainlineLinux=yes mtdids=nand0=orion_nand mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data) partition=nand0,2 preboot_nc=run if_netconsole start_netconsole scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start"; setenv scan_ide "ide reset"; setenv scan_mmc "mmc rescan"; for dev in $devices; do if test $scan_done -eq 0; then echo Scan device $dev; run scan_$dev; for disknum in $disks; do if test $scan_done -eq 0; then echo device $dev $disknum:1; if load $dev $disknum:1 $load_uimage_addr /boot/uImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done serverip=192.168.0.205 set_bootargs=setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts $custom_params start_netconsole=setenv ncip $serverip; setenv bootdelay 10; setenv stdin nc; setenv stdout nc; setenv stderr nc; version; stderr=serial stdin=serial stdout=serial uenv_addr=0x810000 uenv_import=echo importing envs ...; env import -t $uenv_addr $filesize uenv_init_devices=setenv init_usb "usb start"; setenv init_ide "ide reset"; setenv init_mmc "mmc rescan"; for devtype in $devices; do run init_$devtype; done; uenv_load=run uenv_init_devices; setenv uenv_loaded 0; for devtype in $devices; do for disknum in 0; do run uenv_read_disk; done; done; uenv_read=echo loading envs from $devtype $disknum ...; if load $devtype $disknum:1 $uenv_addr /boot/uEnv.txt; then setenv uenv_loaded 1; fi uenv_read_disk=if test $devtype -eq mmc; then if $devtype part; then run uenv_read; fi; else if $devtype part $disknum; then run uenv_read; fi; fi usb_ready_retry=15 Environment size: 3056/131068 bytes Sheevaplug>