Nucleo STM32L053 - LieBtrau/electronics-design-data GitHub Wiki
Installing toolchain
Compiling code didn't seem to work with the built-in Fedora gcc (4.9.2), so the toolchain from Launchpad.net was chosen instead. From the website you can download pre-compiled libraries (32bit) for Linux or other OS's.
Arm-none-eabi-gdb
This one is needed for debugging. In Fedora it's installed by default, in Ubuntu you have to type:
sudo apt-get install gdb-arm-none-eabi
Getting the libraries and an example project
- Register yourself to mbed.
- Select your board
- Create an example project
- Export it to Gcc Make
- Open the makefile of that project and set the GCC_BIN variable to point to the /bin-directory of your toolchain.
- Run make ... It should build without generating errors.
By exporting to GCC, mbed has been so kind to pre-compile their SDK. If you want to see the source files of the mbed library, you'll have to clone the mbed-SDK and setup the build system yourself.
Set up OpenOCD 0.9.0 (or later)
Installation
Don't waste your time trying the STM32L053 with OpenOCD 0.8.0 or earlier versions. This component is not yet supported in those versions.
Check your installation with:
:~$ openocd -v
Open On-Chip Debugger 0.9.0-rc1 (2015-05-18-19:18)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
This version is 0.9.0-rc1. If you have this version or a later one, then there's nothing to be done. Otherwise you'll have to compile the package from source
-
Download the source code from Sourceforge.
-
Install libusb1 On Fedora:
:~$ sudo yum install libusb1-devel
On Ubuntu:
sudo apt-get install libusb-1.0-0-dev
-
Configure, build and install
:
$ ./configure --prefix=/usr --enable-maintainer-mode --enable-stlink$ make
:
:~$ sudo make install -
Check if the installation succeeded
openocd -v
Creating "plugdev" group and adding the current user
In Ubuntu this step is not needed.
:~$ groupadd --force --system plugdev
:~$ usermod --append -G plugdev $USERNAME
Restart your system now to make all above changes take effect.
Testing OpenOCD
Checking openOcd connection
-
Connect the STM32L053 to your computer.
-
Open a terminal and run the following command
:~$ openocd -f board/stm32l0discovery.cfg
The output should show some messages starting with "Info :"
If that is not the case, run the openocd command with debugging info enabled and see if you can find where it goes wrong.
:~$ openocd -f interface/stlink-v2-1.cfg -f target/stm32l0.cfg -d
Checking with Telnet
If you get the above fixed, while openocd is running, open another terminal window and test the following commands.
:~$ telnet localhost 4444
> poll
> init
> reset halt
> flash probe 0
STM32L flash size is 64kb, base address is 0x8000000
flash 'stm32lx' found at 0x08000000
> exit
Check with gdb
While openocd is running, run the gdb version of your toolchain or the one from Fedora in another terminal window. The following commands should work without generating errors.
:~$ arm-none-eabi-gdb
(gdb) target remote :3333
(gdb) mon reg
(gdb) info frame
(gdb) quit
QtCreator setup
You need at least QtCreator 3.4.0
Creating a project
- File -> New File or Project... -> Import Project -> Import Existing project
- -> Project Name: Fill in a self-chosen project name
- -> Location: Browse to the folder where the project (e.g. some C sources and a makefile) reside
- The next steps in this process are self-explanatory.
Enabling the BareMetal plugin
Help -> About Plugins... -> Device Support -> BareMetal
This is a plugin developed by Tim Sander. If you want to see that guy in action, watch the FOSDEM video.
Creating a Kit
Compiler setup
I don't think this is really necessary, as the compiler path has been defined in the makefile.
Tools -> Options -> Build&Run -> Compilers -> Add -> GCC
We use the compiler from the launchpad toolchain, not the one from Fedora.
Screenshot of setting up the compiler
Debugger setup
Tools -> Options -> Build&Run -> Debuggers -> Add
Pay attention here, this is the gdb from Fedora, not the one from the launchpad toolchain. The launchpad toolchain is built in 32bit mode, the gdb of that toolchain want to use 32bit Python. As we're running on a Fedora 64bit machine, this doesn't work (in a straightforward) way.
Screenshot of "debugger" setup
BareMetal setup
Tools -> Options -> BareMetal -> Add -> OpenOCD
The configuration file is the one that you would use in the "-f" argument of OpenOCD. For the STM32L053 Nucleo, "/usr/share/openocd/scripts/board/stm32l0discovery.cfg" can be used.
Screenshot of "BareMetal" setup
Devices setup
Tools -> Options -> Devices -> Add -> Bare Metal Device -> Start Wizard -> GDB server provider: Nucleo_STM32L053
Screenshot of "Devices"-setup
Kit setup
Tools -> Options -> Build&Run -> Kits -> Add
This step ties all of the above steps together
Screenshot of "Kit"-setup
Attaching the kit to your project
Press Ctrl+5 -> Add Kit (or change the current Kit by clicking on the current kit)
Build settings
Build settings, top of window
Build settings: bottom of window
Run settings
Run settings: top of window
Run settings: bottom of window
Libraries
- mbed: code supported also for MCUs of other vendors: examples, GCC support, easiest to use
- STM32CubeL0: Official code from ST: examples (also FreeRTOS), no GCC support
- STM32SnippetsL0: Example Code snippets covering STM32 L0 serie
- LibOpenCM3: open source project: no examples, no support