Skip to content

Commit fa58345

Browse files
committed
Fix building of rp235x on-target tests
1 parent d4769c7 commit fa58345

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

on-target-tests/build.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Set up linker scripts for the rp235x-hal examples
2+
3+
use std::fs::File;
4+
use std::io::Write;
5+
use std::path::PathBuf;
6+
7+
fn main() {
8+
// Put the linker script somewhere the linker can find it
9+
let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
10+
println!("cargo:rustc-link-search={}", out.display());
11+
12+
// The file `memory.x` is loaded by cortex-m-rt's `link.x` script, which
13+
// is what we specify in `.cargo/config.toml` for Arm builds
14+
#[cfg(feature = "rp2040")]
15+
let memory_x = include_bytes!("memory_rp2040.x");
16+
#[cfg(feature = "rp235x")]
17+
let memory_x = include_bytes!("memory_rp235x.x");
18+
let mut f = File::create(out.join("memory.x")).unwrap();
19+
f.write_all(memory_x).unwrap();
20+
println!("cargo:rerun-if-changed=memory.x");
21+
22+
/*
23+
// The file `rp235x_riscv.x` is what we specify in `.cargo/config.toml` for
24+
// RISC-V builds
25+
let rp235x_riscv_x = include_bytes!("rp235x_riscv.x");
26+
let mut f = File::create(out.join("rp235x_riscv.x")).unwrap();
27+
f.write_all(rp235x_riscv_x).unwrap();
28+
println!("cargo:rerun-if-changed=rp235x_riscv.x");
29+
*/
30+
31+
println!("cargo:rerun-if-changed=build.rs");
32+
}

on-target-tests/memory_rp235x.x

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
MEMORY {
2+
/*
3+
* The RP2350 has either external or internal flash.
4+
*
5+
* 2 MiB is a safe default here, although a Pico 2 has 4 MiB.
6+
*/
7+
FLASH : ORIGIN = 0x10000000, LENGTH = 2048K
8+
/*
9+
* RAM consists of 8 banks, SRAM0-SRAM7, with a striped mapping.
10+
* This is usually good for performance, as it distributes load on
11+
* those banks evenly.
12+
*/
13+
RAM : ORIGIN = 0x20000000, LENGTH = 512K
14+
/*
15+
* RAM banks 8 and 9 use a direct mapping. They can be used to have
16+
* memory areas dedicated for some specific job, improving predictability
17+
* of access times.
18+
* Example: Separate stacks for core0 and core1.
19+
*/
20+
SRAM4 : ORIGIN = 0x20080000, LENGTH = 4K
21+
SRAM5 : ORIGIN = 0x20081000, LENGTH = 4K
22+
}
23+
24+
SECTIONS {
25+
/* ### Boot ROM info
26+
*
27+
* Goes after .vector_table, to keep it in the first 4K of flash
28+
* where the Boot ROM (and picotool) can find it
29+
*/
30+
.start_block : ALIGN(4)
31+
{
32+
__start_block_addr = .;
33+
KEEP(*(.start_block));
34+
KEEP(*(.boot_info));
35+
} > FLASH
36+
37+
} INSERT AFTER .vector_table;
38+
39+
/* move .text to start /after/ the boot info */
40+
_stext = ADDR(.start_block) + SIZEOF(.start_block);
41+
42+
SECTIONS {
43+
/* ### Picotool 'Binary Info' Entries
44+
*
45+
* Picotool looks through this block (as we have pointers to it in our
46+
* header) to find interesting information.
47+
*/
48+
.bi_entries : ALIGN(4)
49+
{
50+
/* We put this in the header */
51+
__bi_entries_start = .;
52+
/* Here are the entries */
53+
KEEP(*(.bi_entries));
54+
/* Keep this block a nice round size */
55+
. = ALIGN(4);
56+
/* We put this in the header */
57+
__bi_entries_end = .;
58+
} > FLASH
59+
} INSERT AFTER .text;
60+
61+
SECTIONS {
62+
/* ### Boot ROM extra info
63+
*
64+
* Goes after everything in our program, so it can contain a signature.
65+
*/
66+
.end_block : ALIGN(4)
67+
{
68+
__end_block_addr = .;
69+
KEEP(*(.end_block));
70+
} > FLASH
71+
72+
} INSERT AFTER .uninit;
73+
74+
PROVIDE(start_to_end = __end_block_addr - __start_block_addr);
75+
PROVIDE(end_to_start = __start_block_addr - __end_block_addr);
76+
77+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
# Keep running tests even if one of them fails
4+
# We need to specify probe-rs as our runner via environment variables here
5+
# to control build since we aren't able to override them in config.toml
6+
CARGO_TARGET_THUMBV8M_MAIN_NONE_EABIHF_RUNNER="probe-rs run" cargo test --test dma_dyn --target thumbv8m.main-none-eabihf --no-fail-fast --features rp235x -- --chip rp235x

0 commit comments

Comments
 (0)