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

Wolfgang Denk wd at denx.de
Fri Feb 28 12:23:21 CET 2014


Dear David,

In message <CADqAesiEy5dwjZ5V7qHSVSsEDiOFLzWRWRzY4xgRKdd=gri3uw at mail.gmail.com> you wrote:
>
> First partition is used to store kernel and dtb files. Second, to store
> filesystem and the third stores preloader and u-boot.

Actually this information is mostly irrelevant.  Partitions do not
play a big role here - what matters are file systems.

> 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.

This makes no sense.  If you download a file system _image_ then you
cannot use any file system level commands to write such an image - you
must write the image directly to the storage device.  In your case,
with a MMC based storage device, that would be done using "mmc write".

There are more errors in your posting:

- U-Boot does support writing to ext file system - EXT4, to be
  precise. See CONFIG_CMD_EXT4_WRITE

- fatwrite (and the other fat* commands) operate on FAT file systems;
  it does not matter of these are on partitions with FAT partition
  type.  If you like, you can also put a FAT file system on a partitin
  marked as "swap space" (type 82) and it will just work fine.

But as mentioned - using any file system level commands is inherently
wrong when you try to store a file system image.

> 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

s is the correct thing to do.

> 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

Well, not this is your real problem.  Fix it.

> 1) Change partition 2 to ubifs, and hope that the ubi utilities have
> read/write functions implemented;

It makes no sense to use UBIFS on a MMC device.

> 2) Write the functions in c to write to ext filesystems and export that to
> use in the macros on boot prompt

You do not want to write to an ext (or any other) file system - you
want to write to the raw storage device.  For MMC, this is done with
the "mmc write" command.  If this is not working for you (because you
cannot switch partitions), then you should fix the root cause - the
failing partition switch.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Remember that the best relationship is one in  which  your  love  for
each other exceeds your need for each other.             - Dalai Lama


More information about the U-Boot mailing list