4

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

8
  • 1
    I'm pretty sure that u-boot's tftp command only reads into RAM - you could then write it to storage with other u-boot commands. You'd have to have enough RAM to hold the whole thing, and you'd have to know an appropriate RAM address to use, and the appropriate place on your storage device to write to - none of this can be answered generically. Commented Nov 3, 2017 at 16:44
  • 1
    isn't the idea of "TFTP to load root filesystem" also useful during the developing stage? I thought it should have been realized already.
    – Jerry
    Commented Nov 3, 2017 at 17:37
  • Problem is stated too vaguely, i.e. what file format (image, tar) is the rfs? U-Boot can be configured to have file write capability for ext4 filesystems, or write sectors to the mmc device. But there's no tar extraction. You could always extend U-Boot functionality with a "standalone application" (which could itself be downloaded using TFTP).
    – sawdust
    Commented Nov 3, 2017 at 23:01
  • The specific file format is irrelevant: whichever format works, I will use that format! Basically I prefer to "load everything over network", instead of plug/unplug SD-card reader. This is my key-point!
    – Jerry
    Commented Nov 7, 2017 at 16:13
  • Then create an image of an ext4 fs, and write it using the mmc commands. But for testing a kernel I prefer to use an initramfs: it's appended to the kernel, so the kernel + initramfs is downloaded to the target as one image.
    – sawdust
    Commented Nov 7, 2017 at 19:17

1 Answer 1

5

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!

1
  • Thanks Pierre for your detailed instructions, it works awesome!
    – Jerry
    Commented Dec 4, 2017 at 21:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.