flipperzero-firmware/firmware
あく 76e3fd3060
Firmware, Bootloader: add f3 target. (#215)
* Firmware, Bootloader: add f3 target. Refactor code to be portable across targets.
* Firmware: remove bkpt
* Makefile: debug agent. Debug: f3 platform throw openocd.
* freertos-openocd helper
* separate hal resources
* return of input_dump app
* using hew target resources abstration layer for backlight and blink
* dirty hack for input driver, f3 has no charging pin
* worked input interrupts
* working display
* F3: switch to 32mHz resonator
* F3: configure SD_CS pin
* NFC: port to F3.
* fat uart app
* sd card hal api
* separate CC1101 spi config
* faster spi gpio for sd card
* Assets: disable LFS
* Cube: disable css on LSE
* Input: format code
* Make: add bootloader source code to formatting rule
* F3: enable rf by default, adjust clock settings, map all pins where they should be.
* libs for coreglitch_demo_0
* nvic priority
* bus clocks all to 64
* lf-rfid timer and pin
* irda
* ir rx setup
* tim2 irq handler
* Makefile: environment aware mkdir
* Makefile, Irukagotchi: commit seq number.
* split falling and rising ir rx events
* Makefile: proper git branch detect on old git. Firmware: api fix.
* fix irda
* Makefile,Irukagotchi: date timestamp.
* NFC: adjust SPI speed
* Irukagotchi: format code
* Make: add blackmagic debug in host mode
* Makefile: detach blackmagic from terminal signals
* Makefile,Irukagotchi: stamp target
* add F3 bootloader/firmware to CI

Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
Co-authored-by: aanper <mail@s3f.ru>
2020-11-06 13:52:50 +03:00
..
targets Firmware, Bootloader: add f3 target. (#215) 2020-11-06 13:52:50 +03:00
Makefile show target version, date, commit hash and branch (#221) 2020-11-06 12:31:06 +03:00
ReadMe.md Target refactoring and cube update (#161) 2020-10-07 12:37:43 +03:00

Overview of Flipper firmware architecture:

FW arch

Project structure

.
├── applications    # Flipper applications
├── bootloader      # Bootloader make project
├── core            # Main feature like OS, HAL (target-independed)
├── core-rs         # Rust code
├── docker          # Docker toolchain container
├── firmware        # Firmware make project
├── lib             # Libs and 3rd parties
├── make            # Makefile scripts
├── wiki            # Documentation (wiki) generates from this files
└── wiki_static     # Static files for wiki

HAL

We use STM32 HAL/LL. Description available here: dm00105879.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('f2' and newer) bootloader must be flashed first. Detailed instruction on how to compile and flash it you can find in bootloader folder.

Production version is going to have following features:

  • Hardware initialization
  • Firmware CRC check
  • Firmware update
  • Interactive UI
  • Boot process LED indicators
  • FS check
  • Recovery mode

OS

CMSIS-RTOS2 over FreeRTOS

Timers map

Platform code

CMSIS, Freertos and HAL files are generated by CubeMX. You can find platform code for L476 version in f2 folder:

  • 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
  • cube.ioc — CubeMX project file

You can regenerate platform code:

  1. Download CubeMX from st.com
  2. Open *.ioc file
  3. Click generate code
  4. After regenerating, look at git status, regenerating may broke some files.

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

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)

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