cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
avcon_lee
Scholar
Scholar
718 Views
Registered: ‎07-17-2014

How to make system files writable

Jump to solution

hi everyone

After my board is started from the SD card, I want to operate the system files, such as creating a new folder test123 under the root directory, as shown in the following figure:

屏幕截图 2020-09-17 104733.png

But when I power off and restart, this folder is gone.

What I want to ask is how to make my operation not lost after power failure and restart.

By the way, I have unzipped rootfs.tar.gz and put it into the RootFs partition of SD card.

0 Kudos
1 Solution

Accepted Solutions
watari
Professor
Professor
327 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Did you include system-conf.dtsi during generating dtb phase ?

/{
	chosen {
	       bootargs = " earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait";
	       stdout-path = "serial0:115200n8";
	};
};

 

If no, would you copy the above into <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi ?

Also, you have to rebuild device tree by the following command.

 

petalinux-build -c device-tree -x cleansstate

petalinux-build -c device-tree

 

Would you try it ? Of cause you have to upgrade boot image, too.

 

Best regards,

 

View solution in original post

18 Replies
watari
Professor
Professor
695 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Would you share the following result to give you suggestion ?

 

df -kT

 

Best regards,

0 Kudos
avcon_lee
Scholar
Scholar
690 Views
Registered: ‎07-17-2014

屏幕截图 2020-09-17 104651.png

0 Kudos
watari
Professor
Professor
672 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Since you use initramfs as rootfs, you are facing this issue. Refer your shared picture.

In this case, you have to change linux kernel argument to achieve what you want to do.

 

Would you share whole boot log message to give you suggestion ?

 

Best regards,

0 Kudos
avcon_lee
Scholar
Scholar
655 Views
Registered: ‎07-17-2014

I checked the part about steps to configure initramfs boot in ug1144.

Do I need to copy rootfs.cpio.gz instead of rootfs.tar.gz to the SD card first, and then give you the boot log.

If necessary, does rootfs.cpio.gz also need to be decompressed

0 Kudos
watari
Professor
Professor
648 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Would you refer this page ?

You can achieve what you want to do.

 

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2021_1/ug1144-petalinux-tools-reference-guide.pdf#page=109

 

Best regards,

avcon_lee
Scholar
Scholar
566 Views
Registered: ‎07-17-2014

Thank you for your reply.

When I operated according to page 109, The system encountered a problem during startup. The log file is attached

SD card partition is operated according to page 222, including starting address, etc.

Now how do I solve it.

0 Kudos
watari
Professor
Professor
545 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

From the blow message, you can understand that you don't prepare initrd (*1) and initramfs (*1).

 

## Loading kernel from FIT Image at 10000000 ...
   Using 'conf@system-top.dtb' configuration
   Trying 'kernel@1' kernel subimage
     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x100000e8
     Data Size:    7828413 Bytes = 7.5 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x00080000
     Entry Point:  0x00080000
     Hash algo:    sha256
     Hash value:   459396ad5d32cf6c1b268b3987b4ae492d56f1475fc6fa46c0f1be15c572238a
   Verifying Hash Integrity ... sha256+ OK
## Loading fdt from FIT Image at 10000000 ...
   Using 'conf@system-top.dtb' configuration
   Trying 'fdt@system-top.dtb' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x107775b8
     Data Size:    40868 Bytes = 39.9 KiB
     Architecture: AArch64
     Hash algo:    sha256
     Hash value:   a1743398ae78919429047172ad02273ccc7acb48fe069e624f9a8a6624e5fb72
   Verifying Hash Integrity ... sha256+ OK
   Booting using the fdt blob at 0x107775b8
   Uncompressing Kernel Image
   Loading Device Tree to 000000000fff3000, end 000000000fffffa3 ... OK

 

*1)

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2021_1/ug1144-petalinux-tools-reference-guide.pdf#page=99

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2021_1/ug1144-petalinux-tools-reference-guide.pdf#page=100

 

Also, you can find kernel argument as below.

 

[    0.000000] Kernel command line: earlycon clk_ignore_unused

 

It means that kernel output log message via serial console before starting kernel and linux uses all arm core.

 

[    4.276305] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    4.283784] Please append a correct "root=" boot option; here are the available partitions:

 

As you might know, linux kernel requires root directory (/) as writable.

In this case, since you don't prepare proper rootfs, there is NOT rootfs, kernel outputs suggestion to you as "Please append a correct "root=" boot option; here are the available partitions:".

 

# How to resolve this issue ?

 

It's easy.

As you mentioned before, you'd like to use SD card. So, you need to add "root=/dev/mmcblk0p2" on kernel argument.

Would you try it ?

 

Or, would you refer the following URL ?

 

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2021_1/ug1144-petalinux-tools-reference-guide.pdf#page=61

 

Hope this helps.

 

Best regards,

avcon_lee
Scholar
Scholar
489 Views
Registered: ‎07-17-2014

Thank you very much for your patient explanation.

I set the root path here, but it doesn't seem to work.

 

捕获.PNG

The log in the above post is the result of the setting.

I wonder if there are other places to set up. I checked other posts with similar errors on the forum, mostly pointing to the SD card partition, or rebuilding the petalinux project, etc. I'm a little confused.

0 Kudos
watari
Professor
Professor
483 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Did you extract rootfs.tar.gz file to /dev/mmcblk0p2 as ext3 or ext4 ?

Also, you might need to adjust or update partition information.

 

Best regards,

0 Kudos
avcon_lee
Scholar
Scholar
456 Views
Registered: ‎07-17-2014

Yes, I use commands like the following:

$ sudo tar xvf rootfs.tar.gz -C /media/rootfs

 

I have a little doubt about SD card partition. It is mentioned in the document to ensure 4MB of free space:

1.png

but in the appendix h chapter, its first partition starts from 2048 sector. According to 512 bytes of a sector, there is only 2048 * 512 / 1024 / 1024 = 1MB of free space.

112R.png

so how to understand here.

0 Kudos
watari
Professor
Professor
438 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

I forgot detail about you mentioned.

But, would you try the following ?

 

# I assume device name of your SD card as /dev/sdb.

 

sudo umount /dev/sdb*
sudo parted -s -a optimal /dev/sdb mklabel msdos
sudo parted -s -a optimal /dev/sdb mkpart primary fat32 1 512
sudo parted -s -a optimal /dev/sdb mkpart primary ext4 513 100%
sudo mkfs.vfat -n BOOT /dev/sdb1
sudo mkfs.ext4 -F -L ROOT /dev/sdb2

 

Would you try it ?

 

Best regards,

 

0 Kudos
avcon_lee
Scholar
Scholar
434 Views
Registered: ‎07-17-2014

I tried, and the results were the same.

But thank you very much. These commands are very convenient to use.

0 Kudos
watari
Professor
Professor
398 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Would you share latest boot log message ?

 

FYI.

 

If you'd like to prepare 4MB space before 1st partition.

Would you try the following commands ?

 

sudo umount /dev/sdb*
sudo parted -s -a optimal /dev/sdb mklabel msdos
sudo parted -s -a optimal /dev/sdb mkpart primary fat32 5 516
sudo parted -s -a optimal /dev/sdb mkpart primary ext4 517 100%
sudo mkfs.vfat -n BOOT /dev/sdb1
sudo mkfs.ext4 -F -L ROOT /dev/sdb2

 

Best regards,

0 Kudos
avcon_lee
Scholar
Scholar
370 Views
Registered: ‎07-17-2014

According to the latest command you provided, I tested it. The results don't seem to have changed

The log file is attached

I also tried to build a new petalinux project, but it still didn't work.

0 Kudos
watari
Professor
Professor
353 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

According to boot log, unfortunately, there is not rootfs description on kernel argument.

Could you share system-conf.dtsi and your dtb file ?

 

I will confirm them in my side.

 

BTW, I suggest you to make sure the procedure for building dtb.

 

Hope this helps.

 

Best regards,

0 Kudos
avcon_lee
Scholar
Scholar
337 Views
Registered: ‎07-17-2014

Thank you for your reply, .dtsi and dtb files are attached.

I don't know much about DTB files. I use the petalinux-build command to operate, and then use the following command to generate bin files:

petalinux-package --boot --fsbl zynqmp_fsbl.elf --fpga system.bit --pmufw pmufw.elf --atf bl31.elf --u-boot u-boot.elf --force

Just now I included the dtb file with the following command:

petalinux-package --boot --fsbl zynqmp_fsbl.elf --fpga system.bit --pmufw pmufw.elf --atf bl31.elf --dtb system.dtb --u-boot u-boot.elf --force

But the result is the same,do I miss some steps?

0 Kudos
watari
Professor
Professor
328 Views
Registered: ‎06-16-2013

Hi @avcon_lee 

 

Did you include system-conf.dtsi during generating dtb phase ?

/{
	chosen {
	       bootargs = " earlycon console=ttyPS0,115200 clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait";
	       stdout-path = "serial0:115200n8";
	};
};

 

If no, would you copy the above into <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi ?

Also, you have to rebuild device tree by the following command.

 

petalinux-build -c device-tree -x cleansstate

petalinux-build -c device-tree

 

Would you try it ? Of cause you have to upgrade boot image, too.

 

Best regards,

 

View solution in original post

avcon_lee
Scholar
Scholar
307 Views
Registered: ‎07-17-2014

After including the system-conf.dtsi  file in the system-user.dtsi  file, the log file has made new progress.

Finally, after extracting rootfs.cpio to the root partition of SD card, the system logs in successfully.

There is a problem using the extracted rootfs.tar.gz file.

I found the init file in rootfs.cpio, but not in rootfs.tar.gz.

Thank you again for your reply.

0 Kudos