diff --git a/.github/workflows/build_iar.yml b/.github/workflows/build_iar.yml index c948b5d8d..9c1bfa18a 100644 --- a/.github/workflows/build_iar.yml +++ b/.github/workflows/build_iar.yml @@ -33,6 +33,7 @@ jobs: - 'stm32f7' - 'stm32g4' - 'stm32h7' + - 'stm32l4' steps: - name: Clean workspace run: | diff --git a/hw/bsp/stm32l4/boards/stm32l412nucleo/board.mk b/hw/bsp/stm32l4/boards/stm32l412nucleo/board.mk index 841ee4948..854397fc8 100644 --- a/hw/bsp/stm32l4/boards/stm32l412nucleo/board.mk +++ b/hw/bsp/stm32l4/boards/stm32l412nucleo/board.mk @@ -1,10 +1,13 @@ CFLAGS += \ -DSTM32L412xx \ -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/STM32L412KBUx_FLASH.ld +# GCC +GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l412xx.s +GCC_LD_FILE = $(BOARD_PATH)/STM32L412KBUx_FLASH.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l412xx.s +# IAR +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32l412xx.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32l412xx_flash.icf # For flash-jlink target JLINK_DEVICE = stm32l412kb diff --git a/hw/bsp/stm32l4/boards/stm32l476disco/board.mk b/hw/bsp/stm32l4/boards/stm32l476disco/board.mk index e7b8557a5..125f1f106 100644 --- a/hw/bsp/stm32l4/boards/stm32l476disco/board.mk +++ b/hw/bsp/stm32l4/boards/stm32l476disco/board.mk @@ -1,10 +1,13 @@ CFLAGS += \ -DSTM32L476xx \ -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/STM32L476VGTx_FLASH.ld +# GCC +GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l476xx.s +GCC_LD_FILE = $(BOARD_PATH)/STM32L476VGTx_FLASH.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l476xx.s +# IAR +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32l476xx.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32l476xx_flash.icf # For flash-jlink target JLINK_DEVICE = stm32l476vg diff --git a/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk b/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk index 8252dd838..11edcd9a8 100644 --- a/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk +++ b/hw/bsp/stm32l4/boards/stm32l4p5nucleo/board.mk @@ -1,10 +1,13 @@ CFLAGS += \ -DSTM32L4P5xx \ -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/STM32L4P5ZGTX_FLASH.ld +# GCC +GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4p5xx.s +GCC_LD_FILE = $(BOARD_PATH)/STM32L4P5ZGTX_FLASH.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4p5xx.s +# IAR +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32l4p5xx.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32l4p5xx_flash.icf # For flash-jlink target JLINK_DEVICE = stm32l4p5zg diff --git a/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk b/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk index 3d7fa227b..6dca88a8b 100644 --- a/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk +++ b/hw/bsp/stm32l4/boards/stm32l4r5nucleo/board.mk @@ -2,10 +2,13 @@ CFLAGS += \ -DHSE_VALUE=8000000 \ -DSTM32L4R5xx \ -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/STM32L4RXxI_FLASH.ld +# GCC +GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4r5xx.s +GCC_LD_FILE = $(BOARD_PATH)/STM32L4RXxI_FLASH.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l4r5xx.s +# IAR +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32l4r5xx.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32l4r5xx_flash.icf # For flash-jlink target JLINK_DEVICE = stm32l4r5zi diff --git a/hw/bsp/stm32l4/family.c b/hw/bsp/stm32l4/family.c index 0b1443aa0..19b84c086 100644 --- a/hw/bsp/stm32l4/family.c +++ b/hw/bsp/stm32l4/family.c @@ -179,7 +179,8 @@ void board_init(void) void board_led_write(bool state) { - HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); + GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1-LED_STATE_ON)); + HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state); } uint32_t board_button_read(void) @@ -214,7 +215,7 @@ uint32_t board_millis(void) void HardFault_Handler (void) { - asm("bkpt 0x10"); + __asm("BKPT #0\n"); } // Required by __libc_init_array in startup code if we are compiling using diff --git a/hw/bsp/stm32l4/family.mk b/hw/bsp/stm32l4/family.mk index 1361e184c..4fab7dc0d 100644 --- a/hw/bsp/stm32l4/family.mk +++ b/hw/bsp/stm32l4/family.mk @@ -6,23 +6,36 @@ ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver include $(TOP)/$(BOARD_PATH)/board.mk +# -------------- +# Compiler Flags +# -------------- CFLAGS += \ + -DCFG_TUSB_MCU=OPT_MCU_STM32L4 + +# GCC Flags +GCC_CFLAGS += \ -flto \ -mthumb \ -mabi=aapcs \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ - -nostdlib -nostartfiles \ - -DCFG_TUSB_MCU=OPT_MCU_STM32L4 + -nostdlib -nostartfiles # suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align +GCC_CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align + +# IAR Flags +IAR_CFLAGS += --cpu cortex-m4 --fpu VFPv4 +IAR_ASFLAGS += --cpu cortex-m4 --fpu VFPv4 + +# ----------------- +# Sources & Include +# ----------------- -#src/portable/st/synopsys/dcd_synopsys.c SRC_C += \ src/portable/synopsys/dwc2/dcd_dwc2.c \ - src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \ + src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \