Giter Club home page Giter Club logo

lekaos's People

Contributors

alex0vsky avatar dependabot[bot] avatar hpezz avatar kabroc avatar ladislas avatar madour avatar mmyster avatar yannlocatelli avatar zozo976 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lekaos's Issues

[Story] - Wiki & Documentation

Description

This story's goal is to track the documentation process.

General documentation should be in the Wiki and specific documentation should be in README.md where they belong.

If in double, discussion can happen here.

Documentation list

This list will be updated in the future

  • Driver - SPI - https://github.com/leka/LekaOS/wiki/Driver-SPI
  • How to - Tools, Toolchains & Project Setup
    • Install GCC
    • Install mbed cli
    • Install OpenOCD
    • Install CubeMX (download and symlink)
    • Run CubeMX from command line (-i, csv, etc.)
  • MCU Pins
    • List, description, functions
    • tools to define, modify and export
  • MCU Connectivity (SPI, I2C, etc.) and what they are used for

[Task] - Rework FastLED

Description

FastLED has been included in our project to work with our MCU.

But the FastLED code is bloated, complicated and has a lot of dependencies we don't actually use.

Rework the library to make it more user friendly.

Related epic/story: #30

Subtasks

  • - remove for wait_ns

Add lib example

Add an Hello World library example to make sure compilation works correctly.

[Epic] - Gain deep understanding of mbed os

It's important do precisely study and understand how mbed works, the different API, drivers & communication stacks.

This issue of type: epic will be used to gather information, share what we have learned and things that could be useful in the future.

Resources

[Task] - Clean up targets

Description

Clean up the targets repository.

Related epic/story: #26

Subtasks

  • remove disco ioc, disco modified
  • create disco leka with LekaPinNames.h

[Task] - Robot software specifications for investigation day

Description

Create a document to gather all specifications of the behavior of the robot. Each component of it must be tested at its maximum in order to have the worst situation for investigation day. Values has to be clear.

Related epic/story: #36

Subtasks

  • Draft with an overview of behavior for each component @YannLocatelli
  • First meeting to check the draft @YannLocatelli @ladislas
  • Create the document based on the draft and feedbacks @YannLocatelli
  • Add values (theoretical)
  • Test them (if possible)
  • Contact the design offices
  • Adapting the document with feedbacks
  • Update values (practical)
  • Test them again (if possible)
  • Final meeting to check the document

[Task] - Script to compare pin definition in xlxs to STM32CubeMX file

Description

Develop a simple script to make sure that the design doc containing all the pins and their functions is correctly implemented in STM32CubeMX.

Related epic/story: #26

Subtasks

  • generate .csv file with CubeMX
  • parse design doc and cubemx_pintout.csv
  • check that all the needed pins are present
  • check that the definition/function/label are correct
  • find extraneous pins not present in the design doc

[Task] - Remove uneeded include of mbed.h

Description

A lot of headers and source files are including mbed.h.

A lot of them don't really need mbed.h but only PinNames.h for example.

Check all source files and decide if it's really needed.

Related epic/story: n/a

[Story] - Test Applications

Description

Before implementing a new functionality into the main firmware, it's usually good practice to make a small test application demonstrating the use case, how it works and open discussion to implementation before opening a PR.

This story gathers all the test apps and related discussion.

This main post will be updated with new test apps to include.

Related epic/story: n/a

Test Applications

[Task] - Implement LEKA_V1.0_DEV target

Description

The LEKA_V1.0_DEV target is based on the DISCO_F769 with minor configuration.

As the mainboard evolve, continue to customise the LEKA_V1.0_DEV target to suit our need.

Related epic/story: #26

Subtasks

  • add custom labels
  • add QSPI
  • add BLE
  • add Wifi
  • add Bluetooth

[Epic] - QSPI, OpenOCD, Linker & External flash

Description

Documentation related to QSPI Flash, OpenOCD & Linker configuration.

The goal is to have OpenOCD flash both the main mcu and the factory QSPI flash during manufacturing.

Docs

QSPI

OpenOCD

Linker

[Task] - Implement custom targets

Description

For development and later for production phases, we need to implement custom targets to make the process easier

Related epic/story: #26

Subtasks

  • Leka_v1_DEV DISCO_ORIGINAL - using the 32F769IDISCOVERY while we wait for the mainboard
  • DISCO_MODIFIED - based on DISCO_ORIGINAL but with removed features
  • DISCO_IOC - generated from .ioc file with the same features removed than DISCO_MODIFIED
  • Leka_v1_PROD LEKA_V1.0_DEV - for our development mainboard
  • [ ] Leka_v1_DEV_BLE - using the P-NUCLEO-WB55

[Task] - Separate drivers from libs

Description

Separate drivers (directly talking to hardware) from libs (higher level functions)

Related epic/story: #7

Subtasks

  • rename lib to libs
  • create drivers directory

[Story] - LekaOS BLE v1.0.0

Introduction

BLE communication with the iPad is one of the most important feature of LekaOS. Without it the robot is useless and its presence allow us to:

  • control the robot
  • debug/log what's going on
  • tests new functionalities (FOTA, scheduling, etc.)

Roadmap

  1. Setup a basic working example using mbed
  2. Test the integration with timed tasks and scheduling
  3. Implement Leka Communication Specifications

1. Setup a basic working example using mbed

This first step is really easy: use the examples from mbed-os to create a simple working example of BLE for Leka to pave the way for future developments

This must include:

  • read, write and notifications services/characteristics
  • the use of predefined services (battery) and proprietary services (temperature, firmware version, basic command)

2. Test integration with timed tasks and scheduling

Through out our development we will need to start tasks and stop them. Gaining a deeper understanding about how this will work between BLE and mbed os is paramount as all future development will rely on that.

More information in #1 - #1 (comment)

This must include:

  • starting a long running thread
  • stoping a long running thread anytime
  • starting again from the beginning
  • starting again where we left off (if possible)

3. Implement Leka Communication Specifications

We'll review, update and implement the Leka Communication Specifications in parallel with the iOS app.

The main goal is to have the two perfectly synchronised.

This must include:

  • implement all the services/characteristics
  • implement the command analyser
  • a lot of testing

4. Mandatory commands

  • implement reset command and test in case of infinite loop

[Task] - Screen - Exploration to use JPEG

Ecran - valider le jpeg

Description

Display a JPEG image on the screen connected on Leka board.

Etat initial

Journée d’investigation:

  • LekaScreen avec la structure pour la journée d’investigation qui appelle LekaLCD
  • LekaLCD, code de Modar avec l’animation du cube

Tasks

  • Récupération du fichier JPEG
    • Utilisation de la carte SD (conversion de DISCO-SDMMC vers LEKA-SPI)
      • Add "SD" in components_add in custom_target.json file
      • Add pins in mbed_app.json file
      • Implement SD and FATFileSystem
        • Test - With mbed (SDBlockDevice, FATFileSystem) ✅
        • Test - In ST example (FATFS) ❌
    • Ouverture fichier JPEG
      • Test - With mbed (fopen from FILE) ❌
      • Test - In ST example (f_open from FIL) ✅
      • Vérification de la taille fichier
  • Etat du code de Modar sous mbed
    • Test - Cube animation ✅
    • Test - Image en .h ✅
      • Trouver le code avec le bon commit → #1f3d067
      • Récupérer les images en .h (eye + mouth)
      • Implémenter le code dans celui de la journée d’investigation
    • Test - Image en JPEG ❌
      • Implémenter les libs nécessaires
        • decode_dma
        • jpeg_utils
        • jpeg_utils_conf
        • BSP_DISCO_F769NI
      • (1) Résoudre ERROR (lien) durant l’appel de la fonction JPEG_Decode_DMA
        • Localiser l’erreur
          JPEG_Decode_DMA (decode_dma)
          HAL_JPEG_Decode_DMA (stm32f7xx_hal_jpeg)
          JPEG_DMA_StartProcess (stm32f7xx_hal_jpeg)
          at hjpeg->hdmain->XferCpltCallback = JPEG_DMAInCpltCallback;
        • Identifier les sources
          • Test - hjpeg mal instancié
            HAL_JPEG_MspInit (stm32f7xx_hal_jpeg) vide et en __weak
        • Appliquer des solutions
          • Remplacer par celui proposé dans l’exemple ST → lien
      • (2) Résoudre NOTHING HAPPENS dans le JPEG_Decode_DMA
        • Localiser l’erreur
          JPEG_Decode_DMA (decode_dma)
          HAL_JPEG_Decode_DMA (stm32f7xx_hal_jpeg)
          JPEG_DMA_StartProcess (stm32f7xx_hal_jpeg)
          at JPEG_ENABLE_DMA(hjpeg, JPEG_DMA_IDMA | JPEG_DMA_ODMA);
        • Identifier les sources
          • Macro does not work correctly
        • Appliquer des solutions
          • Test - Remplacer par MODIFY_REG(hjpeg->Instance->CR, ((JPEG_DMA_IDMA | JPEG_DMA_ODMA) & JPEG_DMA_MASK), 1UL);
      • (3) Résoudre NOTHING HAPPENS dans le do{...}while
        • Localiser l’erreur
          JPEG_InputHandler (decode_dma)
        • Identifier les sources
          • Jpeg_IN_BufferTab always FULL
          • JPEG_OutputHandler never FULL
        • Appliquer des solutions
    • Test - Video en AVI (lien)
  • Fusion des libs LekaScreen et LekaLCD (objectif Cube bouncing et une meilleure maîtrise des handlers)
    • Récupérer les sources
      • Code of Modar (link)
      • Example from ST without using JPEG (link)
      • BSP - LCD init (link)
    • Ajout des initialisations dans LekaScreen
      • LCDReset → Hardware reset de ...
      • MSPInit → HAL Initialize modules in MCU related to display process
      • DSIInit → "Driver" Initialize DSI interface
      • LTDCInit → "Driver" Initialize LTDC with SDRAM (?)
      • SDRAMInit (inLTDCInit) → HAL and "Driver" Initialize of SDRAM
      • OTM8009AInit → Driver Initialize LCD
    • Configurations des initialisations selon le code de Modar (annotées avec Previously en cas de changement)
    • Ajout de la partie applicative
      • LTDCLayerInit → Configuration couche écran
      • setActiveLayer → Désigner la couche active (2)
      • clear → Nettoyer l’écran avec une couleur
      • drawRectangle
      • fillBuffer → Transfert du dessin dans DMA2D
    • Vérification des initialisations
      • Résoudre NOTHING HAPPENS après initialisations
        • Localiser l’erreur
        • Identifier les sources
          • DSI_IO_WriteCmd (otm8009a) vide et en __weak
        • Appliquer des solutions
          • Remplacer par la proposition de Modar → lien
      • Identifier la provenance de hdma
    • Vérification de la partie applicative
    • Image en .h
  • Afficher une image JPEG
    • Récupération du fichier JPEG
    • Fusion des libs LekaScreen et LekaLCD
    • Identifier les sources d’inspirations
      • Exemple ST (DISCO) en utilisant le DMA → lien
      • Exemple ST (EVAL) en utilisant le polling → lien
      • Exemple ST (EVAL) en utilisant l’interrupt → lien
      • Exemple video de Modar → lien
  • Ajout à la lib la rotation de l’écran (lié à OTM8009A_MADCTR_MODE_LANDSCAPE dans otm8009a)
  • Réimplémenter OTM8009A_Init dans son driver, nécessite de bien définir DSI_IO_WriteCmd
  • Répartir les différentes initialisations et partie applicative dans différentes "sous-lib"
  • Schéma de la relation entre les différents modules avec le chemin du fichier JPEG dans la carte SD jusqu’à l’affichage sur l’écran
  • Schéma du parcours du code selon les différents libs parcourus (vérification des fonctions vides et en __weak)

[Story] - Organization, Rules, Tools & Toolchain

Introduction

LekaOS is a great project and a big project that will grow in size considerably over the next few months. It's important for the sanity of all the developers involved that good defaults and standards are setup and chosen at the beginning to reduce friction and bikeshedding.

Different topics will be covered:

  • folder organization
  • naming conventions
  • coding style
  • testing
  • CI & automation
  • toolchains

Folder/Directory organization

LekaOS will follow the monorepo philosophy, which means that all the dependencies will be located inside this repository. No external dependencies, no submodules, everything must compile after git clone.

⚠️ One exception might be large binary files (e.g. images, sounds, etc.). Extra care must be taken and each case must be discussed.

Root folders will be:

  • .azure-ci or .github - CI related tasks
  • docs - documentation
  • lib - library folder
  • src - sources of the main application
  • test - tests --> unit, functional, integration
  • script - scripts used by different processes

Naming conventions

⚠️ to do

Coding style

Coding style is taken care of by EditorConfig and ClangFormat.

Testing

⚠️ to do

CI & Automation

⚠️ in progress

Toolchains

LekaOS will be compiled using GCC ARM None Eabi.

Some tests must be run to see wether we use mbed-cli, Make of CMake.

[Epic] - Size Estimation for Memory Specs

LekaOS needs to store and access a lot of information/content while working.

For example:

  • images
  • animations
  • sounds
  • misc data

Estimation on the size required to stock all this content must be done.

[Story] - Firmware Update

Description

This story gathers all the information and ideas about the firmware update process: strategy, support, security, tests, etc.

Related epic/story: n/a

.hex or .bin?

The question asked is should we send the update as a .bin file or .hex.

The question was asked to the community here:

ARM Mbed OS Forum - Firmware Update w/ FlashIAP - .bin or .hex?

The answers provide useful information:

  • .bin is smaller than .hex
  • .hex incorporate a checksum for each lines
  • .bin allows for custom binary framing to provide additional information
  • .bin allows for custom frame length to send more information each time

With those information, the .bin approach seems to be better in many points.

QSPI Flash or SD Card

Following the ".hex or .bin?" question, we must investigate and decide if we want to use SD Memory Card or QSPI Flash.

Pros of the SD Card:

  • we can use a FileSystem to store the .bin
  • we can write frames by frames, we don't have to worry about sector/page size, etc.
  • we have a lot of available memory so we can store a lot of versions if roll back is necessary
  • we can store config files as well

Cons of the SD Card:

  • we need the FileSystem in the bootloader which can add some memory consumption

Pros of the QSPI Flash:

  • we just need QSPI Flash
  • memory is safe and strong

Cons of QSPI Flash:

  • we must deal with sector/page size when writing to the external memory
  • we can store only one previous version
  • we need to use KVStore to store external info (old/new version number, checksum, size, etc.)

With those information, QSPI Flash seems to be a good candidate for simple systems with low resources and low memory available.

On the other hand, the SD Card approach gives us a higher level view of the subject and allow us to use concepts closer to those of a regular computer. The SD Card can also be flashed before and more testing can be done.

In conclusion:

  • we can keep one QSPI Flash for factory firmware (we need to understand how to flash it)
  • the update process can use the SD Card with a dedicated directory

Update workflow

⚠️ to do

Security

For firmware update through untrusted channels (BLE, Wifi, etc.), security is paramount! We can distinguish two types of security:

  • signing
  • encrypting

Signing means that the content of the file is signed, a hash is generated and it can be checked to make sure it comes from Leka and not from someone else. With just signing, the content of the firmware update is visible to the external world.

Encrypting means that from the original content we generate a cyphered version of the update that has to be decrypted once on the device. If someone steals the update, they won't be able to read it's content.

Both signing and encrypting must be done on the firmware sent for the update.

Useful links:

Frame structure

The .bin approach lets us use a custom binary frame for the data we send.

Source: Specs-FOTA-Frame.gsheet

Item Size Type Content Comment
Start bytes 4 bytes array[4] {uint8_t} [2A 2B 2C 2D] Start sequence to recognize a frame
Header
Size 1 byte uint8_t The size of the data contained in the current frame (1..256)
Data type 1 byte uint8_t - 00 - Firmware version
- 01 - Firmware size
- 02 - Number of frames to receive
- 03 - Global CRC
The type of data received
CRC 1 byte uint8_t CRC Checksum of the current frame's data (⚠️ to be investigated)
Data The data contained in the current frame. It can only be of one type
Firmware version 3 bytes array[3] {uint8_t} major minor patch
Firmware size 4 bytes uint32_t Total size of the firmware to be sent
Number of frames to receive 4 bytes uint32_t Number of frames to be sent for the update
Global CRC 4 bytes uint32_t CRC Checksum of the firmware
Stop bytes 4 bytes array[4] {uint8_t} [2D 2C 2B 2A] Stop sequence at the end of a frame

Proofs of concept

1. First Leka Bootloader

  • understand how the bootloader works with mbed-config
  • create a simple bootloader running in a loop
  • send an application and write it to MCU Flash (w/ FlashIAP)
  • send an application and write it to QSPI Flash first, then to MCU Flash (w/ FlashIAP)
♻️ Steps

Step 1.1

Hello, I'm the bootloader!
I'm waiting for 5 seconds before starting the application...

1... 2... 3... 4... 5...

Starting application now!

Hello, I'm application!
I'm running in a loop.
1
2
3
// [...]

Step 1.2

Hello, I'm the bootloader!
I'm waiting for an application to be sent to me...

1... 2... 3... 4... 5... // [...]

An application is available! I'm writing the application to MCU Flash!

// [...]

Application written to MCU Flash!

Starting the application now!

Hello, I'm application!
I'm running in a loop.
1
2
3
// [...]

Step 1.3

Hello, I'm the bootloader!
I'm waiting for an application to be sent to me...

1... 2... 3... 4... 5...

An application is available! I'm writing the application to QSPI flash!

// [...]

Application written to QSPI!

I'm writing the application to MCU Flash!

// [...]

Application written to MCU Flash!

Starting the application now!

Hello, I'm application!
I'm running in a loop.
1
2
3
// [...]

2. In application update

  • start the application and have the application wait for a new version
  • store the new version to QSPI Flash
  • reboot and write the application to MCU Flash
♻️ Steps

Step 2.1

Hello, I'm the bootloader!

Checking if a new application is available...
No application available.

Starting current application now!

Hello, I'm application!
I'm running in a loop waiting for an new application to be sent to me...
1
2
3
// [...]

An application is available! I'm writing the application to QSPI flash!

Application written to QSPI!
Rebooting...

Hello, I'm the bootloader!
Checking if a new application is available...
New application available!

Now I'm written the application to the MCU...
Application written to MCU.

Starting new application now!

Step 2.2

to do

[Task] - Watchdog - Compare between thread and ticker

Description

The current version of the watchdog uses a thread.

@YannLocatelli proposed an alternative solution using a ticker which might be more light weight here: #17 (comment)

#include "mbed.h"

Ticker kicker;

void watchdogKick()
{
    Watchdog::get_instance().kick();
}

int main()
{
    printf("\n\nDemonstration of watchdog in case of error (happens in 10s).\n");

    const uint32_t TIMEOUT_MS = 5000;
    Watchdog &watchdog = Watchdog::get_instance();
    watchdog.start(TIMEOUT_MS);

    kicker.attach_us(watchdogKick, 1000);
    
    ThisThread::sleep_for(10s);
    error("This is a reason why watchdog exists. Restarting in 5000ms...\n");
    
    return 0;
}

Related epic/story: #19

Subtasks

  • create two examples, one with a thread and the other with a timer
  • test them with fatal errors and while loops
  • compare size or executable

[Story] - Leka Mbed Target

Description

Leka is based on the DISCO_F769NI target.

A custom target must be created. This includes:

  • create a dummy target with the DISCO_F769NI
  • creating the target structure
  • adding config files: CubeMX .ioc, CSV with pins
  • creating and adding scripts: CSV to .ioc and .ioc to source code
  • adding the PinNames.h and PeripheralPins.c files
  • copying the files from mbed repository
  • add linker scripts
  • find a way to incorporate the target in mbed-os if needed no need

[Task] - Flex - Test Process

From Pierre:

  • brancher le flex sur le shield de type ARDUINO pour la DISCOVERY ou directement sur la carte mère ( nom : CML01 : carte mère LEKA01 ?)
  • visualiser/ mesurer le courant sur le 5V et le 3.3V ( via ADC sur CML01)
  • faire clignoter en séquentiel les 2 LEDs de tête avec 1 seule couleur puisla 2 ème, puis la 3 ème, puis les 3 couleurs, cycle 0.5s
  • faire clignoter en séquentiel les 20 LEDs de ceinture avec 1 seule couleur puis les 3, cycle 0.5s
  • allumer toutes les LEDS
  • mesurer le courant 5V en conséquence
  • allumer le détecteur de proximité 1 et la LED, en couleur bleue la plus proche, approcher la main. Ceci doit afficher la LED de proximité en rouge. Selon la distance de détection, modifier le règlage. Idem pour les 5 autres.
  • faire un balayage séquentiel des 6 détecteurs : vérifier la bonne détection de la zone concernée
  • activer le lecteur RFID, via une commande RS232 : allumer les 2 LEDs de tête en bleu
  • approcher un tag RFID de petite taille : si détecté, noter la distance de détection et allumer les 2 LEDs de tête en rouge pendant 2 secondes
  • approcher un tag RFID de grande taille ( carte bancaire) : si détecté, noter la distance de détection et allumer pendant 5 secondes les 2 LEDs de tête en rouge pendant 2 secondes

[Task] - Move mbed-os and external libs to extern directory

Description

Currently mbed-os is located inside the lib/_vendor directory.

Even with the _vendor directory, it's not that clear that this library is not supposed to be modified.

We should move it to the extern or external repository at the root of the project.

Related epic/story: #7

[Story] - Leka / LekaOS - QA, Norms, Certifications & Tests

Description

This story gathers all the tasks related to:

  • quality analysis
  • norms & certifications
  • tests & investigation days

Related epic/story: n/a

Step 1 - Journée d'investigation

Répartition des composants pour la journée d’investigation

2020_09_08-Specs-Investigation_day.gdoc

@ladislas:

  • Moteurs et contrôleur moteur
  • LEDs
  • BLE
  • Lecteur RFID
  • Capteurs en I2C : Accéléromètre, Gyroscope, Magnétomètre, Température

@YannLocatelli:

  • Vibreur haptique et amplificateur
  • Capteurs de toucher
  • WIFI
  • Bluetooth
  • Ecran et SDRAM
  • Mémoire SD
  • Mémoire flash externe (QSPI)

Autres:

  • Module de réception de la recharge par induction
  • Capteurs en ADC : luminosité, microphone
  • Watchdog

[Task] - Script to edit .ioc CubeMX file

Description

When #27 is completed and everything is good to go, modify the .ioc file with the correct labels.

Related epic/story: #26 #27

Subtasks

  • parce design doc .csv
  • parce .ioc file
  • add corresponding:
    • P{xx}.GPIOParameters=GPIO_Label
    • P{xx}.GPIO_Label={label}

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.