Saturday, August 1, 2026

Flashing WeAct Studio RA4M1 with the Arduino R4 bootloader

     I've been using an Arduino R4 minima in my Gakken SX-150 project, but I ran out of IO pins. The RA4M1 IC itself has plenty, but only a handful are broken out on the Arduino board. Luckily, there's an alternative board that exposes nearly every IO pin, the WeAct Studio RA4M1.




    The board is pretty spartan, adding little more than a few LEDs, buttons, and a voltage regulator. This gives us the essentials without robbing us of the extra IO we're after. One problem though, it doesn't have out-of-the-box compatibility with the Arduino IDE, despite sharing the same microcontroller.


Arduino Compatibility

    What makes an Arduino an Arduino, and what is this board missing? In a word, the bootloader. The Arduino R4 boards come preprogrammed with a bootloader that allows them to talk to the IDE, and load new sketches. Fortunately, this bootloader is freely available and can be flashed onto the WeAct board.


Setup

    First we need a tool that lets us program the RA4M1 chip. This is imaginatively named "Renesas Flash Programmer", and can be found here: https://www.renesas.com/en/software-tool/renesas-flash-programmer-programming-gui

    Next we need the Arduino R4 Minima bootloader from here: https://github.com/arduino/ArduinoCore-renesas/blob/main/bootloaders/UNO_R4/dfu_minima.hex

    Then connect the WeAct via USBC. It should start flashing a blue LED. This is the "blink" program that it comes with. This is a good sign, and shows that the board is working. We need to stop it though, and get into programming mode. This requires a "secret" button sequence: hold down the "MD" button and press "RES". If done correctly, the LED will stop flashing.

    Now open the Programmer program and select "RA" for the microcontroller, and "COM port" for the tool. It should automatically detect a com port and display it to the right of the "Tool Details..." button.


    Verify that the port is detected as an RA Boot device



    Click the "Add/Remove Files..." button and select the hex file we downloaded


    Click the large "Start" button and wait for confirmation that it was successful.


     Done!


Using the Bootloader

    Now that we have the bootloader, we can use the board as if it were an Arduino R4 Minima. It should appear in the list of boards as an R4 Minima, and respond to programming the same way.  



The Catch

    If you upload the standard "Blink" sketch via the Arduino IDE, you'll find that it doesn't actually blink (flash the LED). This isn't due to any bootloader or firmware problems; the LED is attached to a different pin than on the R4.

    While the microcontroller is compatible with that of the R4, the board is different. The IO pins don't adhere to the Arduino D0-D13/A0-A6 numbering, and many of them aren't supported by the traditional Arduino pinMode()/digitalWrite()/digitalRead() functions. The pin are still very much usable though!

    One solution, offered by WeAct, is to use a new set of functions: R_IOPORT_PinCfg()/R_IOPORT_PinWrite()/R_IOPORT_PinRead()

    These are demonstrated in their "Blink.ino" sketch on the WeAct github: https://github.com/WeActStudio/WeActStudio.RA4M1_64Pin_CoreBoard/blob/master/Examples/Arduino/Blink/Blink.ino


No comments:

Post a Comment