This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM263P4-Q1: AM263P4 MCU+ SDK unsafe init code for multi-core

Part Number: AM263P4-Q1
Other Parts Discussed in Thread: SYSCONFIG, AM263P4

AM263P4-Q1, MCU+ SDK v26.00.00.6

In a past thread here, my colleague asked why SysConfig forces all R5F cores to call init functions (System_init(), Board_init(), etc) at boot even if only one core initializes all peripherals. The received answer was that SysConfig prevents peripherals from being assigned to multiple cores so this is OK ("Syscfg will mostly block you from using the resources in a duplicated manner").

Unfortunately after a lot of debugging, we've discovered this answer was incomplete. It's true that peripherals cannot be assigned to multiple cores in SysConfig, but multiple cores calling init at the same time can create major problems due to lack of cross-core sync in SysConfig generated init code.

Short explanation:

Many functions called by auto-generated SysConfig code lock and unlock the various on-chip MMRs. Since locking and unlocking an MMR isn't synchronized across cores (Semaphore/Spinlock/etc) in MCU+ SDK, it's possible (and unfortunately does happen, as we discovered after a small SysConfig change bricked our product) for one R5F core to call Pinmux_lockMMR after another core calls Pinmux_unlockMMR, but before that core has finished writing its pinmux registers. This results in bad pinmux with no visible error or warning that pinmux wasn't applied. Even worse, the result is non-deterministic since small variations in core boot times affect which pinmux config gets applied and which doesn't.

Pinmux is the tip of the iceberg, as I see many soc and soc_rcm functions also lock and unlock MMRs without synchronization. It's possble that various PLL and SOC settings can also be blocked by this issue. We may have experienced this previously in an instance where the PER PLL didn't come up properly. This wasn't understood at the time, but now we believe this could have been an MMR lock issue caused by multiple cores calling lock/unlock asynchronously at boot.

As a side note the AM64x MCU+ SDK DOES use a semaphore to protect against exactly this kind of race condition in its pinmux init functions. But unfortunately that practice didn't extend to AM263P4 MCU+ SDK as of latest version v26.00.00.06.

Just passing along this information in case other people are bitten by it too.