BASIC OF EMBEDDED SYSTEM

HERE WE WILL DISCUSS SOME TOOLS TERMINOLOGY BASIC CONCEPT USED IN EMBEDDED SYSTEM

Hama
3 min readFeb 12, 2021

An Embedded system is defined as “a complete microsystem that includes some peripheral devices,(that can be used as an input and output) some sensors, actuators communicate with each other through some protocols and microcontroller designed or programmed for a specific function or task”

Hardware Required

  • STM32F303 Board
  • 3.3V USB <-> Serial Module
  • Mini-b USB Cable
  • 10 jumper wires each (Female to Female, Female to male)

Tools Required

  • Rust
  • itmdump
  • OpenOCD
  • arm-none-eabi-gdb V 7.12 (or newer highly recommended)
  • Cargo-binutils
  • minicom on Linux and macOS
  • PuTTY on Windows.

fn main() -> ! is the entry point that returns nothing

no other cargo run is used in it.

follow the link if you want to read more detail about it https://docs.rust-embedded.org/discovery/04-meet-your-hardware/index.html#stm32f3discovery-the-f3

The main objective USED IN EMBEDDED SYSTEM PROGRAMS is to get familiar with Building, Flashing, and Debugging.

BUILDING

  • Writing code the very first thing is building your program.
  • Compiling in Rust is as simple as passing an extra — target flag
  • thumbv7em-none-eabihf, for the Cortex-M4F is used to be downloaded “rustup target add thumbv7em-none-eabihf”
  • All set, we can now compile our program for whatever target we are compiling, using the following command: “ cargo build — target thumbv7em-none-eabihf

FLASHING

  1. Launch OpenOCD $ openocd -f interface/stlink-v2–1.cfg -f target/stm32f3x.cfg(make sure that you are in your targeted diectory )
  2. First we are interacting with st-link to target stm32f303 and ST-LINK opens up a communication channel for us to target.
  3. Open your normal terminal/command prompt
  4. type — — — <gdb> -q target/thumbv7em-none-eabihf/debug/<project-name>
  5. It has 3 ariants gdb, gdb-multiarch* and arm-none-eabi-gdb
  6. *In our case gdb-multiarch will work. Open GDB Server console done
  7. Connect GDB Server to OpenOCD — — - (gdb) target remote :3333”
  8. Load the program— — — “(gdb) load”

Debugging Program

After load command our program stopped at entry point.

There are some helpful commands used for debugging purpose.

break => break command is used to break program at certain point. For example: if we want to stop program at the beginning of main function then we will run: (gdb) break main

continue => this command will take us from one breakpoint to another breakpoint.

For viewing line by line execution of program we can switch to GDB Text User Interface (TUI), for that run: (gdb) layout src (output on next slide)

For disabling TUI mode we can run: (gdb) tui disable

For resetting the program to initial state while debugging run: (gdb) monitor reset halt

For terminating GDB session (gdb) quit

step : for moving to next line

print : for printing values of variables

Info locals : for printing all values of variables at once

Clear shell : for clearing TUI screen

--

--