add make build for maxim
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
# Common make definition for all examples
|
||||
# ---------------------------------------
|
||||
|
||||
# upper helper function
|
||||
to_upper = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$(subst -,_,$(1))))))))))))))))))))))))))))
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Toolchain
|
||||
# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
|
||||
@@ -109,7 +112,7 @@ INC += \
|
||||
$(TOP)/$(FAMILY_PATH) \
|
||||
$(TOP)/src \
|
||||
|
||||
BOARD_UPPER = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$(subst -,_,$(BOARD))))))))))))))))))))))))))))
|
||||
BOARD_UPPER = $(call to_upper,$(BOARD))
|
||||
CFLAGS += -DBOARD_$(BOARD_UPPER)
|
||||
|
||||
ifdef CFLAGS_CLI
|
||||
|
@@ -38,6 +38,11 @@ if (NOT DEFINED TOOLCHAIN)
|
||||
set(TOOLCHAIN gcc)
|
||||
endif ()
|
||||
|
||||
# Optimization
|
||||
if (NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
|
||||
endif ()
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# FAMILY and BOARD
|
||||
#-------------------------------------------------------------
|
||||
|
@@ -39,5 +39,5 @@ 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 `<target>-openocd` CMake
|
||||
OpenOCD instance, run the `flash-msdk` Makefile rule, or `<target>-openocd` CMake
|
||||
target.
|
||||
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32690.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/apard32690/board.mk
Normal file
1
hw/bsp/maxim/boards/apard32690/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32690
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32650.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/max32650evkit/board.mk
Normal file
1
hw/bsp/maxim/boards/max32650evkit/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32650
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32650.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/max32650fthr/board.mk
Normal file
1
hw/bsp/maxim/boards/max32650fthr/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32650
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32650.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
7
hw/bsp/maxim/boards/max32651evkit/board.mk
Normal file
7
hw/bsp/maxim/boards/max32651evkit/board.mk
Normal file
@@ -0,0 +1,7 @@
|
||||
MAX_DEVICE = max32650
|
||||
|
||||
# Use the secure linker file
|
||||
LD_FILE = $(FAMILY_PATH)/linker/max32651.ld
|
||||
|
||||
# Let the family script know the build needs to be signed
|
||||
SIGNED_BUILD := 1
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32665.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/max32666evkit/board.mk
Normal file
1
hw/bsp/maxim/boards/max32666evkit/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32665
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max32665.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/max32666fthr/board.mk
Normal file
1
hw/bsp/maxim/boards/max32666fthr/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32665
|
@@ -32,13 +32,12 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "max32690.h"
|
||||
|
||||
// LED
|
||||
#define LED_PORT MXC_GPIO0
|
||||
#define LED_PIN MXC_GPIO_PIN_14
|
||||
|
1
hw/bsp/maxim/boards/max32690evkit/board.mk
Normal file
1
hw/bsp/maxim/boards/max32690evkit/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max32690
|
@@ -32,8 +32,7 @@
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#include "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
#include "max78002.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
1
hw/bsp/maxim/boards/max78002evkit/board.mk
Normal file
1
hw/bsp/maxim/boards/max78002evkit/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
MAX_DEVICE = max78002
|
@@ -13,8 +13,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
set(CMAKE_SYSTEM_CPU cortex-m4 CACHE INTERNAL "System Processor")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
|
||||
cmake_print_variables(MAX_DEVICE)
|
||||
string(TOUPPER ${MAX_DEVICE} MAX_DEVICE_UPPER)
|
||||
cmake_print_variables(MAX_DEVICE MAX_DEVICE_UPPER)
|
||||
|
||||
set(JLINK_DEVICE ${MAX_DEVICE})
|
||||
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/${MAX_DEVICE}.cfg")
|
||||
@@ -132,18 +132,9 @@ function(add_board_target BOARD_TARGET)
|
||||
MXC_ASSERT_ENABLE
|
||||
${MAX_DEVICE_UPPER}
|
||||
IAR_PRAGMAS=0
|
||||
FLASH_BOOT_SIZE=${FLASH_BOOT_SIZE}
|
||||
MAX_PERIPH_ID=${PERIPH_ID}
|
||||
)
|
||||
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
TARGET=MAX32690
|
||||
TARGET_REV=0x4131
|
||||
MXC_ASSERT_ENABLE
|
||||
MAX32690
|
||||
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
|
||||
)
|
||||
|
||||
target_compile_options(${BOARD_TARGET} PRIVATE
|
||||
-Wno-error=strict-prototypes
|
||||
)
|
||||
|
190
hw/bsp/maxim/family.mk
Normal file
190
hw/bsp/maxim/family.mk
Normal file
@@ -0,0 +1,190 @@
|
||||
MSDK_LIB = hw/mcu/analog/msdk/Libraries
|
||||
|
||||
# Add any board specific make rules
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
CPU_CORE ?= cortex-m4
|
||||
PORT ?= 0
|
||||
JLINK_DEVICE = ${MAX_DEVICE}
|
||||
MAX_DEVICE_UPPER = $(call to_upper,${MAX_DEVICE})
|
||||
|
||||
ifeq ($(MAX_DEVICE),max32650)
|
||||
PERIPH_ID = 10
|
||||
PERIPH_SUFFIX = me
|
||||
endif
|
||||
|
||||
ifneq ($(filter $(MAX_DEVICE),max32665 max32666),)
|
||||
PERIPH_ID = 14
|
||||
PERIPH_SUFFIX = me
|
||||
endif
|
||||
|
||||
ifeq ($(MAX_DEVICE),max32690)
|
||||
PERIPH_ID = 18
|
||||
PERIPH_SUFFIX = me
|
||||
endif
|
||||
|
||||
ifeq ($(MAX_DEVICE),max78002)
|
||||
PERIPH_ID = 87
|
||||
PERIPH_SUFFIX = ai
|
||||
endif
|
||||
|
||||
ifndef PERIPH_ID
|
||||
$(error Unsupported MAX device: ${MAX_DEVICE})
|
||||
endif
|
||||
|
||||
# Configure the flash rule. By default, use JLink.
|
||||
SIGNED_BUILD ?= 0
|
||||
DEFAULT_FLASH = flash-jlink
|
||||
|
||||
# --------------
|
||||
# Compiler Flags
|
||||
# --------------
|
||||
CFLAGS += \
|
||||
-DTARGET=${MAX_DEVICE_UPPER}\
|
||||
-DTARGET_REV=0x4131 \
|
||||
-DMXC_ASSERT_ENABLE \
|
||||
-D${MAX_DEVICE_UPPER} \
|
||||
-DIAR_PRAGMAS=0 \
|
||||
-DMAX_PERIPH_ID=${PERIPH_ID} \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_${MAX_DEVICE_UPPER} \
|
||||
-DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
|
||||
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += \
|
||||
-Wno-error=old-style-declaration \
|
||||
-Wno-error=redundant-decls \
|
||||
-Wno-error=strict-prototypes \
|
||||
-Wno-error=unused-parameter \
|
||||
-Wno-error=cast-align \
|
||||
-Wno-error=cast-qual \
|
||||
-Wno-error=sign-compare \
|
||||
-Wno-error=enum-conversion \
|
||||
|
||||
LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
|
||||
LD_FILE_GCC ?= $(FAMILY_PATH)/linker/${MAX_DEVICE}.ld
|
||||
|
||||
# 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
|
||||
|
||||
# -----------------
|
||||
# Sources & Include
|
||||
# -----------------
|
||||
|
||||
# common
|
||||
SRC_C += \
|
||||
src/portable/mentor/musb/dcd_musb.c \
|
||||
${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/heap.c \
|
||||
${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/system_${MAX_DEVICE}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/mxc_assert.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/mxc_delay.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/mxc_lock.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/nvic_table.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/pins_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/SYS/sys_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/FLC/flc_common.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/FLC/flc_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/FLC/flc_reva.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/GPIO/gpio_common.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/GPIO/gpio_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/GPIO/gpio_reva.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/ICC/icc_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/ICC/icc_reva.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/UART/uart_common.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/UART/uart_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
|
||||
SRC_S_GCC += ${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Source/GCC/startup_${MAX_DEVICE}.S
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/${MSDK_LIB}/CMSIS/5.9.0/Core/Include \
|
||||
$(TOP)/${MSDK_LIB}/CMSIS/Device/Maxim/${MAX_DEVICE_UPPER}/Include \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Include/${MAX_DEVICE_UPPER} \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Source/SYS \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Source/GPIO \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Source/ICC \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Source/FLC \
|
||||
$(TOP)/${MSDK_LIB}/PeriphDrivers/Source/UART \
|
||||
|
||||
# device specific
|
||||
ifneq ($(filter $(MAX_DEVICE),max32650 max32665 max32666),)
|
||||
SRC_C += \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/ICC/icc_common.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/TPU/tpu_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/TPU/tpu_reva.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/UART/uart_reva.c \
|
||||
|
||||
INC += $(TOP)/${MSDK_LIB}/PeriphDrivers/Source/TPU
|
||||
endif
|
||||
|
||||
ifeq (${MAX_DEVICE},max32690)
|
||||
SRC_C += \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/CTB/ctb_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/CTB/ctb_reva.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/CTB/ctb_common.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/UART/uart_revb.c \
|
||||
|
||||
INC += ${TOP}/${MSDK_LIB}/PeriphDrivers/Source/CTB
|
||||
endif
|
||||
|
||||
ifeq (${MAX_DEVICE},max78002)
|
||||
SRC_C += \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/AES/aes_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/AES/aes_revb.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/TRNG/trng_${PERIPH_SUFFIX}${PERIPH_ID}.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/TRNG/trng_revb.c \
|
||||
${MSDK_LIB}/PeriphDrivers/Source/UART/uart_revb.c \
|
||||
|
||||
INC += \
|
||||
${TOP}/${MSDK_LIB}/PeriphDrivers/Source/AES \
|
||||
${TOP}/${MSDK_LIB}/PeriphDrivers/Source/TRNG
|
||||
endif
|
||||
|
||||
|
||||
# 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/msdk/
|
||||
# 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 modify 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"
|
||||
|
||||
# Configure the flash rule
|
||||
flash: $(DEFAULT_FLASH)
|
Reference in New Issue
Block a user