-
Notifications
You must be signed in to change notification settings - Fork 0
Development Adding a new board type
Here are the steps to add a new hardware target. This assumes that the CPU architecture is supported already.
The changes you will need to make for your target should be largely confined to the flight/target/<board name> directory. It is probably easiest to start by copying a directory of a board most similar to yours.
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.
flight/targets/<board name>/fw/Makefile
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.
./flight/targets/<board name>/board-info/board-info.m
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.
This contains a lot of the meta information for your target that is packaged into the boot loader and determines details about the memory layout, as well as the unique board ID. For the board id (BOARD_TYPE) make sure you are not conflicting with the existing targets.
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
flight/targets/<board name>/board-info/board_hw_defs.c
This is one of the most important files for your target, and contains the majority of the hardware mappings. See other examples for the conventions.
flight/targets/<board name>/fw/pios_board.c
This file is the one that predominantly uses board_hw_defs.c to power up the board and contains most of the remainder of the board specific information.
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).