Compare commits
2 commits
9747d94ccc
...
3e30545a55
Author | SHA1 | Date | |
---|---|---|---|
3e30545a55 | |||
51300ffea4 |
9 changed files with 773 additions and 361 deletions
35
Cargo.lock
generated
35
Cargo.lock
generated
|
@ -197,6 +197,28 @@ version = "0.3.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6b0decc02f4636b9ccad390dcbe77b722a77efedfa393caf8379a51d5c61899"
|
||||||
|
dependencies = [
|
||||||
|
"git-version-macro",
|
||||||
|
"proc-macro-hack",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version-macro"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fe69f1cbdb6e28af2bac214e943b99ce8a0a06b447d15d3e61161b0423139f3f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-hack",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.10.3"
|
version = "0.10.3"
|
||||||
|
@ -367,6 +389,12 @@ dependencies = [
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-hack"
|
||||||
|
version = "0.5.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.40"
|
version = "1.0.40"
|
||||||
|
@ -439,10 +467,17 @@ dependencies = [
|
||||||
"defmt-rtt",
|
"defmt-rtt",
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
"embedded-time",
|
"embedded-time",
|
||||||
|
"git-version",
|
||||||
"panic-probe",
|
"panic-probe",
|
||||||
|
"rp-binary-info",
|
||||||
"rp-pico",
|
"rp-pico",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rp-binary-info"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/rp-rs/rp-binary-info#a9397d433b1bea5cedd17192db10c40e5008ab88"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rp-pico"
|
name = "rp-pico"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
|
@ -21,6 +21,12 @@ defmt-rtt = "0.3"
|
||||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||||
rp-pico = "0.4"
|
rp-pico = "0.4"
|
||||||
|
|
||||||
|
[dependencies.rp-binary-info]
|
||||||
|
git = "https://github.com/rp-rs/rp-binary-info"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
git-version = "0.3.5"
|
||||||
|
|
||||||
# cargo build/run
|
# cargo build/run
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
1
build.rs
1
build.rs
|
@ -28,4 +28,5 @@ fn main() {
|
||||||
// here, we ensure the build script is only re-run when
|
// here, we ensure the build script is only re-run when
|
||||||
// `memory.x` is changed.
|
// `memory.x` is changed.
|
||||||
println!("cargo:rerun-if-changed=memory.x");
|
println!("cargo:rerun-if-changed=memory.x");
|
||||||
|
println!("cargo:rustc-env=GIT_VERSION={}", git_version::git_version!());
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
elf2uf2-rs
|
elf2uf2-rs
|
||||||
cargo-embed
|
cargo-embed
|
||||||
llvmPackages_latest.bintools
|
llvmPackages_latest.bintools
|
||||||
|
picotool
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
packages = rec {
|
packages = rec {
|
||||||
|
@ -73,6 +74,9 @@
|
||||||
};
|
};
|
||||||
rkbfirm-crate = (rustPkgs.workspace.rkbfirm {}).overrideAttrs (old: {
|
rkbfirm-crate = (rustPkgs.workspace.rkbfirm {}).overrideAttrs (old: {
|
||||||
configureCargo = "true";
|
configureCargo = "true";
|
||||||
|
postPatch = ''
|
||||||
|
sed -i 's/git_version::git_version!()/"${self.lastModifiedDate}"/' build.rs
|
||||||
|
'';
|
||||||
});
|
});
|
||||||
tinyptr-crate = rustPkgs.workspace.tinyptr {};
|
tinyptr-crate = rustPkgs.workspace.tinyptr {};
|
||||||
tinyptr-alloc-crate = rustPkgs.workspace.tinyptr-alloc {};
|
tinyptr-alloc-crate = rustPkgs.workspace.tinyptr-alloc {};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
use tinyptr::ptr::MutPtr;
|
use tinyptr::ptr::{MutPtr, NonNull};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct ListNode<const BASE: usize> {
|
pub struct ListNode<const BASE: usize> {
|
||||||
|
@ -8,3 +8,22 @@ pub struct ListNode<const BASE: usize> {
|
||||||
pub size: u16
|
pub size: u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<const BASE: usize> ListNode<BASE> {
|
||||||
|
pub unsafe fn next(&mut self) -> Option<&mut Self> {
|
||||||
|
if self.next.is_null() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(&mut *(self.next.wide()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub unsafe fn link_next(&mut self, block: NonNull<Self, BASE>) {
|
||||||
|
(*block.as_ptr().wide()).next = self.next;
|
||||||
|
self.next = block.as_ptr();
|
||||||
|
}
|
||||||
|
pub unsafe fn unlink_next(&mut self) {
|
||||||
|
if self.next.is_null() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.next = (*self.next.wide()).next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
memory.x
18
memory.x
|
@ -13,3 +13,21 @@ SECTIONS {
|
||||||
KEEP(*(.boot2));
|
KEEP(*(.boot2));
|
||||||
} > BOOT2
|
} > BOOT2
|
||||||
} INSERT BEFORE .text;
|
} INSERT BEFORE .text;
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
/* ### Picotool 'Binary Info' Entries
|
||||||
|
*
|
||||||
|
* Picotool looks through this block (as we have pointers to it in our header) to find interesting information.
|
||||||
|
*/
|
||||||
|
.bi_entries : ALIGN(4)
|
||||||
|
{
|
||||||
|
/* We put this in the header */
|
||||||
|
__bi_entries_start = .;
|
||||||
|
/* Here are the entries */
|
||||||
|
KEEP(*(.bi_entries));
|
||||||
|
/* Keep this block a nice round size */
|
||||||
|
. = ALIGN(4);
|
||||||
|
/* We put this in the header */
|
||||||
|
__bi_entries_end = .;
|
||||||
|
} > FLASH
|
||||||
|
} INSERT AFTER .text;
|
||||||
|
|
42
src/binary_info.rs
Normal file
42
src/binary_info.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
extern "C" {
|
||||||
|
static __bi_entries_start: rp_binary_info::entry::Addr;
|
||||||
|
static __bi_entries_end: rp_binary_info::entry::Addr;
|
||||||
|
static __sdata: u32;
|
||||||
|
static __edata: u32;
|
||||||
|
static __sidata: u32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Picotool can find this block in our ELF file and report interesting metadata.
|
||||||
|
#[link_section = ".bi_header"]
|
||||||
|
#[used]
|
||||||
|
pub static PICOTOOL_META: rp_binary_info::Header =
|
||||||
|
unsafe { rp_binary_info::Header::new(&__bi_entries_start, &__bi_entries_end, &MAPPING_TABLE) };
|
||||||
|
|
||||||
|
/// This tells picotool how to convert RAM addresses back into Flash addresses
|
||||||
|
static MAPPING_TABLE: [rp_binary_info::MappingTableEntry; 2] = [
|
||||||
|
// This is the entry for .data
|
||||||
|
rp_binary_info::MappingTableEntry {
|
||||||
|
source_addr_start: unsafe { &__sidata },
|
||||||
|
dest_addr_start: unsafe { &__sdata },
|
||||||
|
dest_addr_end: unsafe { &__edata },
|
||||||
|
},
|
||||||
|
// This is the terminating marker
|
||||||
|
rp_binary_info::MappingTableEntry {
|
||||||
|
source_addr_start: core::ptr::null(),
|
||||||
|
dest_addr_start: core::ptr::null(),
|
||||||
|
dest_addr_end: core::ptr::null(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/// This is a list of references to our table entries
|
||||||
|
#[link_section = ".bi_entries"]
|
||||||
|
#[used]
|
||||||
|
pub static PICOTOOL_ENTRIES: [rp_binary_info::entry::Addr; 2] = [
|
||||||
|
PROGRAM_NAME.addr(),
|
||||||
|
PROGRAM_VERSION.addr(),
|
||||||
|
];
|
||||||
|
|
||||||
|
static PROGRAM_NAME: rp_binary_info::entry::IdAndString =
|
||||||
|
rp_binary_info::program_name(concat!("RKB1 firmware", "\0"));
|
||||||
|
static PROGRAM_VERSION: rp_binary_info::entry::IdAndString =
|
||||||
|
rp_binary_info::version(concat!(env!("GIT_VERSION"), "\0"));
|
|
@ -10,6 +10,7 @@ use defmt_rtt as _;
|
||||||
use embedded_hal::digital::v2::OutputPin;
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
use embedded_time::fixed_point::FixedPoint;
|
use embedded_time::fixed_point::FixedPoint;
|
||||||
use panic_probe as _;
|
use panic_probe as _;
|
||||||
|
mod binary_info;
|
||||||
|
|
||||||
// Provide an alias for our BSP so we can switch targets quickly.
|
// Provide an alias for our BSP so we can switch targets quickly.
|
||||||
// Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change.
|
// Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change.
|
||||||
|
|
Loading…
Reference in a new issue