Hey there !!
As said in a former topic (and I think I’ll ask all my questions in this topic from now on, to avoid flood) I’m writing a port of the SMP Configuration for the Cortex M7. I did a lot of progress imo. The checklist here is completed. Now I’m progressing in the debug of it.
I’m at a state where I need a reference, and the RP2040 seems to be all suited, as its very accessible ! So I just ordered one : I expect to use it with a debugger to observe what is supposed to be a correct behavior. While waiting it get delivered, I’m exploring the port without testing anything. and some parts are confusing me, mainly about the spinlock.
I’ve implemented my software spinlock, and it works, OK. I used it to define the macro portRELEASE_ISR_LOCK()
, portRELEASE_TASK_LOCK()
, portGET_ISR_LOCK()
, and portGET_TASK_LOCK() spinlock_recursiveLock(&spinlock_TASK)
. In port.c file of the RP2040 view, I see there is two spinlock used, defined with static spin_lock_t * pxYieldSpinLock[ configNUMBER_OF_CORES ];
. I’m surprised, because, if I look at the definition of the previous macro for RP2040, the used spinlock are accessed with pxSpinLock
(in portmacro.h.) So the question is : Who are pxYieldSpinLock
? why are they here ? I note that they exist and are used in conditional compilation with configSUPPORT_PICO_SYNC_INTEROP
and not configNUMBER_OF_CORES
, which is the macro used to use or not the SMP Configuration. Can I ignore this for my SMP port ?
Moreover, there is two other spinlock used by the RP2040 :
BaseType_t xPortStartScheduler( void )
{
configASSERT( ucPrimaryCoreNum == INVALID_PRIMARY_CORE_NUM );
/* No one else should use these! */
spin_lock_claim( configSMP_SPINLOCK_0 );
spin_lock_claim( configSMP_SPINLOCK_1 );
#if portRUNNING_ON_BOTH_CORES
ucPrimaryCoreNum = configTICK_CORE;
configASSERT( get_core_num() == 0 ); /* we must be started on core 0 */
multicore_launch_core1( prvDisableInterruptsAndPortStartSchedulerOnCore );
#else
ucPrimaryCoreNum = get_core_num();
#endif
xPortStartSchedulerOnCore();
/* Should not get here! */
return 0;
}
First, I the function used to take them is not the macro function portGET_ISR_LOCK
nor vPortRecursiveLock
(which is behind the macro.) Secondly, configSMP_SPINLOCK_0
and _1
are not pxSpinLock
nor pxYieldSpinLock
. Finally, I don’t understand the reason why “No one else should use these!”. It confuse me a little bit, to write my own port.
I take a look at the TI AM64 port, and I don’t see any mention of a spinlocks here. Instead, I see it disable the IT, which make more sense for me. I think I must do the same !!
I’ll probably get answers when I’ll have my RP2040, but I can’t wait one week to address such an issue. And as I’m currently reworking my xPortStartScheduler
and xPortStartSchedulerOnCore
while waiting, so I must start to think of it.
Thanks for reading !!