File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # -----------------------------------------------------------------------
3+ # rp2040_4k_align.sh - Aligns binary file size to 4KB multiples
4+ # -----------------------------------------------------------------------
5+ # Purpose:
6+ # Pads binary files to 4KB block size to work around an issue with
7+ # the RP2040 bootrom as described in the RP2040 datasheet errata section.
8+ #
9+ # Usage:
10+ # ./rp2040_4k_align.sh input_file output_file
11+ #
12+ # Arguments:
13+ # $1 - Input file path
14+ # $2 - Output file path
15+ #
16+ # Example:
17+ # ./rp2040_4k_align.sh picoboot.bin picoboot_padded.bin
18+ # -----------------------------------------------------------------------
19+
20+ dd if=/dev/zero of=" $2 " bs=1 count=$(( ($(stat - c% s "$1 ") + 4096 - 1 ) / 4096 * 4096 )) 2> /dev/null
21+ dd if=" $1 " of=" $2 " bs=1 count=$( stat -c%s " $1 " ) conv=notrunc 2> /dev/null
You can’t perform that action at this time.
0 commit comments