README.mediawiki 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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, and sets some variables for STM32F10x Standard Peripherals Library.
  9. * CMake project template.
  10. * Example projects
  11. ** blinky - blink LED using timers and PWM.
  12. ** newlib - show date from RTC using uart and libc functions from newlib
  13. == Usage ==
  14. === Configure ===
  15. First of all you need to configure toolchain, you can do this by editing values in stm32.cmake or pass it throught command line.
  16. Variables for toolchain:
  17. * TOOLCHAIN_PREFIX - where toolchain is located, '''default''': /usr
  18. * STM32_StdPeriphLib_DIR - path to STM32F10x Standard Peripherals Library '''default''': /opt/STM32F10x_StdPeriph_Lib_V3.5.0
  19. * TARGET_TRIPLET - toolchain target triplet, '''default''': arm-none-eabi
  20. Than you need to adjust some variables in CMakeLists.txt (example for stm32f103ve):
  21. * PROJECT(stm32-blinky) - Set the project name.
  22. * SET(STM32_FLASH_SIZE "512K") - Select chip's flash size.
  23. * SET(STM32_RAM_SIZE "64K") - Select chip's RAM size.
  24. * SET(STM32_STACK_ADDRESS "0x20010000") - Select stack address = ram origin + ram size
  25. * SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSTM32F10X_HD") - Select your device type in defines (CL, HD, HD_VL, LD, LD_VL, MD, MD_VL, XL, more information in StdPeriphLib)
  26. * SET(STARTUP_SOURCE ${STM32_STARTUP_HD}) - Select your device type for startup files (CL, HD, HD_VL, LD, LD_VL, MD, MD_VL, XL, more information in StdPeriphLib)
  27. * MOD_SOURCES contains list of StdPeriphLib's modules needed for project.
  28. * All projects sources should be listed in PROJECT_SOURCES variable.
  29. Also, you need to adjust StdPeriphLib modules in stm32f10x_conf.h.
  30. === Build ===
  31. Generate Makefile:
  32. cmake -DCMAKE_TOOLCHAIN_FILE=<path_to_stm32.cmake> -DCMAKE_BUILD_TYPE=Debug <path_to_source_dir>
  33. Build:
  34. make
  35. The result is a .elf, .bin, and hex files.
  36. For using with Eclipse CDT:
  37. cmake -DCMAKE_TOOLCHAIN_FILE=<path_to_stm32.cmake> -DCMAKE_BUILD_TYPE=Debug -G "Eclipse CDT4 - Unix Makefiles" <path_to_source_dir>
  38. For release build:
  39. cmake -DCMAKE_TOOLCHAIN_FILE=<path_to_stm32.cmake> -DCMAKE_BUILD_TYPE=Release <path_to_source_dir>