snippet rust programming

Link: https://docs.rust-embedded.org/embedonomicon/

Install cargo-binutils and carg-edit

cargo nm --target thumbv7m-none-eabi -- $PWD/target/thumbv7m-none-eabi/debug/deps/app-*.o | grep '[0-9]* [^N] '

On Ubuntu 18, there's no arm-none-eabi-gdb -> Use gdb-multiarch instead.

Also, had to use the long versions of the flags, otherwise llvm-objdump would complain

cargo objdump --bin app -- -d --no-show-raw-insn
cargo objdump --bin app -- -s --section .vector_table

Needed to install gcc-arm-none-eabi before using the CC package to cross-compile for ARM

https://docs.rust-embedded.org/embedonomicon/exceptions.html The second entry points to address 0x0000_0045, the Reset handler.

The address of the Reset handler can be seen in the disassembly above, being 0x44.
Dissasembly doesn't mention any hexadecimal addresses

https://docs.rust-embedded.org/embedonomicon/asm.html#assembly-on-stable

Now look at the vector table. The 4th entry should be the address of HardFaultTrampoline plus one.

In the code snippets provided, we can't see the address of the corresponding symbols/functions. Running the same command though (with double dashes + direct objdump) I do get the addresses

https://docs.rust-embedded.org/embedonomicon/exceptions.html

cargo objdump --bin app --release -- -s -j .vector_table

app: file format ELF32-arm-little

Contents of section .vector_table: 0000 00000120 45000000 7f000000 7f000000 ... E........... 0010 7f000000 7f000000 7f000000 00000000 ................ 0020 00000000 00000000 00000000 7f000000 ................ 0030 00000000 00000000 7f000000 7f000000 ................

Encode the logging messages into the symbols of the ELF executable; You can encode any characters (including spaces, except from a null byte) in the symbol name.

In this example we'll need some way to do I/O so we'll use the cortex-m-semihosting crate for that. Semihosting is a technique for having a target device borrow the host I/O capabilities; the host here usually refers to the machine that's debugging the target device. In our case, QEMU supports semihosting out of the box so there's no need for a debugger. On a real device you'll have other ways to do I/O like a serial port; we use semihosting in this case because it's the easiest way to do I/O on QEMU.