Hi.
We were forced to update portASM.asm and portmacro.h from our previous version because it caused issues with some features (xWaitTaskNotify) in special cases. The update seemed to work fine when flashing directly to the MCU (without any code offset for bootloader). However, when compiled for bootloading and bootloaded the FW execution hangs (hard to say where since bootloaded).
Our main difference which causes the hanging is the following:
Old version:
//-----------the following is in portmacro.h
extern void vPortEnterCritical(void); extern void vPortExitCritical(void); #define portENTER_CRITICAL() vPortEnterCritical() #define portEXIT_CRITICAL() vPortExitCritical() #define portDISABLE_INTERRUPTS() asm( " CPSID I" ) #define portENABLE_INTERRUPTS() asm( " CPSIE I" ) //--------------------------the following is in port.c /* * Disable interrupts, and keep a count of the nesting depth. */ void vPortEnterCritical( void ) { /* Disable interrupts as per portDISABLE_INTERRUPTS(); */ portDISABLE_INTERRUPTS(); /* Now interrupts are disabled ulCriticalNesting can be accessed directly. Increment ulCriticalNesting to keep a count of how many times portENTER_CRITICAL() has been called. */ ulCriticalNesting++; } /*-----------------------------------------------------------*/ /* * Decrement the critical nesting count, and if it has reached zero, re-enable * interrupts. */ void vPortExitCritical( void ) { if( ulCriticalNesting > 0 ) { /* Decrement the nesting count as we are leaving a critical section. */ ulCriticalNesting--; /* If the nesting level has reached zero then interrupts should be re-enabled. */ if( ulCriticalNesting == 0 ) { /* Enable interrupts as per portENABLE_INTERRUPTS(). */ portENABLE_INTERRUPTS(); } } }
in the new version this is replaced by:
//-------------this is in portmacro.h
#pragma SWI_ALIAS(vPortEnterCritical, 2)
extern void vPortEnterCritical(void);
#pragma SWI_ALIAS(vPortExitCritical, 3)
extern void vPortExitCritical(void);
#pragma SWI_ALIAS(vPortDisableInterrupts, 5)
extern void vPortDisableInterrupts( void );
#pragma SWI_ALIAS(vPortEnableInterrupts, 6)
extern void vPortEnableInterrupts( void );
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
#define portDISABLE_INTERRUPTS() vPortDisableInterrupts()
#define portENABLE_INTERRUPTS() vPortEnableInterrupts()
//--------and the complementary part in portASM.asm
table
.word jumpTable
jumpTable
.word swiPortYield ; 0 - vPortYieldProcessor
.word swiRaisePrivilege ; 1 - Raise Priviledge
.word swiPortEnterCritical ; 2 - vPortEnterCritical
.word swiPortExitCritical ; 3 - vPortExitCritical
.word swiPortTaskUsesFPU ; 4 - vPortTaskUsesFPU
.word swiPortDisableInterrupts ; 5 - vPortDisableInterrupts
.word swiPortEnableInterrupts ; 6 - vPortEnableInterrupts
.endasmfunc
;-------------------------------------------------------------------------------
; swiPortDisableInterrupts
.asmfunc
swiPortDisableInterrupts
mrs r11, SPSR
orr r11, r11, #0x80
msr SPSR_c, r11
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; swiPortEnableInterrupts
.asmfunc
swiPortEnableInterrupts
mrs r11, SPSR
bic r11, r11, #0x80
msr SPSR_c, r11
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; swiPortTaskUsesFPU
.asmfunc
swiPortTaskUsesFPU
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; swiRaisePrivilege
; Must return zero in R0 if caller was in user mode
.asmfunc
swiRaisePrivilege
mrs r12, spsr
ands r0, r12, #0x0F ; return value
orreq r12, r12, #0x1F
msreq spsr_c, r12
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; swiPortEnterCritical
.asmfunc
swiPortEnterCritical
mrs r11, SPSR
orr r11, r11, #0x80
msr SPSR_c, r11
ldr r11, ulCriticalNestingConst
ldr r12, [r11]
add r12, r12, #1
str r12, [r11]
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; swiPortExitCritical
.asmfunc
swiPortExitCritical
ldr r11, ulCriticalNestingConst
ldr r12, [r11]
cmp r12, #0
bxeq r14
subs r12, r12, #1
str r12, [r11]
bxne r14
mrs r11, SPSR
bic r11, r11, #0x80
msr SPSR_c, r11
bx r14
.endasmfunc
;-------------------------------------------------------------------------------
; SetRegion
I am not an expert in asm. Thus i asume that the asm functions might map something differently, which causes issues when bootloading. Any suggestion would be helpful as to why this is happening and how to fix it.
We are running TMS570LS0332 MCU.
Thanks in advance.