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

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
participants (1)
-
Wolfgang Denk