rust-embedded / cortex-m-quickstart

Template to develop bare metal applications for Cortex-M microcontrollers
782 stars 164 forks source link

GDB Load Failed Due to Invalid memory.x Flash Layout #102

Open martinomburajr opened 3 years ago

martinomburajr commented 3 years ago

Description

In the Hardware > Configuring section of the Rust Embedded Book, the FLASH : ORIGIN value is set to 0x08000000. However in the memory.x file, the value is set to 0x00000000.

https://github.com/rust-embedded/cortex-m-quickstart/blob/18bb68071011967d957a5df6c2e5d513e80b2fcb/memory.x#L6

This is a very subtle difference but leads to the following error:

$ arm-none-eabi-gdb -q target/thumbv7em-none-eabihf/debug/examples/hello        
Reading symbols from target/thumbv7em-none-eabihf/debug/examples/hello...
(gdb) target remote :3333
Remote debugging using :3333
cortex_m_semihosting::export::hstdout_fmt (args=...) at /Users/martinomburajr/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-semihosting-0.3.7/src/export.rs:44
44      interrupt::free(|_| unsafe {
(gdb) load
Loading section .vector_table, size 0x400 lma 0x0
Loading section .text, size 0x1134 lma 0x400
Load failed

After changing the value to FLASH : ORIGIN = 0x08000000, LENGTH = 256 the program works as expected.

This was pointed out in a Reddit Post last year.