Skip to content

Commit a259eb7

Browse files
Clean up directory organization, libpico build (#129)
Also add a README.md to the tools directory.
1 parent 7f8f0cc commit a259eb7

File tree

11 files changed

+82
-37
lines changed

11 files changed

+82
-37
lines changed

lib/libpico.a

96 Bytes
Binary file not shown.
File renamed without changes.
File renamed without changes.

lib/platform_inc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-iwithprefixbefore/cores/rp2040/api/deprecated-avr-comp/
2-
-iwithprefixbefore/pico_base/
2+
-iwithprefixbefore/lib/pico_base/
33
-iwithprefixbefore/pico-examples/build/generated/pico_base
44
-iwithprefixbefore/pico-extras/src/common/pico_audio/include
55
-iwithprefixbefore/pico-extras/src/common/pico_util_buffer/include

pico-sdk-lib/boot.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

pico-sdk-lib/build.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

tools/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Tools directory for the RP2040 Arduino-Pico
2+
3+
# get.py
4+
Downloads and installs the toolchain into a GIT clone of the repo. Run
5+
once after the `git clone` and any time the toolchain JSON file updates.
6+
The `dist` directory caches downloaded toolchain files.
7+
8+
# discovery.py
9+
Run in the background by the IDE to scan for UF2 drives to show in the
10+
menus. Normally not run manually by the user.
11+
12+
# uf2conv.py
13+
Manages the upload of the UF2 formatted file to the board. Called as part
14+
of the IDE upload process. Will optionally send the serial reset signal
15+
to get the board into update mode (1200bps connection).
16+
17+
# simplesub.py
18+
Very dumb `sed`-like tool used by the platform scripts to generate the
19+
linker `.ld` file (replacing the EEPROM location, FS sizes, etc.).
20+
Because we run on Windows, Mac, and Linux, need to provide this and not
21+
rely on existance of `sed` command.
22+
23+
# pyserial
24+
`git clone` of the PySerial Python3 library to be used by the IDE.
25+
26+
# makeboards.py
27+
Generates `boards.txt` programmatically. Never edit the `boards.txt` file
28+
manually, use `python3 tools/makeboards.py > boards.py`. Change the script
29+
as necessary to add any add'l fields or menus required. Used because the
30+
`boards.txt` file is very repetitive and it's safer to generate with code
31+
than by hand.
32+
33+
# libpico/make-libpico.sh
34+
Builds the libpico.a file as well as the bootloader stage2 binaries.
35+
Run whenever the pico-sdk is updated.

pico-sdk-lib/CMakeLists.txt renamed to tools/libpico/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ target_link_libraries(pico
7272
)
7373

7474
add_custom_command(TARGET pico PRE_BUILD
75-
COMMAND ../../system/arm-none-eabi/bin/arm-none-eabi-gcc -g -c ../../assembly/crt0.S -I ../../pico-sdk/src/rp2040/hardware_regs/include -I ../../pico-sdk/src/common/pico_binary_info/include/
75+
COMMAND arm-none-eabi-gcc -g -c ../../../assembly/crt0.S -I "${PICO_SDK_PATH}/src/rp2040/hardware_regs/include" -I "${PICO_SDK_PATH}/src/common/pico_binary_info/include/"
7676
)
7777

7878
add_custom_command(TARGET pico POST_BUILD

tools/libpico/make-libpico.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on error
4+
5+
export PICO_SDK_PATH="$(cd ../../pico-sdk/; pwd)"
6+
export PATH="$(cd ../../system/arm-none-eabi/bin; pwd):$PATH"
7+
8+
rm -rf build
9+
mkdir build
10+
cd build
11+
cmake ..
12+
make -j
13+
mv libpico.a ../../../lib/.
14+
mv generated/pico_base/pico/version.h ../../../lib/pico_base/pico/.
15+
16+
rm -rf boot
17+
mkdir boot
18+
cd boot
19+
mkdir -p pico
20+
touch pico/config.h
21+
for type in boot2_generic_03h boot2_is25lp080 boot2_w25q080 boot2_w25x10cl; do
22+
for div in 2 4; do
23+
arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 \
24+
-DNDEBUG -DPICO_FLASH_SPI_CLKDIV=$div \
25+
-c "$PICO_SDK_PATH/src/rp2_common/boot_stage2/$type.S" \
26+
-I "$PICO_SDK_PATH/src/rp2040/hardware_regs/include/" \
27+
-I "$PICO_SDK_PATH/src/rp2_common/pico_platform/include/" \
28+
-I "$PICO_SDK_PATH/src/rp2_common/boot_stage2/asminclude/" \
29+
-I .
30+
31+
arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 \
32+
-DNDEBUG -Wl,--build-id=none --specs=nosys.specs -nostartfiles \
33+
-Wl,--script="$PICO_SDK_PATH/src/rp2_common/boot_stage2/boot_stage2.ld" \
34+
-Wl,-Map=$type.$div.elf.map $type.o -o $type.$div.elf
35+
36+
arm-none-eabi-objdump -h $type.$div.elf > $type.$div.dis
37+
arm-none-eabi-objdump -d $type.$div.elf >> $type.$div.dis
38+
39+
arm-none-eabi-objcopy -Obinary $type.$div.elf $type.$div.bin
40+
41+
python3 "$PICO_SDK_PATH/src/rp2_common/boot_stage2/pad_checksum" \
42+
-s 0xffffffff $type.$div.bin ${type}_${div}_padded_checksum.S
43+
done
44+
done
45+
mv *.S ../../../../assembly/.

0 commit comments

Comments
 (0)