Skip to content

Commit 8633a26

Browse files
committed
update h5 build make/cmake
1 parent 17a0ce6 commit 8633a26

File tree

11 files changed

+100
-264
lines changed

11 files changed

+100
-264
lines changed

.github/workflows/cmake_arm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
- 'stm32f7'
5050
- 'stm32g0'
5151
- 'stm32g4'
52+
- 'stm32h5'
5253
- 'stm32h7'
5354
- 'stm32l4'
5455
- 'stm32u5'

hw/bsp/stm32g4/family.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
UF2_FAMILY_ID = 0x4c71240a
22
ST_FAMILY = g4
3-
DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/st/cmsis_device_$(ST_FAMILY) hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
4-
53
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
64
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
75

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(MCU_VARIANT stm32h563xx)
2+
set(JLINK_DEVICE stm32h563zi)
3+
4+
function(update_board TARGET)
5+
target_compile_definitions(${TARGET} PUBLIC
6+
STM32H563xx
7+
)
8+
endfunction()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MCU_VARIANT = stm32h563xx
2+
3+
CFLAGS += \
4+
-DSTM32H563xx
5+
6+
# For flash-jlink target
7+
JLINK_DEVICE = stm32h563zi

hw/bsp/stm32h5/boards/stm32h573i-dk/STM32H573I-DK_FLASH.ld

Lines changed: 0 additions & 187 deletions
This file was deleted.

hw/bsp/stm32h5/boards/stm32h573i-dk/board.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
set(MCU_VARIANT stm32h573i-dk)
2-
set(JLINK_DEVICE stm32h573i-dk)
3-
4-
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32H573I-DK_FLASH.ld)
1+
set(MCU_VARIANT stm32h573xx)
2+
set(JLINK_DEVICE stm32h573ii)
53

64
function(update_board TARGET)
75
target_compile_definitions(${TARGET} PUBLIC
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1+
MCU_VARIANT = stm32h573xx
2+
13
CFLAGS += \
24
-DSTM32H573xx
35

4-
# GCC
5-
SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32h573xx.s
6-
LD_FILE_GCC = $(BOARD_PATH)/STM32H573I-DK_FLASH.ld
7-
8-
# IAR
9-
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_stm32h573xx.s
10-
LD_FILE_IAR = $(ST_CMSIS)/Source/Templates/iar/linker/stm32h573xx_flash.icf
11-
126
# For flash-jlink target
13-
JLINK_DEVICE = stm32h573i-dk
7+
JLINK_DEVICE = stm32h573ii

hw/bsp/stm32h5/family.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@
2525
* This file is part of the TinyUSB stack.
2626
*/
2727

28+
29+
// Suppress warning caused by mcu driver
30+
#ifdef __GNUC__
31+
#pragma GCC diagnostic push
32+
#pragma GCC diagnostic ignored "-Wundef"
33+
#endif
34+
2835
#include "stm32h5xx_hal.h"
36+
37+
#ifdef __GNUC__
38+
#pragma GCC diagnostic pop
39+
#endif
40+
2941
#include "bsp/board_api.h"
3042
#include "board.h"
3143

hw/bsp/stm32h5/family.cmake

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(CMSIS_5 ${TOP}/lib/CMSIS_5)
1515
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
1616

1717
# toolchain set up
18-
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus CACHE INTERNAL "System Processor")
18+
set(CMAKE_SYSTEM_PROCESSOR cortex-m33 CACHE INTERNAL "System Processor")
1919
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
2020

2121
set(FAMILY_MCUS STM32H5 CACHE INTERNAL "")
@@ -26,52 +26,52 @@ set(FAMILY_MCUS STM32H5 CACHE INTERNAL "")
2626
#------------------------------------
2727
# only need to be built ONCE for all examples
2828
function(add_board_target BOARD_TARGET)
29-
if (NOT TARGET ${BOARD_TARGET})
30-
# Startup & Linker script
31-
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
32-
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
33-
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
34-
35-
add_library(${BOARD_TARGET} STATIC
36-
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
37-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
38-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
39-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr.c
40-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
41-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
42-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
43-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
44-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
45-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
46-
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_dma.c
47-
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
48-
)
49-
target_include_directories(${BOARD_TARGET} PUBLIC
50-
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
51-
${CMSIS_5}/CMSIS/Core/Include
52-
${ST_CMSIS}/Include
53-
${ST_HAL_DRIVER}/Inc
54-
)
55-
target_compile_options(${BOARD_TARGET} PUBLIC
29+
if (TARGET ${BOARD_TARGET})
30+
return()
31+
endif ()
32+
33+
# Startup & Linker script
34+
set(STARTUP_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/startup_${MCU_VARIANT}.s)
35+
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
36+
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
37+
38+
string(REPLACE "stm32h" "STM32H" MCU_VARIANT_UPPER ${MCU_VARIANT})
39+
set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT_UPPER}_FLASH.ld)
40+
41+
add_library(${BOARD_TARGET} STATIC
42+
${ST_CMSIS}/Source/Templates/system_${ST_PREFIX}.c
43+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal.c
44+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_cortex.c
45+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_gpio.c
46+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr.c
47+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_pwr_ex.c
48+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc.c
49+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_rcc_ex.c
50+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart.c
51+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_uart_ex.c
52+
${ST_HAL_DRIVER}/Src/${ST_PREFIX}_hal_dma.c
53+
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
54+
)
55+
target_include_directories(${BOARD_TARGET} PUBLIC
56+
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
57+
${CMSIS_5}/CMSIS/Core/Include
58+
${ST_CMSIS}/Include
59+
${ST_HAL_DRIVER}/Inc
60+
)
61+
62+
update_board(${BOARD_TARGET})
63+
64+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
65+
target_link_options(${BOARD_TARGET} PUBLIC
66+
"LINKER:--script=${LD_FILE_GNU}"
67+
-nostartfiles
68+
# nanolib
69+
--specs=nosys.specs --specs=nano.specs
5670
)
57-
target_compile_definitions(${BOARD_TARGET} PUBLIC
71+
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
72+
target_link_options(${BOARD_TARGET} PUBLIC
73+
"LINKER:--config=${LD_FILE_IAR}"
5874
)
59-
60-
update_board(${BOARD_TARGET})
61-
62-
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
63-
target_link_options(${BOARD_TARGET} PUBLIC
64-
"LINKER:--script=${LD_FILE_GNU}"
65-
-nostartfiles
66-
# nanolib
67-
--specs=nosys.specs
68-
--specs=nano.specs
69-
)
70-
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
71-
target_link_options(${BOARD_TARGET} PUBLIC
72-
"LINKER:--config=${LD_FILE_IAR}"
73-
)
74-
endif ()
7575
endif ()
7676
endfunction()
7777

@@ -112,5 +112,5 @@ function(family_configure_example TARGET RTOS)
112112

113113
# Flashing
114114
family_flash_stlink(${TARGET})
115-
#family_flash_jlink(${TARGET})
115+
family_flash_jlink(${TARGET})
116116
endfunction()

0 commit comments

Comments
 (0)