UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


guides:stm32toolchain

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guides:stm32toolchain [2014/08/17 16:52] – [Step 4 - Adjust for your device] jonsowmanguides:stm32toolchain [2016/04/07 20:48] (current) – [Step 5 (libopencm3 Libraries)] mbrejza
Line 12: Line 12:
   * For use of newlib-nano, best to grab the binary tarball from https://launchpad.net/gcc-arm-embedded. Latest at time of writing is gcc-arm-none-eabi-4_8-2014q2 (-linux or -mac one as appropriate).    * For use of newlib-nano, best to grab the binary tarball from https://launchpad.net/gcc-arm-embedded. Latest at time of writing is gcc-arm-none-eabi-4_8-2014q2 (-linux or -mac one as appropriate). 
   * Extract to somewhere like /usr/local and add /usr/local/gcc-arm-none-eabi-4_8-2014q2/bin to PATH, by adding:    * Extract to somewhere like /usr/local and add /usr/local/gcc-arm-none-eabi-4_8-2014q2/bin to PATH, by adding: 
-export PATH=/usr/local/gcc-arm-none-eabi-4_8-2014q2/bin:$PATH to your ~/.bashrc (assuming using bash).+''export PATH=/usr/local/gcc-arm-none-eabi-4_8-2014q2/bin:$PATH'' to your ~/.bashrc (assuming using bash).
   *Then to use the amended PATH:   *Then to use the amended PATH:
-$ source ~/.bashrc+''$ source ~/.bashrc''
  
  
   * Alternatively (and for when they fix newlib nano in the repos), install from ppa:   * Alternatively (and for when they fix newlib nano in the repos), install from ppa:
-$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded+''$ sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded''
  
-$ sudo apt-get update+''$ sudo apt-get update''
  
-$ sudo apt-get install gcc-arm-none-eabi+''$ sudo apt-get install gcc-arm-none-eabi''
  
   * Check install is working by running   * Check install is working by running
-$ arm-none-eabi-gcc --version+''$ arm-none-eabi-gcc --version''
  
 ==== Step 2 - Clone a blank project ==== ==== Step 2 - Clone a blank project ====
-$ git clone https://github.com/jonsowman/stm32_locm3_template.git+''$ git clone https://github.com/jonsowman/stm32_locm3_template.git''
  
 ==== Step 3 - Fetch and build libopencm3 ==== ==== Step 3 - Fetch and build libopencm3 ====
-  - `cdinto the root of the repo +  - ''cd'' into the root of the repo 
-  - Run $ `git submodule update --initto fetch libopencm3. +  - Run ''$ git submodule update --init'' to fetch libopencm3. 
-  - `cdto the libopencm3 directory and run `maketo build.+  - ''cd'' to the libopencm3 directory and run ''make'' to build.
  
 ==== Step 4 - Adjust for your device ==== ==== Step 4 - Adjust for your device ====
-Open up Makefile in firmware/src/. Adjust the last line for either the F0 or F4 as appropriate 
-  * include ../common/Makefile.f0.include **OR** 
-  * include ../common/Makefile.f4.include 
  
-We've not got things set up for the F1 (or other) series yet, give us a shout if this is what you're after and we can help.+**We've not got things set up for the F1 (or other) series yet, give us a shout if this is what you're after and we can help.** 
 + 
 +Open up Makefile in firmware/src/. Adjust the last line for either the F0 or F4 as appropriate 
 +  * ''include ../common/Makefile.f0.include'' **OR** 
 +  * ''include ../common/Makefile.f4.include''
  
-Now open up common/stm32f0-discovery.ld or common/stm32f4-discovery. Adjust the RAM and ROM lengths as appropriate for your particular device. If you want to change the name of this file to satisfy your OCD, do so and then make the relevant change in firmware/common/Makefile.f//i//.include. +Now open up common/stm32f0-discovery.ld or common/stm32f4-discovery. Adjust the RAM and ROM lengths as appropriate for your particular device. If you want to change the name of this file to satisfy your OCD, do so and then make the relevant change in firmware/common/Makefile.fx.include (where x=0 or 4 as appropriate)
 ==== Step 5 - Install flashing/debug software ==== ==== Step 5 - Install flashing/debug software ====
   * Clone texane's st-link from https://github.com/texane/stlink   * Clone texane's st-link from https://github.com/texane/stlink
-  * Follow the "compiling" instructions to produce the "st-utiland "st-flashbinaries+  * Follow the "compiling" instructions to produce the ''st-util'' and ''st-flash'' binaries
  
 ==== Step 6 - Build ==== ==== Step 6 - Build ====
 A libopencm3 LED blink example is provided in firmware/src/main.c. A libopencm3 LED blink example is provided in firmware/src/main.c.
  
-`cdto this directory and build the firmware with $ make - this should produce the main.elf file. +''cd'' to this directory and build the firmware with ''$ make'' - this should produce the ''main.elf'' file. 
  
-If you're having issues then use $ make V=1 for more verbose build output.+If you're having issues then use ''$ make V=1'' for more verbose build output.
  
 ==== Step 7 - Flash the firmware ==== ==== Step 7 - Flash the firmware ====
   * Connect the board to the machine via the USB port   * Connect the board to the machine via the USB port
-  * Erase the device with $ st-flash erase +  * Erase the device with ''$ st-flash erase'' 
-  * Make the .bin version of the binary with $ make bin +  * Make the .bin version of the binary with ''$ make bin'' 
-  * Flash the firmware to the device with $ st-flash write main.bin 0x8000000+  * Flash the firmware to the device with ''$ st-flash write main.bin 0x8000000''
     * 0x800000 is the start address of the flash memory in the device memory address space     * 0x800000 is the start address of the flash memory in the device memory address space
  
-**On Linux, st-flash needs root privileges (sudo ./st-flash ...) to access the USB system until you set up udev rules**+**On Linux, st-flash needs root privileges ('' sudo ./st-flash ...'') to access the USB system until you set up udev rules**
  
 ---- ----
Line 108: Line 109:
  
 ==== Step 5 (libopencm3 Libraries) ==== ==== Step 5 (libopencm3 Libraries) ====
-Firstly add the libopencm3 files to the project directory. This can be fetched from the [[https://github.com/libopencm3/libopencm3 | libopencm3 repository]] and compiled as per above instructions, however it is unlikely for all the tools (make, python and others) to be set up correctly. As a result, a precompiled version is available [[http://users.ecs.soton.ac.uk/mfb2g09/stm32/libopencm3.zip | here]]. Unzip the contents into a separate libopencm3 folder along side your project+Firstly add the libopencm3 files to the project directory. This can be fetched from the [[https://github.com/libopencm3/libopencm3 | libopencm3 repository]] and compiled as per above instructions, or run ''git submodule add https://github.com/libopencm3/libopencm3 .\firmware\libopencm3'' if you want to add it to an existing repository. Since it is unlikely for all the tools (make, python and others) to be set up correctly. As a result, a precompiled version is available [[http://users.ecs.soton.ac.uk/mfb2g09/stm32/libopencm3.zip | here]]. Unzip the contents into a separate libopencm3 folder along side your project
  
 The final file needed is part of the linker script. Copy [[https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld|this file (f4)]] or [[https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f0/stm32f0-discovery/stm32f0-discovery.ld|this file (f0)]] along side your project. Note that this file needs editing depending on how much flash/RAM the target has The final file needed is part of the linker script. Copy [[https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld|this file (f4)]] or [[https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f0/stm32f0-discovery/stm32f0-discovery.ld|this file (f0)]] along side your project. Note that this file needs editing depending on how much flash/RAM the target has
guides/stm32toolchain.1408294333.txt.gz · Last modified: 2014/08/17 16:52 by jonsowman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki