FreeRTOS library problem

Thanks Norm, all the RTOS source files have .c extensions here’s en extract from the build section of the RTOS help files:

Building the RTOS demo application
FreeRTOS V3.0.0 has replaced the batch files previously used to build the demo application with a single makefile. This was made possible by improvements in ELF and COFF format support in the later versions of WinAVR.

To build the demo application:

    Ensure that WinAVR is correctly installed and accessible from your PATH environment.

    Open a command prompt and navigate to the Demo/AVR_ATMega323_WinAVR directory.

    Type 'make' to build the project. The project should build with no errors or warnings.

    To force a complete rebuild type 'make clean'

    The optimisation level (option -O) and debug level (option -g) can be adjusted within the makefile to suit your application requirements.

The build process will generate a file called RTOSDemo.elf which is suitable for executing and debugging within the free Atmel AVR Studio IDE, and a file called RTOSDemo.hex which is suitable for burning into the processor.

Ensure the -g option is used within the makefile when generating files for debug and simulation.

I’m not sure about ELF and COFF formats, I’ll have to read up on that.

Would it be helpful if I used a different compiler perhaps? I ended up using the Atmel AVR toolchain as it was mentioned in Elliot Williams’ book you kindly pointed me at a while back.

thanks
Paul

ELF is the Linux executable file format. The compiler creates an elf file, then a utility converts it to a hex file for uploading. COFF is Microsoft’s Common Object File Format (if I remember correctly). I’m not sure if it has a place in Arduino land though!

Do you have a link to the demo you are trying to run please? I’ve got a Mega 2560 board and I’ve successfully managed to compile and run the example for the library you are using - PlatformIO Registry - after amending it so that it would compile first though. I had to ad a few bits to the top of the example file:

/*
 * Example of a basic FreeRTOS queue
 * https://www.freertos.org/Embedded-RTOS-Queues.html
 */

// Include Arduino FreeRTOS library
#include <Arduino_FreeRTOS.h>

// Include queue support
#include <queue.h>

// For PlatformIO to actually compile the demo!
// Added by Norm.
#include "Arduino.h"
void TaskAnalogRead(void *pvParameters);
void TaskSerial(void * pvParameters);
void TaskBlink(void *pvParameters);

After this, it compiled and ran successfully. This is using the 10.4.4.2 version of the library, as per the installation instructions. I notice @maxgerhardt has pointed you to a different library based on an older version of FreeRTOS.

If you let me have the URL for the demo, I might get a change to have a look see – my wife and new puppy are out for a walk at the moment so I have free time until they get back! :grin:

Cheers,
Norm.

Thanks Norm - new pups are always great, my son’s a Vet and he told us about the receptive period for training pups around 12 weeks - so if you want it to be good travelling in the car, with a hairdryer, learning things, around 12 weeks is the time to introduce it all. They do learn after that but it takes longer.

Thanks for looking at the RTOS stuff, much appreciated. I downloaded the FreeRTOS from here:

and the demo file I am using then turns up on my c: drive here:

C:\FreeRTOS\FreeRTOSv202107.00\FreeRTOS\Demo\AVR_ATMega323_WinAVR

and the file list there is:

image

I hope that points you to the demo I used

thanks again,
Paul

Interesting link you found there Norm, I hadn’t seen that on the FreeRTOS site, and there’s an ‘open in platformio IDE’

which compiler did you use?

thanks
Paul

I’m using the normal (?) GCC/G++ compilers for the AVR chips. It’s whatever downloads when I use the Arduino framework. Nothing special here. I believe it’s the same on Windows – I’m running Linux.

I’ll hopefully get a look at your FreeRTOS demo soon. (Wife and pup are home again!)

Cheers,
Norm.

The demo code for FreeRTOS/FreeRTOS/Demo/AVR_ATMega323_WinAVR at main · FreeRTOS/FreeRTOS · GitHub is meant for an ATMega323, not an ATmega2560 that you reference in the platformio.ini. The serial code references the wrong registers for your chip type which makes it non-compilable by default.

For reference I created the repository GitHub - maxgerhardt/pio-freertos-avr-port-atmega323 which compiles this exact demo project in PlatformIO for the ATMega323. It is also explalined how the project was created.

I find the description page of this AVR port much more general: FreeRTOS-Kernel/portable/ThirdParty/GCC/ATmega at main · FreeRTOS/FreeRTOS-Kernel · GitHub. This is the port you should be using instead of the ATMega323 port files, which sound very ATMega323-specific (and may only work by chance on similiar microcontrollers).

I’ve used the above port to create a bare-metal (aka, does not compile in the Arduino framework) project at GitHub - maxgerhardt/pio-freertos-avr-port. It succesfully compiles for an ATmega2560 and an ATMega328P (Arduino Uno), on which I’ve tested the project to be working. The README also describes how the project was created.

1 Like

Again, since you also reference framework = arduino in your platformio.ini you seem to be wanting to use FreeRTOS+Arduino, so I can only recommend using the afforementioned Arduino libraries (https://github.com/feilipu/Arduino_FreeRTOS_Library foremost) and writing your code around that library and the FreeRTOS functionality it offers.

Or, you can expand on the original project above.

Fun fact: The person who wrote https://github.com/feilipu/Arduino_FreeRTOS_Library is the same person who PR’ed the generic ATMega support into FreeRTOS (https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/48).

great, thanks for all the info Max, much appreciated. I watched the documentary about the 1969 moon landing last night on TV. Installing freertos seems to be more complex than that :slight_smile:

I just followed the FreeRTOS help pages - they got me to where I am, the demos are predicated on WINAVR and I didn’t want to go back to that… Perhaps the sources on github are more up to date/ focused on a specific chip/ better communicated, I’ll take a look.

From my perspective, I just wanted to try rtos out and I had an arduino mega2560 lying around doing nothing, so thought I’d use that. I don’t really care whether it’s bare bones or arduino, whatever is easiest/ works.

thanks again,
Paul