Image wic with extended partition

Hello,

I need to create a wic image to flash internal mmc with a reserved partition. I need to flash the mmc 0 using the u-boot gzwrite command.

This would be the partition:

/dev/mmcblk0p1 fat boot partition
/dev/mmcblk0p2 ext4 reserved not changed by gzwrite
/dev/mmcblk0p3 / rootfs

Thank you

Best regards

Flavio

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello Flavio,

Thank you for your question!

Based on your requirements, you want to create a .wic image for an internal eMMC, with a reserved ext4 partition that should not be overwritten when using the U-Boot gzwrite command to flash the image.

Here are some key points and workflow recommendations for Toradex modules:

Partition Scheme on Toradex Modules

It is possible to create a custom partition scheme like the one you described:

  • /dev/mmcblk0p1: FAT boot partition (for bootloader/kernel)
  • /dev/mmcblk0p2: ext4 reserved partition (keep intact)
  • /dev/mmcblk0p3: ext4 rootfs (main Linux system)

Reference: Booting from eMMC on Apalis/Colibri modules

About WIC Images

A .wic image typically represents the whole disk layout, so flashing it will overwrite all partitions on your eMMC unless you use a tool or method that flashes only a specific partition.

Using gzwrite in U-Boot

The U-Boot gzwrite command (often available in newer U-Boot versions) is designed to write compressed images directly to a block device. When used to flash a full disk image, it will overwrite the entire device, including your reserved partition.

To preserve your reserved partition (/dev/mmcblk0p2), consider these options:

Option 1: Flash Only Specific Partitions

  • Split your images (for p1 and p3) and write them individually to their corresponding partitions using raw device writes in U-Boot or Linux, leaving p2 untouched. You can create a separate image for the boot and rootfs partitions.
  • This requires your install process (or U-Boot script) to address each partition by offset and size.
  • U-Boot commands for individual partitions may depend on the availability of commands like mmc write.

Option 2: Custom Installation Process

  • Use the Toradex Easy Installer, which can be scripted to preserve certain partitions if you customize its manifest accordingly.

Option 3: Two-Stage Flashing

  • Flash the whole image (with the reserved partition unformatted), then in a secondary process, restore or re-create the reserved partition’s contents if needed.

Summary Recommendation

If your requirement is to never overwrite /dev/mmcblk0p2, it is safest to avoid full-disk images with .wic for gzwrite and instead update partitions individually.

  • If you must use gzwrite with a .wic image, be aware this will overwrite all partitions.
  • For production, using a scripting approach (with part-by-part updates) or the Easy Installer with a custom script will give you the fine control necessary.

Learn more here:

If you need assistance on scripting individual partition updates or customizing the Toradex Easy Installer, please let me know!

Best regards,
Toradex AI Assistant.