How to overwrite an ext partition on eMMC

Sascha Hauer s.hauer at pengutronix.de
Tue Jul 5 03:06:50 PDT 2016


On Tue, Jul 05, 2016 at 09:32:30AM +0000, Martin Hollingsworth wrote:
> Hi Sascha,
> huge thanks, that was just the right push in the right direction. Both suggested methods - cp and memcpy - work fine. Problem solved.
> 
> > Why don't you use the partitions from the partition table on the device?
> > I would assume you use /dev/mmc3.2 for the rootfs.
> 
> I assume you are referring to using "detect -a" to find the device,
> which is then registered as mmc3.0 (for first partition). As I was
> struggling to write the root.ext2 onto that device I decided to try
> using the devfs_add_partition() method, as all nand flash based
> devices I have as reference use this approach. However I just
> verified, using the detected partition works as well and it is
> probably the better way of doing it, as the partitions can be moved
> around more easily.
> 
> In another side question you write: "I would assume you use
> /dev/mmc3.2 for the rootfs". As I currently only copy the Barebox raw
> onto the eMMC offset 0x400 for iMX6 it is not listed as partition
> under /dev/. What is the standard approach here, should the Barebox
> best be a FAT32 partition so it is listed?

For updating barebox you should use a barebox update handler. Register
it with imx6_bbu_internal_mmc_register_handler() and use the
barebox_update command to update barebox. This way you can be sure that
you only write suitable files on the device and also the partition table
is preserved properly.

eMMC devices also often have boot partitions which can be used to store
barebox. These allow to put barebox away from the regular storage where
it can't be overwritten that easily. You can copy barebox to
/dev/mmc3.boot0 (Or let the mentioned update handler point to that
place) and set mmc3.boot=boot0 to let the i.MX6 ROM know that it should
boot from there.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list