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:
@@ -0,0 +1,7 @@
|
||||
# The following lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(COMPONENTS main)
|
||||
project(hello_world)
|
||||
@@ -0,0 +1,45 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | Linux |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | ----- |
|
||||
|
||||
# Hello World Example Compatible with POSIX-port
|
||||
|
||||
This is a version of the "Hello World" example compatible with the linux target. Just by using `idf.py (--preview) set-target <target>`, it can be compiled for chip targets as well as for the [FreeRTOS POSIX/Linux simulator](https://www.freertos.org/FreeRTOS-simulator-for-Linux.html), i.e., for running it on Linux. The applications can then be run on the chosen target.
|
||||
|
||||
## Requirements
|
||||
|
||||
If you want to use this example on Linux, you need a Linux machine as host. The remaining requirements are the same requirements as for [Unit Testing on Linux (using cmock)](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/linux-host-testing.html#requirements), except you do not need Ruby.
|
||||
|
||||
## How to use example
|
||||
|
||||
### Configure the project
|
||||
|
||||
No special configuration is required, we also do not recommend changing configuration when compiled for the POSIX/Linux simulator as this is still in preview. If you have to configure something, use the usual IDF menuconfig:
|
||||
```
|
||||
idf.py menuconfig
|
||||
```
|
||||
|
||||
### Build and Flash
|
||||
|
||||
You can compile this example for chip targets, e.g. ESP32 and then run it by using:
|
||||
```
|
||||
idf.py set-target esp32
|
||||
idf.py build
|
||||
idf.py -p <port> flash monitor
|
||||
```
|
||||
|
||||
If you want to build this example for the linux target and run it, use the same commands except setting the linux target and omitting the flash command:
|
||||
```
|
||||
idf.py --preview set-target linux
|
||||
idf.by build
|
||||
idf.py monitor
|
||||
```
|
||||
The linux target is still in preview, hence the necessary `--preview` argument. Flashing can be omitted on Linux.
|
||||
|
||||
|
||||
## Example folder contents
|
||||
|
||||
The files in this project have the same structure as the files in the [original Hello World application](../../../../examples/get-started/hello_world/).
|
||||
|
||||
## Example Output
|
||||
|
||||
The output is similar to the output of the [original Hello World application](../../../../examples/get-started/hello_world/), except that no chip information is printed and there won't be any bootloader output on the linux target.
|
||||
@@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS "hello_world_main.c"
|
||||
INCLUDE_DIRS "")
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
for (int i = 10; i >= 0; i--) {
|
||||
printf("Restarting in %d seconds...\n", i);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
printf("Restarting now.\n");
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
|
||||
# Note that support for Linux target console applications hasn't been implemented for pytest-embedded yet
|
||||
# (https://github.com/espressif/pytest-embedded/issues/106)
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.generic
|
||||
def test_hello_world_linux_compatible(dut: IdfDut) -> None:
|
||||
dut.expect('Hello world!')
|
||||
Reference in New Issue
Block a user