merge kinetis into its own family in bsp

This commit is contained in:
hathach 2023-03-18 18:30:51 +07:00
parent b13b95a670
commit 2d187777c0
No known key found for this signature in database
GPG Key ID: F5D50C6D51D17CBA
15 changed files with 114 additions and 218 deletions

View File

@ -1,51 +0,0 @@
Jan/13/2023 13:04
The FRDM-K32L2B3 Freedom development board provides a platform for
evaluation and development of the K32 L2B MCU Family. -
https://www.nxp.com/part/FRDM-K32L2B3#/
TinyUSB does not include the board specific drivers. Those drivers
need to be extracted from the MCUXpresso IDE and SDK.
Install MCUXPresso version 11.6 or later and SDK 2.12 or later. Then
build the example project "frdmk32l2b_hellow_worldvirual_com".
From the frdmk32l2b_hellow_worldvirual_com project copy these files to
this directory structure, in this directory:
hw/mcu/nxp/mcux-sdk/devices/K32L2B31A
CMSIS/
config/
drivers/
gcc/
fsl_device_registers.h
K32L2B31A_features.h
K32L2B31A.h
./CMSIS:
cmsis_armcc.h cmsis_armclang_ltm.h cmsis_gcc.h cmsis_version.h mpu_armv7.h
cmsis_armclang.h cmsis_compiler.h cmsis_iccarm.h core_cm0plus.h
./config:
clock_config.c clock_config.h system_K32L2B31A.c system_K32L2B31A.h
./drivers:
fsl_clock.c fsl_common_arm.h fsl_gpio.c fsl_lpuart.h fsl_smc.h
fsl_clock.h fsl_common.c fsl_gpio.h fsl_port.h fsl_uart.c
fsl_common_arm.c fsl_common.h fsl_lpuart.c fsl_smc.c fsl_uart.h
./gcc:
frdmk32l2b.ld startup_k32l2b31a.c
frdmk32l2b_library.ld frdmk32l2b_memory.ld
The linker files have been renamed and the #include directive edited
to match.
Then to build a test project change to the directory
examples/devices/cdc_msc and do:
make BOARD=frdm_k32l2b
The resulting .hex file will be found in the _build directory, copy
that will to the FRDM board to run the demo.

View File

@ -1,80 +0,0 @@
# Default to a less-verbose build. If you want all the gory compiler output,
# "VERBOSE=1" to the make command line.
ifndef VERBOSE
.SILENT:
$(info Non-Verbose Output)
else
$(info Verbose Output)
endif
SDK_DIR = hw/mcu/nxp/mcux-sdk
MCU_DIR = $(SDK_DIR)/devices/K32L2A4S
ifdef VERBOSE
$(info TOP='$(TOP)')
$(info )
$(info BSP='$(TOP)/hw/bsp/$(BOARD)')
$(info )
$(info TOP/SDK_DIR='$(TOP)/$(SDK_DIR)')
$(info )
$(info MCU_DIR='$(MCU_DIR)')
$(info )
endif
DEPS_SUBMODULES += $(SDK_DIR)
CFLAGS += \
-mthumb \
-mabi=aapcs \
-mcpu=cortex-m0plus \
-DCPU_K32L2A41VLH1A \
-DCFG_TUSB_MCU=OPT_MCU_K32L2AXX
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast-qual
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/frdmk32l2a4s.ld
LDFLAGS += -L$(TOP)/$(MCU_DIR)/gcc
# Define Recursive Depth wildcard:
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
SRC_C += \
src/portable/nxp/khci/dcd_khci.c \
$(MCU_DIR)/gcc/startup_k32l2a41a.c
SRC_C += $(call rwildcard,$(TOP)/$(MCU_DIR)/config,*.c)
SRC_C += $(call rwildcard,$(TOP)/$(MCU_DIR)/drivers,*.c)
INC += \
$(TOP)/hw/bsp/$(BOARD) \
$(TOP)/$(MCU_DIR)/CMSIS/ \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/config \
$(TOP)/$(MCU_DIR)/drivers
ifdef VERBOSE
$(info INC = '$(strip $(INC))')
$(info )
$(info SRC_C = '$(sort $(strip $(SRC_C)))')
$(info )
endif
# For freeRTOS port source
FREERTOS_PORT = ARM_CM0
# For flash-jlink target
#JLINK_DEVICE = ?
# For flash-pyocd target
PYOCD_TARGET = K32L2A
# flash using pyocd
flash: flash-pyocd

View File

@ -1,51 +0,0 @@
SDK_DIR = hw/mcu/nxp/mcux-sdk
DEPS_SUBMODULES += $(SDK_DIR)
CFLAGS += \
-mthumb \
-mabi=aapcs \
-mcpu=cortex-m0plus \
-DCPU_K32L2B31VLH0A \
-DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls
MCU_DIR = $(SDK_DIR)/devices/K32L2B31A
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
SRC_C += \
src/portable/nxp/khci/dcd_khci.c \
$(MCU_DIR)/system_K32L2B31A.c \
$(MCU_DIR)/project_template/clock_config.c \
$(MCU_DIR)/drivers/fsl_clock.c \
$(SDK_DIR)/drivers/gpio/fsl_gpio.c \
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
INC += \
$(TOP)/hw/bsp/$(BOARD) \
$(TOP)/$(SDK_DIR)/CMSIS/Include \
$(TOP)/$(SDK_DIR)/drivers/smc \
$(TOP)/$(SDK_DIR)/drivers/common \
$(TOP)/$(SDK_DIR)/drivers/gpio \
$(TOP)/$(SDK_DIR)/drivers/port \
$(TOP)/$(SDK_DIR)/drivers/lpuart \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers \
$(TOP)/$(MCU_DIR)/project_template \
SRC_S += $(MCU_DIR)/gcc/startup_K32L2B31A.S
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
# For flash-jlink target
JLINK_DEVICE = MKL25Z128xxx4
# For flash-pyocd target
PYOCD_TARGET = K32L2B
# flash using pyocd
flash: flash-pyocd

View File

@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2019, Ha Thach (tinyusb.org)

View File

@ -0,0 +1,26 @@
SDK_DIR = hw/mcu/nxp/mcux-sdk
MCU = K32L2A41A
MCU_DIR = $(SDK_DIR)/devices/$(MCU)
CFLAGS += \
-mcpu=cortex-m0plus \
-DCPU_K32L2A41VLH1A \
-DCFG_TUSB_MCU=OPT_MCU_K32L2AXX
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls -Wno-error=cast-qual
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2A41xxxxA_flash.ld
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
# For flash-jlink target
JLINK_DEVICE = K32L2A41xxxxA
# For flash-pyocd target
PYOCD_TARGET = K32L2A
# flash using pyocd
flash: flash-pyocd

View File

@ -25,7 +25,7 @@
* This file is part of the TinyUSB stack.
*/
#include "../board.h"
#include "bsp/board.h"
#include "board.h"
#include "fsl_gpio.h"
#include "fsl_port.h"

View File

@ -0,0 +1,26 @@
SDK_DIR = hw/mcu/nxp/mcux-sdk
MCU = K32L2B31A
MCU_DIR = $(SDK_DIR)/devices/$(MCU)
CFLAGS += \
-mcpu=cortex-m0plus \
-DCPU_K32L2B31VLH0A \
-DCFG_TUSB_MCU=OPT_MCU_K32L2BXX
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=redundant-decls
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/K32L2B31xxxxA_flash.ld
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
# For flash-jlink target
JLINK_DEVICE = K32L2B31xxxxA
# For flash-pyocd target
PYOCD_TARGET = K32L2B
# flash using pyocd
flash: flash-pyocd

View File

@ -25,7 +25,7 @@
* This file is part of the TinyUSB stack.
*/
#include "../board.h"
#include "bsp/board.h"
#include "board.h"
#include "fsl_gpio.h"
#include "fsl_port.h"

View File

@ -1,9 +1,8 @@
SDK_DIR = hw/mcu/nxp/nxp_sdk
DEPS_SUBMODULES += $(SDK_DIR)
MCU = MKL25Z4
MCU_DIR = $(SDK_DIR)/devices/$(MCU)
CFLAGS += \
-mthumb \
-mabi=aapcs \
-mcpu=cortex-m0plus \
-DCPU_MKL25Z128VLK4 \
-DCFG_TUSB_MCU=OPT_MCU_MKL25ZXX \
@ -16,29 +15,9 @@ LDFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=format -Wno-error=redundant-decls
MCU_DIR = $(SDK_DIR)/devices/MKL25Z4
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/MKL25Z128xxx4_flash.ld
SRC_C += \
src/portable/nxp/khci/dcd_khci.c \
src/portable/nxp/khci/hcd_khci.c \
$(MCU_DIR)/system_MKL25Z4.c \
$(MCU_DIR)/project_template/clock_config.c \
$(MCU_DIR)/drivers/fsl_clock.c \
$(MCU_DIR)/drivers/fsl_gpio.c \
$(MCU_DIR)/drivers/fsl_lpsci.c
INC += \
$(TOP)/hw/bsp/$(BOARD) \
$(TOP)/$(SDK_DIR)/CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/drivers \
$(TOP)/$(MCU_DIR)/project_template \
SRC_S += $(MCU_DIR)/gcc/startup_MKL25Z4.S
# For freeRTOS port source
FREERTOS_PORTABLE_SRC = $(FREERTOS_PORTABLE_PATH)/ARM_CM0
@ -49,4 +28,4 @@ JLINK_DEVICE = MKL25Z128xxx4
PYOCD_TARGET = mkl25zl128
# flash using pyocd
flash: flash-pyocd
flash: flash-jlink

46
hw/bsp/kinetis/family.mk Normal file
View File

@ -0,0 +1,46 @@
DEPS_SUBMODULES += hw/mcu/nxp/nxp_sdk hw/mcu/nxp/mcux-sdk
include $(TOP)/$(BOARD_PATH)/board.mk
CFLAGS += \
-mthumb \
-mabi=aapcs \
SRC_C += \
src/portable/nxp/khci/dcd_khci.c \
src/portable/nxp/khci/hcd_khci.c \
$(MCU_DIR)/system_$(MCU).c \
$(MCU_DIR)/project_template/clock_config.c \
$(MCU_DIR)/drivers/fsl_clock.c \
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(SDK_DIR)/CMSIS/Include \
$(TOP)/$(MCU_DIR) \
$(TOP)/$(MCU_DIR)/project_template \
$(TOP)/$(MCU_DIR)/drivers
# mcu-sdk has different driver layout than previous old sdk
ifeq ($(SDK_DIR),hw/mcu/nxp/mcux-sdk)
SRC_C += \
$(SDK_DIR)/drivers/gpio/fsl_gpio.c \
$(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
INC += \
$(TOP)/$(SDK_DIR)/drivers/smc \
$(TOP)/$(SDK_DIR)/drivers/common \
$(TOP)/$(SDK_DIR)/drivers/gpio \
$(TOP)/$(SDK_DIR)/drivers/port \
$(TOP)/$(SDK_DIR)/drivers/lpuart \
else
SRC_C += \
$(MCU_DIR)/drivers/fsl_gpio.c \
$(MCU_DIR)/drivers/fsl_lpsci.c \
$(MCU_DIR)/drivers/fsl_uart.c
endif
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU).S

View File

@ -86,6 +86,8 @@
#define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 HS
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2AXX, OPT_MCU_K32L2BXX)
#define TUP_USBIP_CHIPIDEA_FS
#define TUP_USBIP_CHIPIDEA_FS_KINETIS
#define TUP_DCD_ENDPOINT_MAX 16
#elif TU_CHECK_MCU(OPT_MCU_MM32F327X)

View File

@ -26,15 +26,14 @@
#include "tusb_option.h"
#if CFG_TUD_ENABLED && \
( \
( CFG_TUSB_MCU == OPT_MCU_MKL25ZXX ) || \
( CFG_TUSB_MCU == OPT_MCU_K32L2AXX ) || \
( CFG_TUSB_MCU == OPT_MCU_K32L2BXX ) \
)
#if CFG_TUD_ENABLED && defined(TUP_USBIP_CHIPIDEA_FS)
#include "fsl_device_registers.h"
#define KHCI USB0
#ifdef TUP_USBIP_CHIPIDEA_FS_KINETIS
#include "fsl_device_registers.h"
#define KHCI USB0
#else
#error "MCU is not supported"
#endif
#include "device/dcd.h"

View File

@ -26,7 +26,7 @@
#include "tusb_option.h"
#if CFG_TUD_ENABLED && \
#if CFG_TUH_ENABLED && \
( \
( CFG_TUSB_MCU == OPT_MCU_MKL25ZXX ) || \
( CFG_TUSB_MCU == OPT_MCU_K32L2AXX ) || \