aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-29 22:28:36 +0200
committerDario Nieuwenhuis <[email protected]>2021-03-29 22:28:36 +0200
commitd938b95430d543d8a97e611642ef09d803b7bdc1 (patch)
tree3805f3153072cf7329b3b2c45b296c84e8847c2d
parent4371302da87f7fad4649c0ef4eade9432dc94529 (diff)
rp: add precompiled boot2 to avoid depending on gcc
-rw-r--r--embassy-rp-examples/.cargo/config12
-rw-r--r--embassy-rp-examples/Cargo.toml1
-rw-r--r--embassy-rp-examples/memory.x10
-rw-r--r--embassy-rp-examples/src/example_common.rs4
-rw-r--r--embassy-rp/build.rs17
-rw-r--r--embassy-rp/link-rp.x.in8
-rw-r--r--embassy-rp/src/boot2.binbin0 -> 256 bytes
-rw-r--r--embassy-rp/src/system.rs4
8 files changed, 31 insertions, 25 deletions
diff --git a/embassy-rp-examples/.cargo/config b/embassy-rp-examples/.cargo/config
index 1f6a94f88..8db641544 100644
--- a/embassy-rp-examples/.cargo/config
+++ b/embassy-rp-examples/.cargo/config
@@ -9,19 +9,9 @@ rustflags = [
9 # LLD (shipped with the Rust toolchain) is used as the default linker 9 # LLD (shipped with the Rust toolchain) is used as the default linker
10 "-C", "link-arg=--nmagic", 10 "-C", "link-arg=--nmagic",
11 "-C", "link-arg=-Tlink.x", 11 "-C", "link-arg=-Tlink.x",
12 "-C", "link-arg=-Tlink-rp.x",
12 "-C", "link-arg=-Tdefmt.x", 13 "-C", "link-arg=-Tdefmt.x",
13 14
14 # if you run into problems with LLD switch to the GNU linker by commenting out
15 # this line
16 # "-C", "linker=arm-none-eabi-ld",
17
18 # if you need to link to pre-compiled C libraries provided by a C toolchain
19 # use GCC as the linker by commenting out both lines above and then
20 # uncommenting the three lines below
21 # "-C", "linker=arm-none-eabi-gcc",
22 # "-C", "link-arg=-Wl,-Tlink.x",
23 # "-C", "link-arg=-nostartfiles",
24
25 # Code-size optimizations. 15 # Code-size optimizations.
26 "-Z", "trap-unreachable=no", 16 "-Z", "trap-unreachable=no",
27] 17]
diff --git a/embassy-rp-examples/Cargo.toml b/embassy-rp-examples/Cargo.toml
index 0744fa1e9..dae22f809 100644
--- a/embassy-rp-examples/Cargo.toml
+++ b/embassy-rp-examples/Cargo.toml
@@ -19,7 +19,6 @@ defmt-error = []
19[dependencies] 19[dependencies]
20embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] } 20embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] }
21embassy-rp = { version = "0.1.0", path = "../embassy-rp", features = ["defmt", "defmt-trace"] } 21embassy-rp = { version = "0.1.0", path = "../embassy-rp", features = ["defmt", "defmt-trace"] }
22rp2040-boot2 = { git = "https://github.com/rp-rs/rp2040-boot2-rs", branch="main" }
23rp2040-pac2 = { git = "https://github.com/Dirbaio/rp2040-pac", rev="254f4677937801155ca3cb17c7bb9d38eb62683e" } 22rp2040-pac2 = { git = "https://github.com/Dirbaio/rp2040-pac", rev="254f4677937801155ca3cb17c7bb9d38eb62683e" }
24atomic-polyfill = { version = "0.1.1" } 23atomic-polyfill = { version = "0.1.1" }
25 24
diff --git a/embassy-rp-examples/memory.x b/embassy-rp-examples/memory.x
index 0596611d2..aba861aae 100644
--- a/embassy-rp-examples/memory.x
+++ b/embassy-rp-examples/memory.x
@@ -2,12 +2,4 @@ MEMORY {
2 BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 2 BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
3 FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 3 FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
4 RAM : ORIGIN = 0x20000000, LENGTH = 256K 4 RAM : ORIGIN = 0x20000000, LENGTH = 256K
5} 5} \ No newline at end of file
6
7SECTIONS {
8 /* ### Boot loader */
9 .boot2 ORIGIN(BOOT2) :
10 {
11 KEEP(*(.boot2));
12 } > BOOT2
13} INSERT BEFORE .text; \ No newline at end of file
diff --git a/embassy-rp-examples/src/example_common.rs b/embassy-rp-examples/src/example_common.rs
index 89f35736b..f7c4ef57a 100644
--- a/embassy-rp-examples/src/example_common.rs
+++ b/embassy-rp-examples/src/example_common.rs
@@ -2,10 +2,6 @@ use core::sync::atomic::{AtomicUsize, Ordering};
2use defmt_rtt as _; 2use defmt_rtt as _;
3use panic_probe as _; 3use panic_probe as _;
4 4
5#[link_section = ".boot2"]
6#[used]
7pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER;
8
9defmt::timestamp! {"{=u64}", { 5defmt::timestamp! {"{=u64}", {
10 static COUNT: AtomicUsize = AtomicUsize::new(0); 6 static COUNT: AtomicUsize = AtomicUsize::new(0);
11 // NOTE(no-CAS) `timestamps` runs with interrupts disabled 7 // NOTE(no-CAS) `timestamps` runs with interrupts disabled
diff --git a/embassy-rp/build.rs b/embassy-rp/build.rs
new file mode 100644
index 000000000..bc59ea23b
--- /dev/null
+++ b/embassy-rp/build.rs
@@ -0,0 +1,17 @@
1use std::fs::{self, File};
2use std::io::Write;
3use std::path::{Path, PathBuf};
4use std::{env, ffi::OsStr};
5
6fn main() {
7 // Put the linker script somewhere the linker can find it
8 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
9 let link_x = include_bytes!("link-rp.x.in");
10 let mut f = File::create(out.join("link-rp.x")).unwrap();
11 f.write_all(link_x).unwrap();
12
13 println!("cargo:rustc-link-search={}", out.display());
14
15 println!("cargo:rerun-if-changed=build.rs");
16 println!("cargo:rerun-if-changed=link-rp.x.in");
17}
diff --git a/embassy-rp/link-rp.x.in b/embassy-rp/link-rp.x.in
new file mode 100644
index 000000000..af463f963
--- /dev/null
+++ b/embassy-rp/link-rp.x.in
@@ -0,0 +1,8 @@
1
2SECTIONS {
3 /* ### Boot loader */
4 .boot2 ORIGIN(BOOT2) :
5 {
6 KEEP(*(.boot2));
7 } > BOOT2
8} \ No newline at end of file
diff --git a/embassy-rp/src/boot2.bin b/embassy-rp/src/boot2.bin
new file mode 100644
index 000000000..fdc1fc756
--- /dev/null
+++ b/embassy-rp/src/boot2.bin
Binary files differ
diff --git a/embassy-rp/src/system.rs b/embassy-rp/src/system.rs
index 200f88d63..ba1396433 100644
--- a/embassy-rp/src/system.rs
+++ b/embassy-rp/src/system.rs
@@ -1,5 +1,9 @@
1use crate::{pac, pll, resets}; 1use crate::{pac, pll, resets};
2 2
3#[link_section = ".boot2"]
4#[used]
5pub static BOOT2: [u8; 256] = *include_bytes!("boot2.bin");
6
3#[non_exhaustive] 7#[non_exhaustive]
4pub struct Config {} 8pub struct Config {}
5 9