feat(freertos): Added FreeRTOS POSIX/Linux Simulator

* Added port layer from the FreeRTOS POSIX port, added
  additional port code for ESP-IDF.
* Created another hello world example using that POSIX
  port in tools/test_apps.
* Removed old linux app
This commit is contained in:
Jakob Hasse
2022-09-06 16:09:23 +02:00
parent a9f15d1556
commit bfbbd9d790
28 changed files with 1377 additions and 165 deletions
@@ -6,11 +6,6 @@ examples/build_system/cmake/import_lib:
temporary: true
reason: lack of runners
examples/build_system/cmake/linux_host_app:
enable:
- if: IDF_TARGET == "linux"
reason: only test on linux
examples/build_system/cmake/plugins:
disable_test:
- if: IDF_TARGET not in ["esp32", "esp32c3"]
@@ -1,10 +0,0 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
# Freertos is included via common components, however, currently only the mock component is compatible with linux
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
project(linux_host_app)
@@ -1,38 +0,0 @@
| Supported Targets | Linux |
| ----------------- | ----- |
This hello-world example builds a simple hello-world application for Linux.
The compiler used is the Linux-gcc.
There are two major differences to an IDF application built for an ESP chip compared to an application build for Linux:
1. The entry-point on Linux is `int main(int argc, char **argv)`, instead of `void app_main(void)` on an ESP chip.
In this example for Linux, the `void app_main(void)` function is still included to make the connection to the IDF entry point clearer.
However, it is simply called by `int main(int argc, char **argv)`.
Refer to the source file [linux_host_app.cpp](main/linux_host_app.cpp) to see how it is used.
2. The project-level [CMakeLists.txt](CMakeLists.txt) for Linux is different from that of a normal IDF application for an ESP chip.
On Linux, there is an additional line `set(COMPONENTS main)`, which clears the common requirements (default dependencies usually included in all IDF applications).
This is currently necessary as the Linux-host feature is still under development.
Otherwise, a lot of hardware-dependent code would be pulled in.
# Requirements
Currently, Ruby is required for the mock override of FreeRTOS.
# Build
Source the IDF environment as usual, then set the Linux target:
```bash
idf.py --preview set-target linux
```
sdkconfig.defaults sets the Linux target by default, so this not strictly necessary.
Once this is done, build the application:
```bash
idf.py build
```
Since this application runs on host, the flashing step is unnecessary.
# Run
```bash
`build/linux_host_app.elf`
```
@@ -1 +0,0 @@
idf_component_register(SRCS "linux_host_app.cpp")
@@ -1,30 +0,0 @@
/* Hello World Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "stdio.h"
#include <unistd.h>
void app_main() {
while(1) {
printf("Hello, Host!\n");
for (int i = 10; i >= 0; i--) {
printf("Restarting in %d seconds...\n", i);
sleep(1);
}
}
}
int main(int argc, char **argv)
{
setbuf(stdout, NULL);
app_main();
return 0;
}
@@ -1,3 +0,0 @@
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
CONFIG_IDF_TARGET="linux"
CONFIG_COMPILER_CXX_EXCEPTIONS=y