From 63a6fd36890f01ba8e1ed559c53ce2bdd2042475 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 30 Jan 2023 17:07:06 +0700 Subject: [PATCH] iar g4 --- .github/workflows/build_iar.yml | 1 + hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk | 8 ++++++-- hw/bsp/stm32g4/family.c | 5 +++-- hw/bsp/stm32g4/family.mk | 18 ++++++++++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_iar.yml b/.github/workflows/build_iar.yml index e4b449528..c948b5d8d 100644 --- a/.github/workflows/build_iar.yml +++ b/.github/workflows/build_iar.yml @@ -31,6 +31,7 @@ jobs: - 'stm32f1' - 'stm32f4' - 'stm32f7' + - 'stm32g4' - 'stm32h7' steps: - name: Clean workspace diff --git a/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk b/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk index e41edd3b7..2f6ec0ed6 100644 --- a/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk +++ b/hw/bsp/stm32g4/boards/stm32g474nucleo/board.mk @@ -2,9 +2,13 @@ CFLAGS += \ -DSTM32G474xx \ -DHSE_VALUE=24000000 -LD_FILE = $(BOARD_PATH)/STM32G474RETx_FLASH.ld +# GCC +GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32g474xx.s +GCC_LD_FILE = $(BOARD_PATH)/STM32G474RETx_FLASH.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32g474xx.s +# IAR +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32g474xx.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32g474xx_flash.icf # For flash-jlink target JLINK_DEVICE = stm32g474re diff --git a/hw/bsp/stm32g4/family.c b/hw/bsp/stm32g4/family.c index a2312b0d8..32c46b7d8 100644 --- a/hw/bsp/stm32g4/family.c +++ b/hw/bsp/stm32g4/family.c @@ -137,7 +137,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) @@ -177,7 +178,7 @@ uint32_t board_millis(void) void HardFault_Handler (void) { - asm("bkpt"); + __asm("BKPT #0\n"); } // Required by __libc_init_array in startup code if we are compiling using diff --git a/hw/bsp/stm32g4/family.mk b/hw/bsp/stm32g4/family.mk index 04222f3bb..79defac56 100644 --- a/hw/bsp/stm32g4/family.mk +++ b/hw/bsp/stm32g4/family.mk @@ -7,7 +7,14 @@ 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_STM32G4 + +# GCC Flags +GCC_CFLAGS += \ -flto \ -mthumb \ -mabi=aapcs \ @@ -15,10 +22,17 @@ CFLAGS += \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ -nostdlib -nostartfiles \ - -DCFG_TUSB_MCU=OPT_MCU_STM32G4 # suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=cast-align +GCC_CFLAGS += -Wno-error=cast-align + +# IAR Flags +IAR_CFLAGS += --cpu cortex-m4 --fpu VFPv4 +IAR_ASFLAGS += --cpu cortex-m4 --fpu VFPv4 + +# ----------------- +# Sources & Include +# ----------------- SRC_C += \ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \