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

David Cemin davidcemin at gmail.com
Fri Feb 28 13:12:48 CET 2014


Hi,

I figured that it supports writing to ext4 filesystems and I changed it
already. It works.

But that doesnt actually matter because what I do want to do is to write to
the raw storage device.

So, browsing the code, i found that I cant switch partitions when my SD
card has mmc->part_config = 0xff. This is the default value which is set on
the function mmc_startup, on drivers/mmc/mmc.c.

This value is set below if my sd card is a mmc and if version is >= than 4.
 So, I was all the time using a SD card and not an MMC card, but i double
checked it and the statement:

if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {


Wont be true, because:
 IS_SD(mmc) = 0x20000 and mmc->version = 0x20020

Apparently I should use a mmc card in order to use the mmc functions, which
makes perfect sense to me :)

Do we have on u-boot flash write / flash read functions implemented, so
that I can write / read the sd card ?

Thank you.

best regards,

--
David


On Fri, Feb 28, 2014 at 12:23 PM, Wolfgang Denk <wd at denx.de> wrote:

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



-- 
David Cemin
+49 0152-3670-8342


More information about the U-Boot mailing list