Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devboard) Add support for STM32 F103, F4, and H7 targets #81

Merged
merged 78 commits into from
Feb 11, 2024

Conversation

ZZ-Cat
Copy link
Owner

@ZZ-Cat ZZ-Cat commented Feb 9, 2024

Overview

This Pull Request adds a handful of STM32 targets to CRSF for Arduino's Compatibility Table.
I want to add in as many STM32 F103, F4, F7, and H7 targets as I can, provided they meet the minimum 32 KB of flash memory (see my notes below on why this is now a requirement).

Targets

Here is what's been added:

  • Adafruit
    • Feather F405
  • Arduino
    • Arduino Nicla Vision
    • Arduino Opta
    • Arduino Portenta H7
  • Black Pill
    • F103C8
    • F103C8 (128 KB Flash memory variant)
    • F401CC
    • F411CE
  • Blue Pill
    • F103C6
    • F103C8
    • F103C8 (128 KB Flash memory variant)
  • Generic STM32F103xx
    • STM32F103C6
    • STM32F103C8
    • STM32F103CB
    • STM32F103R6
    • STM32F103R8
    • STM32F103RB
    • STM32F103RC
    • STM32F103RD
    • STM32F103RE
    • STM32F103RF
    • STM32F103RG
    • STM32F103T6
    • STM32F103T8
    • STM32F103TB
    • STM32F103V8
    • STM32F103VB
    • STM32F103VC
    • STM32F103VD
    • STM32F103VE
    • STM32F103VF
    • STM32F103VG
    • STM32F103ZC
    • STM32F103ZD
    • STM32F103ZE
    • STM32F103ZF
    • STM32F103ZG
  • Generic STM32F4xxyy
    • STM32F401CB
    • STM32F401CC
    • STM32F401CD
    • STM32F401CE
    • STM32F401RB
    • STM32F401RC
    • STM32F401RD
    • STM32F401RE
    • STM32F405OE (Only available with stm32duino, and not available in PlatformIO)
    • STM32F405OG (Only available with stm32duino, and not available in PlatformIO)
    • STM32F405RG
    • STM32F405VG (Only available with stm32duino, and not available in PlatformIO)
    • STM32F405ZG (Only available with stm32duino, and not available in PlatformIO)
    • STM32F407VE
    • STM32F407VG
    • STM32F410C8
    • STM32F410CB
    • STM32F410R8
    • STM32F410RB
    • STM32F411CE
    • STM32F411RC
    • STM32F411RE
    • STM32F412CE
    • STM32F412CG
    • STM32F412RE
    • STM32F412RG
    • STM32F413CG
    • STM32F413CH
    • STM32F413RG
    • STM32F413RH
    • STM32F415RG
    • STM32F417VE
    • STM32F417VG
    • STM32F423CH
    • STM32F423RH
    • STM32F446RC
    • STM32F446RE
  • Generic STM32F722xx (Only available with stm32duino, and not available in PlatformIO)
    • STM32F722IC
    • STM32F722IE
    • STM32F722RC
    • STM32F722RE
    • STM32F722VC
    • STM32F722VE
    • STM32F722ZC
    • STM32F722ZE
  • Generic STM32H745xx (Only available with stm32duino, and not available in PlatformIO)
    • STM32H745BG
    • STM32H745BI
    • STM32H745IG
    • STM32H745II
    • STM32H745ZG
    • STM32H745ZI
  • Generic STM32H750xx
    • STM32H750BT
  • SparkFun
    • MicroMod F405
  • ST
    • Black F407VE
    • Black F407VG
    • Black F407ZE
    • Black F407ZG
    • Blue F407VE Mini
    • Discovery F413ZH
    • Disocvery F746NG
    • Nucleo F401RE
    • Nucleo F411RE
    • Nucleo F429ZI
    • Nucleo F446RE
    • Nucleo F722ZE
    • Nucleo F746ZG
    • Nucleo F756ZG
    • Nucleo F767ZI
    • Nucleo H723ZG
    • Nucleo H743ZI

Spite won out - F722 for Arduino IDE

The abysmal F722 support in PlatformIO pissed me off that much, that I added F722 support out of pure spite.
I looked over at stm32duino and found they had every STM32F722 target imaginable. So, I thought "Right! F*** you! I need them! F722 or bust!"

This means that PlatformIO users are still out-of-pocket because the only F722 target you have is the Nucleo F722ZE. Yea, yea. I know. This pisses me off too. Go hit PlatformIO themselves up about it via their Issues tab.

I'm spiteful about the F405, F722, and H745 targets because these are literally used in all of our drone flight controllers. Especially ones that use ArduPilot, Betaflight, INAV, and RotorFlight.
I am also aware that some legacy flight controllers such as the MSH Brain2, BeastX, VBar NEO all use either STM32F103CB or a variant of STM32F405xx.

Additional notes

While working on this Pull Request, I have noticed CRSF for Arduino overflows the flash memory for targets that have smaller than 32 KB of flash memory. Even on targets that have 32 KB of flash memory, CRSF for Arduino takes up approx. 50~60 % of available space. I am not entirely sure on how usable this will be for some of you. If you run into any troubles, let me know.

I am tentatively adding some STM32F103 targets as long as they have at least 32 KB of flash memory.
If I am made aware of these targets being problematic, I may remove them at a later date, and raise the minimum required memory space to around 64~128 KB instead.

Another thing I have noticed with some STM32 targets, is they don't declare Serial1 in their variant layer. Thus, producing a compiler error along the lines of "Undefined reference to Serial1 in SerialReceiver.cpp in function serialReceiverLayer::SerialReceiver()"
So, as a workaround, I'm using preprocessors for STM32 targets that automatically selects the nearest available port as the default. EG If Serial1 isn't available and Serial2 is, CRSF for Arduino's default constructor will pick Serial2.

This only affects the default constructor. Not the constructor you use to provide your own HardwareSerial instance.
IE:

  • CRSFforArduino() 👈 This constructor is affected.
  • CRSFforArduino(HardwareSerial *serialPort) 👈 This constructor is not affected.

I told y'all STM32 is a rabbit hole. =^/.~=

There simply isn't enough flash memory on this target to support CRSF for Arduino
…lt `Serialn` port if `Serial1` is not available

So far, this is only applicable to STMF1 targets
@ZZ-Cat ZZ-Cat linked an issue Feb 9, 2024 that may be closed by this pull request
1 task
@ZZ-Cat ZZ-Cat added the ✨️ Enhancement ✨️ New feature or request label Feb 9, 2024
@ZZ-Cat ZZ-Cat self-assigned this Feb 9, 2024
@ZZ-Cat ZZ-Cat added Arduino IDE ♾️ This is specific to the Arduino IDE PlatformIO 👽 This is specific to PlatformIO. labels Feb 9, 2024
@ZZ-Cat ZZ-Cat added this to the Version 1.0.0 milestone Feb 9, 2024
@ZZ-Cat ZZ-Cat added the ...in progress 🚧 Development on this is in progress label Feb 9, 2024
@ZZ-Cat ZZ-Cat changed the title ZZ-Cat/issue58 feat(dev boards) Add support for STM32 F103, F4, and H7 targets Feb 9, 2024
@ZZ-Cat ZZ-Cat changed the title feat(dev boards) Add support for STM32 F103, F4, and H7 targets feat(devboard) Add support for STM32 F103, F4, and H7 targets Feb 9, 2024
@ZZ-Cat
Copy link
Owner Author

ZZ-Cat commented Feb 11, 2024

Right-oh. Now, I am up to adding the H7 targets. After that, that's this Pull Request done and dusted.
Gods, this was a rabbit hole and a half! =>/.<=

I know there are a few more STM32 targets, however F103, F4, F7 and H7 are the main four I wanted to add, because I know for a fact that Betaflight, INAV, and ArduPilot make use of these targets. If anyone wants me to add more targets, thar quite welcome to ask me to do so via my Issues tab.

I am a little disappointed at the lack of STM32F722xxxx support that the current version of the stm32 package has. But, this is easily offset by the overwhelming amount of F4 and H7 targets, as both of these seem like the desired path for Betaflight and ArduPilot, respectively anyway.

Now... the person that made the request for me to add in STM32 support was not specific about the targets they wanted.
They literally copy-and-pasted "Please add stm32 support" into their Issue several times over. Please do not do this, next time.
It doesn't do you any good, if you're not specific about what you need me to add.

The next time someone is vague about what they need me to do for them, I will ask them to be specific about their needs.
Failing that, I will close their Issue, if they give no response after more than two weeks.

@ZZ-Cat
Copy link
Owner Author

ZZ-Cat commented Feb 11, 2024

Right! That's it. I'm done with this Pull Request.
Currently waiting on the PlatformIO checks to pass, and this sucker can be merged!

I didn't add literally every STM32 target in existence, because this PR was starting to feel like I was bashing my head against a wall.
I feel like there is enough there for most people to be happy. If someone wants me to add their super-obscure target, thar more than welcome to let me know via my Issues tab.

@ZZ-Cat ZZ-Cat marked this pull request as ready for review February 11, 2024 06:54
@ZZ-Cat ZZ-Cat removed the ...in progress 🚧 Development on this is in progress label Feb 11, 2024
@ZZ-Cat ZZ-Cat merged commit 941e1ab into Main-Trunk Feb 11, 2024
4 checks passed
@ZZ-Cat ZZ-Cat deleted the ZZ-Cat/issue58 branch February 11, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arduino IDE ♾️ This is specific to the Arduino IDE ✨️ Enhancement ✨️ New feature or request PlatformIO 👽 This is specific to PlatformIO.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

please support stm32 chip in arduino fremework and vscode pio
1 participant