Porting Betaflight to the Arduino Portenta H7 Board — Part 4

Moving the location of BetaFlight in Flash Memory

David Such

--

As described in Part 1 of our series, we are designing a drone using the new Arduino Portenta H7 as a flight controller.

Our intention is to port BetaFlight across to the STM32H747 microprocessor as the flight controller firmware.

Figure 1. The initial prototype of the Magpie Drone.

We have modified the BetaFlight firmware so that it compiles for the H7. The next step is to load the firmware into memory and tell the processor where the first instruction is located.

Normally you can just use BetaFlight Configurator for this purpose but the Portenta has a custom Arduino bootloader. The Portenta bootloader is accessed by tapping the reset button twice. The issue we have is that the custom Arduino bootloader is located at the same memory address as the BetaFlight ISR vector table. If you overwrite the custom bootloader you will brick your Portenta. Theoretically, you should be able to revive the board using the embedded bootloader (which is selected by connecting the BOOT pin to VCC during reset), but we were unable to do this.

Memory Considerations in the Portenta

Our Portenta is configured with:

  • 8MB SDRAM
  • 16MB NOR Flash

At startup, the boot memory space is selected by the BOOT pin and the BOOT_ADDx option bytes (Figure 2), allowing us to program in any boot memory address from 0x0000 0000 to 0x3FFF FFFF which includes flash memory, SRAM and the system memory (bootloader). The default boot addresses are:

  • Boot address 0: Flash memory at 0x0800 0000 (custom bootloader)
  • Boot address 1: ITCM-RAM at 0x1FF0 0000 (embedded bootloader)
Figure 3. Partial Memory Map.

--

--

David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control