https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html
- Microcontroller: STM32F103C8
- Flash: 64 KB
- RAM: 20 KB
- Clock Speed: 72 MHz
- User LED(s): PC13 (blue; lights when PC13 is LOW)
https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html
The STM32F103xx medium-density performance line family incorporates the high-performance ARM®Cortex®-M3 32-bit RISC core operating at a 72 MHz frequency, high-speed embedded memories, and an extensive range of enhanced I/Os and peripherals connected to two APB buses. All devices offer two 12-bit ADCs, three general purpose 16-bit timers plus one PWM timer, as well as standard and advanced communication interfaces: up to two I2Cs and SPIs, three USARTs, an USB and a CAN.
curl https://sh.rustup.rs -sSf | sh
rustup target add thumbv7m-none-eabi
Note: What is Thumb? See here?
cargo install cargo-binutils
rustup component add llvm-tools-preview
sudo apt install \
gdb-multiarch \
binutils-arm-none-eabi
git clone https://github.com/Doulos/Embedded-Rust-with-PicSimLab.gitcd Embedded-Rust-with-PicSimLabBuild the provided project (inside the project's root directory):
cargo build --release
arm-none-eabi-objcopy -O binary target/thumbv7m-none-eabi/release/bluepill app.bin
You can achieve the same thing by running the shell script:
./run_me.sh
- Optionally you can install
gdb-dashboardfor an improved debugging experience by placing the.gdbinitfile in your home directory.
wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit
Note:Depending on your OS setup, GDB might not be able to pick up the .gdbinit directly from your home directory. In this case, you can try to copy the .gdbinit file to the project's directory instead. If this still doesn't not get picked up automatically, You will have to provide it explicitly as you are calling GDB's command line (see later for an example).
- Optionally, If you want a little bit more eye candy with syntax highlighting inside GDB, you can install:
pip install pygments
PicSimLab is an open-source virtual development boards environment allowing you to execute programs on various popular dev-boards without the need of a Physical board.
- Install PicSimLab (currently using the unstable version : 0.9.2_240706).
https://github.com/lcgamboa/picsimlab/releases/tag/latestbuild
Various executable options are provided in the release web-page, you will need to download and execute the relevant one.
When invoked for the first time, the default board displayed is an Arduino Uno board. For this exercise however, we will use the Cortex-M3 based Blue Pill board.
- Inside the PICSimLab window choose the
Blue Pillboard by selecting theBoard->Blue Pillsub menu - Set the
Qemu CPU MIPSoption to Auto.
- Click on the
Config Qemubutton and select theWait for GDBoption:
- Configure PICSimLab by selecting the sub-menu:
File->Configureand capture the following values:
- Enable debug by clicking on the
Debug buttonand make sure that the GDB debug port shows: 1234
-
Inside the PICSimLab window, display the peripherals used in this demo by selecting the sub-menu
Modules->Spare Parts -
In the
Spare Partswindow, load the providedperiph_configuration.pcffile by selecting the sub-menuFile ->Load configuration
- Inside the PicSimLab window, load the binary file
app.bincreated in an early step with the sub-menu:File->Load Bin
- Inside a terminal window, navigate to the project's directory and call the GDB debugger with the command:
gdb-multiarch target/thumbv7m-none-eabi/release/bluepill
Alternatively, If you are having difficulties getting the .gdbinit file to get detected by GDB, you can use the command:
gdb-multiarch target/thumbv7m-none-eabi/release/bluepill -x .gdbinit
-
Connect GDB to the QEMU (blue pill) GDB server with the command:
target extended-remote localhost:1234And you are rolling! You can issue the following commands to get you started with the GDB debug session:
break main
continue
step
next
run
To exit a running application you can type: Ctrl+c .
To reset the embedded program's execution, you can type system_reset
A helpful GDB tutorial can be found here:
https://freecoder.dev/gdb-cheat-sheet/
A helpful cheat-sheet can be found here:
https://freecoder.dev/GDB_Cheat_Sheet.pdf
- Rust embedded book
- Blue pill
- PicSimLab
- STM32F103C8 info and datasheets
- stm32f1xx-hal crate
- awesome-embedded-rust
- PICSimLab has crashed and now, it keeps-on exiting immediately whenever I call it.
PICSimLab is configured to load automatically the last configuration used, each time you invoke it. To go back to a clean initial setup, simply remove the directory .picsimlab located inside your home directory.









