Skip to content

feat(targets): add basic support for Arduino Uno R4 Minima and WiFi - #5734

Open
ardnew wants to merge 7 commits into
tinygo-org:devfrom
ardnew:uno-r4-bsp
Open

ardnew wants to merge 7 commits into
tinygo-org:devfrom
ardnew:uno-r4-bsp

Conversation

@ardnew

@ardnew ardnew commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Rebased the existing PR #4265, added SysTick and basic GPIO support along with a handful of target definitions:

  • ra4m1 (defines linker script)
    • arduino-uno-r4
      • arduino-uno-r4-minima
      • arduino-uno-r4-wifi

I've left this a draft because it is incomplete and needs a few changes. Specifically, there should be 2 separate boards corresponding to the 2 leaf targets above.

  • machine/board_arduino_uno_r4_minima.go
    • missing
    • The pinout is different (different traces to MCU, includes an SWD footprint, no co-processor, etc.)
    • Uses a different bootup sequence altogether, but this shouldn't be important
  • machine/board-arduino-uno-r4-wifi.go
    • this PR implements this as machine/board-arduino-uno-r4.go and needs to be renamed

The provided runtime implementation and other machine details should be compatible with both boards.

The target JSON for both boards was derived directly from ArduinoCore-renesas; I do not own a Minima board to test.

deadprogram and others added 4 commits September 19, 2026 17:04
Signed-off-by: deadprogram <ron@hybridgroup.com>
Signed-off-by: deadprogram <ron@hybridgroup.com>
Signed-off-by: deadprogram <ron@hybridgroup.com>
Based on parent branch's existing skeleton, rebased on top of branch dev; includes board definition for the WiFi variant.
@deadprogram

Copy link
Copy Markdown
Member

@ardnew I have an R4 whenever this is ready for test...

@dgryski

dgryski commented Sep 28, 2026

Copy link
Copy Markdown
Member

I also have an R4 available for testing packages.

@ardnew

ardnew commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The remaining pieces have been added. Please let me know how testing goes on your boards.

One issue I'm having with the WiFi board is that the flash sequencing doesn't seem to work end-to-end: I have to manually put the board into bootloader mode by double-clicking the reset button, then flash and reset. The target JSON includes "flash-1200-bps-reset": "true". Didn't investigate. Maybe someone more familiar knows the trick?

@ardnew
ardnew marked this pull request as ready for review October 1, 2026 19:56
Copilot AI balanced review requested due to automatic review settings October 1, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Clock initialization and timer reads have confirmed faults that prevent reliable operation.

Review effort: Balanced
Findings: 3 High severity · 1 Medium severity

Open (4)
What changed in this PR

Adds initial TinyGo support for the RA4M1-based Arduino Uno R4 Minima and WiFi boards.

Changes:

  • Adds target definitions, memory layout, and flashing settings.
  • Implements clock setup, SysTick timing, GPIO, and separate board pin maps.
  • Updates SVD generation for reserved fields and register arrays.
File Description
tools/​gen-device-svd/​gen-device-svd.go Adjusts reserved-field and register-array handling.
targets/​ra4m1.ld Defines memory layout and reserves bootloader space.
targets/​ra4m1.json Defines the shared RA4M1 target.
targets/​arduino-uno-r4.json Defines the shared Uno R4 target.
targets/​arduino-uno-r4-wifi.json Adds WiFi flashing and debug settings.
targets/​arduino-uno-r4-minima.json Adds Minima flashing settings.
src/​runtime/​runtime_ra4m1.go Adds clock setup and SysTick timing.
src/​machine/​machine_ra4m1.go Implements RA4M1 GPIO support.
src/​machine/​board_arduino_uno_r4_wifi.go Defines WiFi board pins.
src/​machine/​board_arduino_uno_r4_minima.go Defines Minima board pins.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/runtime/runtime_ra4m1.go Outdated
Comment thread src/runtime/runtime_ra4m1.go Outdated
Comment thread targets/arduino-uno-r4-wifi.json
Comment thread src/machine/machine_ra4m1.go Outdated
@Frelsaren

Frelsaren commented Oct 2, 2026 •

Copy link
Copy Markdown

UNO R4 WIFI: I tested blinky and a very much vibecoded LED matrix test and both works perfectly fine, did not have to manually enter bootloader or anything, it just worked.

EDIT: Also tested reading temp and humidity from a dht11, also works fine.

Well done!

@deadprogram

Copy link
Copy Markdown
Member

Thanks for picking this back up @ardnew. I tested it on an Arduino Uno R4 Minima and took a good look. The following is edited from an automated review:

  1. The PRCR key looks like it needs to be 0xA5. Renesas FSP uses BSP_PRV_PRCR_KEY (0xA500U) in ra/fsp/src/bsp/mcu/all/bsp_register_protection.c. The SVD enum says 0x5A, which seems to be where the mix up came from. On the Minima, writing 0x5A00 | 0x3 to PRCR leaves PRC0 and PRC1 at 0, and 0xA500 | 0x3 sets both. So initClocks currently does not change any clock registers. Blinky still works because the bootloader already runs at 48 MHz. Perhaps use 0xA5 << renesas.SYSTEM_PRCR_PRKEY_Pos with a reference to that file?

  2. The Minima flash-command uses -Q, which is only in the Arduino build of dfu-util. Stock dfu-util 0.11 fails with invalid option -- 'Q'. Without -Q the download works, but the board stays in DFU mode afterwards. With -R it resets and runs the program. Should it be dfu-util --device 2341:0069,:0369 -D {bin} -a0 -R?

  3. PinInputPullup and PinInputPulldown are missing. Most other ports define those names, so portable code that uses them does not compile for these targets.

  4. Neither target is in the smoke tests, so CI does not build them yet. Perhaps add arduino-uno-r4-minima and arduino-uno-r4-wifi to the smoke test list?

What do you think of these? Due to the PR coming from your fork, I cannot just add commits myself. It would be great to get this into the imminent release.

@deadprogram deadprogram added this to the 0.44 milestone Oct 9, 2026
@deadprogram

Copy link
Copy Markdown
Member

Thanks for the updates @ardnew. I tested the latest commit on my Uno R4 Minima and all four earlier points look addressed. The clock registers now read back as expected after initClocks, and flashing with -R runs the program right away. The following is edited from an automated review:

  1. Could you squash the commits down to two? First the tools/gen-device-svd change for the Renesas quirks on its own, then one commit with the rest of the Uno R4 support. The WIP commits add files that later commits rename or remove.

  2. While squashing, perhaps drop the quote style changes in .github/workflows/linux.yml and the reflow of targets/arduino-uno-r4-minima.json? Then the CI change is just the smoketest-renesas line.

Sounds OK?

@ardnew

ardnew commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@deadprogram Yep, will do. That was my editor with the opinionated YAML formatting. I have far fewer opinions on the matter

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.

5 participants