Skip to content

Commit

Permalink
boards: arm: add initial support for Arduino UNO R4 Minima
Browse files Browse the repository at this point in the history
Add support for the Arduino UNO R4 Minima.
This board is the newest version of Arduino that uses Renesas RA4M1 SoC.

This commit provides only limited support to simplify the initial
support patch.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
  • Loading branch information
soburi committed Jul 29, 2023
1 parent 75aec57 commit 27041f5
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boards/arm/arduino_uno_r4/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
# SPDX-License-Identifier: Apache-2.0

config BOARD_ARDUINO_UNO_R4_MINIMA
bool "Arduino Uno R4 Minima board"
depends on SOC_R7FA4M1AB3CFM
9 changes: 9 additions & 0 deletions boards/arm/arduino_uno_r4/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
# SPDX-License-Identifier: Apache-2.0

if BOARD_ARDUINO_UNO_R4_MINIMA

config BOARD
default "arduino_uno_r4_minima" if BOARD_ARDUINO_UNO_R4_MINIMA

endif # BOARD_ARDUINO_UNO_R4_MINIMA
13 changes: 13 additions & 0 deletions boards/arm/arduino_uno_r4/arduino_uno_r4_common.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <renesas/ra/r7fa4m1ab3cfm.dtsi>

/ {
model = "Arduino Uno R4 Board";
compatible = "renesas,r7fa4m1aB3cfm";
};
18 changes: 18 additions & 0 deletions boards/arm/arduino_uno_r4/arduino_uno_r4_minima-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
sci2_default: sci2_default {
group1 {
/* TODO define macros port3:pin0 sci0-txd*/
pinmux = <0x04630000>;
};
group2 {
/* TODO define macros port3:pin1 sci0-rxd*/
pinmux = <0x04650000>;
};
};
};
128 changes: 128 additions & 0 deletions boards/arm/arduino_uno_r4/arduino_uno_r4_minima.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <zephyr/dt-bindings/gpio/gpio.h>

#include "arduino_uno_r4_common.dtsi"
#include "arduino_uno_r4_minima-pinctrl.dtsi"

/ {
model = "Arduino Uno R4 Minima";

chosen {
zephyr,console = &uart2;
zephyr,shell-uart = &uart2;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &code_partition;
};

leds {
compatible = "gpio-leds";
led: led {
gpios = <&ioport1 11 GPIO_ACTIVE_HIGH>;
};
};

aliases {
led0 = &led;
};
};

&sci2 {
status = "okay";
pinctrl-0 = <&sci2_default>;
pinctrl-names = "default";
uart {
status = "okay";
};
};

&ioport1 {
status = "okay";
};

&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "bootloader";
reg = <0x00000000 0x4000>;
read-only;
};

code_partition: partition@4000 {
label = "code";
reg = <0x4000 0x3C000>;
read-only;
};
};
};

&fcu {
status = "okay";
};

&sosc {
status = "okay";
};

&hoco {
status = "okay";
clock-frequency = <48000000>;
};

&moco {
status = "okay";
};

&loco {
status = "okay";
};

&subclk {
status = "okay";
};

&sysclk {
status = "okay";
clocks = <&hoco>;
};

&iclk {
status = "okay";
clock-div = <1>;
};

&pclka {
status = "okay";
clock-div = <1>;
};

&pclkb {
status = "okay";
clock-div = <2>;
};

&pclkc {
status = "okay";
clock-div = <1>;
};

&pclkd {
status = "okay";
clock-div = <1>;
};

&fclk {
status = "okay";
clock-div = <2>;
};
12 changes: 12 additions & 0 deletions boards/arm/arduino_uno_r4/arduino_uno_r4_minima.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
identifier: arduino_uno_r4_minima
name: Arduino Uno R4 Minima
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 32
supported:
- gpio
- uart
25 changes: 25 additions & 0 deletions boards/arm/arduino_uno_r4/arduino_uno_r4_minima_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_RA4M1=y
CONFIG_SOC_R7FA4M1AB3CFM=y

CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000

CONFIG_BUILD_OUTPUT_HEX=y

# enable uart driver
CONFIG_SERIAL=y

# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# enable GPIO
CONFIG_GPIO=y

CONFIG_PINCTRL=y

CONFIG_CLOCK_CONTROL=y

CONFIG_USE_DT_CODE_PARTITION=y
6 changes: 6 additions & 0 deletions boards/arm/arduino_uno_r4/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
# SPDX-License-Identifier: Apache-2.0

board_runner_Args(pyocd "--target=r7fa4m1ab")

include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
63 changes: 63 additions & 0 deletions boards/arm/arduino_uno_r4/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. _arduino_uno_r4:

Arduino UNO R4 Minima
#####################

Overview
********

The Arduino UNO R4 Minima is a development board featuring the Renesas RA4M1 SoC
in the Arduino form factor and is compatible with traditional Arduino.

Programming and debugging
*************************

Building & Flashing
===================

You can build and flash an application in the usual way (See
:ref:`build_an_application` and
:ref:`application_run` for more details).

Here is an example for building and flashing the :ref:`blinky-sample` application.

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: arduino_uno_r4_minima
:goals: build flash

Debugging
=========

Debugging also can be done in the usual way.
The following command is debugging the :ref:`blinky-sample` application.
Also, see the instructions specific to the debug server that you use.

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: arduino_uno_r4_minima
:maybe-skip-config:
:goals: debug


Using pyOCD
-----------

Various debug adapters, including cmsis-dap probes, can debug the Arduino UNO R4 with pyOCD.
The default configuration uses the pyOCD for debugging.
You must install CMSIS-Pack when flashing or debugging Arduino UNO R4 Minima with pyOCD.
If not installed yet, execute the following command to install CMSIS-Pack for Arduino UNO R4.

.. code-block:: console
pyocd pack install r7fa4m1ab
Restoring Arduino Bootloader
============================

If you corrupt the Arduino bootloader, you can restore it with the following command.

.. code-block:: console
wget https://raw.githubusercontent.com/arduino/ArduinoCore-renesas/main/bootloaders/UNO_R4/dfu_minima.hex
pyocd flash -e sector -a 0x0 -t r7fa4m1ab dfu_minima.hex

Check failure on line 63 in boards/arm/arduino_uno_r4/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

boards/arm/arduino_uno_r4/doc/index.rst:63 trailing whitespace

0 comments on commit 27041f5

Please sign in to comment.