Welcome! Log In Create A New Profile

Advanced

Replace Debian with openWRT [invalid dtb and unrecognized/unsupported machine ID]

Posted by shadowpho 
I have NSA325, which has U-Boot 2023.04-tld-1 and OpenWRT 22.04. I have serial port attached and easily available. ROM has 3 bad blocks, all above >1M (I think? log at end).

I want to install debian on it (since it has latest kernel and probably better perf). My plan is to install debian first and then upgrade uBoot since default OpenWRT does not seem to want to run nanddump (nanddump did not work -- i think it was a conflict between musl and ldd).

I made a USB stick with debian-6.5.7 on ext3 partition with label 'rootfs'. I think it's loading it successfully, but then quickly failing with invalid dtb and unrecognized/unsupported machine ID. I attached full serial log in attachment. Also added env_vars which are default ones.

Log from bad blocks:
root@OpenNAS:/# dmesg | grep block                                                                                                       
[    0.704375] Scanning device for bad blocks                                                                                            
[    0.722691] Bad eraseblock 149 at 0x0000012a0000                                                                                      
[    0.758898] Bad eraseblock 482 at 0x000003c40000                                                                                      
[    0.777547] Bad eraseblock 630 at 0x000004ec0000


Lastly, my uboot installation is smaller than 1M. See below, it's only 786kb. I think I can fix it once I get debian to boot, but if I need to reflash u-boot I might as well extend it :)
root@OpenNAS:/# cat /proc/mtd                                                                                                            
dev:    size   erasesize  name                                                                                                           
mtd0: 000c0000 00020000 "uboot"                                                                                                          
mtd1: 00080000 00020000 "uboot_env"                                                                                                      
mtd2: 07ec0000 00020000 "ubi"

Please let me know if anything else will help with debugging! I'll try to get kwboot setup next.
Attachments:
open | download - env_vars.txt (2.7 KB)
open | download - boot_attempt_full.txt (17.8 KB)
Re: Replace Debian with openWRT [invalid dtb and unrecognized/unsupported machine ID]
June 01, 2025 11:56PM
shadowpho,

It's a classic problem when you are booting with stock u-boot envs vs with the env image that comes with the new u-boot. When you installed new u-boot 2023.04-tld-1, you are supposed to boot with the separate DTB, as its default envs are set up to do so.

But, since you set up the boot with OpenWrt, you treated it like OpenWrt and successfully booted.

Now when you are switching to Debian with the below envs:

NSA325> setenv usb_set_bootargs 'setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 earlyprintk=serial'setenv usb_set_bo
otargs 'setenv bootargs console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 earlyprintk=serial'                                          
NSA325> setenv load_uimage 'ext2load usb 0:1 0x800000 /boot/uImage'setenv load_uimage 'ext2load usb 0:1 0x800000 /boot/uImage'           
NSA325> setenv load_uinitrd 'ext2load usb 0:1 0x2100000 /boot/uInitrd'setenv load_uinitrd 'ext2load usb 0:1 0x2100000 /boot/uInitrd'     
NSA325> setenv usb_boot 'mw 0x800000 0 1; run load_uimage; run load_uinitrd; bootm 0x800000 0x2100000'setenv usb_boot 'mw 0x800000 0 1; r
un load_uimage; run load_uinitrd; bootm 0x800000 0x2100000'                                                                              
NSA325> setenv usb_bootcmd 'run usb_set_bootargs; run usb_boot'setenv usb_bootcmd 'run usb_set_bootargs; run usb_boot'                   
NSA325> setenv bootcmd 'usb reset; run usb_bootcmd; usb stop; reset'setenv bootcmd 'usb reset; run usb_bootcmd; usb stop; reset'         
NSA325> printenv

You are booting like with stock again! so you will need to perpare the uImage with the DTB embedded. As the rootfs instruction stated:

Quote

4. (Stock u-boot only) Create uImage with embedded DTB for booting with older u-boots (2012 or earlier). Skip this step if you have installed the latest U-Boot for Kirkwood (or are installing this u-boot at the same time, or running kwboot with latest u-boot image).

Please replace kirkwood-goflexnet.dtb below with the correct DTB name for your box (see the folder /media/sdb1/boot/dts for the exact spelling of your Kirkwood box name).

Generate the uImage with DTB embedded inside:
cd /media/sdb1/boot
cp -a zImage-6.5.7-kirkwood-tld-1 zImage.fdt
cat dts/kirkwood-goflexnet.dtb >> zImage.fdt
mv uImage uImage.orig
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-6.5.7-kirkwood-tld-1 -d zImage.fdt uImage
sync

Take the USB rootfs to another box, mount it. Assuming it's mounted as /media/sdb1.

cd /media/sdb1/boot
cp -a zImage-6.5.7-kirkwood-tld-1  zImage.fdt
cat dts/kirkwood-nsa325.dtb >> zImage.fdt
mv uImage uImage.orig
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-6.5.7-kirkwood-tld-1 -d zImage.fdt  uImage
sync

Umount and bring it back to the NSA325 and repeat what you did in setting envs and boot into Debian USB rootfs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 06/02/2025 12:00AM by bodhi.
Thank you very much! Commands worked perfectly, and it booted straight to debian.

I was confused by "stock u-boot" as I thought that was referring to original bootloader (aka not u-boot :) ). Now re-reading instructions it makes sense!

Thank you again! I'll go reflash u-boot to 2024 and with that I'll update the envs as well.



Edited 1 time(s). Last edit at 06/02/2025 12:57AM by shadowpho.
Re: Replace Debian with openWRT [invalid dtb and unrecognized/unsupported machine ID]
June 02, 2025 02:52PM
> I was confused by "stock u-boot" as I thought that
> was referring to original bootloader (aka not
> u-boot :) ). Now re-reading instructions it makes
> sense!

These ARM boxes use u-boot as boot loader. "Stock u-boot" means to say what the manufacturer installed, usually very old (circa 2012 ) and very limited in capability.

Some ARM boxes also use barebox (u-boot derivative). And very rarely, some uses their own boot loader.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Gotcha, thank you again for your help! It's working great and is really cool for learning how uboot/kernel operate and boot.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: