[U-Boot] Writing to SD partitions from u-boot

David Cemin davidcemin at gmail.com
Fri Feb 28 10:46:10 CET 2014


Hi,

I am trying to use u-boot to replace kernel and filesystem in the SD card.
 I have this set of partitions:

SOCFPGA_CYCLONE5 # mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2121728         1000001         00000000-01     0b
  2     14336           2097153         00000000-02     83
  3     2048            2049            00000000-03     a2


First partition is used to store kernel and dtb files. Second, to store
filesystem and the third stores preloader and u-boot.

Currently, i boot the board by calling mmcload and mmcboot.

mmcboot=setenv bootargs console=ttyS0,57600 root=${mmcroot} rw
rootwait;bootz ${loadaddr} - ${fdtaddr}
mmcload=mmc rescan;${mmcloadcmd} mmc 0:${mmcloadpart} ${loadaddr}
${bootimage};${mmcloadcmd} mmc 0:${mmcloadpart} ${fdtaddr} ${fdtimage}
mmcloadcmd=fatload
mmcloadpart=1
mmcroot=/dev/mmcblk0p2

mmcload script loads kernel and dtb from sdcard to memory and mmcboot boots
using this values and setting root do the second partition of the sdcard.


My first idea would be:

1) tftp rootfs to memory and rewrite the partition 2 from my card.
2) tftp kernel and dtb files and boot from there.

The item 2) can be achieved by calling the script getkernel below:
getkernel=setenv bootargs console=ttyS0,57600 root=${mmcroot} rw
rootwait;tftp ${loadaddr} ${bootimage}; tftp ${fdtaddr} ${fdtimage}; bootz
${loadaddr} - ${fdtaddr}


I am having troubles with the first step though.

First I downloaded the rootfs.img to an address that its not in use
($fpgadata = 0x200000 and $fsimage=rootfs.dtb) :
tftp ${fpgadata} ${fsimage}

My second partition is fomated as ext3 (type 83), but u-boot doesnt have
commands to write to ext partitions. I tried using fatwrite, but it didnt
work, and my first guess is that fatwrite is used to write to partitions
using fat.

 fatwrite mmc 0:2 ${fpgadata} rootfs.img 52428800

** Unable to use mmc 0:2 for fatwrite **

So another option would be using mmc write, but i cant change the partition
from it so that i can write. mmc write has the following syntax:
mmc write addr blk# cnt

So it will write in the current mmc partition the content of the address
addr with size indexed by blk# and cnt.

SOCFPGA_CYCLONE5 # mmc dev 0 2
Card doesn't support part_switch


So i dont know what actually would be easier to do. I could:

1) Change partition 2 to ubifs, and hope that the ubi utilities have
read/write functions implemented;
2) Write the functions in c to write to ext filesystems and export that to
use in the macros on boot prompt

So does anyone have any idea ? It can be another approach or even some
thoughts in what I am trying to do. That would be very helpful !

Thank you.

-- 
David Cemin
+49 0152-3670-8342


More information about the U-Boot mailing list