Skip to content

Commit

Permalink
Adding documentation around board configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
blckmn committed Feb 10, 2023
1 parent 6e94271 commit 53550dd
Showing 1 changed file with 3 additions and 155 deletions.
158 changes: 3 additions & 155 deletions docs/development/development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,162 +201,10 @@ Please note the use of `-D` and the `USE_`. This differs from the way in which t

These defines that we add, either on the command line or in the custom defines (in expert mode) in the configurator, are called `gates`, and include or exclude whole sections of code.


### Custom Defaults - for Developers - DEBUGGER USE ONLY

As all targets are now MCU based (and cloud built), this poses a problem for developers in flashing and running a fully baked "hex" using the standard debugger. The board scratch space (located at the /src/main/board directory) allows developers to setup their environment like they were running a fully baked unified target.

:::warning

These instructions are for flashing with a debugger ONLY. Any hex created this way will not flash using the configurator.

This is by design.

:::

Once setup, you can simply execute make with `make BOARD=BETAFLIGHTF7` where BETAFLIGHTF7 is the sub directory name under /src/main/board i.e. /src/main/board/BETAFLIGHTF7.

For example if you were developing and you had the BETAFLIGHTF7 target:

1. Create the directory /src/main/board/BETAFLIGHTF7

2. Create files, `board.c`, `board.h`, and `board.mk` in the directory created (in #1 above).

3. `board.c` is where you will insert the custom defaults so they are baked into the board already (and do not need to be loaded separately). This is great for debugging as they will already be present in the flash. So the `board.c` for BETAFLIGHTF7 is:

`board.c`
If you want to locally compile the default compile time configuration for a given manufacturer you can do so by:

```
#include "board.h"
const char __attribute__ ((section(".custom_defaults"), used, aligned(4))) customDefaults[] =
"# Betaflight\n"
"board_name BETAFLIGHTF7\n"
"manufacturer_id FPVM\n"
"resource BEEPER 1 D15\n",
"resource MOTOR 1 B00\n",
"resource MOTOR 2 B01\n",
"resource MOTOR 3 E09\n",
"resource MOTOR 4 E11\n",
"resource PPM 1 A03\n",
"resource SONAR_TRIGGER 1 B10\n",
"resource SONAR_ECHO 1 B11\n",
"resource LED_STRIP 1 D12\n",
"resource SERIAL_TX 1 A09\n",
"resource SERIAL_TX 2 A02\n",
"resource SERIAL_TX 3 B10\n",
"resource SERIAL_TX 6 C06\n",
"resource SERIAL_RX 1 A10\n",
"resource SERIAL_RX 2 A03\n",
"resource SERIAL_RX 3 B11\n",
"resource SERIAL_RX 6 C07\n",
"resource LED 1 E00\n",
"resource SPI_SCK 1 A05\n",
"resource SPI_SCK 2 B13\n",
"resource SPI_SCK 3 C10\n",
"resource SPI_SCK 4 E02\n",
"resource SPI_MISO 1 A06\n",
"resource SPI_MISO 2 B14\n",
"resource SPI_MISO 3 C11\n",
"resource SPI_MISO 4 E05\n",
"resource SPI_MOSI 1 A07\n",
"resource SPI_MOSI 2 B15\n",
"resource SPI_MOSI 3 C12\n",
"resource SPI_MOSI 4 E06\n",
"resource CAMERA_CONTROL 1 C08\n",
"resource ADC_BATT 1 C03\n",
"resource ADC_RSSI 1 C05\n",
"resource ADC_CURR 1 C02\n",
"resource BARO_CS 1 A01\n",
"resource FLASH_CS 1 E04\n",
"resource OSD_CS 1 B12\n",
"resource GYRO_EXTI 1 D00\n",
"resource GYRO_EXTI 2 E08\n",
"resource GYRO_CS 1 A04\n",
"resource GYRO_CS 2 A15\n",
"resource USB_DETECT 1 C04\n",
"timer C08 AF3\n",
"timer E13 AF1\n",
"timer B00 AF2\n",
"timer B01 AF2\n",
"timer E09 AF1\n",
"timer E11 AF1\n",
"timer D12 AF2\n",
"timer B10 AF1\n",
"timer B11 AF1\n",
"timer C06 AF3\n",
"timer C07 AF3\n",
"timer A03 AF1\n",
"timer A02 AF3\n",
"dma ADC 1 1\n",
"dma pin C08 1\n",
"dma pin E13 1\n",
"dma pin B00 0\n",
"dma pin B01 0\n",
"dma pin E09 2\n",
"dma pin E11 1\n",
"dma pin D12 0\n",
"dma pin B10 0\n",
"dma pin B11 0\n",
"dma pin C06 0\n",
"dma pin C07 1\n",
"dma pin A03 0\n",
"feature OSD\n",
"set mag_bustype = I2C\n",
"set mag_i2c_device = 2\n",
"set baro_spi_device = 1\n",
"set blackbox_device = SPIFLASH\n",
"set current_meter = ADC\n",
"set battery_meter = ADC\n",
"set beeper_inversion = ON\n",
"set beeper_od = OFF\n",
"set max7456_spi_bus = 2\n",
"set dashboard_i2c_bus = 2\n",
"set flash_spi_bus = 4\n",
"set gyro_1_bustype = SPI\n",
"set gyro_1_spibus = 1\n",
"set gyro_1_sensor_align = CW90\n",
"set gyro_1_align_yaw = 900\n",
"set gyro_2_spibus = 3\n",
"set gyro_2_sensor_align = CW270\n",
"set gyro_2_align_yaw = 2700\n"
"\0";
make CONFIG=BETAFLIGHTF7
```

NOTE: When wanting to do this for other boards, the contents is replaced with everything you need for the custom defaults configuration you want to "bake" into the board when flashed. You can get this from the unified targets repository if needed. DO NOT forget the firstline `# Betaflight\n`, the `\0` terminator (one at the very end of the list), and the `\n` line termination (one at the end of each line) need to be added.

4. `board.h` allows for any defines that you are working on as developers rather than specify via command line in EXTRA_FLAGS (as the cloud build system does). Therefore for `board.h` for the BETAFLIGHTF7 insert the following:

`board.h`

```
#define USE_GYRO_SPI_MPU6000
#define USE_ACC_SPI_MPU6000
#define USE_GYRO_SPI_MPU6500
#define USE_ACC_SPI_MPU6500
#define USE_MAX7456
#define USE_DSHOT
#define USE_SERIALRX
#define USE_SERIALRX_CRSF
#define USE_SERIALRX_GHST
#define USE_SERIALRX_SBUS
#define USE_TELEMETRY
#define USE_FLASH
#define USE_OSD
#define USE_VTX
#define USE_TELEMETRY_CRSF
#define USE_TELEMETRY_GHST
```

5. `board.mk` allows for any additional source files, and to specify the target. The minimum requirement is the target (unless you specify this on the command line for make). So the contents of `board.mk` for BETAFLIGHTF7 is as follows:

`board.mk`

```
TARGET := STM32F7X2
```

6. You should now be able to successfully make a debuggable version of Betaflight for the BETAFLIGHTF7 board, using the command line: `make BOARD=BETAFLIGHTF7`. Other command line options all remain valid also. e.g. `make BOARD=BETAFLIGHTF7 TARGET=STM32F7X2 EXTRA_FLAGS="-DUSE_BATTERY_CONTINUE"`.

NOTE: The **/src/main/board** directory is GIT IGNORED. This is because it is a developers scratch space for this very purpose, so code you include will not be picked up for committing. You can create as many board "profiles" as you like in this directory.
This will build you a target hex file that has everything baked in for that manufacturers configuration, including any default features as specified by the manufacturer.

0 comments on commit 53550dd

Please sign in to comment.