summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-01-22 11:56:50 +0700
committerhathach <[email protected]>2023-01-22 11:56:50 +0700
commitdb36075721b266d40703e4f57683858acb4112fc (patch)
tree73fae2f6fab535d441f85071338f27fd00654d73
parentf4c3f0800d44e19ede428c4d5995910573cf6341 (diff)
update f4 to build with iar
-rw-r--r--hw/bsp/stm32f4/boards/feather_stm32f405/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/pyboardv11/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f407disco/board.mk9
-rw-r--r--hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f411disco/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f412disco/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk8
-rw-r--r--hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk8
-rw-r--r--hw/bsp/stm32f4/family.c5
-rw-r--r--hw/bsp/stm32f4/family.mk16
11 files changed, 71 insertions, 23 deletions
diff --git a/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk b/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk
index 1de56fe5a..1962dd9d8 100644
--- a/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk
+++ b/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F405xx
-LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f405xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f405xx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f405rg
diff --git a/hw/bsp/stm32f4/boards/pyboardv11/board.mk b/hw/bsp/stm32f4/boards/pyboardv11/board.mk
index 02dcd1219..0a9100e1e 100644
--- a/hw/bsp/stm32f4/boards/pyboardv11/board.mk
+++ b/hw/bsp/stm32f4/boards/pyboardv11/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F405xx
-LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F405RGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f405xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f405xx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f405rg
diff --git a/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk b/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk
index de0f3d4c7..11f9b81aa 100644
--- a/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F401xC
-LD_FILE = $(BOARD_PATH)/STM32F401VCTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f401xc.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F401VCTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f401xc.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f401xc.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f401xc_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f401cc
diff --git a/hw/bsp/stm32f4/boards/stm32f407disco/board.mk b/hw/bsp/stm32f4/boards/stm32f407disco/board.mk
index 212b924b4..a184804d3 100644
--- a/hw/bsp/stm32f4/boards/stm32f407disco/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f407disco/board.mk
@@ -1,8 +1,13 @@
CFLAGS += -DSTM32F407xx
-LD_FILE = $(BOARD_PATH)/STM32F407VGTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f407xx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F407VGTx_FLASH.ld
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f407xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f407xx_flash.icf
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f407xx.s
# For flash-jlink target
JLINK_DEVICE = stm32f407vg
diff --git a/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk b/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk
index 78be4348a..ac15eaa5d 100644
--- a/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F411xE
-LD_FILE = $(BOARD_PATH)/STM32F411CEUx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F411CEUx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f411xe.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f411xe_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f411ce
diff --git a/hw/bsp/stm32f4/boards/stm32f411disco/board.mk b/hw/bsp/stm32f4/boards/stm32f411disco/board.mk
index 48272acff..c5736050c 100644
--- a/hw/bsp/stm32f4/boards/stm32f411disco/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f411disco/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F411xE
-LD_FILE = $(BOARD_PATH)/STM32F411VETx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F411VETx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f411xe.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f411xe_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f411ve
diff --git a/hw/bsp/stm32f4/boards/stm32f412disco/board.mk b/hw/bsp/stm32f4/boards/stm32f412disco/board.mk
index 50973f737..7dc3699e0 100644
--- a/hw/bsp/stm32f4/boards/stm32f412disco/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f412disco/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F412Zx
-LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f412zx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f412zx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f412zg
diff --git a/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk b/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk
index 50973f737..7dc3699e0 100644
--- a/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f412nucleo/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F412Zx
-LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F412ZGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f412zx.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f412zx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f412zx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f412zg
diff --git a/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk b/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk
index b7b36a8a6..e1f337a7e 100644
--- a/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk
+++ b/hw/bsp/stm32f4/boards/stm32f439nucleo/board.mk
@@ -1,8 +1,12 @@
CFLAGS += -DSTM32F439xx
-LD_FILE = $(BOARD_PATH)/STM32F439ZITX_FLASH.ld
+# GCC
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f439xx.s
+GCC_LD_FILE = $(BOARD_PATH)/STM32F439ZITX_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f439xx.s
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f439xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f439xx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f439zi
diff --git a/hw/bsp/stm32f4/family.c b/hw/bsp/stm32f4/family.c
index 82d4957e7..674058f50 100644
--- a/hw/bsp/stm32f4/family.c
+++ b/hw/bsp/stm32f4/family.c
@@ -150,7 +150,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)
@@ -190,7 +191,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/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk
index 9811d3371..333857499 100644
--- a/hw/bsp/stm32f4/family.mk
+++ b/hw/bsp/stm32f4/family.mk
@@ -7,18 +7,28 @@ 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_STM32F4
+
+# 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_STM32F4
+ -nostdlib -nostartfiles
# 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
+IAR_ASFLAGS += --cpu cortex-m4
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \