Skip to content

Commit 1e3e962

Browse files
committed
Add script for aligning RP2040 binaries
1 parent e986208 commit 1e3e962

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tools/rp2040_4k_align.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

0 commit comments

Comments
 (0)