Skip to content

Commit cc54299

Browse files
committed
Runs on the Pico 2.
Tested showing 640x480@4bpp images and running the neotracker with DAMAGE.MOD.
1 parent 351571c commit cc54299

File tree

9 files changed

+169
-72
lines changed

9 files changed

+169
-72
lines changed

.cargo/config.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
[target.thumbv6m-none-eabi]
2-
# This will make a UF2 and copy it to the RP2040's Mass Storage Device bootloader
3-
# runner = "elf2uf2-rs -d"
4-
# This will flash over SWD with any compatible probe it finds.
5-
runner = "probe-rs run --chip RP2040 --speed 10000"
1+
[target.thumbv8m.main-none-eabihf]
2+
# This will load the binary with picotool
3+
runner = "picotool load -v -u -x -t elf"
64
rustflags = [
75
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
86
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
@@ -16,7 +14,7 @@ rustflags = [
1614
]
1715

1816
[build]
19-
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
17+
target = "thumbv8m.main-none-eabihf" # Cortex-M33
2018

2119
[env]
2220
DEFMT_LOG = { value = "info" }

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ jobs:
2424
run: |
2525
rustup toolchain install stable --profile minimal --no-self-update
2626
rustup default stable
27-
rustup target add thumbv6m-none-eabi
27+
rustup target add thumbv8m.main-none-eabihf
2828
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
2929
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
3030
3131
- name: Build neotron-pico-bios
3232
run: |
3333
cargo build --release --verbose
34-
mv ./target/thumbv6m-none-eabi/release/neotron-pico-bios ./target/thumbv6m-none-eabi/release/neotron-pico-bios.elf
35-
elf2uf2-rs ./target/thumbv6m-none-eabi/release/neotron-pico-bios.elf
34+
mv ./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios ./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.elf
35+
# elf2uf2-rs ./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.elf
3636
3737
- name: Upload Artifacts
3838
uses: actions/upload-artifact@v4
@@ -41,15 +41,15 @@ jobs:
4141
name: Artifacts
4242
if-no-files-found: error
4343
path: |
44-
./target/thumbv6m-none-eabi/release/neotron-pico-bios.elf
45-
./target/thumbv6m-none-eabi/release/neotron-pico-bios.uf2
44+
./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.elf
45+
./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.uf2
4646
4747
- name: Upload files to Release
4848
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
4949
uses: softprops/action-gh-release@v1
5050
with:
5151
files: |
52-
./target/thumbv6m-none-eabi/release/neotron-pico-bios.elf
53-
./target/thumbv6m-none-eabi/release/neotron-pico-bios.uf2
52+
./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.elf
53+
./target/thumbv8m.main-none-eabihf/release/neotron-pico-bios.uf2
5454
env:
5555
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/clippy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
- name: Add targets/components
2020
run: |
2121
rustup component add clippy
22-
rustup target add thumbv6m-none-eabi
22+
rustup target add thumbv8m.main-none-eabihf
2323
2424
- name: Run Clippy
2525
run: |
26-
cargo clippy --target=thumbv6m-none-eabi --all-features
26+
cargo clippy --target=thumbv8m.main-none-eabihf --all-features

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"coreConfigs": [
1515
{
1616
// Change this to the binary you want to debug
17-
"programBinary": "${workspaceFolder}/target/thumbv6m-none-eabi/release/neotron-pico-bios",
17+
"programBinary": "${workspaceFolder}/target/thumbv8m.main-none-eabihf/release/neotron-pico-bios",
1818
"rttEnabled": true
1919
}
2020
],

Cargo.lock

Lines changed: 80 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ version = "0.7.0"
1111
# Useful Cortex-M specific functions (e.g. SysTick)
1212
cortex-m = "0.7"
1313
# The Raspberry Pi RP2040 HAL (so we can turn defmt on)
14-
rp2040-hal = { version = "0.10", features = [ "defmt", "rt", "critical-section-impl", "rom-func-cache" ] }
14+
# rp2040-hal = { version = "0.10", features = [ "defmt", "rt", "critical-section-impl", "rom-func-cache" ] }
15+
rp235x-hal = { git = "https://github.com/rp-rs/rp-hal", branch = "add-rp235x", features = [ "defmt", "rt", "critical-section-impl", "rom-func-cache" ]}
1516
# Cortex-M run-time (or start-up) code
1617
cortex-m-rt = "0.7"
1718
# The BIOS to OS API

memory.x

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,18 @@
88

99
MEMORY {
1010
/*
11-
* This is bootloader for the RP2040. It must live at the start of the
12-
external flash chip.
11+
* The Pico 2 has 4096 KiB of external Flash Memory. We allow ourselves 128
12+
* KiB for the BIOS, leaving the rest for the OS and any user applications.
1313
*/
14-
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
14+
FLASH : ORIGIN = 0x10000000, LENGTH = 128K
1515
/*
16-
* The Pico has 2048 KiB of external Flash Memory. We allow ourselves 128
17-
* KiB for the BIOS, leaving the rest
18-
* for the OS and any user applications.
16+
* This is the remainder of the 4096 KiB flash chip.
1917
*/
20-
FLASH : ORIGIN = 0x10000100, LENGTH = 128K - 0x100
21-
/*
22-
* This is the remainder of the 2048 KiB flash chip.
23-
*/
24-
FLASH_OS : ORIGIN = 0x10020000, LENGTH = 2048K - 128K
18+
FLASH_OS : ORIGIN = 0x10020000, LENGTH = 4096K - 128K
2519
/*
2620
* This is the bottom of the four striped banks of SRAM in the RP2040.
2721
*/
28-
RAM_OS : ORIGIN = 0x20000000, LENGTH = 0x42000 - 0x9300
22+
RAM_OS : ORIGIN = 0x20000000, LENGTH = 0x82000 - 0x9300
2923
/*
3024
* This is the top of the four striped banks of SRAM in the RP2040, plus
3125
* SRAM_BANK4 and SRAM_BANK5.
@@ -36,7 +30,7 @@ MEMORY {
3630
* 0x9300 should be the (size of .data + size of .bss + size of .uninit +
3731
* 0x2000 for the stack).
3832
*/
39-
RAM : ORIGIN = 0x20042000 - 0x9300, LENGTH = 0x9300
33+
RAM : ORIGIN = 0x20082000 - 0x9300, LENGTH = 0x9300
4034
}
4135

4236
/*
@@ -48,17 +42,55 @@ _ram_os_start = ORIGIN(RAM_OS);
4842
_ram_os_len = LENGTH(RAM_OS);
4943

5044
SECTIONS {
51-
/* ### RP2040 Boot loader */
52-
.boot2 ORIGIN(BOOT2) :
45+
/* ### Boot ROM info
46+
*
47+
* Goes after .vector_table, to keep it in the first 4K of flash
48+
* where the Boot ROM (and picotool) can find it
49+
*/
50+
.start_block : ALIGN(4)
51+
{
52+
__start_block_addr = .;
53+
KEEP(*(.start_block));
54+
} > FLASH
55+
56+
} INSERT AFTER .vector_table;
57+
58+
/* move .text to start /after/ the boot info */
59+
_stext = ADDR(.start_block) + SIZEOF(.start_block);
60+
61+
SECTIONS {
62+
/* ### Picotool 'Binary Info' Entries
63+
*
64+
* Picotool looks through this block (as we have pointers to it in our
65+
* header) to find interesting information.
66+
*/
67+
.bi_entries : ALIGN(4)
5368
{
54-
KEEP(*(.boot2));
55-
} > BOOT2
69+
/* We put this in the header */
70+
__bi_entries_start = .;
71+
/* Here are the entries */
72+
KEEP(*(.bi_entries));
73+
/* Keep this block a nice round size */
74+
. = ALIGN(4);
75+
/* We put this in the header */
76+
__bi_entries_end = .;
77+
} > FLASH
78+
} INSERT AFTER .text;
5679

57-
/* ### Neotron OS */
58-
.flash_os ORIGIN(FLASH_OS) :
80+
SECTIONS {
81+
/* ### Boot ROM extra info
82+
*
83+
* Goes after everything in our program, so it can contain a signature.
84+
*/
85+
.end_block : ALIGN(4)
5986
{
60-
KEEP(*(.flash_os));
61-
} > FLASH_OS
62-
} INSERT BEFORE .text;
87+
__end_block_addr = .;
88+
KEEP(*(.end_block));
89+
} > FLASH
90+
91+
} INSERT AFTER .uninit;
92+
93+
PROVIDE(start_to_end = __end_block_addr - __start_block_addr);
94+
PROVIDE(end_to_start = __start_block_addr - __end_block_addr);
6395

6496

0 commit comments

Comments
 (0)