Przeglądaj źródła

Merge pull request #221 from spacefisch/mueller/gen-bin-gen-hex-functions

added binary and hex generation functions
Hish15 4 lat temu
rodzic
commit
f2e4847a18
2 zmienionych plików z 23 dodań i 0 usunięć
  1. 3 0
      README.md
  2. 20 0
      cmake/stm32/common.cmake

+ 3 - 0
README.md

@@ -136,6 +136,9 @@ CMSIS package will generate linker script for your device automatically (target
 * `stm32_get_chip_info(<chip> [FAMILY <family>] [TYPE <type>] [DEVICE <device>])` - classify device using name, will return device family (into `<family>` variable), type (`<type>`) and canonical name (`<device>`, uppercase without any package codes)
 * `stm32_get_chip_info(<chip> [FAMILY <family>] [TYPE <type>] [DEVICE <device>])` - classify device using name, will return device family (into `<family>` variable), type (`<type>`) and canonical name (`<device>`, uppercase without any package codes)
 * `stm32_get_memory_info((CHIP <chip>)|(DEVICE <device> TYPE <type>) [FLASH|RAM|CCRAM|STACK|HEAP] [SIZE <size>] [ORIGIN <origin>])` - get information about device memories (into `<size>` and `<origin>`). Linker script generator uses values from this function
 * `stm32_get_memory_info((CHIP <chip>)|(DEVICE <device> TYPE <type>) [FLASH|RAM|CCRAM|STACK|HEAP] [SIZE <size>] [ORIGIN <origin>])` - get information about device memories (into `<size>` and `<origin>`). Linker script generator uses values from this function
 * `stm32_get_devices_by_family(DEVICES [FAMILY <family>])` - return into `DEVICES` all supported devices by family (or all devices if `<family>` is empty)
 * `stm32_get_devices_by_family(DEVICES [FAMILY <family>])` - return into `DEVICES` all supported devices by family (or all devices if `<family>` is empty)
+* `stm32_print_size_of_target(<target>)` - Print the application sizes for all formats
+* `stm32_generate_binary_file(<target>)` - Generate the binary file for the given target
+* `stm32_generate_hex_file(<target>)` - Generate the hex file for the given target
 
 
 # Additional CMake modules
 # Additional CMake modules
 
 

+ 20 - 0
cmake/stm32/common.cmake

@@ -50,6 +50,26 @@ function(stm32_print_size_of_target TARGET)
     )
     )
 endfunction()
 endfunction()
 
 
+function(stm32_generate_binary_file TARGET)
+    add_custom_command(
+        TARGET ${TARGET}
+        POST_BUILD
+        COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C} ${TARGET}.bin
+        BYPRODUCTS ${TARGET}.bin
+        COMMENT "Generating binary file ${CMAKE_PROJECT_NAME}.bin"
+    )
+endfunction()
+
+function(stm32_generate_hex_file TARGET)
+    add_custom_command(
+        TARGET ${TARGET}
+        POST_BUILD
+        COMMAND ${CMAKE_OBJCOPY} -O ihex ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C} ${TARGET}.hex
+        BYPRODUCTS ${TARGET}.hex
+        COMMENT "Generating hex file ${CMAKE_PROJECT_NAME}.hex"
+    )
+endfunction()
+
 function(stm32_get_chip_type FAMILY DEVICE TYPE)
 function(stm32_get_chip_type FAMILY DEVICE TYPE)
     set(INDEX 0)
     set(INDEX 0)
     foreach(C_TYPE ${STM32_${FAMILY}_TYPES})
     foreach(C_TYPE ${STM32_${FAMILY}_TYPES})