Skip to content

Add STM32F407 Renode blink Rust firmware and Jumpstarter example#574

Open
mangelajo wants to merge 1 commit intomainfrom
renode-stm32f4-example
Open

Add STM32F407 Renode blink Rust firmware and Jumpstarter example#574
mangelajo wants to merge 1 commit intomainfrom
renode-stm32f4-example

Conversation

@mangelajo
Copy link
Copy Markdown
Member

Create the embedded Rust project (USART2 ON/OFF lines, PD12 LED) with stm32f4xx-hal, plus README, linker script, and rust-toolchain for thumbv7em-none-eabihf. Include Cargo.lock and a prebuilt ELF for flashing.

Made-with: Cursor

Create the embedded Rust project (USART2 ON/OFF lines, PD12 LED) with
stm32f4xx-hal, plus README, linker script, and rust-toolchain for
thumbv7em-none-eabihf. Include Cargo.lock and a prebuilt ELF for flashing.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

This PR adds a complete STM32F407 Rust bare-metal firmware example for Renode simulation, including build configuration, toolchain setup, linker scripts, device initialization code, and comprehensive documentation for the jumpstarter-driver-renode package.

Changes

Cohort / File(s) Summary
Build & Toolchain Configuration
.cargo/config.toml, rust-toolchain.toml, Cargo.toml
Establishes ARM Cortex-M4 build setup with thumbv7em-none-eabihf target, stable Rust toolchain, and firmware dependencies (cortex-m, cortex-m-rt, stm32f4xx-hal, panic-halt).
Linker & Memory Setup
memory.x, build.rs
Defines Flash (1024K @ 0x08000000) and RAM (128K @ 0x20000000) memory regions; build script generates memory.x and configures linker search paths.
Firmware Implementation
src/main.rs
Bare-metal entry point initializing STM32F407 peripherals (RCC, GPIO, USART2, TIM5) and alternating PD12 LED every 200ms with UART status output.
Configuration & Documentation
.gitignore, exporter-stm32f4.yaml, README.md
Adds Renode exporter configuration for stm32f407 discovery board, comprehensive usage guide, and target directory exclusion.

Suggested reviewers

  • raballew

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A blink in the darkness, LED shines bright,
Bare metal magic in Renode's light,
STM32 dancing with Rust's steady hand,
Firmware example, the finest in the land! 💡

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main change: adding an STM32F407 Rust firmware example with Jumpstarter integration for Renode.
Description check ✅ Passed The description is directly related to the changeset, detailing the embedded Rust project, USART2 implementation, LED toggle, build setup, and supporting files included in the example.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch renode-stm32f4-example

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md (3)

21-29: Consider adding a build verification step.

The instructions show how to build and copy the ELF, but don't mention how to verify the build succeeded. Adding a simple check could improve user experience.

💡 Suggested addition

After the build command, add a verification step:

The ELF is `target/thumbv7em-none-eabihf/release/stm32f407-rust-blink`. Verify it exists:

```bash
ls -lh target/thumbv7em-none-eabihf/release/stm32f407-rust-blink

Copy it if you want a stable name for Jumpstarter:

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In
@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md
around lines 21 - 29, Add a post-build verification step to the README after the
cargo build command to confirm the ELF was produced and is non-empty; for
example, instruct users to check the artifact at
target/thumbv7em-none-eabihf/release/stm32f407-rust-blink (or use test -f/ls
-lh) before the cp step so the build in stm32f407-rust-blink/README.md reliably
reports success.


</details>

---

`72-75`: **Consider adding installation links.**

The requirements list what's needed but don't guide users on how to install them. Adding links to installation documentation would improve the user experience, especially for first-time users.


<details>
<summary>📚 Suggested addition</summary>

```diff
 ## Requirements
 
-- **Renode** installed and on `PATH` (the driver spawns it for power/simulation).
-- Jumpstarter CLI (`jmp`) and the **Renode driver** available to the exporter.
+- **Renode** installed and on `PATH` (the driver spawns it for power/simulation). [Download Renode](https://renode.io/)
+- Jumpstarter CLI (`jmp`) and the **Renode driver** available to the exporter. See the [Jumpstarter documentation](../../README.md) for installation.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md`
around lines 72 - 75, Update the "Requirements" section in README.md to include
installation links so users can install dependencies: add a link for Renode's
installation/docs (e.g., Renode website or GitHub docs) next to "Renode
installed and on PATH", add a link for the Jumpstarter CLI (`jmp`) installation
or README next to "Jumpstarter CLI (`jmp`)", and add a link to the Renode driver
installation or exporter integration docs next to "Renode driver available to
the exporter"; keep the wording concise and user-focused so each requirement is
followed by a short parenthetical or inline link to the appropriate installation
or setup guide.

22-22: Consider removing or explaining the PATH modification.

If rustup is installed correctly, cargo should already be on PATH. The explicit PATH="$HOME/.cargo/bin:$PATH" prepend may confuse users who have cargo installed elsewhere or via system packages.

📝 Suggested alternatives

Option 1: Remove the PATH modification and rely on standard rustup installation:

-PATH="$HOME/.cargo/bin:$PATH" cargo build --release
+cargo build --release

Option 2: Add a note explaining when this is needed:

+# If cargo is not on PATH, prepend the default rustup location:
 PATH="$HOME/.cargo/bin:$PATH" cargo build --release
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md`
at line 22, The README currently prepends PATH with
PATH="$HOME/.cargo/bin:$PATH" before running cargo build --release which can be
unnecessary or misleading for users with cargo installed via rustup or system
packages; remove the PATH modification and just use "cargo build --release", or
if you keep it, add a brief note explaining it's only needed when Cargo is
installed in $HOME/.cargo/bin (e.g., installed via rustup without adding to
PATH) so readers know when to apply the PATH prepend.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/exporter-stm32f4.yaml`:
- Around line 7-9: Update the stale header comment that currently reads
"STM32F407 Discovery (opensomeip FreeRTOS/ThreadX)" to accurately describe this
file as the Rust blink example (e.g., "STM32F407 Discovery (Rust blink
example)"); remove or replace the "opensomeip FreeRTOS/ThreadX" text in the top
comment block while keeping other accurate details (like "Uses Renode's built-in
platform, USART2 for console output.") intact so the header reflects the actual
scenario.

In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md`:
- Line 59: Step 5 in the README.md currently instructs "press Ctrl+B three
times" to leave the console; update that line to instruct the correct
Renode/telnet escape sequence by telling users to press "Ctrl+]" once to enter
the telnet command mode and then type "quit" (or equivalent) to exit the
console, replacing the incorrect Ctrl+B instruction.

---

Nitpick comments:
In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md`:
- Around line 21-29: Add a post-build verification step to the README after the
cargo build command to confirm the ELF was produced and is non-empty; for
example, instruct users to check the artifact at
target/thumbv7em-none-eabihf/release/stm32f407-rust-blink (or use test -f/ls
-lh) before the cp step so the build in stm32f407-rust-blink/README.md reliably
reports success.
- Around line 72-75: Update the "Requirements" section in README.md to include
installation links so users can install dependencies: add a link for Renode's
installation/docs (e.g., Renode website or GitHub docs) next to "Renode
installed and on PATH", add a link for the Jumpstarter CLI (`jmp`) installation
or README next to "Jumpstarter CLI (`jmp`)", and add a link to the Renode driver
installation or exporter integration docs next to "Renode driver available to
the exporter"; keep the wording concise and user-focused so each requirement is
followed by a short parenthetical or inline link to the appropriate installation
or setup guide.
- Line 22: The README currently prepends PATH with PATH="$HOME/.cargo/bin:$PATH"
before running cargo build --release which can be unnecessary or misleading for
users with cargo installed via rustup or system packages; remove the PATH
modification and just use "cargo build --release", or if you keep it, add a
brief note explaining it's only needed when Cargo is installed in
$HOME/.cargo/bin (e.g., installed via rustup without adding to PATH) so readers
know when to apply the PATH prepend.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d8f7afa-91fe-4a2c-80c2-ad095fbce32c

📥 Commits

Reviewing files that changed from the base of the PR and between 5cf7e84 and c12d55c.

⛔ Files ignored due to path filters (1)
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/.cargo/config.toml
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/.gitignore
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/Cargo.toml
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/README.md
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/build.rs
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/exporter-stm32f4.yaml
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/memory.x
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/rust-toolchain.toml
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/src/main.rs
  • python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/stm32f407-rust-blink.elf

Comment on lines +7 to +9
# --- STM32F407 Discovery (opensomeip FreeRTOS/ThreadX) ---
# Uses Renode's built-in platform, USART2 for console output.
#
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update stale scenario label in header comments.

The section title/description still mentions opensomeip FreeRTOS/ThreadX, which doesn’t match this Rust blink example and can mislead users.

Suggested doc-only fix
-# --- STM32F407 Discovery (opensomeip FreeRTOS/ThreadX) ---
-# Uses Renode's built-in platform, USART2 for console output.
+# --- STM32F407 Discovery (Rust blink example) ---
+# Uses Renode's built-in platform, USART2 for console output.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# --- STM32F407 Discovery (opensomeip FreeRTOS/ThreadX) ---
# Uses Renode's built-in platform, USART2 for console output.
#
# --- STM32F407 Discovery (Rust blink example) ---
# Uses Renode's built-in platform, USART2 for console output.
#
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-renode/examples/stm32f407-rust-blink/exporter-stm32f4.yaml`
around lines 7 - 9, Update the stale header comment that currently reads
"STM32F407 Discovery (opensomeip FreeRTOS/ThreadX)" to accurately describe this
file as the Rust blink example (e.g., "STM32F407 Discovery (Rust blink
example)"); remove or replace the "opensomeip FreeRTOS/ThreadX" text in the top
comment block while keeping other accurate details (like "Uses Renode's built-in
platform, USART2 for console output.") intact so the header reflects the actual
scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant