cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
525 Views
Registered: ‎10-02-2018

How to modify device-tree once linux runtime?

Hi

My project is using SW Update follow link to update BOOT.BIN, image.ub, rootfs.jffs2 into flash on zcu102:

https://www.zachpfeffer.com/single-post/Integrate-SWUpdate-into-a-PetaLinux-Project

I have finished integrate SW Update into rootfs and boot successfull, and I can access webserver as image I attached.

I plan to reserve 2 partition on flash: one partition for update and one partition for load rootfs, image.ub, boot.bin:

flash@0 {
compatible = "n25q512a", "micron,m25p80";
#address-cells = <0x1>;
#size-cells = <0x1>;
reg = <0x0>;
spi-tx-bus-width = <0x1>;
spi-rx-bus-width = <0x4>;
spi-max-frequency = <0x66ff300>;

partition@0x00000000 {
label = "boot";
reg = <0x0 0xf00000>;
};

partition@0x00f00000 {
label = "bootenv";
reg = <0xf00000 0x40000>;
};

partition@0x00f40000 {
label = "kernel";
reg = <0xf40000 0x1400000>;
};

partition@0x02340000 {
label = "jffs2_3";
reg = <0x2340000 0xf00000>;
};

partition@0x03240000 {
label = "boot_1";
reg = <0x3240000 0xf00000>;
};

partition@0x04140000 {
label = "kernel_1";
reg = <0x4140000 0x1400000>;
};

partition@0x05540000 {
label = "jffs2_6";
reg = <0x5540000 0xf00000>;
};

partition@0x06440000 {
label = "user data";
reg = <0x6440000 0x1400000>;
};

chosen {
bootargs = "earlycon clk_ignore_unused root=mtd:jffs2_3 rw rootfstype=jffs2 rootwait";
stdout-path = "serial0:115200n8";
}

With rootfs.jffs2, May be I must need to override this in the kernel arguments in device-tree from user linux to load rootfs.jffs2 from partition jffs2_6:

chosen {
bootargs = "earlycon clk_ignore_unused root=mtd:jffs2_3 rw rootfstype=jffs2 rootwait";
stdout-path = "serial0:115200n8";
};

How to modify bootargs in device-tree once linux runtime?

Thanks and best regards

0 Kudos
5 Replies
Highlighted
Mentor
Mentor
521 Views
Registered: ‎06-16-2013

Re: How to modify device-tree once linux runtime?

Hi @sonminh 

 

How about regenerating fit image file by mkimage ?

 

Best regards,

0 Kudos
Highlighted
Adventurer
Adventurer
505 Views
Registered: ‎10-02-2018

Re: How to modify device-tree once linux runtime?

Hi @watari ,

I want to modify bootarg in device-tree from linux user after booted, not U-boot

0 Kudos
Highlighted
Mentor
Mentor
491 Views
Registered: ‎06-16-2013

Re: How to modify device-tree once linux runtime?

Hi @sonminh 

 

FIT image file is able to generated by mkimage (*1).

As you know there is argument of linux kernel in device tree blob file.

So, I suggest you to use it after booted. It's basic procedure in linux world. (For example, it is adopted in Ubuntu, Debian and so on.)

 

By the way, do you want to overlay device tree ?

 

*1)

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842374/U-Boot+Images

 

Best regards,

0 Kudos
Highlighted
Adventurer
Adventurer
466 Views
Registered: ‎10-02-2018

Re: How to modify device-tree once linux runtime?

Hi @watari,

I have read link that you provide. But I'm sorry because I don't understand how to modify bootargs in device-tree to load rootfs from differrent partition once runtime:

chosen {
bootargs = "earlycon clk_ignore_unused root=mtd:jffs2_3 rw rootfstype=jffs2 rootwait";
stdout-path = "serial0:115200n8";
};

Can you talk clearly about procedure?

0 Kudos
Highlighted
Mentor
Mentor
419 Views
Registered: ‎06-16-2013

Re: How to modify device-tree once linux runtime?

Hi @sonminh 

 

Here are solution.

 

# Temporally change rootfs

You can use chroot command to change root directory.

ex.

mount /dev/sdb1 /mnt/sdb1

cd /mnt/sdb1

mount -t proc proc proc/

mount -t sysfs sys sys/

mount -o bind /dev dev/

chroot /mnt/sdb1

 

# Permanetlly change rootfs

As I already mentioend, you can update fit image by using mkimage and so on.

 

Best regards,

0 Kudos