Skip to content

Commit c7686f8

Browse files
authored
Merge pull request hathach#2092 from hathach/stm32g4
Stm32g4
2 parents 002cb92 + 2016ad7 commit c7686f8

File tree

39 files changed

+1343
-547
lines changed

39 files changed

+1343
-547
lines changed

.github/workflows/build_arm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- 'stm32f0 stm32f1 stm32f2 stm32f3'
4747
- 'stm32f4'
4848
- 'stm32f7'
49-
- 'stm32g4 stm32h7'
49+
- 'stm32h7'
5050
- 'stm32l0 stm32l4 stm32u5 stm32wb'
5151
- 'tm4c123 xmc4000'
5252
steps:

.github/workflows/build_iar.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ concurrency:
2323
cancel-in-progress: true
2424

2525
jobs:
26-
build-arm:
26+
makefile:
2727
runs-on: [self-hosted, Linux, X64, hifiphile]
2828
strategy:
2929
fail-fast: false
@@ -48,3 +48,29 @@ jobs:
4848

4949
- name: Build
5050
run: python3 tools/build_family.py ${{ matrix.family }} CC=iccarm
51+
52+
cmake:
53+
runs-on: [self-hosted, Linux, X64, hifiphile]
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
family:
58+
# Alphabetical order
59+
# Note: bundle multiple families into a matrix since there is only one self-hosted instance can
60+
# run IAR build. Too many matrix can hurt due to setup/teardown overhead.
61+
- 'stm32g0 stm32g4'
62+
steps:
63+
- name: Clean workspace
64+
run: |
65+
echo "Cleaning up previous run"
66+
rm -rf "${{ github.workspace }}"
67+
mkdir -p "${{ github.workspace }}"
68+
69+
- name: Checkout TinyUSB
70+
uses: actions/checkout@v3
71+
72+
- name: Get Dependencies
73+
run: python3 tools/get_deps.py ${{ matrix.family }}
74+
75+
- name: Build
76+
run: python3 tools/build_cmake.py ${{ matrix.family }} -DTOOLCHAIN=iccarm

.github/workflows/cmake_arm.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- 'imxrt'
3939
- 'rp2040'
4040
- 'stm32g0'
41+
- 'stm32g4'
4142
steps:
4243
- name: Setup Python
4344
uses: actions/setup-python@v4
@@ -75,11 +76,11 @@ jobs:
7576
# Upload binaries for hardware test with self-hosted
7677
- name: Prepare rp2040 Artifacts
7778
if: contains(matrix.family, 'rp2040') && github.repository_owner == 'hathach'
78-
working-directory: ${{github.workspace}}/cmake-build-ci-raspberry_pi_pico
79+
working-directory: ${{github.workspace}}/cmake-build/cmake-build-raspberry_pi_pico
7980
run: |
80-
find device/ -name "*.elf" -exec mv {} ../ \;
81-
# find host/ -name "*.elf" -exec mv {} ../ \;
82-
# find dual/ -name "*.elf" -exec mv {} ../ \;
81+
find device/ -name "*.elf" -exec mv {} ../../ \;
82+
# find host/ -name "*.elf" -exec mv {} ../../ \;
83+
# find dual/ -name "*.elf" -exec mv {} ../../ \;
8384
8485
- name: Upload Artifacts for rp2040
8586
if: contains(matrix.family,'rp2040') && github.repository_owner == 'hathach'

.idea/cmake.xml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/rp2040.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/device/net_lwip_webserver/CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ target_sources(${PROJECT} PUBLIC
7777
)
7878

7979
# due to warnings from other net source, we need to prevent error from some of the warnings options
80-
target_compile_options(${PROJECT} PUBLIC
81-
-Wno-error=null-dereference
82-
-Wno-error=conversion
83-
-Wno-error=sign-conversion
84-
-Wno-error=sign-compare
85-
)
80+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
81+
target_compile_options(${PROJECT} PUBLIC
82+
-Wno-error=null-dereference
83+
-Wno-error=conversion
84+
-Wno-error=sign-conversion
85+
-Wno-error=sign-compare
86+
)
87+
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
88+
89+
endif ()
8690

8791
# Configure compilation flags and libraries for the example... see the corresponding function
8892
# in hw/bsp/FAMILY/family.cmake for details.

hw/bsp/family_support.cmake

Lines changed: 88 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ endfunction()
8484

8585

8686
function(family_initialize_project PROJECT DIR)
87-
# set output suffix to .elf (skip espressif)
88-
if(NOT FAMILY STREQUAL "espressif")
87+
# set output suffix to .elf (skip espressif and rp2040)
88+
if(NOT FAMILY STREQUAL "espressif" AND NOT FAMILY STREQUAL "rp2040")
8989
set(CMAKE_EXECUTABLE_SUFFIX .elf PARENT_SCOPE)
9090
endif()
9191

@@ -97,6 +97,87 @@ function(family_initialize_project PROJECT DIR)
9797
endfunction()
9898

9999

100+
#------------------------------------
101+
# Main target configure
102+
#------------------------------------
103+
104+
# Add common configuration to example
105+
function(family_configure_common TARGET)
106+
# run size after build
107+
add_custom_command(TARGET ${TARGET} POST_BUILD
108+
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
109+
)
110+
111+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
112+
# Generate map file
113+
target_link_options(${TARGET} PUBLIC
114+
# link map
115+
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
116+
)
117+
endif()
118+
endfunction()
119+
120+
121+
# configure an executable target to link to tinyusb in device mode, and add the board implementation
122+
function(family_configure_device_example TARGET)
123+
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
124+
endfunction()
125+
126+
127+
# configure an executable target to link to tinyusb in host mode, and add the board implementation
128+
function(family_configure_host_example TARGET)
129+
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
130+
endfunction()
131+
132+
133+
# Add tinyusb to example
134+
function(family_add_tinyusb TARGET OPT_MCU)
135+
# tinyusb target is built for each example since it depends on example's tusb_config.h
136+
set(TINYUSB_TARGET_PREFIX ${TARGET}-)
137+
add_library(${TARGET}-tinyusb_config INTERFACE)
138+
139+
target_include_directories(${TARGET}-tinyusb_config INTERFACE
140+
${CMAKE_CURRENT_SOURCE_DIR}/src
141+
)
142+
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
143+
CFG_TUSB_MCU=${OPT_MCU}
144+
)
145+
146+
# tinyusb's CMakeList.txt
147+
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
148+
endfunction()
149+
150+
151+
# Add freeRTOS support to example
152+
function(family_add_freertos TARGET)
153+
# freeros config
154+
if (NOT TARGET freertos_config)
155+
add_library(freertos_config INTERFACE)
156+
target_include_directories(freertos_config INTERFACE
157+
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig
158+
)
159+
endif()
160+
161+
# freertos kernel should be generic as freertos_config however, CMAKE complains with missing variable
162+
# such as CMAKE_C_COMPILE_OBJECT
163+
if (NOT TARGET freertos_kernel)
164+
add_subdirectory(${TOP}/lib/FreeRTOS-Kernel ${CMAKE_BINARY_DIR}/lib/freertos_kernel)
165+
endif ()
166+
167+
# Add FreeRTOS option to tinyusb_config
168+
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
169+
CFG_TUSB_OS=OPT_OS_FREERTOS
170+
)
171+
# link tinyusb with freeRTOS kernel
172+
target_link_libraries(${TARGET}-tinyusb PUBLIC
173+
freertos_kernel
174+
)
175+
target_link_libraries(${TARGET} PUBLIC
176+
freertos_kernel
177+
)
178+
endfunction()
179+
180+
100181
function(family_add_default_example_warnings TARGET)
101182
target_compile_options(${TARGET} PUBLIC
102183
-Wall
@@ -144,20 +225,6 @@ function(family_add_default_example_warnings TARGET)
144225
endfunction()
145226

146227

147-
function(family_configure_common TARGET)
148-
# run size after build
149-
add_custom_command(TARGET ${TARGET} POST_BUILD
150-
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>
151-
)
152-
153-
# Generate map file
154-
target_link_options(${TARGET} PUBLIC
155-
# link map
156-
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
157-
)
158-
endfunction()
159-
160-
161228
# Add bin/hex output
162229
function(family_add_bin_hex TARGET)
163230
add_custom_command(TARGET ${TARGET} POST_BUILD
@@ -167,6 +234,10 @@ function(family_add_bin_hex TARGET)
167234
endfunction()
168235

169236

237+
#----------------------------------
238+
# Flashing target
239+
#----------------------------------
240+
170241
# Add flash jlink target
171242
function(family_flash_jlink TARGET)
172243
if (NOT DEFINED JLINKEXE)
@@ -233,48 +304,7 @@ function(family_flash_nxplink TARGET)
233304
endfunction()
234305

235306

236-
# configure an executable target to link to tinyusb in device mode, and add the board implementation
237-
function(family_configure_device_example TARGET)
238-
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
239-
endfunction()
240-
241-
242-
# configure an executable target to link to tinyusb in host mode, and add the board implementation
243-
function(family_configure_host_example TARGET)
244-
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
245-
endfunction()
246-
247-
248-
# Add freeRTOS support to example, can be overridden by FAMILY/family.cmake
249-
function(family_add_freertos TARGET)
250-
# freeros config
251-
if (NOT TARGET freertos_config)
252-
add_library(freertos_config INTERFACE)
253-
target_include_directories(freertos_config SYSTEM INTERFACE
254-
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig
255-
)
256-
endif()
257-
258-
# freertos kernel should be generic as freertos_config however, CMAKE complains with missing variable
259-
# such as CMAKE_C_COMPILE_OBJECT
260-
if (NOT TARGET freertos_kernel)
261-
add_subdirectory(${TOP}/lib/FreeRTOS-Kernel ${CMAKE_BINARY_DIR}/lib/freertos_kernel)
262-
endif ()
263-
264-
# Add FreeRTOS option to tinyusb_config
265-
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
266-
CFG_TUSB_OS=OPT_OS_FREERTOS
267-
)
268-
# link tinyusb with freeRTOS kernel
269-
target_link_libraries(${TARGET}-tinyusb PUBLIC
270-
freertos_kernel
271-
)
272-
target_link_libraries(${TARGET} PUBLIC
273-
freertos_kernel
274-
)
275-
endfunction()
276-
277-
307+
# family specific: can override above functions
278308
include(${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
279309

280310
if (NOT FAMILY_MCUS)

0 commit comments

Comments
 (0)