Skip to content

Instantly share code, notes, and snippets.

View jamesmunns's full-sized avatar

James Munns jamesmunns

View GitHub Profile
[profile.dev]
opt-level = 0
debug = true
[profile.release]
codegen-units = 1
lto = true
opt-level = 3

Graphical Debugging for Embedded Rust

So, I recently re-discovered gdbgui - a python tool that attaches to a GDB server and provides a graphical frontend in your browser. It turns out, this works really well for Embedded Rust Development! This also works across Windows, Mac, and Linux, which means it should be handy for most embedded devs out there!

I noticed a couple small tweaks that were necessary to get this working for me, and I wanted to share. Here are my suggestions for getting started:

1. Install

Check out their installation instructions. In addition, you will also need:

diff --git a/build.rs b/build.rs
index 73d61f7..d7dfb04 100644
--- a/build.rs
+++ b/build.rs
@@ -45,6 +45,7 @@ handlers.");
Build::new().file("exceptions.s").compile("asm");
println!("cargo:rustc-link-search={}", out.display());
+ println!("cargo:rustc-link-lib=static=asm");
pub fn new() -> PeripheralX {
// Syntax could look a little like this:
let int_handle = interrupt!(UARTE0_UART0, |mut cons: Consumer| {
// Do some interrupty things here
cons.read();
// ...
});
// Enable the interrupt, but do not pend
int_handle.spawn();
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index ec7d366c3f..421b741a3a 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -1512,6 +1512,18 @@ impl<T: ?Sized> UnsafeCell<T> {
}
}
+// TODO: correct stable attribute
+#[stable(feature = "rust1", since = "1.0.0")]
@jamesmunns
jamesmunns / arch-linux-install.md
Created July 28, 2018 16:04 — forked from kylemanna/arch-linux-install.md
Minimal instructions for installing arch linux on an UEFI NVMe system with full system encryption using dm-crypt and luks
➜ tinyrocket git:(james-hack) ✗ ls -hal target/x86_64-unknown-linux-gnu/release/tinyrocket
-rwxr-xr-x 2 james users 1.2M Mar 30 14:53 target/x86_64-unknown-linux-gnu/release/tinyrocket
➜ tinyrocket git:(james-hack) ✗ strip target/x86_64-unknown-linux-gnu/release/tinyrocket
➜ tinyrocket git:(james-hack) ✗ ls -hal target/x86_64-unknown-linux-gnu/release/tinyrocket
-rwxr-xr-x 2 james users 816K Mar 30 14:53 target/x86_64-unknown-linux-gnu/release/tinyrocket
➜ tinyrocket git:(james-hack) ✗ ldd target/x86_64-unknown-linux-gnu/release/tinyrocket
linux-vdso.so.1 (0x00007ffdb3fe8000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd659240000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fd659038000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd658e1a000)
# ! [ cfg_attr ( feature = "rt" , feature ( global_asm ) ) ] # ! [ cfg_attr ( feature = "rt" , feature ( macro_reexport ) ) ] # ! [ cfg_attr ( feature = "rt" , feature ( used ) ) ] # ! [ doc = "Peripheral access API for LPC43XX microcontrollers (generated using svd2rust v0.12.0)\n\nYou can find an overview of the API [here].\n\n[here]: https://docs.rs/svd2rust/0.12.0/svd2rust/#peripheral-api" ] # ! [ allow ( private_no_mangle_statics ) ] # ! [ deny ( missing_docs ) ] # ! [ deny ( warnings ) ] # ! [ allow ( non_camel_case_types ) ] # ! [ feature ( const_fn ) ] # ! [ feature ( try_from ) ] # ! [ no_std ]
extern crate bare_metal;
extern crate cortex_m;
#[macro_reexport(default_handler, exception)]
#[cfg(feature = "rt")]
extern crate cortex_m_rt;
extern crate vcell;
use core::ops::Deref;
use core::marker::PhantomData;
#[doc = r" Number available in the NVIC for configuring priority"]
This file has been truncated, but you can view the full file.
# ! [ cfg_attr ( feature = "rt" , feature ( global_asm ) ) ] # ! [ cfg_attr ( feature = "rt" , feature ( macro_reexport ) ) ] # ! [ cfg_attr ( feature = "rt" , feature ( used ) ) ] # ! [ doc = "Peripheral access API for ATSAMD21E15A microcontrollers (generated using svd2rust v0.12.0)\n\nYou can find an overview of the API [here].\n\n[here]: https://docs.rs/svd2rust/0.12.0/svd2rust/#peripheral-api" ] # ! [ allow ( private_no_mangle_statics ) ] # ! [ deny ( missing_docs ) ] # ! [ deny ( warnings ) ] # ! [ allow ( non_camel_case_types ) ] # ! [ feature ( const_fn ) ] # ! [ no_std ]
extern crate bare_metal;
extern crate cortex_m;
#[macro_reexport(default_handler, exception)]
#[cfg(feature = "rt")]
extern crate cortex_m_rt;
extern crate vcell;
use core::ops::Deref;
use core::marker::PhantomData;
#[doc = r" Number available in the NVIC for configuring priority"]
--- ficr-before.rs 2018-02-27 15:45:28.375958754 +0100
+++ ficr-after.rs 2018-02-27 15:44:11.041326001 +0100
@@ -1,413 +1,2311 @@
#[doc = "Factory Information Configuration Registers"]
pub struct FICR {
_marker: PhantomData<*const ()>,
}
unsafe impl Send for FICR {}
impl FICR {
#[doc = r" Returns a pointer to the register block"]