-
Notifications
You must be signed in to change notification settings - Fork 166
Development Adding a new board type
##Development Adding a new board type, flight firmware side##
(Wip) Here are the steps to add a new hardware target. This assumes that the CPU architecture is supported already.
Before being able to compile a firmware for this board, you have to configure the build environment so that the PiOS HAL is mapped to the way the MCU peripherals are configured on your target, how memory is mapped, how the target is programmed, etc.
Add your board name (lowercase) to the "ALL_BOARDS" variable Add your board name (capitalised) to the Friendly names variable If necessary, exclude your board from the boot loader updater targets.
in the "make/boards" create a directory for your target, all in lowercase put board-info.mk there
This file defines the actual hardware chip used by the board, memory mapping, CPU frequency and programming methods. It also contains PiOS-related: board model, revision, type.
add a board define for your board (for instance STM32F4xx_Revolution.h) update pios_board.h to include this define.
this file defines how the various peripherals of the MCU are configured for this target (used by the PiOS drivers):
- Bootloader Settings
- LED defines
- SPI
- Watchdog
- I2C
- Serial ports
- USB It also contains application settings such as:
- Temetry stack
- RC Receiver settings (channels, protocols) It defines low-level hardware configuration specific to the board:
- Clocks, IRQ, DMA
add a directory with board name in lowercase Create a board_hw_defs.c there
Usage of this one ?
flight/PiOS/STM32F4xx/Libraries/CMSIS2/Device/ST/STM32F4xx/Source ( or the relevant device if not STM43F4xx)
add a directory with board name in lowercase, to put the system clock init there.
If you want to use a boot loader for this target, you can create a (capitalized) directory in flight/target/Bootloaders" for your board.
The boot loader uses PiOS, and cannot exist without a main firmware - the BL will not link properly.
in target:
add a directory with the board's name, capitalised
In that directory, you will need:
- Makefile
In that Makefile, you will define the PIOS modules used by your firmware, additional PiOS libraries you want to use, and the PiOS hardware drivers to compile.
- "System" directory
This is where the "main" module of PiOS resides. This is the task that is loaded at startup, and instantiates all the other modules as described below:
System Module This is the first thread that is created at startup. It will read the settings through the corresponding UAVObjects and start the rest of the modules. Which modules start depends on the settings. For example if in HITL mode then certain modules that interface with the sensors will not be started (see example below on how HITL will be implemented). Similarly, the appropriate stabilization module will start depending on the aircraft type (fixed wing or VTOL).