creating flasher image file from running Beaglebone

117 views
Skip to first unread message

John Allwine

unread,
Apr 21, 2021, 5:01:19 PM4/21/21
to BeagleBoard
What's the easiest way to create a Beaglebone flasher image file from a running system? I currently use the beaglebone-black-make-microSD-flasher-from-eMMC.sh script to directly write to a microSD card. I then use dd to copy the microSD card to a file. I currently only have a 32GB microSD card, though, so when I copy it the file is 32GB. With compression that mostly goes away, but and I'd also like it to work with smaller cards than that. Any ideas what the ideal solution is?

Robert Nelson

unread,
Apr 21, 2021, 5:06:00 PM4/21/21
to Beagle Board
On Wed, Apr 21, 2021 at 4:01 PM John Allwine <jo...@pocketnc.com> wrote:
>
> What's the easiest way to create a Beaglebone flasher image file from a running system? I currently use the beaglebone-black-make-microSD-flasher-from-eMMC.sh script to directly write to a microSD card. I then use dd to copy the microSD card to a file. I currently only have a 32GB microSD card, though, so when I copy it the file is 32GB. With compression that mostly goes away, but and I'd also like it to work with smaller cards than that. Any ideas what the ideal solution is?


You should be able to use gparted to shrink the partition size down,
then just dd to the last sector used.. (untested in theory..)

Regards,


--
Robert Nelson
https://rcn-ee.com/

John Allwine

unread,
Apr 22, 2021, 9:26:31 AM4/22/21
to beagl...@googlegroups.com
How about changing the partition size in the make flasher script? Could there be an option to make it the same size as the eMMC? Where is the partition size determined?

> On Apr 21, 2021, at 3:05 PM, Robert Nelson <robert...@gmail.com> wrote:
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAOCHtYge9qFsN1Tq_ZzrxRyhieT_Zz%3DjUbF9SzXO4sDPxeR8Xg%40mail.gmail.com.

Robert Nelson

unread,
Apr 22, 2021, 9:58:42 AM4/22/21
to Beagle Board
On Thu, Apr 22, 2021 at 8:26 AM John Allwine <jo...@pocketnc.com> wrote:
>
> How about changing the partition size in the make flasher script? Could there be an option to make it the same size as the eMMC? Where is the partition size determined?

https://github.com/RobertCNelson/boot-scripts/blob/master/tools/eMMC/functions.sh#L1311-L1318

LC_ALL=C sfdisk ${sfdisk_options} "${destination}" <<-__EOF__
${sfdisk_boot_startmb},,${sfdisk_fstype},*

Change to:
${sfdisk_boot_startmb},${some new var for size},${sfdisk_fstype},*

John Allwine

unread,
Apr 22, 2021, 1:42:06 PM4/22/21
to BeagleBoard
Thanks Robert! I issued a pull request with a couple minor changes to add a variable where you explained:

Here's the text of the pull request that describes how it could be used to make a smaller image size than the size of your microSD card:

Setting the conf_rootfs_partition_size variable allows for better control over the size of the microSD card necessary to house the resulting image when running the beaglebone-black-make-microSD-flasher-from-eMMC.sh script. For example, you might be working with a 32GB microSD card image, but want to generate an image that would also fit on a 4GB microSD card, so you could do the following:
sudo conf_rootfs_partition_size=7462912 /opt/scripts/tools/eMMC/beaglebone-black-make-microSD-flasher-from-eMMC.sh

Which would specify the size as 7462912 sectors, which is the size of the eMMC rootfs partition (at least on the one I was testing on). After making the flasher you could then use dd to get the image off the microSD card for flashing onto other microSD cards:

sudo dd if=<path to microSD card device> of=<path to image file> bs=512 count=7471104

7471104 can be determined by the output from fdisk -l (one more than the End sector, or 8192 more than the size of the rootfs partition):
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 7471103 7462912 3.6G 83 Linux

You may be able to speed up the dd command by using a bigger blocksize and adjusting the count accordingly (using a 4MB block size):
sudo dd if=<path to microSD card device> of=<path to image file> bs=419430 count=912


Robert Nelson

unread,
Apr 22, 2021, 2:03:22 PM4/22/21
to Beagle Board
On Thu, Apr 22, 2021 at 12:42 PM John Allwine <jo...@pocketnc.com> wrote:
>
> Thanks Robert! I issued a pull request with a couple minor changes to add a variable where you explained:
> https://github.com/RobertCNelson/boot-scripts/pull/124
>
> Here's the text of the pull request that describes how it could be used to make a smaller image size than the size of your microSD card:
>
> Setting the conf_rootfs_partition_size variable allows for better control over the size of the microSD card necessary to house the resulting image when running the beaglebone-black-make-microSD-flasher-from-eMMC.sh script. For example, you might be working with a 32GB microSD card image, but want to generate an image that would also fit on a 4GB microSD card, so you could do the following:
> sudo conf_rootfs_partition_size=7462912 /opt/scripts/tools/eMMC/beaglebone-black-make-microSD-flasher-from-eMMC.sh
>
> Which would specify the size as 7462912 sectors, which is the size of the eMMC rootfs partition (at least on the one I was testing on). After making the flasher you could then use dd to get the image off the microSD card for flashing onto other microSD cards:
>
> sudo dd if=<path to microSD card device> of=<path to image file> bs=512 count=7471104
>
> 7471104 can be determined by the output from fdisk -l (one more than the End sector, or 8192 more than the size of the rootfs partition):
> Device Boot Start End Sectors Size Id Type
> /dev/mmcblk0p1 * 8192 7471103 7462912 3.6G 83 Linux
>
> You may be able to speed up the dd command by using a bigger blocksize and adjusting the count accordingly (using a 4MB block size):
> sudo dd if=<path to microSD card device> of=<path to image file> bs=419430 count=912

Thanks all merged up!

PS, you can add the variable to /boot/SOC.sh:

https://github.com/RobertCNelson/boot-scripts/blob/master/tools/eMMC/functions.sh#L1114
Reply all
Reply to author
Forward
0 new messages