Template for creating a simple makefile based project that uses unicore-mx
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
lib
scripts
src
.gitignore
.gitmodules
Makefile
README.md
unicore-mx.rules.mk

README.md

Description

This template compiles a minimal blink code for STM32VLDiscovery, and uses unicore-mx, which has the STM32F100RB chip. To compile for something else, you need to supply(or modify) the correct linker script (src/stm32vl-discovery.ld here), and also edit src/unicore-mx.target.mk to the correct values for LIBNAME, DEFS, FP_FLAGS, ARCH_FLAGS.

Additional source files can be added by editing src/Makefile to add more .o files in OBJS (e.g., write test.o for any of test.c, test.cpp, test.S).

Building

Run git submodule init and then git submodule update the first time you build this template.

You need arm-none-eabi-gcc toolchain installed on your system.

Then from the project root, just type make, it will build both unicore-mx and the app. (src contains the main Makefile, for compiling just the code in src/)

Flashing using Bumpy

(other black magic probe compatible programmers will also work)

bumpy

Connect Bumpy as follows:

Bumpy pin STM32VLDiscovery pin
SWDIO PA13
SWCLK PA14
NRST PB4
3v3 3v3
GND GND

[Pin names are marked on the top silkscreen of the board]

From the template root, you can type make flash BMP_PORT=/dev/ttyACM0, which runs the script scripts/black_magic_probe_flash.scr inside arm-none-eabi-gdb. The same can be achieved manually by running arm-none-eabi-gdb src/blink.elf, and then running the following commands:

Reading symbols from src/blink.elf...done.
gdb$ target ext /dev/ttyACM0
Remote debugging using /dev/ttyACM0
gdb$ mon swdp_scan
Target voltage: unknown
Available Targets:
No. Att Driver
 1      STM32F1 medium density
gdb$ attach 1
Attaching to program: /home/tavish/embedded/bluey/stm32-bumpy/src/blink.elf, Remote target
Error while running hook_stop:
No symbol "disassembly" in current context.
gdb$ load
Loading section .text, size 0x2b0 lma 0x8000000
Start address 0x800021c, load size 688
Transfer rate: 9 KB/sec, 688 bytes/write.

At this point the firmware is written to flash, and you can quit gdb by either pressing Ctrl+D or entering the command quit.

You can also start debugging / stepping through the code and set breakpoints or watches etc.

gdb$ break main
Breakpoint 1 at 0x8000150: file blink.c, line 41.
gdb$ run
Starting program: /home/tavish/embedded/bluey/stm32-bumpy/src/blink.elf
Note: automatically using hardware breakpoints for read-only addresses.
Error while running hook_stop:
No symbol "disassembly" in current context.

Breakpoint 1, main () at blink.c:41
41      {
gdb$ n
Error while running hook_stop:
No symbol "disassembly" in current context.
gpio_setup () at blink.c:29
29              rcc_periph_clock_enable(RCC_GPIOC);