Update kernel command line using flash.sh script (Solved)


I wish to change kernel command line on Xavier. Since only way to boot a custom kernel is using the flash.sh script, I was wondering how to set up the cmdline on Xavier.

I have tried below flash.sh command, but the /proc/cmdline shows the old cmdline.

sudo ./flash.sh -k kernel -C <command-line-value> jetson-xavier mmcblk0p1

When mkbootimg binary is called from flash.sh the --cmdline parameter had the new value as part of the {cmdline} variable, but after system booted up the old cmdline is being displayed. Please help me out.

Just guessing, but there is a device tree “chosen->bootargs” node which you can probably adjust…then flash the new tree with just that change.

Thank linuxdev for the reply. May I know where it is placed if by any chance you know it?

Also, that means that I have to build that dtb everytime I need to change the bootargs. Can’t there be any simpler solution? I usually test patches developed in-house and I have to set one bootarg or the other on every boot. So, this may be a longer (though not difficult) procedure to follow, hence asking for a simpler one. Thanks.

hi linuxdev,

I have got it to work. Probably, my lack of understanding the flash.sh script arguments. Your comment helped me as well. I had to partition kernel-dtb along with the “-C” option, something like this:

sudo ./flash.sh -k kernel -C <command-line-value> -k kernel-dtb jetson-xavier mmcblk0p1

Looks like the “-C” essentially updates a subset of the device tree (probably the “chosen->bootargs”). Did it skip flashing the rootfs?

Well, I don’t know yet what it updates, but you may be right about that. Because the correct .dtb file is updated.

“-C” doesn’t skip the flashing of rootfs but specifying “-k” (small K) skips or restricts the flashing to only the partition that I put in as argument. Probably a comma-separated list of partitions could be specified to “-k” option. (and so for “-C” option)

For flashing the kernel I’m using:

(cd "@L4TDIR@"; sudo ./flash.sh -r -k kernel -K  "$(linux_ZIMAGE)" jetson-xavier mmcblk0p1; )

I’ve had a lot of trouble flashing the DTB. Copying the dtb to L4T/kernel/dtb before flashing is was the only way I have been able to get it to work. The following should work but does not:

(cd "@L4TDIR@"; sudo ./flash.sh -r -k kernel-dtb -d "@DTB_FILE@" jetson-xavier mmcblk0p1; )

This works:

sudo cp "@DTB_FILE@" "@L4TDIR@/kernel/dtb"
	(cd "@L4TDIR@"; sudo ./flash.sh -r -k kernel-dtb jetson-xavier mmcblk0p1; )

Hi D3_growe,

The second method works for the dtb flashing and not the first is the same reason why the command line is not updated with only “-C” option. The flash.sh script copies the “@L4TDIR@”/kernel/dtb/t194.dtb file in the “@L4TDIR@”/bootloader/ folder replacing the .dtb file that you specify with the “-d” option.

Either this was always the behavior (I am not sure) or NVIDIA has changed the way flash.sh uses the command line args and flashes the board.

Anyway, I feel the whole process is a little bit complicated compared to JetPack 3.x releases for TX{1,2,2i}'s.

It must have changed because, on Tx2, the -d method is successful.

:) I’d really prefer having u-boot load the kernel and dtb.

Hello, have you ever added more than one kernel parameter via the flasher script?
I’ve tried with
… -C “a=b foo=bar” …
and also
… -C “a=b” -C “foo=bar” …
but only a=b was added.

Looking at the flash.sh script I see this comment:

# Optional Environment Variables:
# CMDLINE ---------------- Target cmdline. See help for more information.

So perhaps if you have “CMDLINE” as an environment variable, then this would get updated even without the “-C” for any operation updating the device tree. Just guessing, but this before a flash:

export CMDLINE="a=b foo=bar"
sudo ./flash.sh ....

I haven’t tested, but perhaps the environment variable method is better behaved.

No, unfortunately it does not work like that.

Hi Guys,

I see you succeeded with adding additional boot parameters to the kernel. Can you explain in more details which dts file should I change? I believe that I can create a dts from dtb, update it, create dtb from it and finally burn it. What is the file name?