Chuyển tới nội dung
Home » Freertos Esp8266 Arduino Ide | List Of Basic Libraries To Test And Fix

Freertos Esp8266 Arduino Ide | List Of Basic Libraries To Test And Fix

FreeRTOS with ESP32 using Arduino IDE

FreeRTOS Introduction

Unlike typical real-time operating systems, FreeRTOS is specially designed for microcontrollers. Because Microcontrollers come with limited resources, therefore, we need an operating system as per the available resources of microcontrollers. It is an open-source Kernel that means it can download free of cost and be used in RTOS-based applications. Although, it has two commercial variants also such as OpenRTOS and SafeRTOS.

As we mentioned earlier, by using FreeRTOS, we can make sure that each task of Arduino will have a deterministic execution pattern and every task will meet its execution deadline. In other words, it is a scheduler that assigns Arduino CPU resources to every task according to a scheduling algorithm. The real-time operating system has different scheduling algorithms such as:

  • Difference Between Preemptive and Non-Preemptive Scheduling
  • What is a Scheduling Algorithm
  • Rate Monotonic Scheduling
  • Earliest Deadline First
  • Least Laxity First

FreeRTOS Features

Followings are the main kernel features:

  • Fixed Priority Preemptive Time slicing Scheduler
  • Inter-Process Communication through Queues
  • Tasks Management such as Task priority setting, task suspension, task deletion, and Task delay
  • Tasks Synchronization with Gatekeeper Tasks, Semaphore, and Mutex
  • Timing measurement hook
  • Run time Tracing hooks
  • Software timers management
  • Interrupt management

FreeRTOS Task Management

In a multitasking system, an application can consist of many tasks. If we are using a single-core processor, then only one task can run on the processor at any given time. Hence, only one task will be in the running state and all other tasks will be in the not running state. That means, in RTOS based applications, tasks can be either in running state or not running state.

The running state of a task can be further divided into three sub-states such as blocked state, ready state, and suspended state. The figure below shows the transition lifetime of a task in a multitasking system.

FreeRTOS with ESP32 using Arduino IDE
FreeRTOS with ESP32 using Arduino IDE

How to use FreeRTOS with Arduino?

The RTOS used in this project is FreeRTOS. FreeRTOS is developed by Real Time Engineers Ltd. It is an open-source popular Real-Time Operating System kernel. Furthermore, it is used for embedded devices which as microcontrollers, Arduino. It is mostly written in C but some functions are written in assembly. There are also SafeRTOS and OpenRTOS available online which are similar to FreeRTOS.

Download and Install FreeRTOS in Arduino IE

First, you need to download and install FreeRTOS in Arduino IDE. But if you did not use Arduino IDE before, you should go through the following tutorial:

Getting Started with Arduino IDE

After that go to this GitHub link and download the FreeRTOS library:

After downloading the FreeRTOS library, extract the folder and paste this extracted folder in the Arduino IDE libraries folder as shown below:

FreeRTOS library can also be installed directly through the Arduino Library Manager. For this, open Arduino IDE and go to Sketch>>”Include Library” and click on Manage libraries.

After that, type “FreeRTOS in the search window, this library will appear. After that click on the install button.

FreeRTOS Tasks States

Blocked State

A task can be in a blocked state due to many reasons. For example, a task is delayed due to the periodic nature of the task and it will become available periodically after every specified delay. Another reason could be due to interrupt waiting or resource waiting. A task is waiting for the external interrupt or a resource such as binary semaphore, counting semaphore, and a mutex.

Suspended State

A suspended state is also a substrate of a not-running task. The application programmer can suspend the task by using vTaskSuspend() FreeRTOS API function and resume the task using vTaskResume() API function.

Note: The tasks in blocked or suspended states can not be scheduled by a scheduler.

Ready State

If a task is not in either a blocked or suspended state, it will be in a ready state. Tasks that are in a ready state, are ready for execution as soon as the processor picks them according to a scheduling policy.

Whenever a task makes the transition from a running state to a not-running state, a context switch happens. That means, it saves its registers values, temporary variable values, etc into its task control block, and next time when it will enter the running state again, it will start execution from the same point where it left the execution. To start execution from the same location, it will again load values from TCB into processor registers.

What is FreeRTOS? (ESP32 + Arduino series)
What is FreeRTOS? (ESP32 + Arduino series)

Hello,
On ESP32, framework=Arduino, the main loop runs on top of FreeRTOS, whose features can basically be used freely.
On ESP8266 there’s an Arduino framework and a separate FreeRTOS framework. Is there any way to combine the two?

Background: I have this program here which uses both Arduino- and FreeRTOS-style code quite freely. It works on ESP32, but I need to run it (or as much of it as will fit) on an ESP8266.

The fact that there even is a separate SDK for it is rather annoying IMHO. If you want a sustainable ecosystem, you create one SDK. Then you write an open-source shim layer to adapt it to FreeRTOS mainline (where necessary) / add support for it to FreeRTOS mainline (where possible).

Presto, somebody else can do the same thing for any other RTOS.

Actually, now that I think of it, right now my best bet (assuming I want to spend that much effort, which is still up in the air) seems to be to replace the FreeRTOS-specific bits and pieces in the code I’m adapting with RIOT-specific bits and pieces. RIOT has an Arduino shim, so it’ll support the Arduino-ish parts without ripping those out also, and it runs on top of FreeRTOS (ESP32) as well as on bare metal (ESP8266). The problem is that platformio doesn’t support it (yet(?)); see RIOT-OS support · Issue #3456 · platformio/platformio-core · GitHub

Hi! here an update, I recently published an arduino core for esp8266 based on RTOS_SDK (GitHub – espressif/ESP8266_RTOS_SDK: Latest ESP8266 SDK based on FreeRTOS, esp-idf style.), it is a lightweight version of FreeRTOS maintained by espressif that shares idf framework with FreeRTOS for esp32. The project is still in development, but for now you can use the FreeRTOS concurrency tools, basic esp32 arduino core Wifi libraries such as WebServer or HttpClient and others such as ESP32Time using the Arduino environment to develop and install your sketchs on an esp8266.

ESP8266RTOSArduCore

Arduino core for ESP8266_RTOS_SDK, a light version of FreeRTOS, supported by espressif.

RTO_SDK share the same framework with esp-idf [https://github.com/espressif/esp-idf], so this project is based on esp32 arduino core [https://github.com/espressif/arduino-esp32], (version 1.0.6), to provide compatibility between esp32 arduino libraries and this core.

Branchs

  • main: lastest release version.
  • stable: stable version with some update ahead of main branch to test and fix.
  • develop: development branch to merge new features before to pull to stable version.

Index

  • Features
  • Installation:
  • Examples
  • Limitations
  • To Do List
  • List of remaining core files to adapt test and fix
  • List of remaining basic libraries to Test and fix
  • Links of interest

Features

  • Provides FreeRtos concurrency utilities.
  • Share framework with esp32 arduino core.
  • Compatibility with esp32 arduino libraries.
  • Easy installation with arduino board manager.
  • Include WrapperFreeRTOS library to implement concurrent objects.
  • Include EmbeddedMqttBroker library like mqtt broker.

Installation

RTOS Introduction

A Real Time Operating System is also known as RTOS is an operating system which is intended to fulfill the requirement of real time application. It is able to process data as comes in, typically without buffering delays. RTOS is the combination of calling predefined functions.

The key factors in Real Time Operating Systems are minimum interrupt latency and minimum threads switching latency. The Real Time Operating System is valued more for how quickly and how predictably it responds to complete the tasks in a given period of time.

There are three types of RTOS:1. Hard RTOS; bound to complete a task within a given deadline2. Firm RTOS; bound of a deadline but if they miss the deadline it is acceptable but not in the case of Hard RTOS.3. Soft RTOS; not bound by any deadline.

LynxOS, RTLinux, VxWorks, FreeRTOS, OSE, QNX, Windows CE

RTOS Features

When we write good embedded software for Arduino we do not need FREERTOS but when its complexity and size increases FreeRTOS is always beneficial for the reasons listed below:

  • Abstract out timing information
  • Maintainability/Extensibility
  • Modularity
  • Cleaner interfaces
  • Easier testing (in some cases)
  • Code reuse
  • Improved efficiency
  • Idle time
  • Flexible interrupt handling
  • Mixed processing requirements
  • Easier control over peripherals

RTOS Cons

These are the advantages of using RTOS but there are also some disadvantages listed below:

  • Low Priority Tasks
  • Precision of code
  • Limited Tasks
  • Complex Algorithms
  • Device driver and interrupt signals
  • Thread Priority
  • Expensive
  • Not easy to program

To explore further, you can read this post:

How to Multitask with FreeRTOS (ESP32 + Arduino series)
How to Multitask with FreeRTOS (ESP32 + Arduino series)

How to Create Tasks in FreeRTOS?

Multitasking benefits can be achieved only by performing every execution with the help of tasks. For instance, in your Arduino project, you want to measure temperature and want to display its value on LCD. We can divide this project into three tasks such as:

  • Read Arduino ADC Value
  • Converter ADC Value into Temperature
  • Print Temperature on LCD

In this way, we can also assign, priority to each task according to the critical nature of the task. For example, ADC value reading is the most important, and printing temperature value on LCD is the least important task. Hence, we can assign the highest priority to the ADC task and the lowest to the LCD task.

FreeRTOS task Creation

xCreateTask function is used to create tasks and adds them to the ready queue. It takes 5 arguments as inputs to define various features of the task


xTaskCreate(MyTask_pointer, "task_name", 100, Parameter, Priority, TaskHandle);

Pointer to Task Function

MyTask_pointer: This first argument to task creation function is a pointer to a function definition of a task. Because we need to define a task with the help function. We will see later how to define a function and pass this pointer to a function as an argument.

task_name: This argument is just the name of the function/task that we will create.

Stack Size

StackDepth: In multitasking, each task/thread has its own stack. It defines the stack size of a task in bytes. Therefore, you should make sure to select stack size according to the complexity of computation. For instance, we select 100 bytes size in this example.

Parameter: If we want to pass a pointer to a variable as an argument to the task function, we can use this argument. Otherwise, we can pass the NULL value. This argument is a pointer to a variable that the task (function) can receive.

How to set Priority ?

Priority: This is an important parameter because it is used to set the priority of tasks. We set priority with passing numbers as an argument. For example, if we create four tasks and assign them priority 0, 1,2, and 3. Hence, zero means the lowest priority, and 3 means the highest priority.

TaskHandle: This argument keeps the handle of the function that we can use to change function features such as the deletion of a task, changing its priority, etc.

In summary, we can create multiple threads by using xCreatTask. But make sure to provide unique pointer name and name to each task.

Setting Task Execution Pattern

vTaskDelayUntil is used to define a deterministic sequence of task execution. For example, if we have four tasks and we want to execute each task after 100, 120, 130, and 140ms, vTaskDelayUntil blocks the task for a defined time after its first execution.

Note: vTaskDelayUntil is different from delay() of Arduino IDE. Because delay() stalls the CPU execution. On the ther hand, vTaskDelayUntil delays a specific task and CPU keeps executing other threads.

You can learn more details about the two functions in the link.

FreeRTOS Arduino Getting Started Example

Now that you have successfully set up the Arduino IDE and installed the RTOS library. Let’s move forward with the first program in Arduino.

Task switching Example

In this example code, we will create four different tasks using xTaskCreate with different priorities. 3 LEDs indicate three tasks and one Led indicates an idle state. Three tasks are labels as Task1, Task2, and Task3 respectively.

LED blinking with FreeRTOS and Arduino Uno

This code shows a simple example where we control three LEDs with three different tasks. Each task executes after a certain time. This program is similar to typical Arduino code except we include the library file of FreeRTOS.

Arduino Sketch

FreeRTOS follows both pre-emptive scheduling and cooperating scheduling. But by default, this API implements pre-emptive time-slicing scheduling. That means high priority tasks pre-empt low priority tasks and equal priority tasks use time-shared policy to get CPU resources. This code creates four tasks with different priorities. But all three tasks are periodic. Because of vTaskDelay() function, each task goes to a blocking state for a specified time.


#include

void setup() //Initialize the Serial Monitor with 9600 baud rate { Serial.begin(9600); Serial.println(F("In Setup function")); //Set the digital pins 8 to 11 as digital output pins pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); //Create three tasks with labels Task1, Task2 and Task3 and assign the priority as 1, 2 and 3 respectively. //We also create the fourth task labeled as IdelTask when there is no task in //operation and it has the highest priority. xTaskCreate(MyTask1, "Task1", 100, NULL, 1, NULL); xTaskCreate(MyTask2, "Task2", 100, NULL, 2, NULL); xTaskCreate(MyTask3, "Task3", 100, NULL, 3, NULL); xTaskCreate(MyIdleTask, "IdleTask", 100, NULL, 0, NULL);} //We can change the priority of task according to our desire by changing the numeric’s //between NULL texts. void loop() { //There is no instruction in the loop section of the code. // Because each task executes on interrupt after specified time } //The following function is Task1. We display the task label on Serial monitor. static void MyTask1(void* pvParameters) { while(1) { digitalWrite(8,HIGH); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(11,LOW); Serial.println(F("Task1")); vTaskDelay(100/portTICK_PERIOD_MS); } } //Similarly this is task 2 static void MyTask2(void* pvParameters) { while(1) { digitalWrite(8,LOW); digitalWrite(9,HIGH); digitalWrite(10,LOW); digitalWrite(11,LOW); Serial.println(F("Task2")); vTaskDelay(110/portTICK_PERIOD_MS); } } //Similarly this is task 3 static void MyTask3(void* pvParameters) { while(1) { digitalWrite(8,LOW); digitalWrite(9,LOW); digitalWrite(10,HIGH); digitalWrite(11,LOW); Serial.println(F("Task3")); vTaskDelay(120/portTICK_PERIOD_MS); } } //This is the idle task which has the lowest priority and calls when no task is running. static void MyIdleTask(void* pvParameters) { while(1) { digitalWrite(8,LOW); digitalWrite(9,LOW); digitalWrite(10,LOW); digitalWrite(11,HIGH); Serial.println(F("Idle state")); delay(50); } }

Each task has its unique priority and different running duration.

How Code Works?

In this example, task3 has the highest priority and task_idle has the lowest priority. Hence, you will see on your serial monitor that task3 will execute first when we first-time power up the Arduino board. On the contrary, task_idle which is the lowest priority task will execute at the end or when no other task is available to run. For the demo, check this video:

Hardware Demonstration

Serial Monitor Ouput

As you can see from the output of the serial monitor, the lowest priority task ( Idle task) executes only when the processor is free and not any other task is available to execute.

  • T1: Task3 starts to execute first being the highest priority task that is three. After that, it enters the blocking state for 120ms.
  • T2: After that Task2 starts to execute because it now attains the highest priority because Task3 is in blocking state. Similarly, it also completes its execution and goes to a blocked state and remains there for 110ms.
  • T3: Currently, both Task3 and Task2 are waiting for the blocked time to end. Hence, Task1 starts to execute because its priority is higher than the idle task. Therefore, it also enters the running state and completes its execution and goes to blocking mode for 120ms.
  • T4: Now, all high priority task has completed their execution and they are in blocked state waiting for their blocking time to end. Therefore, the processor keeps executing, idle_task until a high priority task comes out of a blocking state.
  • Furthermore, the shortest blocking time is used for task1 that is 100ms. Therefore, it will enter the running state before other high priority tasks and similarly for task2 and task3.

After that, all threads keep executing according to their priority and blocking time.

Other FreeRTOS tutorials, you may like to read:

  • Arduino FreeRTOS Queue Management – How to use Queues
  • How to use FreeRTOS structure Queue to Receive Data from Multiple Tasks
  • FreeRTOS Arduino : How to Delete Tasks with vTaskDelete() API
  • How to change Task Priority in FreeRTOS?
  • FreeRTOS Binary Semaphore – Examples of Tasks Interrupt Synchronization using Arduino
  • FreeRTOS Mutex Tutorial with Arduino – Avoid Priority Inversion

Other Related Tutorials:

by Denis Nuțiu

How to get started with FreeRTOS and ESP8266

Recently, I purchased a NodeMCU from AliExpress for about $4. The reason I did this was to find out what all the fuss is about with ESP8266.

NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.

Compared to the Arduino UNO, my ESP8266 totally knocks it out of the park when it comes to CPU power and price.

The ESP8266 is 500% faster and 82% cheaper than the Arduino. The ESP8266 also has WiFi connectivity.

I was very surprised when I visited the Espressif website for the ESP8266. There’s lots of documentation and resources that you can use. For example, there’s an Android application which tells your ESP8266 to connect to your WiFi. The app sends the SSID and password as packets, the ESP8266 sniffs them, and then it connects to your WiFi. This is called SmartConfig, and was invented by Texas Instruments.

In this article, I will guide you to setup and run the Smart Config example from the Espressif RTOS SDK.

Here’s the things you’ll need:
  • A modern computer.
  • A NodeMCU board with ESP12-E
  • VirtualBox (https://www.virtualbox.org/wiki/Downloads)
  • Ubuntu Server LTS (https://www.ubuntu.com/download/server)

Configuring VirtualBox for development

  1. Download VirtualBox and install Ubuntu Server. This should be easy to do, but if you don’t know how, Google it or have a look at this graphic step by step guide. Installing an OS is a nice skill to have. (Tip: When VirtualBox prompts you to select the disk, make it dynamically allocated and at least 50GB in size. This will save you some headaches further down the line.)
  2. Make sure that you can access the internet from within the virtual machine and configure the DNS server:

To configure the DNS server, have a look at this example.

Example:

dns-nameservers 8.8.8.8 8.8.4.4

If you can ping Google, then you’re good to go!

3. (Optional) Install OpenSSH and Samba server. This will make your life much easier.

4. (Optional) Enable port forwarding. In order to SSH directly into your virtual machine, you need to enable port forwarding. For example, to map the port 2222 on your host machine to the port 22 of your virtual machine.

If you have enabled port forwarding, you can now SSH into your virtual machine from your Host machine as in the figure below.

Note: If you’re on Windows, you need Putty in order to SSH into the virtual machine.

5. Plug in your NodeMCU and execute the following command:


tail -f /var/log/kern.log

This should reveal to you that the device has been identified as /dev/ttyUSB0. If nothing happens, then you need to add the USB to the virtual machine. After adding the USB, unplug and plug your device in again.

If you’ve reached this point and every thing is working, congratulations! You’re now ready to compile the SDK and run the SmartConfig example. You can even shoot me a tweet at https://twitter.com/metonymyqt

Compiling the SDK and flashing the board

  1. Install the required packages (as below). This info is also available on the SDK’s readme.md.


sudo apt-get install make unrar-free autoconf automake libtool gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial sed git unzip bash help2man wget bzip2 libtool-bin

2. Create a new folder and navigate into it:

mkdir Development && cd Development

3. Clone the Open SDK: https://github.com/pfalcon/esp-open-sdk


git clone --recursive https://github.com/pfalcon/esp-open-sdk.git

3. Run make:

make

Warning: This step will take a while to finish so please be patient. On my virtual machine it completed after 50 minutes. On yours it might take more or less, but before you run, make make sure that you’re connected to the internet and DNS is properly configured. The best way to check this is to execute a ping to Google or some other site if Google is blocked in your region.

If your ping is successful, you can minimize the windows and watch an episode of your favorite TV show. Come back after about 40 minutes (but make sure your computer doesn’t go to sleep).

After the SDK has been built successfully, you’ll see a message telling you to put something in your path. To do so, execute the following:


echo 'export PATH=/home/denis/Development/esp-open-sdk/xtensa-lx106-elf/bin:$PATH' >> ~/.profile

The command will append the string to the ~/.profile file. Now please run the following command:


xtensa-lx106-elf-gcc --version

If the command executes successfully, then you’re good to go!

4. Test your board

Plug your NodeMCU and run lsusb to verify that your device is connected. After that, run esptool.py chip_id. You should now see the board’s chip id.

5. Clone ESP8266_RTOS_SDK


git clone https://github.com/espressif/ESP8266_RTOS_SDK.git

6. Export the SDK path and SDK/BIN path using the commands below.


echo 'export SDK_PATH=/home/denis/Development/ESP8266_RTOS_SDK' >> ~/.profile


echo 'export BIN_PATH=/home/denis/Development/ESP8266_RTOS_SDK/bin' >> ~/.profile

7. Compile the SmartConfig example


cd /home/denis/Development/ESP8266_RTOS_SDK/examples/smart_config/


chmod +x ./gen_misc.sh


./gen_misc.sh

Now accept the default values until you’re asked for SPI_SIZE_MAP. This is where you select 4 because the NodeMCU has a flash size of 32Mbit and this translates to 4MB. You can also select SPI_SPEED 3=80Mhz

You’ll see something like this:


!!!SDK_PATH: /home/denis/Development/ESP8266_RTOS_SDKBIN_PATH: /home/denis/Development/ESP8266_RTOS_SDK/bin


No boot needed.Generate eagle.flash.bin and eagle.irom0text.bin successully in BIN_PATHeagle.flash.bin — — — →0x00000eagle.irom0text.bin — →0x20000!!!

8. Flash the board


cd $BIN_PATH


esptool.py erase_flash


esptool.py write_flash 0x00000 $BIN_PATH/eagle.flash.bin 0x20000 $BIN_PATH/eagle.irom0text.bin 0x3FC000 $BIN_PATH/esp_init_data_default.bin

Now, if you reset the board, you should see no LED blinking.

9. Use the Phone Application

Open the Application, make sure that you’re connected to a WiFi AP, enter your password, and press confirm. After a few seconds the ESP8266 should connect to your AP. That’s it. Congratulations for reaching the end!

If you want to develop more using the ESP8266-RTOS-SDK, please visit the official websites. You’ll find a lot of resources and documentation there. Also, please take a look at the other examples found in the SDK folder.

Thank you very much for your time reading this. If you want to reach out to me, you can do so on Twitter: MetonymyQT

#381 How to work with a Real Time Operating System and is it any good? (FreeRTOS, ESP32)
#381 How to work with a Real Time Operating System and is it any good? (FreeRTOS, ESP32)

LinuxOS-MacOS

You can install this core using arduino board manager with this package index
:


https://raw.githubusercontent.com/alexCajas/esp8266RTOSArduCore/main/package/package_esp8266RTOS_index.json

Then you need to install esp8266_RTOS_SDK requirements in your system:

  • Go to your arduino cores installation directory, tipically:


cd ~/.arduino15/packages/esp8266RTOS/hardware/esp8266RTOS/1.0.1/

  • In this path you will find the file requirementes.txt, install that using pip:


pip3 install -r requirements.txt

  • Select esp8266 boards RTOS:
  • Now you are ready to write and install sketchs using Arduino IDE or VScode IDE!

WindowsOS

  • It is experimental, there is not good compatibility between rtos_sdk tools and arduino cli

You can install this core using arduino board manager with this package index
:


https://raw.githubusercontent.com/alexCajas/esp8266RTOSArduCore/main/package/package_esp8266RTOS_index.json

  • at the end of the installation, You will get this error:
  • In this point, esp8266RTOSArduCore is installed.

  • This proccess is to link configuration of the esp8266RTOSCore with Arduino IDE, but idf tools needs a git repository in the sdk, so, download this project with git and copy the entire git repository to the arduino core installation directory, even .git directory. Tipically, you core installation will be in:


C:\Users\YouUser\AppData\Local\Arduino15\packages\esp8266RTOS\hardware\esp8266RTOS\1.0.2

  • Also You need Msys2, it is a linux enviroment for windows systems, you can find an official version for esp8266-rtos-sdk in:


https://dl.espressif.com/dl/esp32_win32_msys2_environment_and_toolchain-20181001.zip

  • This core asume that you unzip Msys2 in C:\msys32\
  • Now you need to replace some files, download MsysRTOSArduCorePatch.zip:


https://drive.google.com/file/d/1WZ_h3bHvFZLzoajv5q8BT9Hcy7K82l5e/view?usp=drive_link

  • And replace C:\msys32\mingw64\ directory, and C:\msys32\etc\profile file with their respective counterparts in the zip.

  • Then, open a msys terminal (C:\msys32\msys2.exe), go to your ESP8266RTOSArduCore directory and install requeriments.txt:

  • Last, select esp8266 boards RTOS:

Now you are ready to write and install sketchs using Arduino IDE or VScode IDE!

Warnnig

idf building proccess is tipicall more slow in windows than linux distributions, I recomend you to use a Linux distribution like ubuntu to develop with this core and idf projects in general.

How esp8266_rtos_sdk use msys2 to build and flash projects, there are limitations with arduino:

  • when you verify or upload some skecth, arduino cli will open a msys2 terminal, and finish with any error while msys2 terminal are building the project, so the info of compile errors, warnigs etc are in the msys2 terminal.
  • Follow the instrucctions of msys2 terminal to flash the device with the sketch:

Examples

  • Basic blink example

/* * Based on arduino esp32 arduino core FreeRTOS.ino example. */ #ifndef LED_BUILTIN #define LED_BUILTIN 2 #endif // define two tasks for Blink void TaskBlink( void *pvParameters ); // the setup function runs once when you press reset or power the board void setup() { // initialize serial communication at 115200 bits per second: Serial.begin(115200); // Now set up tasks to run independently. xTaskCreatePinnedToCore( TaskBlink , “TaskBlink” // A name just for humans , 1024 // This stack size can be checked & adjusted by reading the Stack Highwater , NULL , 2 // Priority, with 3 (configMAX_PRIORITIES – 1) being the highest, and 0 being the lowest. , NULL , ARDUINO_RUNNING_CORE); // in esp8266 allways is 0 // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started. } void loop() { // do nothing. } void TaskBlink(void *pvParameters) { pinMode(LED_BUILTIN, OUTPUT); while (true) // A Task shall never return or exit. { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) vTaskDelay(pdMS_TO_TICKS(500)); digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW vTaskDelay(pdMS_TO_TICKS(500)); } }

  • More examples in


~/.arduino15/packages/esp8266RTOS/hardware/esp8266RTOS/1.0.1/libraries/

Limitations

  • The compatibility between libraries of esp8266ArduinoCore based on NONOSDK, and this core, esp8266RTOSArduCore based on FreeRTOS is limited, in general you can use the same esp8266ArduinoCore libraries that have compatibily with esp32 arduino core.

  • It is assumed that external third-party-libaries are in ~/Arduino/libraries.

  • There is not supported to recursive includes to external libraries, all libraries you need must be includes in your .ino scketch:

    • example incorrect include:

~/Arduino/libraries/libraryOne/headerOne.h:

#include “headerTwo.h”

scketchs.ino:

#include “headerOne.h” // sdk don’t loock for headers into heraderOne.h!, headerTwo.h is not included in to compile process, so librariOne is not linked with headerTwo in compile time.

  • Rigth way to include:

~/Arduino/libraries/libraryOne/headerOne.h:

#include “headerTwo.h”

scketchs.ino:

#include “headerOne.h” #include “headerTwo.h” // now compiler use all data of headerTwo.h to compile and link with headerOne.h and scketchs.ino.

  • Note: if you remove #include “headerTwo.h” of “headerOne.h”, libraryOne will not be linked with “headerTwo.h” even if you include that in sckets.ino.

  • libraries or utilities for specific hardware of esp32, like bluetooth or hall sensor is not supported in this core.

  • set compile option is not supported yet.

  • for now only support generic board esp8266 pins map, that is only for the way to name gpios pin in scketchs. You can install scketchs in others boards using generic name of gipo pins.

  • It is not supported changes deboug level info from IDE yet, you need to changes it manually in esp32-hal-log.h

To Do List

  • Implement way to resolve recursive includes.
  • Rewrite paltafrom.txt to give support to compile options.
  • Add esp8266 boards configurations in boards.txt
  • Add pins map support for more models of esp8266 boards.
  • Changes bash scripts to python scripts to support more OS.
  • adapt, test and fix remaining core files with hardware dependencies of esp32 core. See this section.
  • Test and fix remaining basic libraries of esp32 core. See this section.
  • Think in add #if TARGET_CONF_esp32 to more compatibility. –> I think that is a good idea because RTOS is more ligth than FreeRtos.

List of core files to adapt test and fix

  • core/esp8266/esp32-hal-adc.c
  • core/esp8266/esp32-hal-i2c.c
  • core/esp8266/esp32-hal-i2c-slave.c
  • core/esp8266/esp32-hal-psram.c
  • core/esp8266/esp32-hal-sigmadelta.c
  • core/esp8266/esp32-hal-spi.c
  • core/esp8266/esp32-hal-time.c
  • core/esp8266/esp32-hal-timer.c
  • core/esp8266/Tone.cpp
  • core/esp8266/esp32-hal-tinyusb.c ?
  • core/esp8266/base64.cpp
  • core/esp8266/cbuf.cpp
  • core/esp8266/esp32-hal-time.c
  • core/esp8266/esp32-hal-cpu.c
  • core/esp8266/esp32-hal-gpio.c
  • core/esp8266/esp32-hal-misc.c
  • core/esp8266/esp32-hal-uart.c
  • core/esp8266/Esp.cpp
  • core/esp8266/FunctionalInterrupt.cpp
  • core/esp8266/HardwareSerial.cpp
  • core/esp8266/IPAddress.cpp
  • core/esp8266/IPv6Address.cpp
  • core/esp8266/libb64/cdecode.c
  • core/esp8266/libb64/cencode.c
  • core/esp8266/main.cpp
  • core/esp8266/MD5Builder.cpp
  • core/esp8266/Print.cpp
  • core/esp8266/stdlib_noniso.c
  • core/esp8266/Stream.cpp
  • core/esp8266/StreamString.cpp
  • core/esp8266/wiring_pulse.cpp
  • core/esp8266/wiring_shift.cpp
  • core/esp8266/WMath.cpp
  • core/esp8266/WString.cpp

List of basic libraries to Test and fix

  • WiFi
  • EmbeddedMqttBroker
  • WrapperFreeRTOS
  • WebServer
  • WiFiClientSecure
  • WiFiProv
  • HTTPClient
  • HttpUpdate
  • HttpUPdateServer
  • DNSServer
  • ESPmDNS
  • AyncUDP?
  • Update
  • ArduinoOta
  • EEPROM
  • ESP[32|8266] examples
  • FFat
  • FS
  • NetBios
  • Preferences?
  • SD
  • SDMMC?
  • SPI
  • SPIFFS
  • Ticker
  • Wire

License

  • esp8266_RTOS_SDK is under Apache-2.0 license.

I have a very general question, so please excuse me if this is not the appropriate place to ask this. I have a rather complex project for a LEGO robotic arm controlled by several motors. The motors are driven by Adafruit motor shields and I also use gyroscopes, and current sensors to measure power consumptions. I’m using Adafruit libraries for the motor shields and the current sensors. My code is written in the typical arduino-style cpp and I’m using PlatformIO.

I was thinking to convert my code to FreeRTOS for better time handling. I had no experience with FreeRTOS so when I realized it’s a completely different framework I thought that that would be impossible. So my question is: what are the minimum requirements to convert my code to FreeRTOS and what would be a good introduction for that? I’ve already compiled and run a few examples so the PlatformIO is setup I think, at least I can run the Blink-Hello World-WiFi connect examples to start with.

Timing

FreeRTOS Real Time Operating System implemented for AVR (Uno, Nano, Leonardo, Mega).
The primary design goals are: Easy to use, Small footprint, Robust. Uses Watchdog Timer for 15ms resolution. Slow blink = stack overflow. Fast blink = heap malloc() failure.

Maintainer: Phillip Stevens

This library is compatible with the avr architecture so you should be able to use it on the following Arduino boards:

Note: while the library is supposed to compile correctly on these architectures, it might require specific hardware features that may be available only on some boards.

To use this library, open the Library Manager in the Arduino IDE and install it from there.

Đăng nhập/Đăng ký
Ranking
Tất cả
Editor Choice
Kiến thức
Tin tức
Series
Top list
Review
Chủ đề nổi bật
Danh sách Tag phổ biến:
Tác giả hàng đầu
lg

lg

Chủ đề nổi bật
Tag phổ biến
Tác giả hàng đầu
Chia sẻ kiến thức – Kết nối tương lai
Về chúng tôi
Về chúng tôi
Giới thiệu
Chính sách bảo mật
Điều khoản dịch vụ
Học miễn phí
Học miễn phí
Khóa học
Luyện tập
Cộng đồng
Cộng đồng
Kiến thức
Tin tức
Hỏi đáp
CÔNG TY CỔ PHẦN CÔNG NGHỆ GIÁO DỤC VÀ DỊCH VỤ BRONTOBYTE
The Manor Central Park, đường Nguyễn Xiển, phường Đại Kim, quận Hoàng Mai, TP. Hà Nội
THÔNG TIN LIÊN HỆ
[email protected]
©2024 TEK4.VN
Copyright © 2024
TEK4.VN

Do you want to have #FreeRTOS and #Arduino Framework in #ESP8266 ?

Just released https://github.com/aleksmarcelo/LibEspArduino.git …

Any help would be most welcome !

Cheers

Explore… Chat… Share…

Moderator: igrr

Announcement: esp8266.com is closed; specifically,[…]

It takes about 20-25 seconds for home assistant c[…]

I tried to upgrade tof my sonoff basic R2 with the[…]

Hi, I’m developing a mobile IoT solution. It’s a t[…]

Does your NodeMCU actually have a CH340 and not […]

a problem Perhaps you want to define “Probl[…]

Does this give you any pointers? Of course doesn[…]

Good morning, I don’t know if it is possible to co[…]

Good day How to do it so that, for example, the st[…]

Hello, I can no longer find where I have to go to […]

Rebooting your router will not give you a faster I[…]

There are no other notifications from esptool.py i[…]

Using the Arduino IDE, you’ll learn how to set up […]

In this project, you will post to Twitter using an[…]

In this project, we will build a water level contr[…]

I removed a large amount pf pcb from under the ant[…]

I guess I’m late, but I had the same problem and f[…]

Last night I received my first D1 Minis for a lear[…]

Hi Guys, [url=”https://vancedyoutube.org/&quo[…]

Although I am aware that this is an old post, I fe[…]

This is a getting started tutorial on FreeRTOS using Arduino. To demonstrate examples and use of various features of the FreeRTOS operating system, we will use Arduino Uno board and Arduino IDE for writing programs. But you can also use other development boards such as ESP32 and ESP8266.

In this article, you will learn how to use FreeRTOS real-time operating system with Arduino to perform multiple specific tasks within a specified deadline. We will learn to execute multiple threads or tasks with FreeRTOS using the Arduino Uno board.

In this tutorial, we will cover the following topics:

  • RTOS Introduction
  • FreeRTOS Introduction
  • Add FreeRTOS library in Arduino IDE
  • How to use FreeRTOS with Arduino IDE
  • Writing your first FreeRTOS based Arduino sketch

For demonstration, we will create four tasks and assign Arduino’s resources to each task for a specific time and also assign priority to each task.

01  Basic example of FreeRTOS with Arduino |Led Blinking with FreeRTOS|
01 Basic example of FreeRTOS with Arduino |Led Blinking with FreeRTOS|

Keywords searched by users: freertos esp8266 arduino ide

Sharkssl Freertos/Lwip Esp8266 Ide - Youtube
Sharkssl Freertos/Lwip Esp8266 Ide – Youtube
Arduino Freertos Tutorial 1- Creating A Freertos Task To Blink Led In Arduino  Uno
Arduino Freertos Tutorial 1- Creating A Freertos Task To Blink Led In Arduino Uno
00 Start With Freertos With Arduino |How To Install Arduino Ide And  Library| - Youtube
00 Start With Freertos With Arduino |How To Install Arduino Ide And Library| – Youtube
Setting Up Freertos On Arduino - Tutorials
Setting Up Freertos On Arduino – Tutorials
Freertos With Esp32 Using Arduino Ide - Youtube
Freertos With Esp32 Using Arduino Ide – Youtube
Lập Trình Esp 32- Freertos] Bài 5- Đồng Bộ Tác Vụ | Tek4.Vn - Youtube
Lập Trình Esp 32- Freertos] Bài 5- Đồng Bộ Tác Vụ | Tek4.Vn – Youtube
Keep Wifi Connection Alive With A Freertos Task | Simply Explained
Keep Wifi Connection Alive With A Freertos Task | Simply Explained
Getting Started With Vs Code And Platformio Ide For Esp32 And Esp8266 |  Random Nerd Tutorials
Getting Started With Vs Code And Platformio Ide For Esp32 And Esp8266 | Random Nerd Tutorials
Nodemcu Esp8266 Vs. Arduino Uno Board - Makerguides.Com
Nodemcu Esp8266 Vs. Arduino Uno Board – Makerguides.Com

See more here: kientrucannam.vn

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *