Skip to content

RP2040 fixes #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ endif ()
if (NOT FREERTOS_KERNEL_PATH)
foreach(POSSIBLE_SUFFIX Source FreeRTOS-Kernel FreeRTOS/Source)
# check if FreeRTOS-Kernel exists under directory that included us
set(SEARCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}})
set(SEARCH_ROOT ../../../..)
set(SEARCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
get_filename_component(_POSSIBLE_PATH ${SEARCH_ROOT}/${POSSIBLE_SUFFIX} REALPATH)
if (EXISTS ${_POSSIBLE_PATH}/${FREERTOS_KERNEL_RP2040_RELATIVE_PATH}/CMakeLists.txt)
get_filename_component(FREERTOS_KERNEL_PATH ${_POSSIBLE_PATH} REALPATH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#ifndef __ASSEMBLER__
#include "FreeRTOSConfig.h"
#include "rp2040_config.h"

#ifndef PICO_USE_MALLOC_MUTEX
// malloc needs to be made thread safe
#define PICO_USE_MALLOC_MUTEX 1
#endif /* PICO_USE_MALLOC_MUTEX */
#if ( configSUPPORT_PICO_SYNC_INTEROP == 1 )
// increase the amount of time it may reasonably take to wake us up
#ifndef PICO_TIME_SLEEP_OVERHEAD_ADJUST_US
Expand Down
23 changes: 11 additions & 12 deletions portable/ThirdParty/GCC/RP2040/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ static void prvTaskExitError( void );
/*-----------------------------------------------------------*/

/* Each task maintains its own interrupt status in the critical nesting
* variable. */
static UBaseType_t uxCriticalNesting = {0xaaaaaaaa};
* variable. This is initialized to 0 to allow vPortEnter/ExitCritical
* to be called before the scheduler is started */
static UBaseType_t uxCriticalNesting;

/*-----------------------------------------------------------*/

Expand Down Expand Up @@ -158,13 +159,9 @@ static UBaseType_t uxCriticalNesting = {0xaaaaaaaa};

/*-----------------------------------------------------------*/

#if ( LIB_PICO_MULTICORE == 1 )
#define INVALID_LAUNCH_CORE_NUM 0xffu
static uint8_t ucLaunchCoreNum = INVALID_LAUNCH_CORE_NUM;
#define portIS_FREE_RTOS_CORE() ( ucLaunchCoreNum == get_core_num() )
#else
#define portIS_FREE_RTOS_CORE() pdTRUE
#endif /* LIB_PICO_MULTICORE */
#define INVALID_LAUNCH_CORE_NUM 0xffu
static uint8_t ucLaunchCoreNum = INVALID_LAUNCH_CORE_NUM;
#define portIS_FREE_RTOS_CORE() ( ucLaunchCoreNum == get_core_num() )

/*
* See header file for description.
Expand Down Expand Up @@ -266,8 +263,8 @@ BaseType_t xPortStartScheduler( void )
/* Initialise the critical nesting count ready for the first task. */
uxCriticalNesting = 0;

ucLaunchCoreNum = get_core_num();
#if (LIB_PICO_MULTICORE == 1)
ucLaunchCoreNum = get_core_num();
#if ( configSUPPORT_PICO_SYNC_INTEROP == 1)
multicore_fifo_clear_irq();
multicore_fifo_drain();
Expand Down Expand Up @@ -728,7 +725,6 @@ __attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
void vPortLockInternalSpinUnlockWithWait( struct lock_core * pxLock, uint32_t ulSave )
{
configASSERT( !portCHECK_IF_IN_ISR() );
// note no need to check LIB_PICO_MULTICORE, as this is always returns true if that is not defined
if( !portIS_FREE_RTOS_CORE() )
{
spin_unlock(pxLock->spin_lock, ulSave );
Expand Down Expand Up @@ -806,7 +802,6 @@ __attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
}
else
{
configASSERT( portIS_FREE_RTOS_CORE() );
configASSERT( pxYieldSpinLock == NULL );

TickType_t uxTicksToWait = prvGetTicksToWaitBefore( uxUntil );
Expand Down Expand Up @@ -858,6 +853,10 @@ __attribute__( ( weak ) ) void vPortSetupTimerInterrupt( void )
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
xEventGroup = xEventGroupCreateStatic(&xStaticEventGroup);
#else
/* Note that it is slightly dubious calling this here before the scheduler is initialized,
* however the only thing it touches is the allocator which then calls vPortEnterCritical
* and vPortExitCritical, and allocating here saves us checking the one time initialized variable in
* some rather critical code paths */
xEventGroup = xEventGroupCreate();
#endif /* configSUPPORT_STATIC_ALLOCATION */
}
Expand Down