From f49725d2c958dd1368b5ca191a00be72543c0752 Mon Sep 17 00:00:00 2001 From: Brent Kowal Date: Wed, 10 Jul 2024 15:18:59 -0400 Subject: [PATCH] BSP Cleanup - Added MSDK flash rules for CMake - Removed partial IAR support. Uniform GCC support across MAX32 parts - Updated build scripts for correctly signing the MAX32651 - Added README files for the BSPs to describe flashing and limitiations --- hw/bsp/max32650/README.md | 46 +++++++++++++ .../max32650/boards/max32650evkit/board.cmake | 11 +++- hw/bsp/max32650/boards/max32650evkit/board.mk | 17 +---- .../max32650/boards/max32650fthr/board.cmake | 9 +++ hw/bsp/max32650/boards/max32650fthr/board.mk | 17 +---- .../max32650/boards/max32651evkit/board.cmake | 31 ++++++++- hw/bsp/max32650/boards/max32651evkit/board.mk | 43 +------------ hw/bsp/max32650/family.cmake | 32 +++++++--- hw/bsp/max32650/family.mk | 64 +++++++++++++++++-- hw/bsp/max32666/README.md | 32 ++++++++++ hw/bsp/max32666/family.cmake | 19 ++++-- hw/bsp/max32666/family.mk | 6 +- hw/bsp/max32690/README.md | 31 +++++++++ hw/bsp/max32690/family.cmake | 21 ++++-- hw/bsp/max32690/family.mk | 6 +- hw/bsp/max78002/README.md | 28 ++++++++ hw/bsp/max78002/family.cmake | 27 +++++--- hw/bsp/max78002/family.mk | 6 +- 18 files changed, 325 insertions(+), 121 deletions(-) create mode 100644 hw/bsp/max32650/README.md create mode 100644 hw/bsp/max32666/README.md create mode 100644 hw/bsp/max32690/README.md create mode 100644 hw/bsp/max78002/README.md diff --git a/hw/bsp/max32650/README.md b/hw/bsp/max32650/README.md new file mode 100644 index 000000000..cb8069bba --- /dev/null +++ b/hw/bsp/max32650/README.md @@ -0,0 +1,46 @@ +# Analog Devices MAX32650/1/2 + +This BSP is for working with the Analog Devices +[MAX32650](https://www.analog.com/en/products/max32650.html), +[MAX32651](https://www.analog.com/en/products/max32651.html) and +[MAX32652](https://www.analog.com/en/products/max32652.html) +microcontrollers. The following boards are supported: + * [MAX32650EVKIT](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32650-evkit.html) + * [MAX32650FTHR](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32650fthr.html) + * [MAX32651EVKIT](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32651-evkit.html) (Secure Bootloader) + +This part family leverages the Maxim Microcontrollers SDK (MSDK) for the device +interfaces and hardware abstraction layers. This source code package is fetched +as part of the get-deps script. + +The microcontrollers utilize the standard GNU ARM toolchain. If this toolchain +is not already available on your build machine, it can be installed by using the +bundled MSDK installation. Details on downloading and installing can be found +in the [User's Guide](https://analogdevicesinc.github.io/msdk//USERGUIDE/). + +## Flashing + +### MAX32650 and MAX32652 + +The default flashing behavior in this BSP for the MAX32650 and MAX32652 is to +utilize JLink. This can be done by running the `flash` or `flash-jlink` rule +for Makefiles, or the `-jlink` target for CMake. + +Both the Evaluation Kit and Feather boards are shipped with a CMSIS-DAP +compatible debug probe. However, at the time of writing, the necessary flashing +algorithms for OpenOCD have not yet been incorporated into the OpenOCD master +branch. To utilize the provided debug probes, please install the bundled MSDK +package which includes the appropriate OpenOCD modifications. To leverage this +OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake +target. + +### MAX32651 + +The MAX32651 features an integrated secure bootloader which requires the +application image be signed prior to flashing. Both the Makefile and CMake +scripts account for this signing automatically when building for the +MAX32651EVKIT. + +To flash the signed image, the MSDK's OpenOCD variant must be used. To flash +the MAX32651EVKIT please install the bundled MSDK, and utilize the `flash-msdk` +and `-msdk` rule and target. \ No newline at end of file diff --git a/hw/bsp/max32650/boards/max32650evkit/board.cmake b/hw/bsp/max32650/boards/max32650evkit/board.cmake index e094b89e1..fffdcc9fb 100644 --- a/hw/bsp/max32650/boards/max32650evkit/board.cmake +++ b/hw/bsp/max32650/boards/max32650evkit/board.cmake @@ -1 +1,10 @@ -set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld) \ No newline at end of file +# Use the standard, non-secure linker file +set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld) + +function(update_board_extras TARGET) + #No extra arguments +endfunction() + +function(prepare_image TARGET_IN) + #No signing required +endfunction() diff --git a/hw/bsp/max32650/boards/max32650evkit/board.mk b/hw/bsp/max32650/boards/max32650evkit/board.mk index ad7125573..0bc210e11 100644 --- a/hw/bsp/max32650/boards/max32650evkit/board.mk +++ b/hw/bsp/max32650/boards/max32650evkit/board.mk @@ -1,17 +1,2 @@ +# Use the standard, non-secure linker file LD_FILE = $(BOARD_PATH)/max32650.ld - -# For flash-jlink target -JLINK_DEVICE = max32650 - -# flash target using Jlik -flash: flash-jlink - -# Optional flash option when running within an installed MSDK to use OpenOCD -# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated. -# If the MSDK is installed, flash-msdk can be run to utilize the the modified -# openocd with the algorithms -MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) -flash-msdk: $(BUILD)/$(PROJECT).elf - $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \ - -f interface/cmsis-dap.cfg -f target/max32650.cfg \ - -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit" \ No newline at end of file diff --git a/hw/bsp/max32650/boards/max32650fthr/board.cmake b/hw/bsp/max32650/boards/max32650fthr/board.cmake index a9ce39b4d..fffdcc9fb 100644 --- a/hw/bsp/max32650/boards/max32650fthr/board.cmake +++ b/hw/bsp/max32650/boards/max32650fthr/board.cmake @@ -1 +1,10 @@ +# Use the standard, non-secure linker file set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld) + +function(update_board_extras TARGET) + #No extra arguments +endfunction() + +function(prepare_image TARGET_IN) + #No signing required +endfunction() diff --git a/hw/bsp/max32650/boards/max32650fthr/board.mk b/hw/bsp/max32650/boards/max32650fthr/board.mk index c6f018810..0bc210e11 100644 --- a/hw/bsp/max32650/boards/max32650fthr/board.mk +++ b/hw/bsp/max32650/boards/max32650fthr/board.mk @@ -1,17 +1,2 @@ +# Use the standard, non-secure linker file LD_FILE = $(BOARD_PATH)/max32650.ld - -# For flash-jlink target -JLINK_DEVICE = max32650 - -# flash target using Jlik -flash: flash-jlink - -# Optional flash option when running within an installed MSDK to use OpenOCD -# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated. -# If the MSDK is installed, flash-msdk can be run to utilize the the modified -# openocd with the algorithms -MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) -flash-msdk: $(BUILD)/$(PROJECT).elf - $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \ - -f interface/cmsis-dap.cfg -f target/max32650.cfg \ - -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit" diff --git a/hw/bsp/max32650/boards/max32651evkit/board.cmake b/hw/bsp/max32650/boards/max32651evkit/board.cmake index 8bb3e6edd..bd8077a42 100644 --- a/hw/bsp/max32650/boards/max32651evkit/board.cmake +++ b/hw/bsp/max32650/boards/max32651evkit/board.cmake @@ -1 +1,30 @@ -set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32651.ld) \ No newline at end of file +# Use the secure linker file +set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32651.ld) + +function(update_board_extras TARGET) + # for the signed target, need to add the __SLA_FWK__ define + target_compile_definitions(${TARGET} PUBLIC + __SLA_FWK__ + ) +endfunction() + +function(prepare_image TARGET_IN) + #For the signed target, set up a POST_BUILD command to sign the elf file once + #created + if((WIN32) OR (MINGW) OR (MSYS)) + set(SIGN_EXE "sign_app.exe") + else() + set(SIGN_EXE "sign_app") + endif() + set(MCU_PATH "${TOP}/hw/mcu/analog/max32/") + + # Custom POST_BUILD command + add_custom_command( + TARGET ${TARGET_IN} POST_BUILD + COMMAND ${CMAKE_OBJCOPY} $ -R .sig -O binary $/${TARGET_IN}.bin + COMMAND ${MCU_PATH}/Tools/SBT/bin/${SIGN_EXE} -c MAX32651 key_file=${MCU_PATH}/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key + ca=$/${TARGET_IN}.bin sca=$/${TARGET_IN}.sbin + COMMAND ${CMAKE_OBJCOPY} $ --update-section .sig=$/${TARGET_IN}.sig + VERBATIM + ) +endfunction() diff --git a/hw/bsp/max32650/boards/max32651evkit/board.mk b/hw/bsp/max32650/boards/max32651evkit/board.mk index 8d13d8edf..b609598c1 100644 --- a/hw/bsp/max32650/boards/max32651evkit/board.mk +++ b/hw/bsp/max32650/boards/max32651evkit/board.mk @@ -1,42 +1,5 @@ +# Use the secure linker file LD_FILE = $(BOARD_PATH)/max32651.ld -CFLAGS += -D__SLA_FWK__ - -# For flash-jlink target -JLINK_DEVICE = max32650 - -# flash target using MSDK signing the image -flash: flash-msdk-signed - - -MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) - -# The MAX32651EVKIT is pin for pin identical to the MAX32650EVKIT, however the -# MAX32651 has a secure bootloader which requires the image to be signed before -# loading into flash. All MAX32651EVKIT's have the same key for evaluation -# purposes, so create a special flash rule to sign the binary and flash using -# the MSDK. -# For the MAX32650, the regular flash, flash-jlink and flash-msdk are sufficient -MCU_PATH = $(TOP)/hw/mcu/analog/max32/ -# Assume no extension for sign utility -SIGN_EXE = sign_app -ifeq ($(OS), Windows_NT) -# Must use .exe extension on Windows, since the binaries -# for Linux may live in the same place. -SIGN_EXE := sign_app.exe -else -UNAME = $(shell uname -s) -ifneq ($(findstring MSYS_NT,$(UNAME)),) -# Must also use .exe extension for MSYS2 -SIGN_EXE := sign_app.exe -endif -endif - -flash-msdk-signed: $(BUILD)/$(PROJECT).elf - $(OBJCOPY) $(BUILD)/$(PROJECT).elf -R .sig -O binary $(BUILD)/$(PROJECT).bin - $(MCU_PATH)/Tools/SBT/bin/$(SIGN_EXE) -c MAX32651 key_file="$(MCU_PATH)/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key" \ - ca=$(BUILD)/$(PROJECT).bin sca=$(BUILD)/$(PROJECT).sbin - $(OBJCOPY) $(BUILD)/$(PROJECT).elf --update-section .sig=$(BUILD)/$(PROJECT).sig - $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \ - -f interface/cmsis-dap.cfg -f target/max32650.cfg \ - -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit" +# Let the family script know the build needs to be signed +SIGNED_BUILD := 1 diff --git a/hw/bsp/max32650/family.cmake b/hw/bsp/max32650/family.cmake index 764356495..129d99af8 100644 --- a/hw/bsp/max32650/family.cmake +++ b/hw/bsp/max32650/family.cmake @@ -4,10 +4,10 @@ set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers) set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS) set(CMSIS_5 ${TOP}/lib/CMSIS_5) -# include board specific +# include board specific information and functions include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) -# Get the linker file from current location (family) +# Get the linker file set(LD_FILE_Clang ${LD_FILE_GNU}) # toolchain set up @@ -27,6 +27,9 @@ function(update_board TARGET) CFG_TUSB_MCU=OPT_MCU_MAX32650 BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED ) + + # Run any board specific updates + update_board_extras(${TARGET}) endfunction() #------------------------------------ @@ -41,11 +44,11 @@ function(add_board_target BOARD_TARGET) # Startup & Linker script set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S) set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU}) - #set(STARTUP_FILE_IAR ?) set(PERIPH_SRC ${MAX32_PERIPH}/Source) add_library(${BOARD_TARGET} STATIC ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/heap.c + ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/header_MAX32650.c ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/system_max32650.c ${PERIPH_SRC}/SYS/mxc_assert.c ${PERIPH_SRC}/SYS/mxc_delay.c @@ -84,7 +87,7 @@ function(add_board_target BOARD_TARGET) ) target_compile_options(${BOARD_TARGET} PRIVATE - -Wno-error=strict-prototypes + -Wno-error=strict-prototypes ) update_board(${BOARD_TARGET}) @@ -93,15 +96,12 @@ function(add_board_target BOARD_TARGET) "LINKER:--script=${LD_FILE_GNU}" -nostartfiles --specs=nosys.specs --specs=nano.specs + -u sb_header #Needed when linking libraries to not lose the Signing header ) elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang") target_link_options(${BOARD_TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}" ) - elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") - target_link_options(${BOARD_TARGET} PUBLIC - "LINKER:--config=${LD_FILE_IAR}" - ) endif () endfunction() @@ -148,5 +148,21 @@ function(family_configure_example TARGET RTOS) # Flashing family_flash_jlink(${TARGET}) + + # Add the optional MSDK OpenOCD flashing + family_flash_msdk(${TARGET}) endfunction() +function(family_flash_msdk TARGET) + # Prepare the image (signed) if the board requires it + prepare_image(${TARGET}) + + set(MAXIM_PATH "$ENV{MAXIM_PATH}") + add_custom_target(${TARGET}-msdk + DEPENDS ${TARGET} + COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts + -f interface/cmsis-dap.cfg -f target/max32650.cfg + -c "program $ verify; init; reset; exit" + VERBATIM + ) +endfunction() diff --git a/hw/bsp/max32650/family.mk b/hw/bsp/max32650/family.mk index 6e9b7b835..577d96717 100644 --- a/hw/bsp/max32650/family.mk +++ b/hw/bsp/max32650/family.mk @@ -13,9 +13,6 @@ PORT ?= 0 # GCC SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S -# IAR -#SRC_S_IAR += ? - # -------------- # Compiler Flags # -------------- @@ -40,6 +37,26 @@ CFLAGS += -Wno-error=strict-prototypes \ LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs +# Configure the flash rule. By default, use JLink. +SIGNED_BUILD ?= 0 +DEFAULT_FLASH = flash-jlink + +# If the applications needs to be signed (for the MAX32651), sign it first and +# then need to use MSDK's OpenOCD to flash it +# Also need to include the __SLA_FWK__ define to enable the signed header into +# memory +ifeq ($(SIGNED_BUILD), 1) +# Extra definitions to build for the secure part +CFLAGS += -D__SLA_FWK__ +DEFAULT_FLASH := sign-build flash-msdk +endif + +# For flash-jlink target +JLINK_DEVICE = max32650 + +# Configure the flash rule +flash: $(DEFAULT_FLASH) + # ----------------- # Sources & Include # ----------------- @@ -70,7 +87,6 @@ SRC_C += \ $(PERIPH_SRC)/UART/uart_me10.c \ $(PERIPH_SRC)/UART/uart_reva.c \ - INC += \ $(TOP)/$(BOARD_PATH) \ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \ @@ -83,3 +99,43 @@ INC += \ $(PERIPH_SRC)/FLC \ $(PERIPH_SRC)/TPU \ $(PERIPH_SRC)/UART + + +# The MAX32651EVKIT is pin for pin identical to the MAX32650EVKIT, however the +# MAX32651 has a secure bootloader which requires the image to be signed before +# loading into flash. All MAX32651EVKIT's have the same key for evaluation +# purposes, so create a special flash rule to sign the binary and flash using +# the MSDK. +MCU_PATH = $(TOP)/hw/mcu/analog/max32/ +# Assume no extension for sign utility +SIGN_EXE = sign_app +ifeq ($(OS), Windows_NT) +# Must use .exe extension on Windows, since the binaries +# for Linux may live in the same place. +SIGN_EXE := sign_app.exe +else +UNAME = $(shell uname -s) +ifneq ($(findstring MSYS_NT,$(UNAME)),) +# Must also use .exe extension for MSYS2 +SIGN_EXE := sign_app.exe +endif +endif + +# Rule to sign the build. This will in-place modifiy the existing .elf file +# an populate the .sig section with the signature value +sign-build: $(BUILD)/$(PROJECT).elf + $(OBJCOPY) $(BUILD)/$(PROJECT).elf -R .sig -O binary $(BUILD)/$(PROJECT).bin + $(MCU_PATH)/Tools/SBT/bin/$(SIGN_EXE) -c MAX32651 \ + key_file="$(MCU_PATH)/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key" \ + ca=$(BUILD)/$(PROJECT).bin sca=$(BUILD)/$(PROJECT).sbin + $(OBJCOPY) $(BUILD)/$(PROJECT).elf --update-section .sig=$(BUILD)/$(PROJECT).sig + +# Optional flash option when running within an installed MSDK to use OpenOCD +# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated. +# If the MSDK is installed, flash-msdk can be run to utilize the the modified +# openocd with the algorithms +MAXIM_PATH := $(subst \,/,$(MAXIM_PATH)) +flash-msdk: $(BUILD)/$(PROJECT).elf + $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \ + -f interface/cmsis-dap.cfg -f target/max32650.cfg \ + -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit" diff --git a/hw/bsp/max32666/README.md b/hw/bsp/max32666/README.md new file mode 100644 index 000000000..902d82e25 --- /dev/null +++ b/hw/bsp/max32666/README.md @@ -0,0 +1,32 @@ +# Analog Devices MAX32665/6 + +This BSP is for working with the Analog Devices +[MAX32665](https://www.analog.com/en/products/max32665.html) and +[MAX32666](https://www.analog.com/en/products/max32666.html) microcontrollers. +The following boards are supported: + * [MAX32666EVKIT](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32666evkit.html) + * [MAX32666FTHR](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32666fthr.html) + + +This part family leverages the Maxim Microcontrollers SDK (MSDK) for the device +interfaces and hardware abstraction layers. This source code package is fetched +as part of the get-deps script. + +The microcontrollers utilize the standard GNU ARM toolchain. If this toolchain +is not already available on your build machine, it can be installed by using the +bundled MSDK installation. Details on downloading and installing can be found +in the [User's Guide](https://analogdevicesinc.github.io/msdk//USERGUIDE/). + +## Flashing + +The default flashing behavior in this BSP is to utilize JLink. This can be done +by running the `flash` or `flash-jlink` rule for Makefiles, or the +`-jlink` target for CMake. + +Both the Evaluation Kit and Feather boards are shipped with a CMSIS-DAP +compatible debug probe. However, at the time of writing, the necessary flashing +algorithms for OpenOCD have not yet been incorporated into the OpenOCD master +branch. To utilize the provided debug probes, please install the bundled MSDK +package which includes the appropriate OpenOCD modifications. To leverage this +OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake +target. diff --git a/hw/bsp/max32666/family.cmake b/hw/bsp/max32666/family.cmake index c9fa2510a..ef2a2bb63 100644 --- a/hw/bsp/max32666/family.cmake +++ b/hw/bsp/max32666/family.cmake @@ -42,7 +42,6 @@ function(add_board_target BOARD_TARGET) # Startup & Linker script set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32665/Source/GCC/startup_max32665.S) set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU}) - set(STARTUP_FILE_IAR ${MAX32_CMSIS}/Device/Maxim/MAX32665/Source/IAR/startup_max32665.S) set(PERIPH_SRC ${MAX32_PERIPH}/Source) add_library(${BOARD_TARGET} STATIC @@ -98,10 +97,6 @@ function(add_board_target BOARD_TARGET) target_link_options(${BOARD_TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}" ) - elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") - target_link_options(${BOARD_TARGET} PUBLIC - "LINKER:--config=${LD_FILE_IAR}" - ) endif () endfunction() @@ -148,4 +143,18 @@ function(family_configure_example TARGET RTOS) # Flashing family_flash_jlink(${TARGET}) + family_flash_msdk(${TARGET}) +endfunction() + +# Add flash msdk target +function(family_flash_msdk TARGET) + set(MAXIM_PATH "$ENV{MAXIM_PATH}") + + add_custom_target(${TARGET}-msdk + DEPENDS ${TARGET} + COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts + -f interface/cmsis-dap.cfg -f target/max32665.cfg + -c "program $ verify; init; reset; exit" + VERBATIM + ) endfunction() diff --git a/hw/bsp/max32666/family.mk b/hw/bsp/max32666/family.mk index 31428cacd..31f81f014 100644 --- a/hw/bsp/max32666/family.mk +++ b/hw/bsp/max32666/family.mk @@ -14,9 +14,6 @@ PORT ?= 0 SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32665/Source/GCC/startup_max32665.S LD_FILE = $(FAMILY_PATH)/max32666.ld -# IAR -#SRC_S_IAR += ? - # -------------- # Compiler Flags # -------------- @@ -42,7 +39,7 @@ LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs # For flash-jlink target JLINK_DEVICE = max32666 -# flash target using Jlik +# flash target using Jlink by default flash: flash-jlink # Optional flash option when running within an installed MSDK to use OpenOCD @@ -83,7 +80,6 @@ SRC_C += \ $(PERIPH_SRC)/UART/uart_me14.c \ $(PERIPH_SRC)/UART/uart_reva.c \ - INC += \ $(TOP)/$(BOARD_PATH) \ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \ diff --git a/hw/bsp/max32690/README.md b/hw/bsp/max32690/README.md new file mode 100644 index 000000000..081ae0ad4 --- /dev/null +++ b/hw/bsp/max32690/README.md @@ -0,0 +1,31 @@ +# Analog Devices MAX32690 + +This BSP is for working with the Analog Devices +[MAX32690](https://www.analog.com/en/products/max32690.html) microcontroller. +The following boards are supported: + * [MAX32690EVKIT](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max32690evkit.html) + * [AD-APARD32690-SL](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/ad-apard32690-sl.html) + + +This part family leverages the Maxim Microcontrollers SDK (MSDK) for the device +interfaces and hardware abstraction layers. This source code package is fetched +as part of the get-deps script. + +The microcontroller utilizes the standard GNU ARM toolchain. If this toolchain +is not already available on your build machine, it can be installed by using the +bundled MSDK installation. Details on downloading and installing can be found +in the [User's Guide](https://analogdevicesinc.github.io/msdk//USERGUIDE/). + +## Flashing + +The default flashing behavior in this BSP is to utilize JLink. This can be done +by running the `flash` or `flash-jlink` rule for Makefiles, or the +`-jlink` target for CMake. + +Both the Evaluation Kit and APARD boards are shipped with a CMSIS-DAP +compatible debug probe. However, at the time of writing, the necessary flashing +algorithms for OpenOCD have not yet been incorporated into the OpenOCD master +branch. To utilize the provided debug probes, please install the bundled MSDK +package which includes the appropriate OpenOCD modifications. To leverage this +OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake +target. diff --git a/hw/bsp/max32690/family.cmake b/hw/bsp/max32690/family.cmake index 8b117bae5..5c470f86b 100644 --- a/hw/bsp/max32690/family.cmake +++ b/hw/bsp/max32690/family.cmake @@ -46,7 +46,6 @@ function(add_board_target BOARD_TARGET) # Startup & Linker script set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32690/Source/GCC/startup_max32690.s) set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU}) - set(STARTUP_FILE_IAR ${MAX32_CMSIS}/Device/Maxim/MAX32690/Source/IAR/startup_max32690.s) set(PERIPH_SRC ${MAX32_PERIPH}/Source) add_library(${BOARD_TARGET} STATIC @@ -89,7 +88,7 @@ function(add_board_target BOARD_TARGET) ) target_compile_options(${BOARD_TARGET} PRIVATE - -Wno-error=strict-prototypes + -Wno-error=strict-prototypes ) update_board(${BOARD_TARGET}) @@ -103,10 +102,6 @@ function(add_board_target BOARD_TARGET) target_link_options(${BOARD_TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}" ) - elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") - target_link_options(${BOARD_TARGET} PUBLIC - "LINKER:--config=${LD_FILE_IAR}" - ) endif () endfunction() @@ -153,4 +148,18 @@ function(family_configure_example TARGET RTOS) # Flashing family_flash_jlink(${TARGET}) + family_flash_msdk(${TARGET}) +endfunction() + +# Add flash msdk target +function(family_flash_msdk TARGET) + set(MAXIM_PATH "$ENV{MAXIM_PATH}") + + add_custom_target(${TARGET}-msdk + DEPENDS ${TARGET} + COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts + -f interface/cmsis-dap.cfg -f target/max32690.cfg + -c "program $ verify; init; reset; exit" + VERBATIM + ) endfunction() diff --git a/hw/bsp/max32690/family.mk b/hw/bsp/max32690/family.mk index 0405a2914..8b9fbc175 100644 --- a/hw/bsp/max32690/family.mk +++ b/hw/bsp/max32690/family.mk @@ -14,9 +14,6 @@ PORT ?= 0 SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32690/Source/GCC/startup_max32690.s LD_FILE = $(FAMILY_PATH)/max32690.ld -# IAR -SRC_S_IAR += $(MAX32_CMSIS)/Device/Maxim/MAX32690/Source/IAR/startup_max32690.s - # -------------- # Compiler Flags # -------------- @@ -49,7 +46,7 @@ LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs # For flash-jlink target JLINK_DEVICE = max32690 -# flash target using Jlik +# flash target using Jlink by default flash: flash-jlink # Optional flash option when running within an installed MSDK to use OpenOCD @@ -91,7 +88,6 @@ SRC_C += \ $(PERIPH_SRC)/UART/uart_me18.c \ $(PERIPH_SRC)/UART/uart_revb.c \ - INC += \ $(TOP)/$(BOARD_PATH) \ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \ diff --git a/hw/bsp/max78002/README.md b/hw/bsp/max78002/README.md new file mode 100644 index 000000000..4fb1bede4 --- /dev/null +++ b/hw/bsp/max78002/README.md @@ -0,0 +1,28 @@ +# Analog Devices MAX78002 + +This BSP is for working with the Analog Devices +[MAX78002](https://www.analog.com/en/products/max78002.html) AI microcontroller. +The following boards are supported: + * [MAX78002EVKIT](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/max78002evkit.html) + +This part family leverages the Maxim Microcontrollers SDK (MSDK) for the device +interfaces and hardware abstraction layers. This source code package is fetched +as part of the get-deps script. + +The microcontroller utilizes the standard GNU ARM toolchain. If this toolchain +is not already available on your build machine, it can be installed by using the +bundled MSDK installation. Details on downloading and installing can be found +in the [User's Guide](https://analogdevicesinc.github.io/msdk//USERGUIDE/). + +## Flashing + +The default flashing behavior in this BSP is to utilize JLink. This can be done +by running the `flash` or `flash-jlink` rule for Makefiles, or the +`-jlink` target for CMake. + +The Evaluation Kit is shipped with a CMSIS-DAP compatible debug probe. However, +at the time of writing, the necessary flashing algorithms for OpenOCD have not +yet been incorporated into the OpenOCD master branch. To utilize the provided +debug probes, please install the bundled MSDK package which includes the +appropriate OpenOCD modifications. To leverage this OpenOCD instance, run the +`flash-msdk` Makefile rule, or `-msdk` CMake target. diff --git a/hw/bsp/max78002/family.cmake b/hw/bsp/max78002/family.cmake index 28eaaa7e9..83fd3007f 100644 --- a/hw/bsp/max78002/family.cmake +++ b/hw/bsp/max78002/family.cmake @@ -42,7 +42,6 @@ function(add_board_target BOARD_TARGET) # Startup & Linker script set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX78002/Source/GCC/startup_max78002.S) set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU}) - #set(STARTUP_FILE_IAR ?) set(PERIPH_SRC ${MAX32_PERIPH}/Source) add_library(${BOARD_TARGET} STATIC @@ -87,8 +86,8 @@ function(add_board_target BOARD_TARGET) ) target_compile_options(${BOARD_TARGET} PRIVATE - -Wno-error=strict-prototypes - -Wno-error=redundant-decls + -Wno-error=strict-prototypes + -Wno-error=redundant-decls ) update_board(${BOARD_TARGET}) @@ -102,10 +101,6 @@ function(add_board_target BOARD_TARGET) target_link_options(${BOARD_TARGET} PUBLIC "LINKER:--script=${LD_FILE_Clang}" ) - elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") - target_link_options(${BOARD_TARGET} PUBLIC - "LINKER:--config=${LD_FILE_IAR}" - ) endif () endfunction() @@ -146,8 +141,8 @@ function(family_configure_example TARGET RTOS) ) target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD}) target_compile_options(${TARGET}-tinyusb PRIVATE - -Wno-error=strict-prototypes - -Wno-error=redundant-decls + -Wno-error=strict-prototypes + -Wno-error=redundant-decls ) # Link dependencies @@ -155,4 +150,18 @@ function(family_configure_example TARGET RTOS) # Flashing family_flash_jlink(${TARGET}) + family_flash_msdk(${TARGET}) +endfunction() + +# Add flash msdk target +function(family_flash_msdk TARGET) + set(MAXIM_PATH "$ENV{MAXIM_PATH}") + + add_custom_target(${TARGET}-msdk + DEPENDS ${TARGET} + COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts + -f interface/cmsis-dap.cfg -f target/max78002.cfg + -c "program $ verify; init; reset; exit" + VERBATIM + ) endfunction() diff --git a/hw/bsp/max78002/family.mk b/hw/bsp/max78002/family.mk index 04163417c..8df8517da 100644 --- a/hw/bsp/max78002/family.mk +++ b/hw/bsp/max78002/family.mk @@ -14,9 +14,6 @@ PORT ?= 0 SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX78002/Source/GCC/startup_max78002.S LD_FILE = $(FAMILY_PATH)/max78002.ld -# IAR -#SRC_S_IAR += - # -------------- # Compiler Flags # -------------- @@ -45,7 +42,7 @@ LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs # For flash-jlink target JLINK_DEVICE = max78000 -# flash target using Jlik +# flash target using Jlink by default flash: flash-jlink # Optional flash option when running within an installed MSDK to use OpenOCD @@ -88,7 +85,6 @@ SRC_C += \ $(PERIPH_SRC)/UART/uart_ai87.c \ $(PERIPH_SRC)/UART/uart_revb.c \ - INC += \ $(TOP)/$(BOARD_PATH) \ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \