Giter Site home page Giter Site logo

imtatlantique-2023's Introduction

IMT Atlantique - 2023 - OS for embedded devices

Embedded software development

Schedule

  • 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

Course material

Session 1 - 03-Jan - Hardware, and a little bit of software

Session 2 - 04-Jan - Software - part 1

Session 3 - 10-Jan - Playing with the target board

  • RTOS - Concurrency control, synchronizaton, communication

Note: for what follows, the development environment must have been installed (see farther below).

Development environment

Hardware environment

Software development

Some sample examples
  • 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 of gpio_isr_register
    • Build, flash, check messages
    • Modify for detection on rising edge and falling edge

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...

Session 4 - 17-Jan - End of RTOS part + part 1 of Communications

Session 5 - 18-Jan - Communications - part 2

Practical sessions

ESP32

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.

Overview of ESP-IDF

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, 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.

Installation of the development environment

Install the following applications in this order (see below for some additional information):

  1. Eclipse for C/C++ Developers, version 2022โ€‘09 R
  2. Eclipse IDF plugin, version 2.7.0
  3. 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).

A first sample application

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.

Let's dive in

Development environment

Hardware environment

Some sample examples

  • 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 of gpio_isr_register
    • Build, flash, check messages
    • Modify for detection on rising edge and falling edge

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...

Exercise 1

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.

Going on with sample applications

Note: FreeRTOS has been slightly adapted to ESP-IDF.

Exercise 2

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.

Going on with sample applications

  • 04-binSemaphore
    • How to use a (binary) semaphore to synchronize a task and an ISR

Exercise 3

Modify exercise1 in order to use synchronization on a binary semaphore instead of polling of a flag.

Going on with sample applications

  • 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

Exercise 4

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.

Going on with sample applications

06-skeletonApp

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
Exchange UDP datagrams with a remote application

Check this repository.

imtatlantique-2023's People

Contributors

pascalbod avatar

Stargazers

 avatar GUOXIONG SUN avatar Chello avatar

Watchers

 avatar  avatar

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.