Part Number: AM2434
Other Parts Discussed in Thread: SYSCONFIG
We are seeing a stability issue when using LwIP (CPSW) with FreeRTOS on AM2434 (MCU+ SDK). Under heavy RX traffic, the system frequently stops in an assert inside LwIP’s FreeRTOS port:
sys_arch.c (around line 191)
LWIP_ASSERT("unexpected sys_arch_protect_nesting", sys_arch_protect_nesting > 0);
Observed behavior
- The issue reproduces even with low RX load; the probability of hitting the assert increases with RX traffic volume.
- The assert indicates that sys_arch_unprotect() is being called when sys_arch_protect_nesting is already 0 (i.e., the nesting counter appears to go out of sync).
- We reviewed the call flow and also checked the generated assembly around the increment/decrement, but it seems ok.
- Another possibility is an extra unprotect, but when tracing sys_arch_protect() / sys_arch_unprotect() and monitoring sys_arch_protect_nesting , everything looks consistent until the point where the counter becomes inconsistent.
Workaround / mitigation
We tried to guard the increment/decrement of sys_arch_protect_nesting with a critical section and taking care of cache coherency but no luck. We were able to eliminate the issue by changing the macro:
LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX = 0
With this setting, the port uses a critical section (interrupt masking up to syscall priority) instead of a mutex for sys_arch_protect() / sys_arch_unprotect() . Given that these protect/unprotect regions are typically small and frequent, we also suspect the mutex-based approach may add unnecessary overhead and additional context-switch complexity under load.
Questions
- Is this a known issue in the MCU+ SDK LwIP FreeRTOS port for AM243x?
- Is setting LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX to 0 considered a correct/endorsed solution, or is there a recommended fix/patch/configuration we should apply instead?
- Are there specific LwIP/FreeRTOS configuration constraints (e.g., priority settings, interrupt priorities, cache coherency expectations) that could lead to this behavior?
File references
- source/networking/lwip/lwip-port/freertos/src/sys_arch.c
- source/networking/lwip/lwip-port/freertos/include/lwipopts_os.h
Development environment
- MCU+ SDK: 11.00.00.15
- Compiler: TI ARM CLANG 4.0.4 LTS
- SysConfig: 1.26.0
- CCS: 20.40
- Device: AM2434 (Cortex-R5F_0-0)