README.mediawiki 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. == About ==
  2. This project is used to develop applications for stm32 - ST's ARM Cortex-M3 MCUs, using cmake, GCC, newlib (libc) and STM32F10x Standard Peripherals Library.
  3. Requirements:
  4. * cmake >= 2.6
  5. * GCC toolchain with newlib.
  6. * STM32F10x Standard Peripherals Library
  7. Project contains:
  8. * CMake toolchain file, that configures cmake to use arm toolchain.
  9. * CMake projects that builds CMSIS and STM32F10x Standard Peripherals Library into static libraries.
  10. * CMake modules to find and configure CMSIS ans StdPeriphLib libraries.
  11. * CMake project template.
  12. * Example projects
  13. ** blinky - blink LED using timers and PWM.
  14. ** newlib - show date from RTC using uart and libc functions from newlib
  15. == Usage ==
  16. == Building & Installing ==
  17. First of all you need to configure toolchain and libraries, you can do this by editing gcc_stm32.cmake or pass it throught command line.
  18. Variables for toolchain:
  19. * TOOLCHAIN_PREFIX - where toolchain is located, '''default''': /usr
  20. * TARGET_TRIPLET - toolchain target triplet, '''default''': arm-none-eabi
  21. Variables for CMSIS and StdPeriphLib:
  22. * STM32_StdPeriphLib_DIR - path to STM32F10x Standard Peripherals Library '''default''': /opt/STM32F10x_StdPeriph_Lib_V3.5.0
  23. * USE_ASSERT - Use internal asserts in Standard Peripherals Library.
  24. === Build CMSIS and Standard Peripherals Library ===
  25. In cmsis folder:
  26. cmake -DCMAKE_TOOLCHAIN_FILE=../gcc_stm32.cmake -DCMAKE_INSTALL_PREFIX=<path_to_toolchain>/arm-none-eabi/ -DCMAKE_BUILD_TYPE=Release
  27. make && make install
  28. In stdperiph folder
  29. cmake -DCMAKE_TOOLCHAIN_FILE=../gcc_stm32.cmake -DCMAKE_INSTALL_PREFIX=<path_to_toolchain>/arm-none-eabi/ -DCMAKE_BUILD_TYPE=Release
  30. make && make install
  31. '''Note:''' You can use different CMAKE_INSTALL_PREFIX, but than you'll have to configure cmake search paths when using cmake modules.
  32. '''Note:''' To prevent header collision file "misc.h" from Standard Peripherals Library will be installed as stm32f10x_misc.h
  33. == Usage ==
  34. After building you need to copy cmake modules in cmake's modules path, or just set CMAKE_MODULE_PATH in project.
  35. Than you need to adjust some variables in CMakeLists.txt (example for stm32f103ve):
  36. * PROJECT(stm32-template) - Set the project name.
  37. * FIND_PACKAGE(StdPeriphLib REQUIRED) - comment/remove this if you don't need StdPeriphLib. CMSIS package are always required.
  38. * STM32_SET_PARAMS("512K" "64K" "0x20010000") - Set chip's flash size, ram size, and stack bottom address. Also, you can change min heap size, stack size, etc. - look into FindCMSIS.cmake
  39. * All projects sources should be listed in PROJECT_SOURCES variable.
  40. Also, if you using StdPeriphLib you need to adjust modules in stm32f10x_conf.h.
  41. === Build ===
  42. Generate Makefile:
  43. cmake -DSTM32_CHIP_TYPE=<chip type> -DCMAKE_TOOLCHAIN_FILE=<path_to_gcc_stm32.cmake> -DCMAKE_BUILD_TYPE=Debug <path_to_source_dir>
  44. Where <chip type>:
  45. * HD - High Density MCUs
  46. * HD_VL - High Density Value Line MCUs
  47. * MD - Medium Density MCUs
  48. * MD_VL - Medium Density Value Line MCUs
  49. * LD - Low Density MCUs
  50. * LD_VL - Low Density Value Line MCUs
  51. * CL - Connectivity Line MCUs
  52. * XL - XL Density MCUs
  53. Build:
  54. make
  55. The result is a .elf file, to build .hex:
  56. make <project name>.hex
  57. or .bin:
  58. make <project name>.bin
  59. For using with Eclipse CDT:
  60. cmake -DSTM32_CHIP_TYPE=<chip type> -DCMAKE_TOOLCHAIN_FILE=<path_to_stm32.cmake> -DCMAKE_BUILD_TYPE=Debug -G "Eclipse CDT4 - Unix Makefiles" <path_to_source_dir>
  61. For release build:
  62. cmake -DSTM32_CHIP_TYPE=<chip type> -DCMAKE_TOOLCHAIN_FILE=<path_to_stm32.cmake> -DCMAKE_BUILD_TYPE=Release <path_to_source_dir>