- Tue 03-Jan - 09:30-10:45, 11:00-12:15 - session 1 - remote
- Wed 04-Jan - 09:30-10:45, 11:00-12:15 - session 2 - remote
- Tue 10-Jan - 09:30-10:45, 11:00-12:15 - session 3 - on site
- Wed 11-Jan - 09:30-10:45, 11:00-12:15 - session 3b + practical session - on site, with Sebastian
- Tue 17-Jan - 09:30-10:45, 11:00-12:15 - practical session, by Sebastian
- Tue 17-Jan - 13:45-15:00, 15:15-16:30 - session 4 - remote
- Wed 18-Jan - 09:30-10:45, 11:00-12:15 - session 5 - remote
- Some extracts from this presentation about connected devices
- This presentation about RTOS
- An ESP-EYE
- Hardware progress
- Memory, processing power and application
- Connected device architecture
- Computer vs microcontroller
- Memory
- Architecture
- Important characteristics
- Common microcontroller families for connected devices
- Peripherals
- Interfacing with peripherals
- Floating point arithmetic
- Cross development
- Execution environments
- OS
- RTOS
- Bare metal
- Interruptions and background task
- Usual architecture of a bare metal application
- Useful design patterns
- RTOS - up to Tasks section
- RTOS - Concurrency control, synchronizaton, communication
Note: for what follows, the development environment must have been installed (see farther below).
- Eclipse IDE - open source, free, developed by the Eclipse Foundation
- Eclipse IDF plugin - open source, free, developed by Espressif
- ESP-IDF:
- Overview
- Getting started
- open source, free, developed by Espressif
- FreeRTOS:
- C language: a list of resources
- ESP32:
- ESP-EYE:
Hello World
- Eclipse workspace
- A first ESP-IDF project
- ESP-IDF automatically starts FreeRTOS scheduler
- Then it starts the
app_main
task, which must be implemented by the developer - Build, flash, check messages
- First sample application:
01-detectionLed
- Overview of ESP-EYE
- The schematic, from the Reference Design
- ESP32 pin layout: section 2.1 of the DS
- ESP32 GPIO: section 4.1.1 of the DS, section 4 of the TRM
- Which state after reset: section 4.10 of the TRM
- Pull-down resistor
- Summary: the project
README
file
- ESP-IDF GPIO
- A rapid overview
- A link to some examples
- The API
- Import project
- Build, flash, check messages
- Modify
- Second sample application:
02-sideButton
- Using
gpio_install_isr_service
instead ofgpio_isr_register
- Build, flash, check messages
- Modify for detection on rising edge and falling edge
- Using
How the LED and the button could be used in a real-life application? Pressing on the side button could start some data acquisition and an inference, the end of the inference could be signaled by the LED...
- RTOS - Time, memory allocation
- Integrating AI and RTOS:
06-skeletonApp
- Data interchange
- Stream or message
- Transparency, endianness, serialization
- MQTT, CoAP, other
- Integration in the Internet
The ESP32 is a microcontroller with Wi-Fi and Bluetooth connectivity. It has been created by Espressif. It's part of the ESP family. We will look at this microcontroller in more details during the course.
ESP-IDF (IoT Development Framework) is Espressif's SDK (Software Development Kit) for developing applications for the ESP32.
ESP-IDF is based on FreeRTOS and provides a rich set of libraries.
FreeRTOS, as an RTOS (Real-Time Operating System), provides the means to architect an application: tasks, synchronization primitives, etc. The libraries, on their side, provide the means to handle hardware resources: Wi-Fi, Bluetooth, Flash memory, interfaces, etc.
An application can be developped using three different types of environments:
- Eclipse IDE (Integrated Development Environment), thanks to a dedicated plugin
- Visual Studio Code, thanks to a dedicated extension
- the command line, with any code editor
Eclipse, Visual Studio Code and ESP-IDF can be used in Linux, macOS or Windows.
In our practical sessions, we will use Eclipse with the dedicated plugin.
Programming language will be C.
Install the following applications in this order (see below for some additional information):
- Eclipse for C/C++ Developers, version 2022โ09 R
- Eclipse IDF plugin, version 2.7.0
- ESP-IDF, version 4.4.3
Beware: stick to the Eclipse version and to the ESP-IDF version.
Eclipse for C/C++ Developers can be installed thanks to the Eclipse Installer, which can be downloaded from this page. Select the suitable version for your operating system and computer (Linux Intel or Arm, macOS Intel or Arm, Windows).
The Eclipse IDF plugin can be installed according to the installation instructions from this page. Among the prerequisites listed by the page, only two are really mandatory, in our case:
- Python 3.6 or above
- Git
Java has been installed by the Eclipse Installer, Eclipse has been installed by you, and ESP-IDF will be installed by the Eclipse plugin.
Once the Eclipse plugin is installed, use it to install ESP-IDF and Tools, as described in the same page.
Note: you can follow the instructions from this page to create a virtual machine with the above applications. Creating a virtual machine allows you not to modify the configuration of your computer (excepted for VirtualBox installation).
Follow these instructions to create a first sample application, based on the hello_world template.
Compile the project, flash it on the ESP32 board, and display the output of the application.
- Eclipse IDE - open source, free, developed by the Eclipse Foundation
- Eclipse IDF plugin - open source, free, developed by Espressif
- ESP-IDF:
- Overview
- Getting started
- open source, free, developed by Espressif
- FreeRTOS:
- C language: a list of resources
- ESP32:
- ESP-EYE:
Hello World
- Eclipse workspace
- A first ESP-IDF project
- ESP-IDF automatically starts FreeRTOS scheduler
- Then it starts the
app_main
task, which must be implemented by the developer - Build, flash, check messages
01-detectionLed
- Overview of ESP-EYE
- The schematic, from the Reference Design
- ESP32 pin layout: section 2.1 of the DS
- ESP32 GPIO: section 4.1.1 of the DS, section 4 of the TRM
- Which state after reset: section 4.10 of the TRM
- Pull-down resistor
- Summary: the project
README
file
- ESP-IDF GPIO
- A rapid overview
- A link to some examples
- The API
- Import project
- Build, flash, check messages
- Modify
02-sideButton
- Using
gpio_install_isr_service
instead ofgpio_isr_register
- Build, flash, check messages
- Modify for detection on rising edge and falling edge
- Using
How the LED and the button could be used in a real-life application? Pressing on the side button could start some data acquisition and an inference, the end of the inference could be signaled by the LED...
Create an application according to the following specifications:
- Right after reset, the LED is off
- Pressing on the button and keeping it pressed turns the LED on
- Releasing the button turns the LED off
The project must be named exercise1
.
03-tasks
- A task is a FreeRTOS object
- A task has its own stack
Note: FreeRTOS has been slightly adapted to ESP-IDF.
Question 1: each task displays a trace message. How does it happen that the contents of the messages are not mixed, from time to time?
Question 2: remove the call to vTaskDelay
function in one task. Build, run, check trace messages. What happens? How do you explain this?
Question 3: reduce task stack size to 100. Build, run, check trace messages. What happens?
Question 4: read the description of the uxTaskGetStackHighWaterMark
function. Then, use the function to find a minimal value for task1 stack depth, and test it.
04-binSemaphore
- How to use a (binary) semaphore to synchronize a task and an ISR
Modify exercise1
in order to use synchronization on a binary semaphore instead of polling of a flag.
05-messageQueue
- How to exchange data between asynchronous code, and to synchronize: the main task waits for messages sent by two other tasks. Every message contains a counter
- Additionally: how to serialize events
Create a copy of 05-messageQueue
and modify it so that you can let the two tasks use the same function. In other words, instead of having two very similar task1
and task2
functions, you'll have only one function. But the application will still start two tasks, one sending MSG_TASK1
messages and the other one sending MSG_TASK2
messages.
Fnctional point of view:
- When the user clicks on the side button, the camera starts returning a stream of pictures
- Every picture is sent to a function provided by the user. This function may perform some processing on the picture
- When the user function is done, it can call a function provided by the skeleton, which will set the detection LED on for a short period of time
The architecture of the skeleton application relies on the following elements:
- Several tasks are running
- A first task, named the button task, is in charge of detecting a press on the side button
- A second task, named the led task, is in charge of controlling the detection LED
- A third task, named the camera task, is in charge of starting and stopping the camera component provided by ESP-WHO
- A fourth task, named the frame task, receives the camera frames provided by the camera component, and calls the user function
- A fifth task, named the main task:
- Waits for a message from the button task, which tells it that the button has been pressed
- Tells the camera task to start the camera
- Waits for a second press on the button, which would indicate that the camera has to be stopped
- The led task waits for a message from the frame task, which tells it to set the LED on for a short period of time
The user function may be written in C++.
Check the README
file of the project for more information.
Important: the project reuses components provided by ESP-WHO. If ESP-WHO is not installed yet, download it:
$ git clone --recursive https://github.com/espressif/esp-who.git
Then, configure 06-skeletonApp
by modifying the top CMakeLists.txt
file in order to adapt the definition of EXTRA_COMPONENT_DIRS
to your ESP-WHO installation:
# 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.5)
set(EXTRA_COMPONENT_DIRS /home/developer/DevTools/esp-who/components) # <== adapt directory path
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId})
Finally:
- Select the type of the board (ESP-EYE) with Component Config > ESP-WHO Configuration
- Enable SPI RAM (PSRAM) with Component Config > ESP32-specific > Support for external, SPI-connected RAM
Check this repository.