Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to generate DAPLink files #1907

Merged
merged 1 commit into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CMake/Modules/FindBuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@ function(NF_GENERATE_HEX_PACKAGE FILE1 FILE2 OUTPUTFILENAME)

endfunction()

# generates a binary file with nanoBooter + nanoCLR at the proper addresses
# ready to be drag & drop on targets that feature DAPLink
function(NF_GENERATE_BIN_PACKAGE FILE1 FILE2 OFFSET OUTPUTFILENAME)

add_custom_command(

TARGET ${NANOCLR_PROJECT_NAME}.elf POST_BUILD

COMMAND ${TOOL_SRECORD_PREFIX}/srec_cat

${FILE1} -Binary
${FILE2} -Binary -offset 0x${OFFSET}
-o ${OUTPUTFILENAME} -Binary

WORKING_DIRECTORY ${TOOL_SRECORD_PREFIX}

COMMENT "exporting hex files to one binary file"
)

# need to add a dependency of NANOCLR to NANOBOOTER because SRECORD util needs hex outputs of both targets
add_dependencies(${NANOCLR_PROJECT_NAME}.elf ${NANOBOOTER_PROJECT_NAME}.elf)

endfunction()

function(NF_GENERATE_BUILD_OUTPUT_FILES TARGET)

# need to remove the .elf suffix from target name
Expand Down
5 changes: 4 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,13 @@ jobs:
BuildOptions: -DTARGET_SERIES=STM32F0xx -DRTOS=CHIBIOS -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DUSE_RNG=OFF -DNF_PLATFORM_NO_CLR_TRACE=ON -DNF_CLR_NO_IL_INLINE=ON -DAPI_Hardware.Stm32=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_System.Device.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_System.Device.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_System.Device.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_nanoFramework.System.Text=ON
GccArm_Version:
NeedsDFU: false
NeedsSRECORD: true
ST_STM32F769I_DISCOVERY:
TargetBoard: ST_STM32F769I_DISCOVERY
BuildOptions: -DTARGET_SERIES=STM32F7xx -DRTOS=CHIBIOS -DSUPPORT_ANY_BASE_CONVERSION=ON -DNF_FEATURE_DEBUGGER=ON -DNF_FEATURE_RTC=ON -DNF_FEATURE_HAS_SDCARD=ON -DAPI_System.Math=ON -DAPI_Hardware.Stm32=ON -DNF_FEATURE_HAS_CONFIG_BLOCK=ON -DAPI_Windows.Devices.Gpio=ON -DAPI_System.Device.Gpio=ON -DAPI_Windows.Devices.Spi=ON -DAPI_System.Device.Spi=ON -DAPI_Windows.Devices.I2c=ON -DAPI_System.Device.I2c=ON -DAPI_Windows.Devices.Pwm=ON -DAPI_Windows.Devices.SerialCommunication=ON -DAPI_Windows.Devices.Adc=ON -DAPI_System.Device.Dac=ON -DAPI_System.Net=ON -DNF_SECURITY_MBEDTLS=ON -DAPI_nanoFramework.Devices.OneWire=ON -DAPI_nanoFramework.Devices.Can=ON -DAPI_System.IO.FileSystem=ON -DAPI_nanoFramework.ResourceManager=ON -DAPI_nanoFramework.System.Collections=ON -DAPI_nanoFramework.System.Text=ON -DAPI_nanoFramework.Graphics=ON -DGRAPHICS_MEMORY=Graphics_Memory.cpp -DGRAPHICS_DISPLAY=Otm8009a_DSI_Video_Mode.cpp -DGRAPHICS_DISPLAY_INTERFACE=DSI_To_Display_Video_Mode.cpp -DTOUCHPANEL_DEVICE=ft6x06_I2C.cpp -DTOUCHPANEL_INTERFACE=I2C_To_TouchPanel.cpp
GccArm_Version:
NeedsDFU: false
NeedsDFU: false
NeedsSRECORD: true

variables:
# creates a counter and assigns it to the revision variable
Expand All @@ -301,6 +303,7 @@ jobs:
- template: azure-pipelines-templates/nb-gitversioning.yml
- template: azure-pipelines-templates/download-install-arm-gcc-toolchain.yml
- template: azure-pipelines-templates/download-install-ninja.yml
- template: azure-pipelines-templates/download-srecord.yml
- template: azure-pipelines-templates/download-hexdfu.yml
- template: azure-pipelines-templates/build-chibios-stm32.yml
- template: azure-pipelines-templates/pack-publish-artifacts.yml
Expand Down
15 changes: 15 additions & 0 deletions targets/ChibiOS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ if(DEFINED TOOL_HEX2DFU_PREFIX)
endif()
endif()

########################################################
# check availability of SRecord tool, if specified
if(DEFINED TOOL_SRECORD_PREFIX)
if(NOT ((EXISTS ${TOOL_SRECORD_PREFIX}/srec_cat.exe) OR (EXISTS ${TOOL_SRECORD_PREFIX}/srec_cat)))
message(STATUS "")
message(STATUS "Couldn't find the srec_cat tool at the specified path: ${TOOL_SRECORD_PREFIX}/srec_cat.exe")
message(STATUS "Make sure that the CMake option TOOL_SRECORD_PREFIX has the correct path.")
message(STATUS "If you don't have this tool download it from https://sourceforge.net/projects/srecord/files/srecord-win32/")
message(STATUS "")
message(FATAL_ERROR "srec_cat tool not found")
else()
set(SRECORD_TOOL_AVAILABLE TRUE CACHE INTERNAL "srec_cat tool available")
endif()
endif()

# check if RTOS_SOURCE_FOLDER was specified or if it's empty (default is empty)
set(NO_RTOS_SOURCE_FOLDER TRUE)
if(RTOS_SOURCE_FOLDER)
Expand Down
24 changes: 24 additions & 0 deletions targets/ChibiOS/ST_NUCLEO64_F091RC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,27 @@ set_property(TARGET ${NANOCLR_PROJECT_NAME}.elf APPEND_STRING PROPERTY LINK_FLAG
# generate output files
nf_generate_build_output_files(${NANOBOOTER_PROJECT_NAME}.elf)
nf_generate_build_output_files(${NANOCLR_PROJECT_NAME}.elf)

# generate bin file for deployment
if(SRECORD_TOOL_AVAILABLE)

############################################################################################################
## when changing the linker file make sure to update the addresses below with the offset of the CLR image ##
## DO NOT use the leading 0x notation, just the address in plain hexadecimal formating ##
############################################################################################################

if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
NF_GENERATE_BIN_PACKAGE(
${CMAKE_SOURCE_DIR}/build/${NANOBOOTER_PROJECT_NAME}.bin
${CMAKE_SOURCE_DIR}/build/${NANOCLR_PROJECT_NAME}.bin
5000
${CMAKE_SOURCE_DIR}/build/nanobooter-nanoclr.bin)
else()
NF_GENERATE_BIN_PACKAGE(
${CMAKE_SOURCE_DIR}/build/${NANOBOOTER_PROJECT_NAME}.bin
${CMAKE_SOURCE_DIR}/build/${NANOCLR_PROJECT_NAME}.bin
2800
${CMAKE_SOURCE_DIR}/build/nanobooter-nanoclr.bin)
endif()

endif()
1 change: 1 addition & 0 deletions targets/ChibiOS/ST_NUCLEO64_F091RC/cmake-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"CMAKE_TOOLCHAIN_FILE": "CMake/toolchain.arm-none-eabi.cmake",
"TOOLCHAIN_PREFIX": "<absolute-path-to-the-toolchain-folder-mind-the-forward-slashes>",
"TOOL_HEX2DFU_PREFIX": "<absolute-path-to-hex2dfu-mind-the-forward-slashes>",
"TOOL_SRECORD_PREFIX": "<absolute-path-to-srecord-folder-mind-the-forward-slashes>",
"TARGET_SERIES": "STM32F0xx",
"RTOS": "CHIBIOS",
"RTOS_SOURCE_FOLDER": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
/*
* STM32F091xC memory setup.
*/

/*
* When updating the flash0 address below make sure to update the address in NF_GENERATE_BIN_PACKAGE
*/

MEMORY
{
flash0 (rx) : org = 0x08005000, len = 256k - 20k - 46k /* flash size less the space reserved for nanoBooter and application deployment*/
Expand Down
5 changes: 5 additions & 0 deletions targets/ChibiOS/ST_NUCLEO64_F091RC/nanoCLR/STM32F091xC_CLR.ld
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
/*
* STM32F091xC memory setup.
*/

/*
* When updating the flash0 address below make sure to update the address in NF_GENERATE_BIN_PACKAGE
*/

MEMORY
{
flash0 (rx) : org = 0x08002800, len = 256k - 10k - 88k /* flash size less the space reserved for nanoBooter and application deployment*/
Expand Down
24 changes: 24 additions & 0 deletions targets/ChibiOS/ST_STM32F769I_DISCOVERY/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,27 @@ set_property(TARGET ${NANOCLR_PROJECT_NAME}.elf APPEND_STRING PROPERTY LINK_FLAG
# generate output files
nf_generate_build_output_files(${NANOBOOTER_PROJECT_NAME}.elf)
nf_generate_build_output_files(${NANOCLR_PROJECT_NAME}.elf)

# generate bin file for deployment
if(SRECORD_TOOL_AVAILABLE)

############################################################################################################
## when changing the linker file make sure to update the addresses below with the offset of the CLR image ##
## DO NOT use the leading 0x notation, just the address in plain hexadecimal formating ##
############################################################################################################

if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
NF_GENERATE_BIN_PACKAGE(
${CMAKE_SOURCE_DIR}/build/${NANOBOOTER_PROJECT_NAME}.bin
${CMAKE_SOURCE_DIR}/build/${NANOCLR_PROJECT_NAME}.bin
10000
${CMAKE_SOURCE_DIR}/build/nanobooter-nanoclr.bin)
else()
NF_GENERATE_BIN_PACKAGE(
${CMAKE_SOURCE_DIR}/build/${NANOBOOTER_PROJECT_NAME}.bin
${CMAKE_SOURCE_DIR}/build/${NANOCLR_PROJECT_NAME}.bin
10000
${CMAKE_SOURCE_DIR}/build/nanobooter-nanoclr.bin)
endif()

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"CMAKE_TOOLCHAIN_FILE": "CMake/toolchain.arm-none-eabi.cmake",
"TOOLCHAIN_PREFIX": "<absolute-path-to-the-toolchain-folder-mind-the-forward-slashes>",
"TOOL_HEX2DFU_PREFIX": "<absolute-path-to-hex2dfu-mind-the-forward-slashes>",
"TOOL_SRECORD_PREFIX": "<absolute-path-to-srecord-folder-mind-the-forward-slashes>",
"RTOS": "CHIBIOS",
"TARGET_SERIES": "STM32F7xx",
"RTOS_SOURCE_FOLDER": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
* Notes:
* BSS is placed in DTCM RAM in order to simplify DMA buffers management.
* When updating the flash0 address below make sure to update the address in NF_GENERATE_BIN_PACKAGE
*/
MEMORY
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*
* Notes:
* BSS is placed in DTCM RAM in order to simplify DMA buffers management.
* When updating the flash0 address below make sure to update the address in NF_GENERATE_BIN_PACKAGE
*/
MEMORY
{
Expand Down