Giter VIP home page Giter VIP logo

freertos-teensy's Introduction

FreeRTOS Port for Teensy 3.5, 3.6, 4.0, 4.1

This is a basic port of FreeRTOS for the Teensy 3.5, Teensy 3.6, Teensy 4.0 and Teensy 4.1 boards.

Introduction

To make FreeRTOS work on the teensy boards I had to adjust the EventResponder class of the Teensy Arduino core library and optimized some minor parts. Therefore a custom platform setting is used (platform = https://github.com/tsandmann/platform-teensy). It uses a more recent compiler toolchain (e.g. to support C++20) and a slightly modified Arduino core library. The latter is needed because FreeRTOS needs some interrupt vectors that are also used by the Arduino core (SysTick and PendSV for EventResponder) to be set up for the RTOS. The modified core library supports these services by running them ontop of the RTOS.

Notice

Consider this as experimental code and work in progress. If it breaks, you get to keep both pieces.

Current Limitations

  • Updated libraries may cause some incompatibilities with the custom core library. More testing and documentation is needed before the custom core library change may be integrated in the official library.
  • This is a port of FreeRTOS to run its kernel on the Teensy boards. It does not include thread-safe peripheral drivers, thread-safe teensy libraries and so on! If you want to use peripherals (e.g. serial ports, I2C, SPI, etc.) from different tasks, you may have to synchronize the access. On the other hand C-library calls like malloc or free are thread-safe due to provided guards for newlib.
  • Documentation is very limited (including this readme).

PlatformIO Usage

  1. Install PlatformIO core as described here
  2. Clone this git repository: git clone https://github.com/tsandmann/freertos-teensy
  3. Open an example of the cloned repo, e.g. freertos-teensy/example/blink
  4. Select the correct project environment PlatformIO toolbar for your Teensy board, e.g. teensy41
  5. Build project: use Build button on the PlatformIO toolbar or shortcut (ctrl/cmd+alt+b)
  6. Upload firmware image
    • Connect USB cable to teensy board
    • Use Upload button on the PlatformIO toolbar or shortcut (ctrl/cmd+alt+t) and select "PlatformIO: Upload"
  7. Use a terminal program (e.g. minicom) to connect to the USB serial device
    • If you use minicom: goto Serial port setup settings and set Serial Device to your serial device (typically sth. like /dev/cu.usbmodemXXXXXXX or /dev/tty.usbmodemXXXXXXX)

Teensyduino Usage

There is a test version available which can be used with Teensyduino. If you want to try it out:

  1. Download the library here as a zip archive.
  2. In Teensyduino select "Sketch -> Include Library -> Add .ZIP Library" and specify the downloaded zip archive.
  3. Create a new sketch in Teensyduino, e.g. blink.ino.
  4. Copy the contents of main.cpp to it.
  5. Compile and upload the sketch as usual.

Currently there are the following limitations for Teensyduino projects:

  • There is no support for C++'s std::thread, std::jthread or Futures (custom compiler options for the library would be necessary which is currently not possible with arduino's IDE).
  • If the sketch (or any included library) uses the EventResponder class, the EventResponder::attachInterrupt() variant must not be used, otherwise FreeRTOS will stop working. An update of the Teenys core library is required to make this work (this Pull request needs to be merged for this).
  • For Teensy 4.x: To print useful stack traces (see void HardFault_HandlerC(unsigned int* hardfault_args) and _Unwind_Reason_Code trace_fcn(_Unwind_Context* ctx, void* depth)) in case of a crash or an exception, the code must be compiled by using the -fasynchronous-unwind-tables option to tell gcc to generate the needed unwind tables. Furthermore, an updated linker script is needed to put .ARM.exidx and .ARM.extab in the right place and some (startup) code to copy these tables into RAM. (libgcc's unwind code requires the unwind table at an address reachable by a 31-bit signed offset (+/- 0x3FFFFFFF) from executed instructions). To support call traces over C-library calls, newlib has to be compiled with -fasynchronous-unwind-tables option as well.
  • I haven't done much testing so far as I don't use Teensyduino for my projects.

Continuous Integration Tests

TBD

freertos-teensy's People

Contributors

mjs513 avatar tsandmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freertos-teensy's Issues

Platform IO SD Card Example

Hello,

I am trying to use your SD card example. However I got the error that FileImpl was not found or defined. Turns out PlatformIO for VSCode uses its own libraries rather than those used by Arduino and Teensyduino.

I was wondering do you know how to point my application to use the correct libraries? Or how do you run this? I am fine not using PlatformIO, I just want to get it running.

freertos-teensy porting for Teensyduino

Hi Timo,

following my issue on Phillip library, I move here to ask you if you think to make a version of your library that can be used in the Teensyduino environment. :-)

Thanks a lot in advance,

Guglielmo

teensy-FreeRTOS event group handler Issue when trying to use C++ Exceptions

I have been trying to add a try-catch statement to my project, so I added -fexceptions and -xc++ to my build flags to enable that functionality. However when I do that I get a compiler error from teensy-freertos:

error: invalid conversion from 'void*' to 'EventGroupHandle_t' {aka 'EventGroupDef_t*'} [-fpermissive]

Not sure what exactly this means but I haven't found anything online that would suggest that this is a larger freeRTOS issue as people have been able to enable exceptions in other vanilla freertos projects, so I thought I'd raise it here.

Issue with using PlatformIO

Error when compiling blink example:

.pio/build/teensy41/libFrameworkArduino.a(startup.c.o): In function `_sbrk':
startup.c:(.text._sbrk+0x0): multiple definition of `_sbrk'
.pio/build/teensy41/libc07/libfreertos-teensy-master.a(teensy_common.cpp.o):teensy_common.cpp:(.text._sbrk+0x0): first defined here
/home/kemal/.platformio/packages/[email protected]/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: Disabling relaxation: it will not work with multiple definitions
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy41/firmware.elf] Error 1
===============================================

Support for teensy 3.1 and 3.2

Would it be possible to make this library work on a teensy 3.1 or 3.2? Or are there limitations on this board that would keep this from working?

A thank you and a question.

Hello Timo

Many thanks for this excellent work.

Can I make a very small set of contributions in return? Would you be interested in a PR or two for extended examples? I've got networking just about running on a T4.1 using the ethernet adapter and a dedicated FreeRTOS task using PlatformIO.

Best wishes,

Jerry.

PlatformIO: Can't find 'arduino_freertos.h' when using strict library compatibility mode

Problem
When the following property is specified:
lib_compat_mode = strict

The PlatformIO library dependency resolved is unable to find the base 'arduino_freertos.h' header file.
src/main.cpp:2:12: fatal error: arduino_freertos.h: No such file or directory

Steps to reproduce:

  1. Open blink example within examples/blink
  2. Specify strict library compatibility mode within the platformio.ini file (ex: under teensy4.0)
  3. Try to build project and expect to see same error as above

Potential Solutions
I suspect the file structure used in this repo does not follow the typical 'PlatformIO library' directory structure. As such, P.IO struggles to identify the header file.

This may also be fixed by using an appropriate P.IO library dependency finder mode - however I haven't tested this fully.

Latest PULL example stdThread Hangs at runtime

commenting out task3 fixes the issues, assume this is being tested for std:async and futures. Also the serial port has been set in the code to 115200, but platformIO.ini has not set the serial port up to 115200, so default to 9600 baud

Unaligned access UsageFault

Hello, I am trying to use your port of freertos to teensy to build an acquisition system which communicates over Ethernet.
I was able to implement many functionalities without any issue. I managed to get UCP communications working without problems, analogRead from the ADC and a simple state machine, all working in separate tasks. I need to read a device attached to the SPI bus, I have tested the read/config code without freertos withou any issues. It also works in the setup() function but the moment I put the read code inside a task I get the following error:

I/O configured and initialised
Starting LTC2983
Setup of LTC2983 complete
readADC channel 1 state=5 val=-273.15
Ethernet cable is not connected.
Ethernet initialised
running FreeRTOS kernel V10.4.6.
setup(): starting scheduler...
Fault IRQ: 0x00000006
sp: 0x2021E5B0
lr: 0xFFFFFFED
stacked_r0: 0x00000000
stacked_r1: 0x00000000
stacked_r2: 0x00000001
stacked_r3: 0x403A0000
stacked_r12: 0xA5A5A5A5
stacked_lr: 0x0000B831
stacked_pc: 0x0000C4D4
stacked_psr: 0x41000000
_CFSR: 0x01000000
(UNALIGNED) Unaligned access UsageFault
_HFSR: 0x00000000
_DFSR: 0x00000000
_AFSR: 0x00000000
_BFAR: 0x00000000
_MMAR: 0x00000000
Active task (TCB): readTCfro
Active task (stack): readTCfro

And the system keeps throwing memory management errors at me.
Here is the task's code:
static void readTCfromLTC2983(void*)
{
while (true)
{
ltc.beginConversion(1);
do {
::vTaskDelay(pdMS_TO_TICKS(1'0));
} while (!ltc.isDone());
double val = ltc.readTemperature(1);
Serial.print("readADC channel 1 state=");
Serial.print(ltc.getState());
Serial.print(" val=");
Serial.println(val);
Serial.println("Reading temps");
::vTaskDelay(pdMS_TO_TICKS(500));
}
}

I have also tried to access directly the SPI directly without the library for the LTC2983 from inside the task without success. In this case the task is written as:
static void readTCfromLTC2983(void*)
{
while (true)
{
SPI.beginTransaction( SPISettings(2000000, arduino::MSBFIRST, SPI_MODE0));
digitalWrite(10, arduino::LOW);
SPI.transfer(LTC298X_SPI_WRITE);
SPI.transfer16(LTC298X_ADDR_CMD);
SPI.transfer(LTC298X_CMD_BEGIN | 1);
digitalWrite(10, arduino::HIGH);*/
::vTaskDelay(pdMS_TO_TICKS(500));
}
}
And the errors I get are these:

I/O configured and initialised
Starting LTC2983
Setup of LTC2983 complete
readADC channel 1 state=5 val=-273.15
Ethernet cable is not connected.
Ethernet initialised

running FreeRTOS kernel V10.4.6.
setup(): starting scheduler...
Fault IRQ: 0x00000005
sp: 0x202206D8
lr: 0xFFFFFFFD
stacked_r0: 0x0000000A
stacked_r1: 0x00000000
stacked_r2: 0x00000001
stacked_r3: 0x403A0000
stacked_r12: 0xA5A5A5A5
stacked_lr: 0x00000259
stacked_pc: 0x0000C58C
stacked_psr: 0x21000000
_CFSR: 0x00008200
(PRECISERR) Data bus error (address in BFAR)
(BFARVALID) Bus Fault Address Valid
_HFSR: 0x00000000
_DFSR: 0x00000000
_AFSR: 0x00000000
_BFAR: 0x403A002C
_MMAR: 0x403A002C

Active task (TCB): readTCfro
Active task (stack): readTCfro

What could be causing this behaviour? Thanks in advanced!

Linker error: can't find reference to serialEvent_default

Looks like using the latest version of freertos port to teensy is causing linker issues with finding the serialEvent function. Implementing it in a .cpp file did not seem to make a difference.

platformio file that does not work:

[env:teensy_pat]
platform               = https://github.com/tsandmann/platform-teensy.git
board                  = teensy41
framework              = arduino
lib_deps               = 
  https://github.com/tsandmann/freertos-teensy
  SPI
  https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library.git
  https://github.com/PaulStoffregen/Time.git#a18e50dcea4ee17285d732d39e7bc559482d1d3d

platformio file that does work (hammering the commit)

[env:teensy_pat]
platform               = https://github.com/tsandmann/platform-teensy.git
board                  = teensy41
framework              = arduino
lib_deps               = 
  https://github.com/tsandmann/freertos-teensy#379d9b5ad82f8c1be995f95add3fd32bb3add2c1
  SPI
  https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library.git
  https://github.com/PaulStoffregen/Time.git#a18e50dcea4ee17285d732d39e7bc559482d1d3d

Linker error:

Indexing .pio/build/teensy_pat/libFrameworkArduino.a
Linking .pio/build/teensy_pat/firmware.elf
/home/vagrant/.platformio/packages/toolchain-arm-cortexm-linux/bin/../lib/gcc/arm-cortexm7f-eabi/12.2.0/../../../../arm-cortexm7f-eabi/bin/ld: .pio/build/teensy_pat/lib953/libfreertos-teensy.a(teensy_4.cpp.o): in function `_ZN8freertos5yieldEv':
teensy_4.cpp:(.flashmem+0x100): undefined reference to `_ZN8freertos20_serialEvent_defaultE'
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy_pat/firmware.elf] Error 1

Volatile Error On Compilation Fix

HI can you apply this mod to your freeRTOS implementation, as the warning messages become a bit annoying , when trying to find your own issues and warning when compiling,. The following small change just sorts this out, with the compiler you are using. There are also a few other warnings that need to be addressed

class CrashReportClass: public Printable {
public:
virtual size_t printTo(Print& p) const;
void clear();
operator bool();
void breadcrumb(unsigned int num, unsigned int value) {
// crashreport_breadcrumbs_struct occupies exactly 1 cache row
volatile struct crashreport_breadcrumbs_struct *bc =
(struct crashreport_breadcrumbs_struct *)0x2027FFC0;
if (num >= 1 && num <= 6) {
num--;
bc->value[num] = value;
// volatile depreciation fix, suggestion is to not use |=
// doing it this way cleans up the compilation errors, and makes it easier to read
// or find your own errors in your owen projects
bc->bitmask = (bc->bitmask | (1 << num));
// bc->bitmask |= (1 << num);
arm_dcache_flush((void *)bc, sizeof(struct crashreport_breadcrumbs_struct));
}
}
};

analogWriteResolution(12), freezes the task and stop the PWM

Hello,
Teensy 4.0
TeensyDuino 157
Frequency 600 MHz

I encounter a problem using PWMServo and investigating in the code, I discovered that the call to analogWriteResolution(12)causes the calling task to freeze and the PWM to stop. Additionnaly, the orange LED is blinking 4 times every 4 sec. Don't what could it mean.

Here is my code:

#include <Arduino.h>
#include "arduino_freertos.h"
#include <PWMServo.h>

#define Serial Serial

#define SERVO_PWM              2
#define CYCLE_TIME                3

PWMServo myServo;
int8_t cycle;

static void task_ICM( void *) {

  for (;;) {
    cycle = !cycle;
    digitalWriteFast(CYCLE_TIME, cycle);

    uint32_t oldres = analogWriteResolution(12);
    analogWrite(SERVO_PWM, 301);
    analogWriteResolution(oldres);

    ::vTaskDelay(1);
  } // For ever   
}

void setup()
{
  pinMode(CYCLE_TIME,arduino::OUTPUT);  //cycle time measure
  pinMode(SERVO_PWM,arduino::OUTPUT);  //Servo PWM
  
  Serial.begin(115200); // Start the serial console
  while (Serial.available()) // Make sure the serial RX buffer is empty
    Serial.read();

  delay(100);

  // Initialize Servo
  myServo.attach(SERVO_PWM);
  Serial.println("Calling Servo.write()");
  myServo.write(90); // Works fine here
  
  Serial.println();
  Serial.println(PSTR("Configuration complete!"));

  arduino::Serial.println(PSTR("\r\nrunning FreeRTOS kernel " tskKERNEL_VERSION_NUMBER "."));
  ::xTaskCreate(task_ICM, "task_ICM", 2048, nullptr, tskIDLE_PRIORITY + 0, nullptr);
  ::vTaskStartScheduler();
}

void loop()  { }

I already looked for info on FreeRTOS forum without success.
Any idea about what could cause this problem?

Failure to run __libc_init_array when using GCC 11.3.1 on Teensy 4.1

I am building a project for Teensy4.1 on platformio. I have created a very basic project, although I'm not even getting to main() (and of course setup()). Whenever I include this project, the startup code will not get past
__libc_init_array();
in the startup file. I have tried with the latest gcc 11.3.1 xpack as well as the standard teensy platform compiler (5.4.1).

It seems to be dying when it tries to call the function in the init_array_start vector assigned to eh_alloc.c. This seems to be related to exception handlers although I have -fno-exceptions as a build flag set.

Compiler error when using LTO

From commit 9b7ab75 onwards I receive the following error message the moment I try to use any of the LTO compiler flags defined in https://docs.platformio.org/en/latest/platforms/teensy.html#optimization

Linking .pio/build/teensy40/firmware.elf
/tmp/cclcmWf4.s: Assembler messages:
/tmp/cclcmWf4.s:706: Error: symbol `_MSP' is already defined
make: *** [/tmp/ccllgz6G.mk:2: /tmp/ccMTmdkH.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/home/elizabeth/.platformio/packages/toolchain-arm-cortexm-linux/bin/../lib/gcc/arm-cortexm7f-eabi/11.1.0/../../../../arm-cortexm7f-eabi/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy40/firmware.elf] Error 1

I can use any other optimization with the LTO attribute without problems.

#include "arduino_freertos.h" breaks other libraries that use the arduino namespace

I'm working on a project that requires an RTOS and the FlexCAN_T4 library, and I noticed some strange behaviour with the library. First I tried just adding freetos-teensy to my lib_deps and manually importing the headers and setting up freeRTOS tasks but I noticed when i did things that way, my program only worked if I had the serial monitor open. I messed around with it for some time, and wasn't making any progress, so I removed my program entirely, copied the blink example from this library, and that proceeded to work without the serial monitor open, so I told myself I'd just start from this example instead and went to move over my CAN bus usage. However, after adding declaring my FlexCAN object, the program wouldn't compile since the FlexCAN library uses many of the arduino namespace defines and I get this kind of error:
I'm working on a project that requires an RTOS and the FlexCAN_T4 library, and I noticed some strange behaviour with the library. First I tried just adding freetos-teensy to my lib_deps and manually importing the headers and setting up freeRTOS tasks but I noticed when i did things that way, my program only worked if I had the serial monitor open. I messed around with it for some time, and wasn't making any progress, so I removed my program entirely, copied the blink example from this library, and that proceeded to work without the serial monitor open, so I told myself I'd just start from this example instead and went to move over my CAN bus usage. However, after adding declaring my FlexCAN object, the program wouldn't compile since the FlexCAN library uses many of the arduino namespace defines and I get this kind of error:

.pio\libdeps\teensy41\FlexCAN_T4/FlexCAN_T4FD.tpp:810:53: error: 'HEX' was not declared in this scope; did you mean 'arduino::HEX'?

Here is my original program where I didn't have issues compiling, but the program wouldn't work unless the serial monitor was open:

#include <Arduino.h>
#include <FlexCAN_T4.h>
#include "arduino_freertos.h"
#include "avr/pgmspace.h"

FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> Can0;


// put function declarations here:
void canSniff(const CAN_message_t &msg);
static void task1(void*);

void setup() {
  Serial.begin(250000);
  Can0.begin();
  Can0.setBaudRate(500000);
  Can0.setMaxMB(64);
  Can0.enableFIFO();
  Can0.enableMBInterrupt(FIFO);
  Can0.enableFIFOInterrupt();
  Can0.onReceive(canSniff);
  pinMode(arduino::LED_BUILTIN, arduino::OUTPUT);
  if (CrashReport) {
        ::Serial.print(CrashReport);
        ::Serial.println();
        ::Serial.flush();
    }
  Serial.println(PSTR("\r\nBooting FreeRTOS kernel " tskKERNEL_VERSION_NUMBER ". Built by gcc " __VERSION__ " (newlib " _NEWLIB_VERSION ") on " __DATE__ ". ***\r\n"));
  xTaskCreate(task1, "task1", 128, nullptr, 2, nullptr);
  Serial.println("setup(): starting scheduler...");
  vTaskStartScheduler();

}

void loop() {
 
}
void canSniff(const CAN_message_t &msg) {
  Serial.print(msg.id);
  Serial.print(" ");
  for ( uint8_t i = 0; i < msg.len; i++ ) {
    Serial.print(msg.buf[i]); Serial.print(" ");
  } Serial.println();
}


static void task1(void*) {
    while (true) {
        ::digitalWriteFast(arduino::LED_BUILTIN, arduino::LOW);
        ::vTaskDelay(pdMS_TO_TICKS(500));

        ::digitalWriteFast(arduino::LED_BUILTIN, arduino::HIGH);
        ::vTaskDelay(pdMS_TO_TICKS(500));
    }
}

and here is the program in which it refuses to compile due to namespace issues (just the blink example with my object declaration added):


#include "arduino_freertos.h"
#include "Arduino.h"
#include <FlexCAN_T4.h>
#include "avr/pgmspace.h"


namespace arduino{
    FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> Can0;
}


static void task1(void*) {
    while (true) {
        ::digitalWriteFast(arduino::LED_BUILTIN, arduino::LOW);
        ::vTaskDelay(pdMS_TO_TICKS(500));

        ::digitalWriteFast(arduino::LED_BUILTIN, arduino::HIGH);
        ::vTaskDelay(pdMS_TO_TICKS(500));
    }
}

static void task2(void*) {
    while (true) {
        ::Serial.println("TICK");
        ::vTaskDelay(pdMS_TO_TICKS(1'000));

        ::Serial.println("TOCK");
        ::vTaskDelay(pdMS_TO_TICKS(1'000));
    }
}

FLASHMEM __attribute__((noinline)) void setup() {
    ::Serial.begin(250000);
    ::pinMode(arduino::LED_BUILTIN, arduino::OUTPUT);
    ::digitalWriteFast(arduino::LED_BUILTIN, arduino::HIGH);

    ::delay(5'000);

    if (CrashReport) {
        ::Serial.print(CrashReport);
        ::Serial.println();
        ::Serial.flush();
    }

    ::Serial.println(PSTR("\r\nBooting FreeRTOS kernel " tskKERNEL_VERSION_NUMBER ". Built by gcc " __VERSION__ " (newlib " _NEWLIB_VERSION ") on " __DATE__ ". ***\r\n"));

    ::xTaskCreate(task1, "task1", 128, nullptr, 2, nullptr);
    ::xTaskCreate(task2, "task2", 128, nullptr, 2, nullptr);

    ::Serial.println("setup(): starting scheduler...");
    ::Serial.flush();

    ::vTaskStartScheduler();
}

void loop() {}

Teensy 4 compile error due to missing symbol

From cd38223 onward the compiler will throw:

Linking .pio/build/teensy40/firmware.elf
/home/elizabeth/.platformio/packages/toolchain-arm-cortexm-linux/bin/../lib/gcc/arm-cortexm7f-eabi/11.1.0/../../../../arm-cortexm7f-eabi/bin/ld: .pio/build/teensy40/libb49/libfreertos-teensy.a(teensy_4.cpp.o): in function `vPortSetupTimerInterrupt':
teensy_4.cpp:(.flashmem+0x25c): undefined reference to `unused_interrupt_vector'
collect2: error: ld returned 1 exit status
*** [.pio/build/teensy40/firmware.elf] Error 1

I assume it is due to the introduction of unused_interrupt_vector as an external void in the file src/portable/teensy_4.cpp without mentioning it anywhere else in the code except in vPortSetupTimerInterrupt

How to add new libraries to project

I am trying to use freertos with the SD.h library. When I add the include statement I get the following error.

Compiling .pio/build/teensy41/src/main.cpp.o
src/main.cpp:23:10: fatal error: SD.h: No such file or directory
************************************************************
* Looking for SD.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SD.h"
* Web  > https://platformio.org/lib/search?query=header:SD.h
*
************************************************************
   23 | #include < SD.h>
      |          ^~~~~~
compilation terminated. 

When I change the platform variable in platformio.ini to from https://github.com/tsandmann/platform-teensy.git
to teensy I fix this dependency issue, however, then all of the freertos libraries will have a similar error. How can I set up my
project so that I can use all the needed libraries?

Can't use std::mutex in PlatformIO library.

Problem:

When creating source files inside the PlatformIO "lib" folder, std::mutex and also std::condition_variable can not be used.
Building a project with the follówing code inside lib/testlib/testlib.cpp

#include "testlib.hpp"

#include <mutex>

void testfunc()
{
    static std::mutex m;
}

fails with
lib\testlib\testlib.cpp:8:15: error: 'mutex' in namespace 'std' does not name a type

I'm guessing there is some kind of include path missing?
The platformio.ini file looks like this:

[env:teensy40]
platform = https://github.com/tsandmann/platform-teensy.git
board = teensy40
framework = arduino
lib_deps =
    https://github.com/tsandmann/freertos-teensy.git
build_flags = -Wformat=1 -DTEENSY_OPT_FASTER_LTO
build_unflags = --specs=nano.specs
upload_flags = -v
upload_protocol = teensy-cli

PlatformIO's verbose Output shows the following:

Processing teensy40 (platform: https://github.com/tsandmann/platform-teensy.git; board: teensy40; framework: arduino; lib_deps: https://github.com/tsandmann/freertos-teensy.git; build_flags: -Wformat=1 -DTEENSY_OPT_FASTER_LTO; build_unflags: --specs=nano.specs; upload_flags: -v; upload_protocol: teensy-cli)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PlatformIO running on windows_amd64
CONFIGURATION: https://docs.platformio.org/page/boards/teensy-ts/teensy40.html
PLATFORM: Teensy (4.17.0+sha.b92da4f) (git+https://github.com/tsandmann/platform-teensy.git) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy @ 1.157.1+sha.704a666 (git+https://github.com/tsandmann/teensy-cores.git#no_warnings) 
 - framework-arduinoteensy @ 1.157.220801 (1.57) 
 - tool-teensy @ 1.157.0 (1.57)
 - toolchain-arm-cortexm-win64 @ 12.2.0-3+sha.b1c22e4 (git+https://github.com/tsandmann/arm-cortexm-toolchain-win64.git)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 94 compatible libraries
Scanning dependencies...
Dependency Graph
|-- freertos-teensy @ 10.5.1-5+sha.b419f64 (License: MIT, URI: git+https://github.com/tsandmann/freertos-teensy.git, Path: C:\Users\tom\Documents\PlatformIO\Projects\teensy4_libtests\.pio\libdeps\teensy40\freertos-teensy)
|   |-- SdFat @ 2.1.2 (License: MIT, Path: C:\Users\tom\.platformio\packages\framework-arduinoteensy\libraries\SdFat)
|   |   |-- SPI @ 1.0 (License: Unknown, Path: C:\Users\tom\.platformio\packages\framework-arduinoteensy\libraries\SPI)
|   |-- SPI @ 1.0 (License: Unknown, Path: C:\Users\tom\.platformio\packages\framework-arduinoteensy\libraries\SPI)
|   |-- Wire @ 1.0 (License: Unknown, Path: C:\Users\tom\.platformio\packages\framework-arduinoteensy\libraries\Wire)
|-- testlib (License: Unknown, Path: C:\Users\tom\Documents\PlatformIO\Projects\teensy4_libtests\lib\testlib)
Building in release mode
arm-cortexm7f-eabi-g++ -o .pio\build\teensy40\libb4a\testlib\testlib.cpp.o -c -fno-exceptions -fno-non-call-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -felide-constructors -fno-rtti -std=gnu++20 -Wno-error=narrowing -fpermissive -Wformat=1 -Wall -Wextra -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m7 -fsingle-precision-constant -mfloat-abi=hard -mfpu=fpv5-d16 -O2 -flto -fipa-pta -DPLATFORMIO=60106 -D__IMXRT1062__ -DARDUINO_TEENSY40 -DTEENSY_OPT_FASTER_LTO -DUSB_SERIAL -DARDUINO=10819 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=600000000 -DLAYOUT_US_ENGLISH -Ilib\testlib -IC:\Users\tom\.platformio\packages\framework-arduinoteensy@src-ec76f8a486a2c31ea130ab62366da5c5\teensy4 lib\testlib\testlib.cpp
lib\testlib\testlib.cpp: In function 'void testfunc()':
lib\testlib\testlib.cpp:7:17: error: 'mutex' in namespace 'std' does not name a type
    7 |     static std::mutex m;
      |                 ^~~~~
lib\testlib\testlib.cpp:2:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
    1 | #include "testlib.hpp"
  +++ |+#include <mutex>
    2 |
*** [.pio\build\teensy40\libb4a\testlib\testlib.cpp.o] Error 1

I need std::thread, std::mutex, etc. support for including an external library so any help is appreciated!

Compile error on timeval freertos::clock::offset_ in teensy.h

Hello there.

I am, whenever using the #include <freertos_arduino.h>, getting the follow error:
Arduino\libraries\freertos-teensy\src/arduino_freertos.h:222:0,
sketch_mar28a.ino:26: (Note, the mistake is at whatever line the first command is called)
\Arduino\libraries\freertos-teensy\src/portable/teensy.h:138:40: error: 'offset_' declared as an 'inline' field
static inline timeval offset_ {0, 0};
^
arning: 'constexpr' needed for in-class initialization of static data member 'timeval freertos::clock::offset_' of non-integral type [-fpermissive]
This error code comes from the main.ccp. In my own sketch, I get the issue at line 1, as the #include is at line 1.

If I comment out the freertos_arduino, from my code, looking like this:
`#include <arduino_freertos.h>
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>

#define sample_rate_hz 80000
#define sample_period (10000000/sample_rate_hz)
#define buffer_size 1024

const int analogPin = A0;
uint16_t buffer[buffer_size];
uint16_t buffer_index = 0;
QueueHandle_t adc_queue;

void setup(){

}

void loop(){

}`

The error code I get then:

In file included from c:\Users\soren\OneDrive\Documents\Arduino\libraries\freertos-teensy\src\portable\event_responder_support.cpp:27:0:
c:\Users\soren\OneDrive\Documents\Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: error: 'offset_' declared as an 'inline' field
static inline timeval offset_ {0, 0};
^
Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: warning: 'constexpr' needed for in-class initialization of static data member 'timeval freertos::clock::offset_' of non-integral type [-fpermissive]
In file included from Arduino\libraries\freertos-teensy\src\portable\teensy_4.cpp:32:0:
Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: error: 'offset_' declared as an 'inline' field
static inline timeval offset_ {0, 0};
^
Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: warning: 'constexpr' needed for in-class initialization of static data member 'timeval freertos::clock::offset_' of non-integral type [-fpermissive]
In file included from Arduino\libraries\freertos-teensy\src\portable\teensy_common.cpp:39:0:
Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: error: 'offset_' declared as an 'inline' field
static inline timeval offset_ {0, 0};
^
Arduino\libraries\freertos-teensy\src\portable\teensy.h:138:40: warning: 'constexpr' needed for in-class initialization of static data member 'timeval freertos::clock::offset_' of non-integral type [-fpermissive]

While the program is short and not saying much, I've been busy trying to troubleshoot the teensy.h issue, without any results, before continuing.

Any help is appreciated.

Changing FreeRTOS Tick rate

I wanted to run the freeRTOS port with a tick rate of 10kHZ. Do I need to change anything else except the

#define configTICK_RATE_HZ ( (TickType_t) 10000 )

in FreeRTOSConfig.h?

reent.h missing

Hello,

I cloned your master branch, opened the folder in VS Code. I have also tried opening only the example blink as a PIO project. In both cases the reent.h file is missing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.