Target refactoring and cube update (#161)
* Lib: move cube to libs. Firmware: prepare for code base refactoring, detach from cube, port to cmsis_os2. * Firmware, target f2: regenerate project with latest cube package, tim17 for os ticks. * Firmware: unified codebase. * Core: do not include semaphore on old targets. Firmware: dfu uplaod target. * CI: submodules, add firmware build. * CI: proper submodule config. * refactor build system * CI: update chain to use new targets. Documentation: update to match current structure. * CI: clean before rebuild. * Add local test docker-compose exec dev make -C firmware TARGET=local TEST=1 run * Makefile: target specific build directory. CI: updated artifacts path. * Makefile: init git submodules if they don't exists. * Makefile: debug rule now doesn't reset MCU, prevent SIGINT propagation to st-util. * Makefile: proper rebuild sequence in zz and zzz * Makefile: timestamp tracking for flash and upload commands. * Apps: modular build. Input: fix flipper hal inline. * Wiki: proper bootloader link. * Applications: fix broken build for local targets. * add st-flash to docker * fix build * force rebuild app * move app force to firmware part * fix build deps * qrcode build ok * fix example display * add testing routine * update build instruction Co-authored-by: Aleksandr Kutuzov <aku@plooks.com> Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
@@ -60,3 +60,52 @@
|
||||
* wait 0.05
|
||||
|
||||
TODO: add debouncing check (multiple press and check there is no multiple events)
|
||||
|
||||
# General building testcase
|
||||
|
||||
Local target:
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_TEST=1 clean`
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_TEST=1 run`
|
||||
* check tests pass/fail
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_BLINK=1 run`
|
||||
* GPIO on and off
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_UART_WRITE=1 run`
|
||||
* GPIO on/off and `counter: %` writes
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_IPC=1 run`
|
||||
* ASCII display draw
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_INPUT_DUMP=1 run` not implemented
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_QRCODE=1 run`
|
||||
* Some writes to display
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_EXAMPLE_DISPLAY=1 run`
|
||||
* Some writes to display
|
||||
|
||||
F2 target:
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_TEST=1 clean`
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_TEST=1 flash`
|
||||
* check UART for test pass/fail
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_BLINK=1 flash`
|
||||
* Red LED blink (1s period)
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_UART_WRITE=1 flash`
|
||||
* Red LED shortly blinking, `counter: %` writes to UART
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_IPC=1 flash`
|
||||
* ASCII display draw in UART
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_INPUT_DUMP=1 flash`
|
||||
* Press all buttons, `state` and `event` writes to UART
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_QRCODE=1 flash`
|
||||
* QR code show on the screen
|
||||
|
||||
* `docker-compose exec dev make -C firmware TARGET=f2 APP_EXAMPLE_DISPLAY=1 flash`
|
||||
* `Hello world` show on the screen
|
||||
|
@@ -1 +1 @@
|
||||
bootloader/ReadMe.md
|
||||
../../bootloader/ReadMe.md
|
@@ -14,9 +14,8 @@ For simple case as unit tests or integration test that no require hardware we mo
|
||||
|
||||
You can run firmware locally (with HAL stub).
|
||||
|
||||
* `docker-compose exec dev make -C target_lo` for build
|
||||
* `docker-compose exec dev target_lo/build/target_lo` for run
|
||||
* `docker-compose exec dev make -C target_lo test` for running tests
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_TEST=1 run` for running tests
|
||||
* `docker-compose exec dev make -C firmware TARGET=local APP_*=1 run` for running examples (see `applications/applications.mk` for list of applications/examples)
|
||||
|
||||
For UI we do "UI emulator" (not implemented)
|
||||
|
||||
@@ -24,6 +23,10 @@ For UI we do "UI emulator" (not implemented)
|
||||
2. Local (linux) version of firmware. All calls, writing data to UI like display or LED, redirects to unix socket writes, and messages from unix socket redirect to firmware (emulates button press, change batt level, insert/remove USB, etc.)
|
||||
3. Webserver that run linux version fw, pass events from webpage to unixsocket and vice versa.
|
||||
|
||||
## F2 build
|
||||
|
||||
`docker-compose exec dev make -C firmware TARGET=f2 APP_*=1 flash` for build and flash dev board (see `applications/applications.mk` for list of applications/examples)
|
||||
|
||||
## Firmware emulation (not implemented)
|
||||
|
||||
For more HW- and RTOS- specific checks we run real FW in [Renode](https://interrupt.memfault.com/blog/intro-to-renode)
|
||||
|
@@ -1,136 +0,0 @@
|
||||
_Overview of Flipper firmware architecture:_
|
||||
|
||||

|
||||
|
||||
# Project structure
|
||||
|
||||
```
|
||||
.
|
||||
├── applications # Flipper applications
|
||||
│ └── furi_test # Test app for checking and demonstrating FURI func
|
||||
├── bootloader # Firmware bootloader, used for `target_f2` and newer
|
||||
├── core # Main feature like OS, HAL (target-independed)
|
||||
├── target_f1 # Target-depended code for target F1
|
||||
│ ├── Drivers # STM HAL drivers
|
||||
│ │ ├── CMSIS
|
||||
│ │ └── STM32L4xx_HAL_Driver
|
||||
│ │ ├── Inc
|
||||
│ │ │ └── Legacy
|
||||
│ │ └── Src
|
||||
│ ├── Inc # Autogenerated CubeMX code and target-depended includes
|
||||
│ ├── Middlewares
|
||||
│ │ ├── ST
|
||||
│ │ │ └── STM32_USB_Device_Library
|
||||
│ │ └── Third_Party
|
||||
│ │ └── FreeRTOS
|
||||
│ └── Src # Autogenerated CubeMX code and target-depended sources
|
||||
├── target_lo # Target-depended code for local linux target
|
||||
│ ├── Inc
|
||||
│ └── Src
|
||||
└── wiki # Documentation (wiki) generates from this files
|
||||
├── applications # info about separate features of flipper
|
||||
├── fw # core, environment info about firmware
|
||||
└── hw # info about hardware
|
||||
```
|
||||
|
||||
# HAL
|
||||
|
||||
We use STM32 HAL/LL. Description available here: [dm00105879.pdf](https://github.com/Flipper-Zero/flipperzero-firmware-community/raw/master/wiki_static/dm00105879-description-of-stm32f4-hal-and-ll-drivers-stmicroelectronics.pdf)
|
||||
|
||||
## Flipper HAL
|
||||
|
||||
Some flipper-specific implementation of gpio/HAL:
|
||||
|
||||
* Init gpio pin: `app_gpio_init`
|
||||
* Fast write gpio (inline): `app_gpio_write`
|
||||
* Fast read gpio (inline): `app_gpio_read`
|
||||
* Microsecond delay `delay_us`
|
||||
* Set PWM on timer's pin: `pwm_set`
|
||||
|
||||
Files location: `/app/app_hal.[ch]`
|
||||
|
||||
# Bootloader
|
||||
|
||||
For production targets('target_f2' and newer) bootloader must be flashed first.
|
||||
Detailed instruction on how to compile and flash you can find in `bootloader` fodler.
|
||||
|
||||
Production version will have following features:
|
||||
|
||||
- Hardware initialization
|
||||
- Firmware CRC check
|
||||
- Firmware update
|
||||
- Interactive UI
|
||||
- Boot process LED indicators
|
||||
- FS check
|
||||
- Recovery mode
|
||||
|
||||
# OS
|
||||
|
||||
We use FreeRTOS 10.0.1 for sheduling. Documentation available on [freertos.org](https://www.freertos.org/a00106.html).
|
||||
|
||||
Files location for L476 version: `/target_f1/Middlewares/Third_Party/FreeRTOS`
|
||||
|
||||
**[Timers map](Timers)**
|
||||
|
||||
# Platform code
|
||||
|
||||
CMSIS, Freertos and HAL files are generated by CubeMX.
|
||||
You can find platform code for L476 version in `target_f1` folder:
|
||||
|
||||
* `Drivers/STM32L4xx_HAL_Driver` – hardware abstraction layer
|
||||
* `Drivers/CMSIS` — ARM specific code
|
||||
* `Inc` `Src` — CubeMX generated headers & code
|
||||
* `Middlewares/Third_Party/FreeRTOS/Source` — freeRTOS
|
||||
* `deploy.sh` — flash firmware to device
|
||||
* `STM32L476RGTx_FLASH.ld` — linker script
|
||||
* `startup_stm32l476xx.s` — board startup/initialization assembler code
|
||||
* `flipperzero_l476.ioc` — CubeMX project file
|
||||
|
||||
You can regenerate platform code:
|
||||
1. Download CubeMX from [st.com](https://www.st.com/en/development-tools/stm32cubemx.html)
|
||||
2. Open `*.ioc` file
|
||||
3. Click `generate code`
|
||||
4. After regenerating, look at git status, regenerating may broke some files.
|
||||
|
||||
## Arduino compatibility
|
||||
|
||||
There are some arduino-style defines (digitalWrite, delay, etc.). Include `Arduino.h` from `/app/Arduino.h`
|
||||
|
||||
# Flipper Universal Registry Implementation (FURI)
|
||||
|
||||
FURI is used to:
|
||||
|
||||
* application control (start, exit, switch between active)
|
||||
* data exchange between application (create/open channel, subscribe and push messages or read/write values)
|
||||
* non-volatile data storage for application (create/open value and read/write)
|
||||
|
||||
Read more at [FURI page](FURI)
|
||||
|
||||
# FS (not implemented)
|
||||
|
||||
File system is used to volaile storage some files (config, application data, etc.). There are some folders mounted to different volumes:
|
||||
|
||||
* `/usr` for store static data like assets, menu items. Build system add files to usr while building. It can be useful for exchange some static data between application. For example, your app can add link to itself to Plugins menu items file, user will see your app and can call it from this menu.
|
||||
* Specially `/usr/etc-default` folder contains default configs for apps. Bootloader has `factory default` options to reset applications config. Also when new app is bootstapping, system copy files from default config folder to `/etc`.
|
||||
* `/etc` for store configs of application. This volume not overwrite during flashing.
|
||||
* `/var` for store some application data (saved keys, application database, logs). This volume also not overwrite during flashing.
|
||||
* `/media/*` mounted if SD card is inserted.
|
||||
|
||||
# Flipper applications
|
||||
|
||||
Each flipper functionality except OS/HAL/FURI doing by Flipper application. Some application are called at startup, the rest are called by the user (for example, from menu).
|
||||
|
||||
(you can see some [examples](Application-examples))
|
||||
|
||||
For exchange data between application each app expose own record in FURI. You can subscribe on/read record to get data from application and write to record to send data to application.
|
||||
|
||||
**[List of FURI records](FURI-records-list)**
|
||||
|
||||
# Bootloader (not implemented)
|
||||
|
||||
After start, bootloader run first. It can:
|
||||
|
||||
1. Runs main firmware
|
||||
2. Reflashes firmware from temporary area after updating from usb/bluetooth
|
||||
3. Restores factory default firmware for protected flash area
|
||||
4. Restores application settings to default by clearing `/etc` volume
|
1
wiki/fw/Firmware.md
Symbolic link
1
wiki/fw/Firmware.md
Symbolic link
@@ -0,0 +1 @@
|
||||
../../firmware/ReadMe.md
|
Reference in New Issue
Block a user