kafna wrote on Saturday, January 06, 2018:
Hi,
I’m working on a port of freertos to raspberry pi , I want to eventually port it to pi3 on 64 bit.
The code of pxPortInitialiseStack , portRESTORE_CONTEXT and portSAVE_CONTEXT is identical to the port for GCC/ARM7_AT91FR40008
I added uart driver with an intrrupt handler that works , and I want to start by porting only the uart driver. So I don’t want to enable the timer interrupt and the scheduler, instead I want to run an endless loop in main function.
I wrote a function xInitPxCurrentTCB
which initialize pxCurrentTCB since it is used to save the sp register in context switch.
The main function initializes the uart, then calls xInitPxCurrentTCB and then enables the interrupts.
It also initialize the spsr register to 0x1f as this is the initial value set in the function pxPortInitialiseStack
it then enters an endless loop where it turn the green led on and off.
The code for main.
I have two bugs that I couldn’t figure them out:
- If I don’t initialize the spsr register, then upon sending rx to the uart, the main function then starts from it’s beginning after the interrupt handler returns instead of continuing from somewhere in the endless loop where the interrupt fired.
- If do initalize the spsr in the main function with:
__asm volatile("nop");
__asm volatile ("push {r0}");
__asm volatile ("mov r0, #31");
__asm volatile ("msr spsr_cxsf, r0");
__asm volatile ("pop {r0}");
Then it seems that there is a contraption , as the green led stop blinking.