Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
282d113
Add script to convert a BF unified target to an INAV target
mmosca Jan 29, 2023
8983e5a
Setup basic peripherals.
mmosca Jan 29, 2023
63b3939
Add OSD, Blackbox definitions. Also add ADC but still missing ADC DMA
mmosca Jan 30, 2023
be8c03d
compile error
mmosca Feb 1, 2023
da0cd56
All files generated. Still missing ADC info
mmosca Feb 7, 2023
3d1d280
Handle missing timer information for beeper/led
mmosca Feb 7, 2023
6269852
Sometimes it generates a working target
mmosca Feb 8, 2023
98186bc
Add USE_VCP
mmosca Feb 8, 2023
c256f9d
Merge remote-tracking branch 'origin/master' into mosca-target-converter
mmosca Sep 8, 2023
ea67957
Small update
mmosca Sep 8, 2023
36f513f
Merge remote-tracking branch 'origin/master' into mosca-target-converter
mmosca Dec 5, 2023
82fcff6
Add remarks about unified-targets being replaced with config.h
mmosca Dec 5, 2023
eab995f
Merge remote-tracking branch 'origin/master' into mosca-target-converter
mmosca Dec 9, 2023
23e0741
Add file with timer pin mappings.
mmosca Dec 9, 2023
d5e68df
Add STM32F405
mmosca Dec 9, 2023
65f6329
Add STM32H743
mmosca Dec 9, 2023
d744126
More updates to read config.h instead of unified targets
mmosca Dec 10, 2023
ca0ff6a
target.h mostly converted to read config.h
mmosca Dec 10, 2023
c605784
Back to stage one.
mmosca Dec 10, 2023
bfaf1a4
Small issues found by converting BETAFPVF405 (pavo pico's fc)
mmosca Dec 10, 2023
291fe98
Fix mcu2timerKey
mmosca Dec 10, 2023
2231d1c
fix usb errors
mmosca Dec 10, 2023
c940461
small cosmetic change
mmosca Dec 10, 2023
610f22a
Add some breif info
mmosca Dec 10, 2023
cb9fa01
Remove target added by accident
mmosca Dec 10, 2023
224441b
add stm32f722 7x5
mmosca Dec 10, 2023
cfc45ad
small changes on mcu match
mmosca Dec 10, 2023
f2cbbd5
Add documentation for bf2inav.py script
mmosca Dec 11, 2023
3443f26
Fix typo
mmosca Dec 11, 2023
7c532cd
Add PINIO
mmosca Dec 12, 2023
4b92544
Fix missing GYRO_1_ALIGN for AIKONF7
mmosca Dec 29, 2023
d2a55d4
Always cound usb vcp as serial.
mmosca Dec 29, 2023
4f2345a
Fix SPI baro case
mmosca Dec 29, 2023
4e14423
Add missing USE_BARO_BMP280 to SPI case
mmosca Dec 29, 2023
c14f030
bf2inav.py: clearer error messages, number PWM outputs
sensei-hacker Jan 1, 2024
e284bd5
Merge pull request #9611 from sensei-hacker/mosca-target-converter
mmosca Jan 1, 2024
225895a
Merge remote-tracking branch 'origin/master' into mosca-target-converter
mmosca Mar 25, 2024
2fe6f04
Merge remote-tracking branch 'origin/master' into mosca-target-converter
mmosca Apr 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/development/Converting Betaflight Targets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
If your flight controller does not have an official INAV target, it is possible to use src/utils/bf2inav.py script to generate a good starting point for an unofficial INAV target.

This script can read the config.h from [Betaflight's target configuration repository](https://github.com/betaflight/config) and it currently supports STM32F405, STM32F722, STM32F745, STM32H743 and AT32F435 targets.
Locate your Flight Controller target config.h in BetaFlight's repo, eg.: [config.h](https://github.com/betaflight/config/blob/master/configs/BETAFPVF405/config.h), for BETAFPVF435 target.

It is also advisable to record the output of the timer command from BetaFlight, as it will provide useful information on `timer` usage that can be used to adjust the generated target later.

```
# timer
timer B08 AF3
# pin B08: TIM10 CH1 (AF3)
timer C08 AF3
# pin C08: TIM8 CH3 (AF3)
timer B00 AF2
# pin B00: TIM3 CH3 (AF2)
timer B01 AF2
# pin B01: TIM3 CH4 (AF2)
timer A03 AF1
# pin A03: TIM2 CH4 (AF1)
timer A02 AF1
# pin A02: TIM2 CH3 (AF1)
timer B06 AF2
# pin B06: TIM4 CH1 (AF2)
timer A08 AF1
# pin A08: TIM1 CH1 (AF1)
timer A09 AF1
# pin A09: TIM1 CH2 (AF1)
timer A10 AF1
# pin A10: TIM1 CH3 (AF1)
```
In the above example, `pin B08: TIM10 CH1 (AF3)` means that pind to CH1. This information can be used to fix the generated timer assigned to match BetaFlight's allocation by editing the `target.c` file generated by the `bf2inav.py` script.


Using the BETAFPVF405 target mentioned above, to create the target now we need to:

1. Download INAV source code and be able to build
2. Download the config.h from BetaFlight repository
3. Create a target folder that will be used as the output folder for the `bf2inav.py` script, eg: `inav/src/main/targets/BETAFPVF405`
4. Navigate to the script folder in `inav/src/utils/`
5. `python3 ./bf2inav.py -i config.h -o ../main/target/BETAFPVF405/`
6. Edit generated `target.c` and chose the correct timer definitions to match Betaflight's timer definitions.
```
timerHardware_t timerHardware[] = {
DEF_TIM(TIM3, CH3, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH2N, PB0, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM3, CH4, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM8, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM1, CH3N, PB1, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH2, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH4, PA3, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM5, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM9, CH1, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),
DEF_TIM(TIM2, CH3, PA2, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM8, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),
//DEF_TIM(TIM3, CH3, PC8, TIM_USE_OUTPUT_AUTO, 0, 0),

DEF_TIM(TIM1, CH1, PA8, TIM_USE_OUTPUT_AUTO, 0, 0),

//DEF_TIM(TIM3, CH1, PB4, TIM_USE_BEEPER, 0, 0),

DEF_TIM(TIM4, CH1, PB6, TIM_USE_LED, 0, 0),

};
```
In this particular example, PA3, PA2 were changed to match Betaflight's mapping, and the timer PB4 was disabled, due to a timer conflict. Normal channels are prefered over N channels (CH1, over CH1N) or C channels in AT32 architectures.
7. Now update yout build scripts by running `cmake` and build the target you just created. The target name can be checked in the generated `CMakeLists.txt`, but should match the Betaflight target name.

For information on how to build INAV, check the documents in the [docs/development](https://github.com/iNavFlight/inav/tree/master/docs/development) folder.
Loading