Is it possible to create a project in System Workbench for STM32 with CMSIS but without HAL library? My target microcontroller is STM32L053R8 on a Nucleo board. When I create a with HAL and delete all the files related to this library, I get a lot of errors and some source files can't see header files. Generally, I want to have clean project with CMSIS only.
Electronic – CMSIS without HAL
cmsishalstm32
Related Solutions
I strongly recommend the libraries. A big advantage of cortex M is to be able to easily move your code to other members of the same family (i.e. STMF0 to STMF4), or even to different manufacturers, and you lose this advantage if you don't use the libraries.
BTW, many vendor specific libraries are CMSIS compliant.
I've avoided families that don't supply CMSIS compliant libraries. Also, I've not tried STM Cube for much the same reasons.
I actually work with this setup, it works wonderful.
First make sure you use a recent Qt Creator version. I downloaded mine from the website. In some Linux repositories it is outdated and does not support the BareMetal plugin, and/or QBS (which is quite useful).
Requisites:
- Qt Creator (download from QT site)
- ARM GCC (Ubuntu: apt-get install gcc-arm-none-eabi)
- GDB source archive (download from archive)
- OpenOCD (Ubuntu: apt-get install openocd)
Versions used: Qt Creator 3.6.0, ARM GCC 4.8.2-14ubuntu1+6, ARM GDB 7.6/7.10 with python support and OpenOCD 0.7.0.
1) Install Qt Creator. Open Help -> About Plugins. Find category Device Support and check BareMetal.
2) Go to Tools -> Options. There are a few settings we need to create and adjust in order to compile for an ARM Cortex controller.
a) Go to "Bare Metal" (last category) - add a debugger of your choice. I personally use OpenOCD. At this point you can set the connection to gdb and it's port, as well as init commands. The standard commands are set for STM32F4xx chips - but I guess you can modify it to work with any ARM Cortex controller.
b) Go to "Devices". Add a new device, choose Bare Metal and the GDB provider you have just created. There is nothing else to setup here.
c) Go to "Build & Run" - tab Debuggers. This has been the most trickiest thing to do.
You need an arm gdb version with python scripting support. At the time (about 9 months back when I write this post) the binaries in Ubuntu repo does not have this option. You can save a lot of time/hassle by checking if this has changed.
Nevertheless if you do need to compile GDB with python supporet, here is how to do it. Download GDB from the download archives. I still use GDB-7.6 which seems to work fine, but for this tutorial I have recompiled it for GDB-7.10.
Extract the source archive. Open in terminal and run "./configure --with-python --target=arm-elf". This sets up the make environment for ARM targets with python scripting enabled. Then run make. This takes a while, depending on your system speed. Unfortunately you may be a bit on your own once the compilation stops because of dependency issues. Don't be afraid - this happened to me on my first try too and I figured it out with a bunch of google searches! If python fails, make sure to install the python2.x-dev package (check your version no - likely 2.7). Assuming compilation went well, you can find the gdb executable in the main directory.
If you're on Mac, the process will likely be similar. But I am not familiar with OSX. If you're on Windows, sorry you will need to google a bit on how to do this with Mingw or whatever (honestly I don't know). Or maybe find binaries that have this support enabled.
Once you acquired a gdb executable, call it e.g. "ARM GDB" and set the path to it. I personally don't bother to place it in /usr/bin/, but I guess you could.
This window will throw an error if you use a gdb executable that is not compiled with Python Scripting.
d) Tab "Build & Run" - "Compilers"
Create a new "GCC compiler" and call it "ARM GCC". For path use "/usr/bin/arm-none-eabi-gcc". The "ABI" is not really important, I have just set it to arm-unknown-unknown-unknown-32bit.
e) Tab "Build & Run" - "Kits". Add a new kit, I called mine "ARM Bare Metal". Device type: "Bare Metal" Device: point to the Device you have created with it's OpenOCD/St link GDB server Sysroot: leave it empty Compiler: ARM GCC Debugger: ARM GDB Qt Version: None - You obviously cannot run the QT runtime on a Cortex m4! Cmake tool: unused
Make sure there are no warnings in any of the Build & Run tab
3) Make your make/qmake/QBS project. On left side go to tab "projects" and at left-top add the "ARM Bare Metal" kit. This should work without errors. Your project may start out with a desktop kit. Replacing usually does not work. In that case add an ARM kit and then remove the desktop one.
4) Start your OpenOcd server. I use a STM32F4 discovery for development, and also off-board programming to my own STM32 boards. For any STM32F40x/STM32F41x targets run:
openocd -f board/stm32f4discovery.cfg
This starts a gdb server at port 3333 and a telnet server (for OpenOCD commands) at 4444. As a shortcut I create a few .sh files in my home directory for a quick startup of a GDB server.
5) Start the debug session. It should program and run!
You can set breakpoints, step through code, even more PC back, watch call stack, variables (locals / watch), and disassembly. I'm really quited please with this, but obviously it lacks a few things like: 1) "Register view". Yes it has one, but that's just the CPU registers. I want register view of my peripherals as well. 2) Download progress or more detailed info about connection state. You need to refer to openocd for this.
edit: I have put up an example project on this Github repository.. It contains this post with a few dialog screenshots added, as well as a blinky project for the STM32F4 Discovery board using a QBS project in Qt Creator.
Best Answer
I've found it.
In the properties of the project, you need to go to C/C++ build -> Settings -> Tool Settings -> Includes. In the Include paths (-l), remove the HAL-related directories and add a catalogue with your own prepared drivers. Save the settings.
The last step is to rebuild indexes.