betaflight icon indicating copy to clipboard operation
betaflight copied to clipboard

Add support for BMP390

Open haslinghuis opened this issue 11 months ago • 15 comments

  • Fixes #13446

haslinghuis avatar Mar 12 '24 16:03 haslinghuis

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13447 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

github-actions[bot] avatar Mar 12 '24 16:03 github-actions[bot]

It would be great to go over bmp388CompensateTemperature / bmp388CompensatePressure and replace it with something reasonable ...

ledvinap avatar Mar 12 '24 17:03 ledvinap

~~I'm looking to test this with a local .config file. Am I still able to specific the commit in the Configurator?~~

~~See log~~

Nevermind, I forgot the '#'

ws998116 avatar Mar 12 '24 17:03 ws998116

Sorry, I'm still figuring out how to use the cloud build.

I want to test this PR with my custom hardware. I'm able to create a build with #13447 but I have a .config file that I want to use along with it. When I load the .config file, the Build Configuration settings go away. Could someone walk me through how to apply the .config file with this PR?

ws998116 avatar Mar 12 '24 17:03 ws998116

With local build and custom config.h need to do it locally

Checkout this PR

make configs
make arm_sdk_install
edit your config locally in src/config
make BOARD

haslinghuis avatar Mar 12 '24 17:03 haslinghuis

Thanks @haslinghuis!

I did

make configs
make arm_sdk_install

But then I realized I have a .config file (like a unified target), not a config.h file. I'm not quite sure how to convert it. Let me know if you have thoughts.

Thanks so much 🙂

ws998116 avatar Mar 12 '24 18:03 ws998116

Post the unified target file here

haslinghuis avatar Mar 12 '24 18:03 haslinghuis

config.h.txt

Need to add timers and dma using cli as the config did not provide the output of timers - only AF.

haslinghuis avatar Mar 12 '24 18:03 haslinghuis

Thank you again!

I've used your config.h and ran make RRIOTF722 but the build failed. A lot of errors so I'm not sure where to start. I can post a log file if needed.

ws998116 avatar Mar 12 '24 18:03 ws998116

@ws998116

Need to cut out - and use cli to add these

# timer
timer C08 AF2
timer C09 AF2
timer A08 AF2
timer A09 AF2
timer B04 AF2
timer B05 AF2

# dma
dma pin C08 0
dma pin C09 0
dma pin A08 0
dma pin A09 0
dma pin B04 0
dma pin B05 0

haslinghuis avatar Mar 12 '24 18:03 haslinghuis

Thanks @haslinghuis, I was able to build it. I will test this tomorrow and report my results.

ws998116 avatar Mar 12 '24 19:03 ws998116

I've flashed the build on my hardware, but I'm not getting any indication that the barometer is working. I'm using the CLI to see if the barometer is recognized at all, but it doesn't seem like it.

My hardware has the BMP390 using SPI, but it seems like bmp388Detect should still work. I see that you recommended not sharing the SPI bus and I'm wondering if this has something to do with it. The BMP390 does has its own CS pin set up in my hardware though.

I'm now looking into how I can debug this further.

CLI output
resource show
Currently active IO resource assignments:
(reboot to update)
--------------------
A00: FREE
A01: FREE
A02: FREE
A03: FREE
A04: GYRO_CS 1
A05: FREE
A06: FREE
A07: FREE
A08: MOTOR 3
A09: MOTOR 4
A10: FLASH_CS
A11: USB
A12: USB
A13: SWD
A14: SWD
A15: FREE
B00: FREE
B01: FREE
B02: PREINIT 2
B03: LED 1
B04: FREE
B05: FREE
B06: FREE
B07: FREE
B08: CAMERA_CONTROL
B09: FREE
B10: FREE
B11: FREE
B12: PREINIT 4
B13: SPI_SCK 2
B14: SPI_SDI 2
B15: SPI_SDO 2
C00: FREE
C01: ADC_CURR
C02: FREE
C03: ADC_BATT
C04: FREE
C05: FREE
C06: FREE
C07: FREE
C08: MOTOR 1
C09: MOTOR 2
C10: FREE
C11: FREE
C12: FREE
C13: FREE
C14: FREE
C15: BEEPER
D00: FREE
D01: FREE
D02: FREE
D03: FREE
D04: FREE
D05: FREE
D06: FREE
D07: FREE
D08: FREE
D09: FREE
D10: FREE
D11: FREE
D12: FREE
D13: FREE
D14: FREE
D15: FREE
E00: FREE
E01: FREE
E02: FREE
E03: FREE
E04: FREE
E05: FREE
E06: FREE
E07: FREE
E08: FREE
E09: FREE
E10: FREE
E11: FREE
E12: FREE
E13: FREE
E14: FREE
E15: FREE
F00: FREE
F01: FREE
F02: FREE
F03: FREE
F04: FREE
F05: FREE
F06: FREE
F07: FREE
F08: FREE
F09: FREE
F10: FREE
F11: FREE
F12: FREE
F13: FREE
F14: FREE
F15: FREE

feature list
Available: RX_PPM INFLIGHT_ACC_CAL RX_SERIAL MOTOR_STOP SERVO_TILT SOFTSERIAL GPS RANGEFINDER TELEMETRY 3D RX_PARALLEL_PWM RX_MSP RSSI_ADC LED_STRIP DISPLAY OSD CHANNEL_FORWARDING TRANSPONDER AIRMODE RX_SPI ESC_SENSOR ANTI_GRAVITY

dma show

Currently active DMA:
--------------------
DMA1 Stream 0: FREE
DMA1 Stream 1: FREE
DMA1 Stream 2: FREE
DMA1 Stream 3: SPI_SDI 2
DMA1 Stream 4: SPI_SDO 2
DMA1 Stream 5: FREE
DMA1 Stream 6: FREE
DMA1 Stream 7: FREE
DMA2 Stream 0: ADC
DMA2 Stream 1: FREE
DMA2 Stream 2: DSHOT_BITBANG 3
DMA2 Stream 3: DSHOT_BITBANG 1
DMA2 Stream 4: FREE
DMA2 Stream 5: FREE
DMA2 Stream 6: FREE
DMA2 Stream 7: FREE

ws998116 avatar Mar 13 '24 15:03 ws998116

@ws998116 , i edited your spoiler. needed emptyline after /summary to render properly

[...]</summary>

[content]

nerdCopter avatar Mar 13 '24 15:03 nerdCopter

I've found at least part of the problem that I'm experiencing. I looked through the Bosch API for the BMP3XX and found that SPI communication requires an extra dummy byte to be read (see here).

To test this, I've changed static uint8_t bmp388_chip_id = 0; to static uint8_t bmp388_chip_id[2]; and read 2 bytes for the chip ID, where the actual value is stored in bmp388_chip_id[1]. I have verified that the chip is recognized this way but it does not seem to output correct altitude data. See my changes here. Obviously these changes cannot be directly used because they are specific to using the barometer with SPI.

image

ws998116 avatar Mar 15 '24 14:03 ws998116

Can you test https://github.com/betaflight/betaflight/pull/13458 ?

ledvinap avatar Mar 18 '24 12:03 ledvinap

Closing in favor of #13458

haslinghuis avatar Mar 18 '24 13:03 haslinghuis