Skip to content

Commit f3ff2be

Browse files
authored
Merge branch 'main' into main
2 parents 45f3611 + e6f6d0e commit f3ff2be

File tree

4 files changed

+74
-10
lines changed

4 files changed

+74
-10
lines changed

portable/GCC/ARM_CM3_MPU/port.c

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,12 +1095,28 @@ __attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
10951095

10961096
static void prvSetupMPU( void )
10971097
{
1098-
extern uint32_t __privileged_functions_start__[];
1099-
extern uint32_t __privileged_functions_end__[];
1100-
extern uint32_t __FLASH_segment_start__[];
1101-
extern uint32_t __FLASH_segment_end__[];
1102-
extern uint32_t __privileged_data_start__[];
1103-
extern uint32_t __privileged_data_end__[];
1098+
#if defined( __ARMCC_VERSION )
1099+
1100+
/* Declaration when these variable are defined in code instead of being
1101+
* exported from linker scripts. */
1102+
extern uint32_t * __privileged_functions_start__;
1103+
extern uint32_t * __privileged_functions_end__;
1104+
extern uint32_t * __FLASH_segment_start__;
1105+
extern uint32_t * __FLASH_segment_end__;
1106+
extern uint32_t * __privileged_data_start__;
1107+
extern uint32_t * __privileged_data_end__;
1108+
#else
1109+
/* Declaration when these variable are exported from linker scripts. */
1110+
extern uint32_t __privileged_functions_start__[];
1111+
extern uint32_t __privileged_functions_end__[];
1112+
extern uint32_t __FLASH_segment_start__[];
1113+
extern uint32_t __FLASH_segment_end__[];
1114+
extern uint32_t __privileged_data_start__[];
1115+
extern uint32_t __privileged_data_end__[];
1116+
#endif /* if defined( __ARMCC_VERSION ) */
1117+
1118+
/* Ensure that the device has the expected MPU type */
1119+
configASSERT( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE );
11041120

11051121
/* Check the expected MPU is present. */
11061122
if( portMPU_TYPE_REG == portEXPECTED_MPU_TYPE_VALUE )
@@ -1229,10 +1245,22 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
12291245
StackType_t * pxBottomOfStack,
12301246
configSTACK_DEPTH_TYPE ulStackDepth )
12311247
{
1232-
extern uint32_t __SRAM_segment_start__[];
1233-
extern uint32_t __SRAM_segment_end__[];
1234-
extern uint32_t __privileged_data_start__[];
1235-
extern uint32_t __privileged_data_end__[];
1248+
#if defined( __ARMCC_VERSION )
1249+
1250+
/* Declaration when these variable are defined in code instead of being
1251+
* exported from linker scripts. */
1252+
extern uint32_t * __SRAM_segment_start__;
1253+
extern uint32_t * __SRAM_segment_end__;
1254+
extern uint32_t * __privileged_data_start__;
1255+
extern uint32_t * __privileged_data_end__;
1256+
#else
1257+
/* Declaration when these variable are exported from linker scripts. */
1258+
extern uint32_t __SRAM_segment_start__[];
1259+
extern uint32_t __SRAM_segment_end__[];
1260+
extern uint32_t __privileged_data_start__[];
1261+
extern uint32_t __privileged_data_end__[];
1262+
#endif /* if defined( __ARMCC_VERSION ) */
1263+
12361264
int32_t lIndex;
12371265
uint32_t ul;
12381266

portable/GCC/ARM_CM3_MPU/portmacro.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ typedef unsigned long UBaseType_t;
8686
#define portMPU_REGION_CACHEABLE_BUFFERABLE ( 0x07UL << 16UL )
8787
#define portMPU_REGION_EXECUTE_NEVER ( 0x01UL << 28UL )
8888

89+
/* MPU settings that can be overriden in FreeRTOSConfig.h. */
90+
#ifndef configTOTAL_MPU_REGIONS
91+
/* Define to 8 for backward compatibility. */
92+
#define configTOTAL_MPU_REGIONS ( 8UL )
93+
#elif( configTOTAL_MPU_REGIONS != 8UL )
94+
/* The Cortex M3 only supports 8 MPU regions. For more information refer to:
95+
* https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/optional-memory-protection-unit */
96+
#error configTOTAL_MPU_REGIONS must be 8 for this port.
97+
#endif /* configTOTAL_MPU_REGIONS Check */
8998
#define portSTACK_REGION ( 3UL )
9099
#define portGENERAL_PERIPHERALS_REGION ( 4UL )
91100
#define portUNPRIVILEGED_FLASH_REGION ( 5UL )

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
*----------------------------------------------------------*/
5252
#include "portmacro.h"
5353

54+
#ifdef __linux__
55+
#define __USE_GNU
56+
#endif
57+
5458
#include <errno.h>
5559
#include <pthread.h>
5660
#include <signal.h>
@@ -134,6 +138,16 @@ void prvFatalError( const char * pcCall,
134138
}
135139
/*-----------------------------------------------------------*/
136140

141+
static void prvPortSetCurrentThreadName(char * pxThreadName)
142+
{
143+
#ifdef __APPLE__
144+
pthread_setname_np(pxThreadName);
145+
#else
146+
pthread_setname_np(pthread_self(), pxThreadName);
147+
#endif
148+
}
149+
/*-----------------------------------------------------------*/
150+
137151
/*
138152
* See header file for description.
139153
*/
@@ -224,6 +238,7 @@ BaseType_t xPortStartScheduler( void )
224238
const ListItem_t * pxEndMarker;
225239

226240
hMainThread = pthread_self();
241+
prvPortSetCurrentThreadName("Scheduler");
227242

228243
/* Start the timer that generates the tick ISR(SIGALRM).
229244
* Interrupts are disabled here already. */
@@ -383,6 +398,8 @@ static void * prvTimerTickHandler( void * arg )
383398
{
384399
( void ) arg;
385400

401+
prvPortSetCurrentThreadName("Scheduler timer");
402+
386403
while( xTimerTickThreadShouldRun )
387404
{
388405
/*
@@ -493,6 +510,9 @@ static void * prvWaitForStart( void * pvParams )
493510
uxCriticalNesting = 0;
494511
vPortEnableInterrupts();
495512

513+
/* Set thread name */
514+
prvPortSetCurrentThreadName(pcTaskGetName(xTaskGetCurrentTaskHandle()));
515+
496516
/* Call the task's entry point. */
497517
pxThread->pxCode( pxThread->pvParams );
498518

tasks.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
#include "timers.h"
4242
#include "stack_macros.h"
4343

44+
/* The default definitions are only available for non-MPU ports. The
45+
* reason is that the stack alignment requirements vary for different
46+
* architectures.*/
47+
#if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configKERNEL_PROVIDED_STATIC_MEMORY == 1 ) && ( portUSING_MPU_WRAPPERS != 0 ) )
48+
#error configKERNEL_PROVIDED_STATIC_MEMORY cannot be set to 1 when using an MPU port. The vApplicationGet*TaskMemory() functions must be provided manually.
49+
#endif
50+
4451
/* The MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
4552
* for the header files above, but not in this file, in order to generate the
4653
* correct privileged Vs unprivileged linkage and placement. */

0 commit comments

Comments
 (0)