Skip to content

Commit 93c40b6

Browse files
committed
Add Support stm32h5 for stm32h573i based on stm32_fsdev G0 implementation Tested on Windows with IAR and gcc toolchain ( via cubeide) Tested only with audio examples, but sould be ok for other examples Cmake pacthed : but not tested Linux build : not tested Added a temporary workaround in make file to support H5 HAL repo ( ARMCC_VERSION=0)
1 parent 59ecdb7 commit 93c40b6

File tree

15 files changed

+1295
-6
lines changed

15 files changed

+1295
-6
lines changed

hw/bsp/board_mcu.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
// Include order follows OPT_MCU_ number
4242
#if TU_CHECK_MCU(OPT_MCU_LPC11UXX, OPT_MCU_LPC13XX, OPT_MCU_LPC15XX) || \
43-
TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC18XX) || \
44-
TU_CHECK_MCU(OPT_MCU_LPC40XX, OPT_MCU_LPC43XX)
43+
TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC18XX) || \
44+
TU_CHECK_MCU(OPT_MCU_LPC40XX, OPT_MCU_LPC43XX)
4545
#include "chip.h"
4646

4747
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX, OPT_MCU_LPC54XXX, OPT_MCU_LPC55XX, OPT_MCU_MCXN9)
@@ -54,8 +54,8 @@
5454
#include "nrf.h"
5555

5656
#elif CFG_TUSB_MCU == OPT_MCU_SAMD11 || CFG_TUSB_MCU == OPT_MCU_SAMD21 || \
57-
CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X || \
58-
CFG_TUSB_MCU == OPT_MCU_SAML22 || CFG_TUSB_MCU == OPT_MCU_SAML21
57+
CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X || \
58+
CFG_TUSB_MCU == OPT_MCU_SAML22 || CFG_TUSB_MCU == OPT_MCU_SAML21
5959
#include "sam.h"
6060

6161
#elif CFG_TUSB_MCU == OPT_MCU_SAMG
@@ -83,6 +83,9 @@
8383
#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
8484
#include "stm32g4xx.h"
8585

86+
#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
87+
#include "stm32h5xx.h"
88+
8689
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
8790
#include "stm32h7xx.h"
8891

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
* FreeRTOS Kernel V10.0.0
3+
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so,
10+
* subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software. If you wish to use our Amazon
14+
* FreeRTOS name, please do so in a fair use way that does not cause confusion.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
* http://www.FreeRTOS.org
24+
* http://aws.amazon.com/freertos
25+
*
26+
* 1 tab == 4 spaces!
27+
*/
28+
29+
30+
#ifndef FREERTOS_CONFIG_H
31+
#define FREERTOS_CONFIG_H
32+
33+
/*-----------------------------------------------------------
34+
* Application specific definitions.
35+
*
36+
* These definitions should be adjusted for your particular hardware and
37+
* application requirements.
38+
*
39+
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
40+
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
41+
*
42+
* See http://www.freertos.org/a00110.html.
43+
*----------------------------------------------------------*/
44+
45+
// skip if included from IAR assembler
46+
#ifndef __IASMARM__
47+
#include "stm32g0xx.h"
48+
#endif
49+
50+
/* Cortex M23/M33 port configuration. */
51+
#define configENABLE_MPU 0
52+
#define configENABLE_FPU 1
53+
#define configENABLE_TRUSTZONE 0
54+
#define configMINIMAL_SECURE_STACK_SIZE (1024)
55+
56+
#define configUSE_PREEMPTION 1
57+
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
58+
#define configCPU_CLOCK_HZ SystemCoreClock
59+
#define configTICK_RATE_HZ ( 1000 )
60+
#define configMAX_PRIORITIES ( 5 )
61+
#define configMINIMAL_STACK_SIZE ( 128 )
62+
#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
63+
#define configMAX_TASK_NAME_LEN 16
64+
#define configUSE_16_BIT_TICKS 0
65+
#define configIDLE_SHOULD_YIELD 1
66+
#define configUSE_MUTEXES 1
67+
#define configUSE_RECURSIVE_MUTEXES 1
68+
#define configUSE_COUNTING_SEMAPHORES 1
69+
#define configQUEUE_REGISTRY_SIZE 4
70+
#define configUSE_QUEUE_SETS 0
71+
#define configUSE_TIME_SLICING 0
72+
#define configUSE_NEWLIB_REENTRANT 0
73+
#define configENABLE_BACKWARD_COMPATIBILITY 1
74+
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
75+
76+
#define configSUPPORT_STATIC_ALLOCATION 1
77+
#define configSUPPORT_DYNAMIC_ALLOCATION 0
78+
79+
/* Hook function related definitions. */
80+
#define configUSE_IDLE_HOOK 0
81+
#define configUSE_TICK_HOOK 0
82+
#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
83+
#define configCHECK_FOR_STACK_OVERFLOW 2
84+
85+
/* Run time and task stats gathering related definitions. */
86+
#define configGENERATE_RUN_TIME_STATS 0
87+
#define configRECORD_STACK_HIGH_ADDRESS 1
88+
#define configUSE_TRACE_FACILITY 1 // legacy trace
89+
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
90+
91+
/* Co-routine definitions. */
92+
#define configUSE_CO_ROUTINES 0
93+
#define configMAX_CO_ROUTINE_PRIORITIES 2
94+
95+
/* Software timer related definitions. */
96+
#define configUSE_TIMERS 1
97+
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
98+
#define configTIMER_QUEUE_LENGTH 32
99+
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
100+
101+
/* Optional functions - most linkers will remove unused functions anyway. */
102+
#define INCLUDE_vTaskPrioritySet 0
103+
#define INCLUDE_uxTaskPriorityGet 0
104+
#define INCLUDE_vTaskDelete 0
105+
#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
106+
#define INCLUDE_xResumeFromISR 0
107+
#define INCLUDE_vTaskDelayUntil 1
108+
#define INCLUDE_vTaskDelay 1
109+
#define INCLUDE_xTaskGetSchedulerState 0
110+
#define INCLUDE_xTaskGetCurrentTaskHandle 1
111+
#define INCLUDE_uxTaskGetStackHighWaterMark 0
112+
#define INCLUDE_xTaskGetIdleTaskHandle 0
113+
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
114+
#define INCLUDE_pcTaskGetTaskName 0
115+
#define INCLUDE_eTaskGetState 0
116+
#define INCLUDE_xEventGroupSetBitFromISR 0
117+
#define INCLUDE_xTimerPendFunctionCall 0
118+
119+
/* Define to trap errors during development. */
120+
// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
121+
#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
122+
#define configASSERT(_exp) \
123+
do {\
124+
if ( !(_exp) ) { \
125+
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
126+
if ( (*ARM_CM_DHCSR) & 1UL ) { /* Only halt mcu if debugger is attached */ \
127+
taskDISABLE_INTERRUPTS(); \
128+
__asm("BKPT #0\n"); \
129+
}\
130+
}\
131+
} while(0)
132+
#else
133+
#define configASSERT( x )
134+
#endif
135+
136+
/* FreeRTOS hooks to NVIC vectors */
137+
#define xPortPendSVHandler PendSV_Handler
138+
#define xPortSysTickHandler SysTick_Handler
139+
#define vPortSVCHandler SVC_Handler
140+
141+
//--------------------------------------------------------------------+
142+
// Interrupt nesting behavior configuration.
143+
//--------------------------------------------------------------------+
144+
145+
// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
146+
#define configPRIO_BITS 2
147+
148+
/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
149+
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<<configPRIO_BITS) - 1)
150+
151+
/* The highest interrupt priority that can be used by any interrupt service
152+
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
153+
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
154+
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
155+
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 2
156+
157+
/* Interrupt priorities used by the kernel port layer itself. These are generic
158+
to all Cortex-M ports, and do not rely on any particular library functions. */
159+
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
160+
161+
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
162+
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
163+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
164+
165+
#endif
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/*
2+
******************************************************************************
3+
**
4+
5+
** File : LinkerScript.ld
6+
**
7+
** Author : STM32CubeMX
8+
**
9+
** Abstract : Linker script for stm32h573i-dk series
10+
** 640Kbytes FLASH and 2048Kbytes RAM
11+
**
12+
** Set heap size, stack size and stack location according
13+
** to application requirements.
14+
**
15+
** Set memory bank area and size if external memory is used.
16+
**
17+
** Target : STMicroelectronics STM32
18+
**
19+
** Distribution: The file is distributed “as is,” without any warranty
20+
** of any kind.
21+
**
22+
*****************************************************************************
23+
** @attention
24+
**
25+
** <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
26+
**
27+
** Redistribution and use in source and binary forms, with or without modification,
28+
** are permitted provided that the following conditions are met:
29+
** 1. Redistributions of source code must retain the above copyright notice,
30+
** this list of conditions and the following disclaimer.
31+
** 2. Redistributions in binary form must reproduce the above copyright notice,
32+
** this list of conditions and the following disclaimer in the documentation
33+
** and/or other materials provided with the distribution.
34+
** 3. Neither the name of STMicroelectronics nor the names of its contributors
35+
** may be used to endorse or promote products derived from this software
36+
** without specific prior written permission.
37+
**
38+
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39+
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40+
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41+
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42+
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43+
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44+
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45+
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46+
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47+
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+
**
49+
*****************************************************************************
50+
*/
51+
52+
/* Entry Point */
53+
ENTRY(Reset_Handler)
54+
55+
/* Highest address of the user mode stack */
56+
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
57+
/* Generate a link error if heap and stack don't fit into RAM */
58+
_Min_Heap_Size = 0x200; /* required amount of heap */
59+
_Min_Stack_Size = 0x400; /* required amount of stack */
60+
61+
/* Specify the memory areas */
62+
MEMORY
63+
{
64+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
65+
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
66+
}
67+
68+
/* Define output sections */
69+
SECTIONS
70+
{
71+
/* The startup code goes first into FLASH */
72+
.isr_vector :
73+
{
74+
. = ALIGN(4);
75+
KEEP(*(.isr_vector)) /* Startup code */
76+
. = ALIGN(4);
77+
} >FLASH
78+
79+
/* The program code and other data goes into FLASH */
80+
.text :
81+
{
82+
. = ALIGN(4);
83+
*(.text) /* .text sections (code) */
84+
*(.text*) /* .text* sections (code) */
85+
*(.glue_7) /* glue arm to thumb code */
86+
*(.glue_7t) /* glue thumb to arm code */
87+
*(.eh_frame)
88+
89+
KEEP (*(.init))
90+
KEEP (*(.fini))
91+
92+
. = ALIGN(4);
93+
_etext = .; /* define a global symbols at end of code */
94+
} >FLASH
95+
96+
/* Constant data goes into FLASH */
97+
.rodata :
98+
{
99+
. = ALIGN(4);
100+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
101+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102+
. = ALIGN(4);
103+
} >FLASH
104+
105+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
106+
.ARM : {
107+
__exidx_start = .;
108+
*(.ARM.exidx*)
109+
__exidx_end = .;
110+
} >FLASH
111+
112+
.preinit_array :
113+
{
114+
PROVIDE_HIDDEN (__preinit_array_start = .);
115+
KEEP (*(.preinit_array*))
116+
PROVIDE_HIDDEN (__preinit_array_end = .);
117+
} >FLASH
118+
.init_array :
119+
{
120+
PROVIDE_HIDDEN (__init_array_start = .);
121+
KEEP (*(SORT(.init_array.*)))
122+
KEEP (*(.init_array*))
123+
PROVIDE_HIDDEN (__init_array_end = .);
124+
} >FLASH
125+
.fini_array :
126+
{
127+
PROVIDE_HIDDEN (__fini_array_start = .);
128+
KEEP (*(SORT(.fini_array.*)))
129+
KEEP (*(.fini_array*))
130+
PROVIDE_HIDDEN (__fini_array_end = .);
131+
} >FLASH
132+
133+
/* used by the startup to initialize data */
134+
_sidata = LOADADDR(.data);
135+
136+
/* Initialized data sections goes into RAM, load LMA copy after code */
137+
.data :
138+
{
139+
. = ALIGN(4);
140+
_sdata = .; /* create a global symbol at data start */
141+
*(.data) /* .data sections */
142+
*(.data*) /* .data* sections */
143+
144+
. = ALIGN(4);
145+
_edata = .; /* define a global symbol at data end */
146+
} >RAM AT> FLASH
147+
148+
149+
/* Uninitialized data section */
150+
. = ALIGN(4);
151+
.bss :
152+
{
153+
/* This is used by the startup in order to initialize the .bss section */
154+
_sbss = .; /* define a global symbol at bss start */
155+
__bss_start__ = _sbss;
156+
*(.bss)
157+
*(.bss*)
158+
*(COMMON)
159+
160+
. = ALIGN(4);
161+
_ebss = .; /* define a global symbol at bss end */
162+
__bss_end__ = _ebss;
163+
} >RAM
164+
165+
/* User_heap_stack section, used to check that there is enough RAM left */
166+
._user_heap_stack :
167+
{
168+
. = ALIGN(8);
169+
PROVIDE ( end = . );
170+
PROVIDE ( _end = . );
171+
. = . + _Min_Heap_Size;
172+
. = . + _Min_Stack_Size;
173+
. = ALIGN(8);
174+
} >RAM
175+
176+
177+
178+
/* Remove information from the standard libraries */
179+
/DISCARD/ :
180+
{
181+
libc.a ( * )
182+
libm.a ( * )
183+
libgcc.a ( * )
184+
}
185+
186+
.ARM.attributes 0 : { *(.ARM.attributes) }
187+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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)
5+
6+
function(update_board TARGET)
7+
target_compile_definitions(${TARGET} PUBLIC
8+
STM32H573xx
9+
)
10+
endfunction()

0 commit comments

Comments
 (0)