Add renode MCU emulation support (WIP) - #33975
Open
tridge wants to merge 10 commits into
Open
Conversation
Run unmodified STM32F405 and STM32H743 ChibiOS firmware under Renode. Generate board overlays and launch scripts at invocation time from the application and bootloader hwdefs instead of maintaining board copies. Add shared MCU platforms, peripheral models, persistent media, real-time pacing, and a deterministic H743 BLHeli/Shared_DMA reproduction.
Generate IOMCU, SPI chip-select routing, and required sensor models from the compiled hwdef data. Preserve RAMTRON writes at real chip-select transaction boundaries so parameters survive firmware resets and Renode restarts.
Deliver host bytes over virtual time so H7 UART DMA can rearm between bounce buffers, and synthesize IDLE only after a real input gap. Preserve the last valid baud rate while the UART resets so queued MAVProxy traffic cannot abort Renode during reboot.
Bridge generated CAN controllers to ArduPilot multicast buses and connect H7 Ethernet controllers to a host TAP. Add the sensor and controller behavior needed to run Pixhawk6X firmware with those interfaces enabled.
Extend generated platform support across additional STM32F4, STM32F7, and STM32H7 flight controllers. Add the IMU, barometer, SDMMC, USB, and IOMCU models required by their production hwdefs.
Correct H7 Ethernet receive descriptor handling and complete the generated SPI and ICM42688 behavior needed for reliable Pixhawk6X startup and operation.
Expose ChibiOS threads and saved contexts through a GDB remote proxy. Support bounded Renode reverse execution, reconnect the proxy after snapshot restore, and keep affected peripherals snapshot-safe. Reduce reverse snapshot storage while keeping normal debugging responsive by forwarding interrupts during execution and batching thread registry reads.
Select AP_Periph firmware automatically and derive simulated GPS, airspeed, battery, and serial rangefinder devices from hwdef feature definitions. Route generated CAN interfaces to consecutive multicast buses by default. Add platform support for compatible STM32F1, STM32F3, STM32F4, STM32F7, STM32G4, STM32H7, and STM32L4 targets, covering all STM32 AP_Periph builds.
Report occupied proxy ports without a Python traceback and wait for the proxy to become ready before starting Renode or launching GDB.
Back the full internal MCU flash using BOARD_FLASH_SIZE so linker layout changes do not invalidate persistent state. Overlay the selected firmware's file-backed bytes without clearing crash data. Import legacy storage and crash-log images once at their physical addresses and retain the old files as backups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for "renode" (see https://renode.io/ ) for emulating STM32 MCUs, allowing unmodified ArduPilot for STM32/ChibiOS to be booted within a MCU emulator. This is evolving rapidly as I add new features, but roughly speaking at the moment it supports:
Speed is roughly equal to realtime on my (quite fast) laptop.
We're using a modified version of renode which I have put here:
https://github.com/ArduPilot/renode/tree/pr-arudpilot-am32-perf
it also needs .NET 10 (you can apt-get install on recent linux). I have the following installed on ubuntu 26.04:
There is a lot more to do and many things are emulated in a very minimal form, just enough to get us booting, but it has already reproduced and fixed its first bug, see #33933