Thank you Hertaville
I set up this tutorial using a lot of resources I found at Hertaville. Thanks, thanks, thanks!
1 – get the GCC compiler
Download toolchain from https://launchpad.net/gcc-arm-embedded/ and add directory with ‘arm-none-eabi-gcc’ and others to path
Linux: get the TAR with the binaries, and extract somewhere. I put them in Documents. Yes, I know that that is not a sensible location, you could do otherwise if you’d like to. I changed the path to point to the binaries.
Under Windows, just run the installer, everything will be fine. At the end of the installer, let the PATH be adapted (option box selected).
2 – get OpenOCD, part of the debugging solution
Go to the OpenOCD site and download the sources. For windows: there’s a binary installer available somewhere, check Hertavilles site.
sudo make install
3 – install Code::Blocks if you hadn’t already
Download Code::Blocks from their website, installation instructions are here.
For linux (my distro refuses to update to 11.20) you’ll have to install the archives that BerliOS provides, windows users can easily install the binaries.
4 – Download the important source files
OK; we’re getting somewhere!
From the ST website download this, and unpack in your folder-of-choice. For me: /home/victor/Dropbox/ARM/ST
From Hertaville, take the ‘toggleiom0′, I unzipped it in /home/victor/Dropbox/ARM/workspace/iotogglem0/:
Configuring Code::Blocks for compilation
- Start Code::Blocks, create a new empty project in the iotogglem0 folder
- Select ‘empty Project’
- Name: iotogglem0
- Remove extra ‘iotogglem0′ in ‘directory’ and ‘resulting filename’.
- Compiler: GNU ARM C, and leave everything else default, Finish
- You’ll get some warnings from Code::Blocks, we’re going to fix those in a minute
- Right-Click on the bold ‘iotogglem0′ in the left pane, and choose ‘Add files recursively’
- Go one folder up, and select the iotogglem0 folder
- In the same way add the files from the ‘Libraries’ folders from the Standard Peripheral Libraries:
- Do the same with the files in the …/ARM/ST/STM32F0xx_StdPeriph_Lib_V1.0.0/Libraries/CMSIS folder.
Change compiler settings
- Go to project-> build options
- Select ‘iotogglem0′ in the left pane
- Click the tab ‘other options’
- Add the following line:
-mcpu=cortex-m0 -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Os
- At the tab ‘#defines’ add these lines:
- at the tab linker settings, add this in ‘other options':
-mthumb -nostartfiles -Tstm32f0_linker.ld -Wl,-Map=iotogglem0.map,--cref,--no-warn-mismatch
- Search directories, compiler:
- Search directories, linker: add linker directory (~/Dropbox/ARM/workspace/iotogglem0/linker in my case)
- Pre/post build steps: add post-build steps:
arm-none-eabi-objcopy $(TARGET_OUTPUT_FILE) -O ihex $(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).hex
Change compiler command
- Change drop-down to GNU ARM
- Toolchain executables tab
Enable debugging from Code::Blocks
- From the openocd source directory copy the file stm32f0discovery.cfg (in ./tcl/board/) to your output directory (~/Dropbox/ARM/workspace/iotogglem0/bin/Debug in my case)
- In Code::Blocks, change the settings for debugging by making an ARM-GDB setting:
- Settings->Debugger: turn on ‘full-debug-log’ to get more info of what is happening, if that’s what you like (I do).
- In the left pane, select GDB/CDB Debugger, and press the button ‘Create Config’. Type in the new config name, I chose ‘ARM OpenOCD’
- Click ‘ARM OpenOCD’ in the left pane, change settings as shown below
Changed items are: executable, ‘do not run’
- Click ‘Project->Properties’
- Go to the Debugger tab
- Choose ”, and apply presets as below:
- The following options are set to load the correct output file in the microcontroller:
- actual settings should be:
monitor sleep 1000
- Choose Debug->Active Debuggers->GDB/CDB Debugger: ARM OpenOCD
- Open a terminal and go to your output directory (for me: /home/victor/Dropbox/ARM/workspace/iotogglem0/bin/Debug) and type
openocd -f stm32f0discovery.cfg
- Start debugging by pressing the red arrow (Run / continue) in the debugging toolbar