japaric / embedded-in-rust Goto Github PK
View Code? Open in Web Editor NEWA blog about Rust and embedded stuff
Home Page: https://blog.japaric.io
License: Creative Commons Attribution 4.0 International
A blog about Rust and embedded stuff
Home Page: https://blog.japaric.io
License: Creative Commons Attribution 4.0 International
In the quickstart post you mention lldb not having a load command. For a workaround for devices that support st-link you can use st-flash to load. You have to use arm-none-eabi-objcopy to convert the elf to a bin first, but it's pretty easy to automate with a makefile or script.
I saw that the japaric.io
redirects to http://blog.japaric.io
I get the following linker issues when I add sections to the linker script:
(I used the linker script successfully in a C project)
> = note: rust-lld: error: section .vector_table file range overlaps with .text
> >>> .vector_table range is [0x1000, 0x10BF]
> >>> .text range is [0x1000, 0x6D07]
>
> rust-lld: error: section .text file range overlaps with .debug_str
> >>> .text range is [0x1000, 0x6D07]
> >>> .debug_str range is [0x2000, 0x36DE7]
>
> rust-lld: error: section .text virtual address range overlaps with .vector_table
> >>> .text range is [0x8000000, 0x8005D07]
> >>> .vector_table range is [0x8000000, 0x80000BF]
>
> rust-lld: error: section .text load address range overlaps with .vector_table
> >>> .text range is [0x8000000, 0x8005D07]
> >>> .vector_table range is [0x8000000, 0x80000BF]
Linker script:
MEMORY {
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
}
SECTIONS
{
.text : {
*(.vectors)
*(.text*)
. = ALIGN(4);
*(.rodata*)
. = ALIGN(4);
} >FLASH
}
Application source (blink)
extern crate cortex_m_semihosting as sh;
extern crate panic_semihosting;
extern crate stm32l0;
extern crate cortex_m;
use stm32l0::stm32l0x3;
use core::fmt::Write;
use rt::ExceptionFrame;
use sh::hio;
use cortex_m::asm;
entry!(main);
fn main() -> ! {
let mut stdout = hio::hstdout().unwrap();
writeln!(stdout, "REL STINKT!").unwrap();
let per = stm32l0x3::Peripherals::take().unwrap();
let gpioa = &per.GPIOA;
let rcc = &per.RCC;
rcc.iopenr.write(|w| w.iopaen().set_bit());
unsafe {
gpioa.moder.write(|w| w.mode5().bits(1));
}
loop {
gpioa.odr.write(|w| {
w.od5().bit(gpioa.odr.read().od5().bit_is_clear())
});
for i in 0..1000 {
asm::nop()
}
}
}
exception!(HardFault, hard_fault);
fn hard_fault(ef: &ExceptionFrame) -> ! {
panic!("HardFault at {:#?}", ef);
}
exception!(*, default_handler);
fn default_handler(irqn: i16) {
panic!("Unhandled exception (IRQn = {})", irqn);
}
Environment:
o blink cargo -V
cargo 1.30.0-nightly (2fb77a49b 2018-09-07)
o blink rustup -V
rustup 1.13.0
o blink cat Cargo.toml
[package]
name = "cortex-m-blink"
version = "0.3.4"
authors = ["roel0"]
description = "a simple blink app"
keywords = ["arm", "cortex-m", "template"]
categories = ["embedded", "no-std"][profile.release]
lto = true
codegen-units = 1
debug = false[dependencies.cortex-m]
version = "0.5.6"[dependencies.cortex-m-rt]
version = "0.5.3"[dependencies.cortex-m-semihosting]
version = "0.3.1"[dependencies.panic-semihosting]
version = "0.3.0"[dependencies.stm32l0]
version = "0.2.3"
features = ["stm32l0x3", "rt"]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.