Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Arduino UNO R4 #60760

Merged
merged 8 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";
};
15 changes: 15 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,15 @@
/*
* Copyright (c) 2023 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl-r7fa4m1xxxxxx.h>

&pinctrl {
sci2_default: sci2_default {
group1 {
pinmux = <P301_RXD2>, <P302_TXD2>;
};
};
};
88 changes: 88 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,88 @@
/*
* 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";
uart2: uart {
current-speed = <115200>;
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";
};

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

&cgc {
clock-source = <&hoco>;
iclk-div = <1>;
pclka-div = <1>;
pclkb-div = <2>;
pclkc-div = <1>;
pclkd-div = <1>;
fclk-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)
64 changes: 64 additions & 0 deletions boards/arm/arduino_uno_r4/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. _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 :zephyr:code-sample:`blinky` 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 :zephyr:code-sample:`blinky` 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
1 change: 1 addition & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SAM clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SMARTBOND clock_control_smartbond.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NUMAKER_SCC clock_control_numaker_scc.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NXP_S32 clock_control_nxp_s32.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RA clock_control_ra.c)


if(CONFIG_CLOCK_CONTROL_STM32_CUBE)
Expand Down
2 changes: 2 additions & 0 deletions drivers/clock_control/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ source "drivers/clock_control/Kconfig.nxp_s32"

source "drivers/clock_control/Kconfig.agilex5"

source "drivers/clock_control/Kconfig.ra"

endif # CLOCK_CONTROL
9 changes: 9 additions & 0 deletions drivers/clock_control/Kconfig.ra
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

config CLOCK_CONTROL_RA
bool "Renesas RA series clock generation circuit driver"
default y
depends on DT_HAS_RENESAS_RA_CLOCK_GENERATION_CIRCUIT_ENABLED
help
Enable Renesas RA series clock generation circuit driver.