redpitaya-puzzlefw/sw/23_sdcard_image.sh

29 lines
600 B
Bash
Raw Normal View History

2024-10-14 21:38:13 +02:00
#!/bin/bash
set -e
. script_env
# Delete stale output file.
rm -f "$SDCARD_IMG"
# Create empty SD card image.
dd if=/dev/zero of="$SDCARD_IMG" bs=1M seek=507 count=1
# Create partition table.
cat <<END | /sbin/sfdisk "$SDCARD_IMG"
label: dos
start=8192, size=512000, type=e
start=524288, size=512000, type=83
END
# Create DOS partition.
/sbin/mkdosfs -F 16 --offset 8192 ${SDCARD_IMG} 256000
# Copy files to SD card.
mcopy -i ${SDCARD_IMG}@@4M ${SDCARD_DIR}/* ::
# Create empty ext4 partition for configuration.
/sbin/mke2fs -t ext4 -b 4096 -E offset=$((524288 * 512)) ${SDCARD_IMG} 256000k