dafna
Posts: 9
Joined: Wed Dec 20, 2017 6:55 pm

freertos for rpi without scheduler

Sat Jan 06, 2018 9:38 am

Hi,
I'm working on a port of freertos to raspberry pi https://github.com/kamomil/RaspberryPi-FreeRTOS, I want to eventually port it to pi3 on 64 bit.

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.

So I wrote a function xInitPxCurrentTCB https://github.com/kamomil/RaspberryPi- ... sks.c#L411

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: https://github.com/kamomil/RaspberryPi- ... ort.c#L110

it then enters an endless loop where it turn the green led on and off.

The code for main: https://github.com/kamomil/RaspberryPi- ... emo/main.c

I have two bugs that I couldn't figure them out:

1. 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.
2. 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.

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 3 guests