Welcome! Log In Create A New Profile

Advanced

Change bootargs in uboot

Posted by lordzahl 
Change bootargs in uboot
November 14, 2021 04:34AM
Hi Bodhi, Hi @All,

I recently updated my Thecus N2350 to Debian Bullseye as well as the newest kernel 5.14.9. Working fine as always, thanks!
I do now have some problems with Docker and cgroups v2 and wanted to change the init system (init=/bin/systemd) or even set a custom systemd config (systemd.unified_cgroup_hierarchy=0) as kernel parameters.

I did set my set_bootargs parameter in uboot:
bootdelay=5
baudrate=115200
boot_config=setenv devices "usb scsi"; setenv bootdev usb; setenv device 0:1; setenv disks "0 1 2 3 4 5 6 7";
scan_disk=echo running scan_disk ...; scan_done=0; setenv scan_usb "usb start";  setenv scan_scsi "scsi reset"; 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 ext2load $dev $disknum:1 $load_image_addr /boot/zImage 1; then scan_done=1; echo Found bootable drive on $dev $disknum; setenv device $disknum:1; setenv bootdev $dev; fi; fi; done; fi; done
kernel_config=setenv load_dtb_addr 0x1000000; setenv load_initrd_addr 0x3000000; setenv load_image_addr 0x02000000; setenv dtb_file /boot/dts/armada-385-thecus-n2350.dtb
load_image=echo loading uImage ...; ext2load $bootdev $device $load_image_addr /boot/uImage
load_dtb=echo loading DTB $dtb_file ...; ext2load $bootdev $device $load_dtb_addr $dtb_file
load_initrd=echo loading uInitrd ...; ext2load $bootdev $device $load_initrd_addr /boot/uInitrd
set_bootargs_stock=setenv bootargs "root=/dev/ram0 rw max_loop=210 console=ttyS0,115200 init=sbin/init rootdelay=3 ubi.mtd=0 mtdparts=armada-nand:-(ubifs);spi_flash:0x00400000(uboot),0x00010000@0x00100000(uboot_env)"
bootcmd_exec=echo Booting from $bootdev $device …; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; if run load_image; then if run load_initrd; then bootm $load_image_addr $load_initrd_addr; else bootm $load_image_addr; fi; fi
bootcmd_custom=run boot_config; run kernel_config; run scan_disk; run set_bootargs; run bootcmd_exec
bootcmd=echo Booting Debian ...; run bootcmd_custom; echo Booting stock ...; run set_bootargs_stock; usb reset; if fatload usb 0:1 0x2000000 rescue_fw/rescue_fw.img;then imi 0x2000000;source 0x2000000; fi; ubi part ubifs;ubifsmount boot;ubifsload 0x2000000 boot/bzImage;ubifsload 0x3000000 boot/ramdisk;bootm 0x2000000 0x3000000
set_bootargs=setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=armada-nand:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial init=/bin/systemd"

to activate systemd, but it seems, that my parameters are ignored.
mjung@vega:~$ cat /proc/cmdline                                                                                                                                                                                     console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial

Systemd is of course installed
mjung@vega:~$ ls -lh /bin/systemd                                                                                                                                                                                   lrwxrwxrwx 1 root root 20 Jul 13 19:29 /bin/systemd -> /lib/systemd/systemd

Thanks!
Re: Change bootargs in uboot
November 14, 2021 03:20PM
Hey Manuel :)

Glad to see you stopping by again!

mjung@vega:~$ cat /proc/cmdline

Quote

console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial

Somehow your bootargs did not show up in the command line. Let me take a close look.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Change bootargs in uboot
November 14, 2021 04:33PM
Manuel,

I could not see anything wrong either! may be there is a hidden character.

How about trying it manually in serial console:
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=armada-nand:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial init=/bin/systemd"'
printenv set_bootargs

and then
boot

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



Edited 1 time(s). Last edit at 11/14/2021 04:34PM by bodhi.
Re: Change bootargs in uboot
November 18, 2021 11:20AM
Hi bodhi,

Thanks for you advice.
Today i connected by serial and indeed my envs were not set correctly.
Actually my log from /proc/cmdline above includes "mtdparts=pxa3xx_nand-0" which i never set at all.
Maybe my fw_setenv wrote to the wrong addresses? I also installed a few days back your new uboot (finally) and its envs were not saved at all.
I did that now from the stock os and stock kernel 3.10 and now they are how i wanted them to be with the extra kernel parameter.

Docker is running again..
I would like to be able to set the uboot envs from my normal debian system in the future.
Cheers Manuel
Re: Change bootargs in uboot
November 18, 2021 03:06PM
Hi Manuel,

Verify that you see these

# cat /proc/cmdline
console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 20000000 00020000 "ubifs"
mtd1: 00400000 00001000 "uboot"
mtd2: 00010000 00001000 "uboot_env"
mtd3: 00010000 00001000 "uboot_scr"

# cat /etc/fw_env.config
# MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
#
# Thecus N2350
/dev/mtd2 0x00000 0x10000 0x10000


> Actually my log from /proc/cmdline above includes
> "mtdparts=pxa3xx_nand-0" which i never set at
> all.
> Maybe my fw_setenv wrote to the wrong addresses?

That pxa3xx_nand-0 should be part of the mtd definition. That's how we got the NAND mtd correctly identified in Linux (in stock OS it was a different name for old Armada driver).

Note that mtd0 is in NAND flash, and mtd1 to mtd3 are in SPI flash. Thus, the bootargs must be:

mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr)

(spi1.0: is this SPI device name in Linux).


> I would like to be able to set the uboot envs from
> my normal debian system in the future.

It should work when the mtd definition is correct. In Debian do:

fw_printenv
And then once you see all envs are listed OK. Set something to test, such as

fw_setenv test_001 yes
fw_printenv test_001
After a reboot you should see it in serial console and then in Debian. And then remove it

fw_setenv test_001

=========

Stock FW mtd definition is quite awkward, I would never use such arrangement. I would move the UBIFS mtd to the last mtd. That way u-boot image is on mtd0, as the normal convention always has been. But since we are running a rebuilt and patched stock u-boot, I kept the same definition for backward compatibilty (.i.e. in case someone wants to flash the original stock u-boot back).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Change bootargs in uboot
November 20, 2021 10:36AM
Hi,

I get
mjung@vega:~$ cat /proc/cmdline 
console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=armada-nand:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial systemd.unified_cgroup_hierarchy=0
mjung@vega:~$ cat /etc/fw_env.config 
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
/dev/mtd0		0xc0000		0x20000		0x20000
mjung@vega:~$ cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 20000000 00020000 "ubifs"
mtd1: 00400000 00001000 "uboot"
mtd2: 00010000 00001000 "uboot_env"
mtd3: 00010000 00001000 "uboot_scr"

I guess my fw_config is wrong?
Cheers,
Manuel
Re: Change bootargs in uboot
November 20, 2021 03:20PM
Manuel,


> # MTD device name Device offset Env. size Flash
> sector size Number of sectors
> /dev/mtd0 0xc0000 0x20000 0x20000

The above is the Kirkwood rootfs settings.

> mjung@vega:~$ cat /proc/mtd
> dev: size erasesize name
> mtd0: 20000000 00020000 "ubifs"
> mtd1: 00400000 00001000 "uboot"
> mtd2: 00010000 00001000 "uboot_env"
> mtd3: 00010000 00001000 "uboot_scr"
> [/code]

Your MTDs are OK.

> I guess my fw_config is wrong?

Correct, it was wrong. It should be:

# cat /etc/fw_env.config
# MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
#
# Thecus N2350
/dev/mtd2 0x00000 0x10000 0x10000

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



Edited 1 time(s). Last edit at 11/20/2021 03:22PM by bodhi.
Re: Change bootargs in uboot
November 21, 2021 06:27AM
bodhi Wrote:
-------------------------------------------------------
> Correct, it was wrong. It should be:
>
> # cat /etc/fw_env.config
>
> # MTD device name	Device offset	Env. size	Flash
> sector size	Number of sectors
> #
> # Thecus N2350
> /dev/mtd2 0x00000 0x10000 0x10000
>
Ok, i fixed it, and now fw_printenv shows all the envs correctly.

I am still a little bit confused about bootargs though. You said the need to include
mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr)

But i installed the u-boot you supplied here: https://forum.doozan.com/read.php?2,92234
And this set different mtdparts, which i have set right now. I will also keep it this way right now, because everything works, and i need to host some photos right now and my wife would not be happy if the server is offline again..
Cheers! Manuel
Re: Change bootargs in uboot
November 21, 2021 02:51PM
Manuel,

> But i installed the u-boot you supplied here:
> https://forum.doozan.com/read.php?2,92234
> And this set different mtdparts, which i have set
> right now.

Thanks! I'll check the installation instruction.

> I will also keep it this way right now,
> because everything works, and i need to host some
> photos right now and my wife would not be happy if
> the server is offline again..

Please do. You're a wise man :)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Change bootargs in uboot
November 21, 2021 06:51PM
Manuel,

Thanks for reporting this problem. Indeed I had an error in the script

thecus-n2350-boot-script-tld-5.sh

fw_setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=armada-nand:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr) earlyprintk=serial"'

Should be:
fw_setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=pxa3xx_nand-0:-(ubifs);spi1.0:0x00400000(uboot),0x00010000@0x00100000(uboot_env),0x00010000@0x00300000(uboot_scr)earlyprintk=serial"'

I've modified the installation instruction to add the correction.

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



Edited 1 time(s). Last edit at 11/21/2021 06:58PM by bodhi.
Author:

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: