Skip to content

Instantly share code, notes, and snippets.

@Zixuan-Qiao
Created March 14, 2024 20:03
Show Gist options
  • Save Zixuan-Qiao/c655a37a09375575acb9d54d2a38d7c8 to your computer and use it in GitHub Desktop.
Save Zixuan-Qiao/c655a37a09375575acb9d54d2a38d7c8 to your computer and use it in GitHub Desktop.
Summary on how to save U-boot configuration to SD cards

Beaglebone Black - Saving U-boot Config to SD Cards

U-boot is an open-source boot loader used in embedded devices such as the Beaglebone Black. Like many other boot loaders, it can be configured to have different behaviors. However, saving the configuration may not be as straightforward as it seems. In this article, the issues I encountered and the corresponding solutions are documented, hopefully they can be helpful for others.

Issue of Saving without an SD Card

The u-boot that came with the board is compiled to save its configurations to the SD card, regardless of the availability. Thus, running saveenv without one will generate a "Card did not respond to voltage selected" error. This problem can be solved by adding an SD card or flashing the firmware. The second solution can be found on Bootlin's github: https://github.com/bootlin/training-materials/tree/master/lab-data/common/bootloader/beaglebone-black The first solution is introduced below.

Required Hardware

Beaglebone Black development board, PC running on Ubuntu (ver 20.04)

Serial to USB cable, USB type A to mini-B cable, micro SD card (SDHC) and adapter

Instruction

1. Format the SD card

Find the name of your card by running lsblk / fdisk -l / dmesg or checking under /dev.

Wipe out the data from the card:

dd if=/dev/zero of=/dev/$name-of-your-card$ bs=$size-dependent$ count=$size-dependent$

Create a GPT partition table with:

parted /dev/$name-of-your-card$ --script -- mklabel gpt

Create one EXT4 partition that takes all the space:

parted /dev/$name-of-your-card$ --script -- mkpart primary ext4 0% 100%

Format the partition:

mkfs.ext4 -F /dev/$name-of-your-card$

2. Adding configurations

Create a file named uEnv.txt in the SD card with the following content:

mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro
optargs=quiet

In the /etc/fstab file of your board, add:

/dev/mmcblk0p1 /media/data auto rw 0 0

3. Disable checksum

U-boot is not compatible with checksum, thus it has to be disabled.

First, validate your card with:

fsck /dev/$name-of-your-card-partition$

Then disable checksum with:

tune2fs -O ^metadata_csum /dev/$name-of-your-card-partition$

4. Create /boot directory

U-boot reads and writes the configuration file to /boot directory, if it does not exist, an "Invalid path" error will be generated.

Create /boot directory in your SD card with:

mkdir boot

Now, the saveenv command should be able to complete without error, and the configuration will be saved to the SD card.

References

  1. https://forum.digikey.com/t/question-for-card-did-not-respond-to-voltage-select/2763
  2. https://forum.beagleboard.org/t/strip-down-beaglebone-ai-to-save-costs/31517/6
  3. https://www.ti.com/lit/ds/symlink/am3359.pdf
  4. https://forum.beagleboard.org/t/surely-a-faq-but-i-cant-find-the-answer-maximum-sd-card-size-for-bbb/533
  5. https://groups.google.com/g/beagleboard/c/rK3y2ih1kig
  6. https://linuxize.com/post/how-to-format-usb-sd-card-linux/
  7. https://superuser.com/questions/923744/unable-to-format-partitioned-32-gb-micro-sd-card
  8. https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums
  9. https://elinux.org/Beagleboard:MicroSD_As_Extra_Storage
  10. https://stackoverflow.com/questions/30857575/using-sd-card-as-external-storage-for-beaglebone-black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment