All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Writing to SD partitions from u-boot
Date: Fri, 28 Feb 2014 18:56:50 +0100	[thread overview]
Message-ID: <20140228175650.32666380BF4@gemini.denx.de> (raw)
In-Reply-To: <CADqAesgH4uFznSFYZutvsB64Tr6gD3DwL4kttUGqinWUmhKcMQ@mail.gmail.com>

Dear David,

please make sure to keep the mailing list on Cc:

In message <CADqAesgH4uFznSFYZutvsB64Tr6gD3DwL4kttUGqinWUmhKcMQ@mail.gmail.com> you wrote:
>
> Ok, thats good to know, thank you. That doesnt explain though what kind of
> sd cards I should use to be able to switch partitions. Am I
> misunderstanding the function that does that? From the code, i will only be
> able to do that when mmc->part_config is different than 0xff
> (MMCPART_NOAVAILABLE). What should I do with my card to get it to work ?

I don't see why exactly you need to switch partitions...

The "mme part" command will print you the numbers of the first sector
in each partition, so it's trivial to write an image.

For example, assume we want to write the file system image
"rootfs.img" into the second partition of an SDcard:

=> tftp $loadaddr rootfs.img
Using FEC device
TFTP from server 192.168.1.1; our IP address is 192.168.20.56
Filename 'rootfs.img'.
Load address: 0x70800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ############
         763.7 KiB/s
done
Bytes transferred = 16385024 (fa0400 hex)
=> setexpr cnt $filesize + 0x1ff
=> setexpr cnt $cnt / 0x200
=> mmc part

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

Part    Start Sector    Num Sectors     UUID            Type
  1     8192            131072          00000000-01     83
  2     139264          7753728         00000000-02     83
=> mmc write $loadaddr 0x22000 $cnt

MMC write: dev # 0, block # 139264, count 32002 ... 32002 blocks write: OK


The only "tricky" part here is to convert the decimal number 139264
for the start sector of partition 2 into hexadecimal format as
expected by "mmc write": decimal 139264 = 0x22000.

[Note that even the conversion of the file size in bytes into block
numbers can be scripted with two simple "setexpr" commands.]


Hope this helps.

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
When in doubt, mumble;   when in trouble, delegate;  when in  charge,
ponder.                                             -- James H. Boren

      parent reply	other threads:[~2014-02-28 17:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28  9:46 [U-Boot] Writing to SD partitions from u-boot David Cemin
2014-02-28 11:23 ` Wolfgang Denk
2014-02-28 12:12   ` David Cemin
     [not found]   ` <CADqAesiqEdc41z1zc7nAQJXLaKe5q-cTUbXwi3N_bPJTJeyKaQ@mail.gmail.com>
2014-02-28 14:50     ` Wolfgang Denk
     [not found]     ` <20140228145054.9B5C4381338@gemini.denx.de>
     [not found]       ` <CADqAesgH4uFznSFYZutvsB64Tr6gD3DwL4kttUGqinWUmhKcMQ@mail.gmail.com>
2014-02-28 17:56         ` Wolfgang Denk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140228175650.32666380BF4@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.