Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible: TFTP in u-boot to load root filesystem to SD card? (I don't want NFS)

I know we can use NFS, but I just don't want to use it.

(don't want to keep network connection to NFS server all the time).

  • I know we can use tftp in u-boot to load kernel and device-tree!
  • But can we use tftp in u-boot to download root-filesystem, put it in the right partition of SD card, and boot?
  • If yes, how to do it? (I googled, but found no answers)

Thanks, Jerry

like image 899
Jerry Avatar asked Oct 18 '25 11:10

Jerry


1 Answers

I use TFTP in uboot to flash my rootfs (for debug purposes) on my internal eMMC. It's nearly the same case as you.

First download in you RAM the filesystem:

tftpboot ${rootfs_addr} ${tftppath}/${rootfs_file}
  • rootfs_addr will be the RAM address, I use 0x10800000.
  • tftppath is the TFTP path (depends on your configuration)
  • rootfs_file is the ext4 or ext3 file

Then update the mmc device (you can run mmc listto show SD u-boot number)

mmc dev 2

Here I set the device to the number 2, you need to set it corresponding to the mmc list command.

Then write the content of the RAM to the SD:

setexpr rootfsblksz ${filesize} / 200 
setexpr rootfsblksz ${rootfsblksz} + 1 
mmc write ${rootfs_addr} 6000 ${rootfsblksz}

Description:

  • I create a rootfsblksz variable, it converts the number of bytes downloaded to a number of blocks. filesizeis set automatically when we use TFTP, it represents the size of the last downloaded file (in Bytes). Here my block is 512Bytes (0x200)
  • I add +1 to the blocksize (to be shure to have all the data)
  • I write it on the eMMC (or SD) at the address 0x6000 (in blocks) -> 24 576 blocks -> 12 582 912 (in Bytes) -> 12MB because my ext partition is at 12MB offset

Hope it helps!

like image 184
PierreOlivier Avatar answered Oct 22 '25 07:10

PierreOlivier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!