Skip to content

micropython: support armv7r5f [do not merge]#467

Draft
mateusz-bloch wants to merge 2 commits intomasterfrom
mateusz-bloch/micropython_for_armv7r5f
Draft

micropython: support armv7r5f [do not merge]#467
mateusz-bloch wants to merge 2 commits intomasterfrom
mateusz-bloch/micropython_for_armv7r5f

Conversation

@mateusz-bloch
Copy link
Member

JIRA: CI-645

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (list targets here).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces foundational support for running MicroPython tests on the armv7r5f architecture. It provides a dedicated test harness that automates the process of deploying, executing, and verifying MicroPython test scripts on the target system, which is crucial for expanding test coverage and ensuring compatibility with new hardware platforms.

Highlights

  • New MicroPython Test Harness: Introduced a new Python script, micropython_armv7r5f.py, which serves as a test harness specifically designed for running MicroPython tests on the armv7r5f-zynqmp-qemu platform.
  • Test Execution Logic: The harness defines a harness function that reads test and expected output files, creates the test file on the Device Under Test (DUT) using an editor, executes the MicroPython script, and validates its output against predefined expectations or skips if a specific pattern is matched.
  • Regex Output Handling: Includes a TESTS_WITH_REGEX_OUTPUT set to identify specific tests whose output should be treated as a regex pattern for more flexible matching, rather than a literal string.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new test harness for MicroPython on the armv7r5f architecture. The changes primarily involve setting up the test environment, interacting with an editor to load test scripts, and executing them. While the overall structure is in place, several areas require attention to improve correctness, robustness, and maintainability. Specifically, the editor interaction logic relies on fragile workarounds and hardcoded control characters, and there's a critical error in how expected outputs are handled for tests requiring regex matching. Additionally, the hardcoded root path for MicroPython tests could be made more flexible.

Comment on lines +66 to +67
else:
expected = test_name

Choose a reason for hiding this comment

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

critical

In the else branch, when test_name is in TESTS_WITH_REGEX_OUTPUT, expected is incorrectly set to test_name. The expected variable should contain the content of the .exp file, processed as a regular expression, not the test file's name. This logic will cause tests that require regex output matching to fail.

Suggested change
else:
expected = test_name
expected = create_regex(expected_output)

from trunner.types import Status, TestResult

import psh.tools.psh as psh

Choose a reason for hiding this comment

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

critical

The create_regex function, which is essential for correctly processing expected output for tests with regex output, is defined in micropython/micropython.py but not imported into this file. It needs to be imported to be used in the harness function.

Suggested change
from micropython.micropython import create_regex

Comment on lines +33 to +36
# Hack
for _ in range(attempts):
dut.sendline("")

Choose a reason for hiding this comment

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

medium

The comment "# Hack" indicates this is a workaround. Sending empty lines repeatedly to wait for the editor to be ready is fragile and can lead to flaky tests if the editor's startup time varies. It's better to expect a specific prompt or a known editor state to ensure readiness, making the test more robust and less prone to timing issues.

Comment on lines +40 to +41
dut.send("\x13") # Ctrl+S
dut.send("\x11") # Ctrl+Q

Choose a reason for hiding this comment

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

medium

Using hardcoded control characters like "\x13" (Ctrl+S) and "\x11" (Ctrl+Q) for editor operations makes this script highly dependent on the specific editor's keybindings, reducing maintainability and portability. If the underlying editor changes or has different keybindings, this part of the test will break. Consider using a more abstract way to interact with the editor if available, or document this dependency clearly.

Comment on lines +22 to +25
MICROPYTHON_ROOT = (
Path(__file__).resolve().parent
/ "../../_fs/armv7r5f-zynqmp-qemu/root/usr/test/micropython"
).resolve()

Choose a reason for hiding this comment

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

medium

The MICROPYTHON_ROOT path is hardcoded, making the test harness less flexible and prone to breakage if the project's file layout changes. Consider making this path configurable, perhaps through a TestContext parameter or an environment variable, to improve portability and maintainability.

@github-actions
Copy link

github-actions bot commented Mar 23, 2026

Unit Test Results

     1 files  ±     0   2 027 suites  +1 402   6h 3m 55s ⏱️ + 5h 12m 23s
23 236 tests +12 777  19 450 ✅ +9 653  3 785 💤 +3 123  1 ❌ +1 
23 422 runs  +12 963  19 597 ✅ +9 800  3 824 💤 +3 162  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 43bdb70. ± Comparison against base commit f7978fc.

This pull request removes 1942 and adds 14719 tests. Note that renamed tests count towards both.
flash ‑ armv7a7-imx6ull-evk:flash
flash ‑ armv7r5f-zynqmp-qemu:flash
phoenix-rtos-tests/cpp/hello-cpp ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/cpp/hello-cpp
phoenix-rtos-tests/cpp/hello-cpp ‑ armv7r5f-zynqmp-qemu:phoenix-rtos-tests/cpp/hello-cpp
phoenix-rtos-tests/initfini/main ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/initfini/main
phoenix-rtos-tests/initfini/main ‑ armv7r5f-zynqmp-qemu:phoenix-rtos-tests/initfini/main
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_in
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_in_big
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_inout
phoenix-rtos-tests/ioctl/test-ioctl ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/ioctl/test-ioctl.ioctl.data_inout_big
…
phoenix-rtos-tests/busybox/basename ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/basename.basename-does-not-remove-identical-extension
phoenix-rtos-tests/busybox/basename ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/basename.basename-works
phoenix-rtos-tests/busybox/basename ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/basename.basename-does-not-remove-identical-extension
phoenix-rtos-tests/busybox/basename ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/basename.basename-works
phoenix-rtos-tests/busybox/basename ‑ ia32-generic-qemu:phoenix-rtos-tests/busybox/basename.basename-does-not-remove-identical-extension
phoenix-rtos-tests/busybox/basename ‑ ia32-generic-qemu:phoenix-rtos-tests/busybox/basename.basename-works
phoenix-rtos-tests/busybox/bunzip2 ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/bunzip2 ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/bunzip2 ‑ ia32-generic-qemu:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/busybox ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/busybox.busybox --help
…
This pull request removes 134 skipped tests and adds 3257 skipped tests. Note that renamed tests count towards both.
phoenix-rtos-tests/libc/exit ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/exit.unistd_Exit.unblock_thread_wait
phoenix-rtos-tests/libc/exit ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/exit.unistd_Exit.unblock_thread_waitpid
phoenix-rtos-tests/libc/exit ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/exit.unistd_exit.unblock_thread_wait
phoenix-rtos-tests/libc/exit ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/exit.unistd_exit.unblock_thread_waitpid
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.ctype._tolower
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.ctype._toupper
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.ctype.toascii
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.resolve_path.realpath_max_path
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.stat_errno.enotdir
phoenix-rtos-tests/libc/misc ‑ armv7a7-imx6ull-evk:phoenix-rtos-tests/libc/misc.stat_mode.chr_type
…
phoenix-rtos-tests/busybox/bunzip2 ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/bunzip2 ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/bunzip2 ‑ ia32-generic-qemu:phoenix-rtos-tests/busybox/bunzip2
phoenix-rtos-tests/busybox/busybox ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/busybox.busybox --help
phoenix-rtos-tests/busybox/busybox ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/busybox.busybox --help
phoenix-rtos-tests/busybox/busybox ‑ ia32-generic-qemu:phoenix-rtos-tests/busybox/busybox.busybox --help
phoenix-rtos-tests/busybox/cp ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/cp.cp-parents
phoenix-rtos-tests/busybox/cp ‑ armv7a9-zynq7000-qemu:phoenix-rtos-tests/busybox/cp.cp-preserves-hard-links
phoenix-rtos-tests/busybox/cp ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/cp.cp-parents
phoenix-rtos-tests/busybox/cp ‑ armv7a9-zynq7000-zedboard:phoenix-rtos-tests/busybox/cp.cp-preserves-hard-links
…

♻️ This comment has been updated with latest results.

@mateusz-bloch mateusz-bloch force-pushed the mateusz-bloch/micropython_for_armv7r5f branch 19 times, most recently from fa10b35 to bbabae8 Compare March 25, 2026 15:00
@mateusz-bloch mateusz-bloch force-pushed the mateusz-bloch/micropython_for_armv7r5f branch from bbabae8 to 43bdb70 Compare March 26, 2026 15:01
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