Category: ARM

Programming on ARM cpu

Super quick guide : setup stm32 development environment

Super quick guide : setup stm32 development environment, follow these steps:

  1. Download STM32CubeL4, My STM32L476RG board is L4, so don’t download Stm32Cube, just download STM32CubeL4
  2. Download and install eclipse
  3. Install eclipse CDT
  4. (Optional) Install GNU ARM for eclipse . After install you have this, the funny thing is that this plugin has stm32 projects but STM32 workbench plugin don’t have
  5. Install GNU ARM Embedded Toolchain, this is optional because i guess step 4 already include an arm compiler, unless you want to manually run arm-none-eabi-gcc in your terminal
  6. (Must do this) Install SW4STM32, just install it as a plugin to eclipse
  7. Open eclipse
  8. File -> Import -> Existing projects into workspace , choose the from the folder from STM32CubeL4, /Users/peter/Desktop/STM32Cube_FW_L4_V1.8.0/Projects/STM32L476RG-Nucleo/Examples_LL/GPIO/GPIO_InfiniteLedToggling
  9. In eclipse, click Project -> Build project, if everything ok, you will find the bin file in Debug folder, just burn it to the board using command “st-flash write Debug/STM32L476RG_NUCLEO.bin 0x8000000”
  10. Led should be blinking now, see my video
  11. Set come breakpoints and right click the project -> debug, eclipse should able to trap the breakpoint, see below video

read count : 25


Affordable and flexible platform to ease prototyping using a STM32L476RGT6 microcontroller.


The STM32 Nucleo board provides an affordable and flexible way for users to try out new ideas and build prototypes with any STM32 microcontroller line, choosing from the various combinations of performance, power consumption and features.

The Arduino™ connectivity support and ST Morpho headers make it easy to expand the functionality of the STM32 Nucleo open development platform with a wide choice of specialized shields.

The STM32 Nucleo board does not require any separate probe as it integrates the ST-LINK/V2-1 debugger/programmer.

Microcontroller features

  • STM32L476RGT6 in LQFP64 package
  • ARM®32-bit Cortex®-M4 CPU
  • Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from Flash memory
  • 80 MHz max CPU frequency
  • VDD from 1.71 V to 3.6 V
  • 1 MB Flash
  • 128 KB SRAM
  • random generator (TRNG for HW entropy)
  • Quad SPI (1)
  • Timers General Purpose (7)
  • Timers Advanced-Control (2)
  • Timers Basic (2)
  • Timers LowPower (2)
  • Systick
  • Watchdog (2)
  • SPI (3)
  • I2C (3)
  • USART (3)
  • UART (2)
  • LPUART (1)
  • USB OTG Full Speed
  • CAN (1)
  • SAI (2)
  • LCD 8×28 or 4×32
  • GPIO (51) with external interrupt capability
  • Capacitive sensing with 12 channels
  • 12-bit ADC (3) with 16 channels
  • 12-bit DAC with 2 channels
  • Analog comparator (2)
  • Opamp (2)

Nucleo features

  • Two types of extension resources
    • Arduino Uno Revision 3 connectivity
    • STMicroelectronics Morpho extension pin headers for full access to all STM32 I/Os
  • On-board ST-LINK/V2-1 debugger/programmer with SWD connector
    • Selection-mode switch to use the kit as a standalone ST-LINK/V2-1
  • Flexible board power supply
    • USB VBUS or external source (3.3 V, 5 V, 7 – 12 V)
    • Power management access point
  • User LED (LD2)
  • Two push buttons: USER and RESET
  • USB re-enumeration capability: three different interfaces supported on USB
    • Virtual Com port
    • Mass storage (USB Disk drive) for drag’n’drop programming
    • Debug port

Nucleo pinout

Arduino-compatible headers


Morpho headers

These headers give access to all STM32 pins.



Only the labels written in blue/white or green/white (i.e. PA_4, PB_5, A0, D14, LED1…) must be used in your code. The other labels are given as information (alternate-functions, power pins, …).

You can find more details on the available pins and labels in the following files (link to the latest mbed-dev library version):

Supported shields

ST X-NUCLEO boards

See Matrix of tested boards.

Other Non-ST boards

See here.

Getting started

Nucleo ST-LINK/V2 driver installation and firmware upgrade

  • Install the ST-LINK/V2 driver before connecting the Nucleo board to your PC the first time. Follow this LINK for all details.
  • For optimum performances, ensure that the Nucleo ST-LINK/V2 firmware is upgraded to the latest version. Follow this LINK for all details.

Technical references

For more information, please refer to:

Known limitations

The following section describes known limitations of the platform. Note that general issues are tracked into the mbed repositoryavailable on GitHub.

This platform does not present any limitation.

read count : 5

Flashing bin file to nucleo-L476RG

This command works!!!

/root/Desktop>st-flash --reset write Nucleo_blink_led_NUCLEO_L476RG.bin 0x8000000
2016-01-17T15:53:54 INFO src/stlink-common.c: Loading device parameters....
2016-01-17T15:53:54 INFO src/stlink-common.c: Device connected is: L4 device, id 0x10076415
2016-01-17T15:53:54 INFO src/stlink-common.c: SRAM size: 0x18000 bytes (96 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 2048 bytes
2016-01-17T15:53:54 INFO src/stlink-common.c: Attempting to write 16544 (0x40a0) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08004000 erased
2016-01-17T15:53:54 INFO src/stlink-common.c: Finished erasing 9 pages of 2048 (0x800) bytes
2016-01-17T15:53:54 INFO src/stlink-common.c: Starting Flash write for F2/F4/L4
2016-01-17T15:53:54 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 16544
2016-01-17T15:53:55 INFO src/stlink-common.c: Starting verification of write complete
2016-01-17T15:53:55 INFO src/stlink-common.c: Flash written and verified! jolly good!

read count : 18

Nucleo STM32F103 dev board with built in STlinkV2-1 programmer


1. GNU ARM Tool Chain
2. IDE Eclipse
3. STmicro libraries
4. GDB Serve

1. GNU ARM Tool Chain
$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
(if using 14.04 follow extras steps when adding PPA)
$ sudo apt-get update
$ sudo apt-get install gcc-arm-none-eabi
if 64bit, we need 32-bit libs
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

2. Eclipse IDE & ARM plugin 
Verify Java version is 1.7 or newer
$ java -version
Choose IDE for C/C++ for 32 / 64 bit
Extract and run $ ./eclipse
Add c++ dev tools
Help → Install New Software > releases
Select ‘Luna’ eclipse release
Group by category > programming languages > C/C++ dev tools
Add ARM plugin
Help → Install New Software > releases

3. STmicro libraries 
template makefile compile environment:
git clone git://

4. GDB Server
GDB Server – debugging – ST link is not native compatible with Linux however, it’s been reverse engineered:
git clone git://
$ sudo apt-get install libusb-1.0
$ sudo apt-get install autoreconf
$ cd stlink
$ ./
$ ./configure
$ make
$ sudo cp 49-stlinkv2-1.rules /etc/udev/rules.d
$ sudo udevadm control –reload-rules
$ sudo udevadm trigger
$ sudo ./st-util

GUI – QSTLink2
$ sudo add-apt-repository ppa:fpoussin/ppa
$ sudo apt-get install qstlink2
To flash code to the board…

Binary Flash 
./st-flash write blinky.bin 0x8000000

ELF Executable Linkable Format
1. Start ST-link server on port 4242
$ ./st-util #check ST link is connected ok
$ ./st-util 4242 /dev/stlink
2. Start GDB and connect to ST-link server on port 4242
start an instance of arm-noneeabi-gdb
in a separate window and execute the following
$ arm-none-eabi-gdb BlinkingLights.elf
$(gdb) target extended-remote :4242
$(gdb) load
$(gdb) continue

Serial Output 
Nucleo board serial output can be viewed by opening serial port /dev/ttyACM0

Getting started wtih Eclipse
1. Select new C++ project for STMF10x project
2. Check through default options
3. select blinky example
4. in BlinkLed.h change port number to be ‘0’ for A and pin number to be 5 (on the necleo board the LED is on A5)
5. Click build
6. .elf file is now in the debug folder

read count : 11