summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-01-22 12:10:27 +0700
committerhathach <[email protected]>2023-01-22 12:11:01 +0700
commit0a4e611e3738189f00ec17ebd831436ed51e15ec (patch)
treee16340bf908365e860ad5acbafa712605e2e5463
parentdb36075721b266d40703e4f57683858acb4112fc (diff)
update stm32f7 to build with iar
-rw-r--r--.github/workflows/build_iar.yml2
-rw-r--r--hw/bsp/stm32f4/family.mk4
-rw-r--r--hw/bsp/stm32f7/boards/stlinkv3mini/board.mk10
-rw-r--r--hw/bsp/stm32f7/boards/stm32f723disco/board.mk9
-rw-r--r--hw/bsp/stm32f7/boards/stm32f746disco/board.mk9
-rw-r--r--hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk9
-rw-r--r--hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk9
-rw-r--r--hw/bsp/stm32f7/boards/stm32f769disco/board.mk9
-rw-r--r--hw/bsp/stm32f7/family.c5
-rw-r--r--hw/bsp/stm32f7/family.mk30
10 files changed, 73 insertions, 23 deletions
diff --git a/.github/workflows/build_iar.yml b/.github/workflows/build_iar.yml
index 40c7d7f26..1facd8ab9 100644
--- a/.github/workflows/build_iar.yml
+++ b/.github/workflows/build_iar.yml
@@ -29,6 +29,8 @@ jobs:
# Alphabetical order
- 'stm32f0'
- 'stm32f1'
+ - 'stm32f4'
+ - 'stm32f7'
steps:
- name: Clean workspace
run: |
diff --git a/hw/bsp/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk
index 333857499..3da4f7bf8 100644
--- a/hw/bsp/stm32f4/family.mk
+++ b/hw/bsp/stm32f4/family.mk
@@ -30,6 +30,10 @@ GCC_CFLAGS += -Wno-error=cast-align
IAR_CFLAGS += --cpu cortex-m4
IAR_ASFLAGS += --cpu cortex-m4
+# -----------------
+# Sources & Include
+# -----------------
+
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \
diff --git a/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk b/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk
index a18b3231d..c28dae9bf 100644
--- a/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk
+++ b/hw/bsp/stm32f7/boards/stlinkv3mini/board.mk
@@ -6,9 +6,13 @@ CFLAGS += \
-DSTM32F723xx \
-DHSE_VALUE=25000000 \
-# All source paths should be relative to the top level.
-LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f723xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f723xx_flash.icf
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32f7/boards/stm32f723disco/board.mk b/hw/bsp/stm32f7/boards/stm32f723disco/board.mk
index 66d9ff8fb..6ddb727c7 100644
--- a/hw/bsp/stm32f7/boards/stm32f723disco/board.mk
+++ b/hw/bsp/stm32f7/boards/stm32f723disco/board.mk
@@ -5,8 +5,13 @@ CFLAGS += \
-DSTM32F723xx \
-DHSE_VALUE=25000000 \
-LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F723xE_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f723xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f723xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f723xx_flash.icf
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32f7/boards/stm32f746disco/board.mk b/hw/bsp/stm32f7/boards/stm32f746disco/board.mk
index 2ba59f67a..ba31baa16 100644
--- a/hw/bsp/stm32f7/boards/stm32f746disco/board.mk
+++ b/hw/bsp/stm32f7/boards/stm32f746disco/board.mk
@@ -5,8 +5,13 @@ CFLAGS += \
-DSTM32F746xx \
-DHSE_VALUE=25000000
-LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f746xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f746xx_flash.icf
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk b/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk
index 3dcf4817e..e4d31040e 100644
--- a/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk
+++ b/hw/bsp/stm32f7/boards/stm32f746nucleo/board.mk
@@ -5,8 +5,13 @@ CFLAGS += \
-DSTM32F746xx \
-DHSE_VALUE=8000000
-LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F746ZGTx_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f746xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f746xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f746xx_flash.icf
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk b/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk
index 7710619e5..a460245b2 100644
--- a/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk
+++ b/hw/bsp/stm32f7/boards/stm32f767nucleo/board.mk
@@ -5,8 +5,13 @@ CFLAGS += \
-DSTM32F767xx \
-DHSE_VALUE=8000000 \
-LD_FILE = $(BOARD_PATH)/STM32F767ZITx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f767xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F767ZITx_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f767xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f767xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f767xx_flash.icf
# For flash-jlink target
JLINK_DEVICE = stm32f767zi
diff --git a/hw/bsp/stm32f7/boards/stm32f769disco/board.mk b/hw/bsp/stm32f7/boards/stm32f769disco/board.mk
index 45b4a78c7..18f59e8b2 100644
--- a/hw/bsp/stm32f7/boards/stm32f769disco/board.mk
+++ b/hw/bsp/stm32f7/boards/stm32f769disco/board.mk
@@ -6,8 +6,13 @@ CFLAGS += \
-DSTM32F769xx \
-DHSE_VALUE=25000000 \
-LD_FILE = $(BOARD_PATH)/STM32F769ZITx_FLASH.ld
-SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f769xx.s
+# GCC
+GCC_LD_FILE = $(BOARD_PATH)/STM32F769ZITx_FLASH.ld
+GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f769xx.s
+
+# IAR
+IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f769xx.s
+IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f769xx_flash.icf
# flash target using on-board stlink
flash: flash-stlink
diff --git a/hw/bsp/stm32f7/family.c b/hw/bsp/stm32f7/family.c
index 425e6e1bc..536eb0554 100644
--- a/hw/bsp/stm32f7/family.c
+++ b/hw/bsp/stm32f7/family.c
@@ -268,7 +268,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)
@@ -303,7 +304,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/stm32f7/family.mk b/hw/bsp/stm32f7/family.mk
index b8a5d7ead..733769d8b 100644
--- a/hw/bsp/stm32f7/family.mk
+++ b/hw/bsp/stm32f7/family.mk
@@ -7,14 +7,10 @@ ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
include $(TOP)/$(BOARD_PATH)/board.mk
+# --------------
+# Compiler Flags
+# --------------
CFLAGS += \
- -flto \
- -mthumb \
- -mabi=aapcs \
- -mcpu=cortex-m7 \
- -mfloat-abi=hard \
- -mfpu=fpv5-d16 \
- -nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
-DBOARD_TUD_RHPORT=$(PORT)
@@ -30,8 +26,26 @@ else
$(info "Using OTG_FS")
endif
+# GCC Flags
+GCC_CFLAGS += \
+ -flto \
+ -mthumb \
+ -mabi=aapcs \
+ -mcpu=cortex-m7 \
+ -mfloat-abi=hard \
+ -mfpu=fpv5-d16 \
+ -nostdlib -nostartfiles
+
# mcu driver cause following warnings
-CFLAGS += -Wno-error=shadow -Wno-error=cast-align
+GCC_CFLAGS += -Wno-error=shadow -Wno-error=cast-align
+
+# IAR Flags
+IAR_CFLAGS += --cpu cortex-m7
+IAR_ASFLAGS += --cpu cortex-m7
+
+# -----------------
+# Sources & Include
+# -----------------
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \