diff --git a/boards/arm/arduino_uno_r4/Kconfig.board b/boards/arm/arduino_uno_r4/Kconfig.board new file mode 100644 index 000000000000000..d56eff75387fa91 --- /dev/null +++ b/boards/arm/arduino_uno_r4/Kconfig.board @@ -0,0 +1,6 @@ +# Copyright (c) 2023 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ARDUINO_UNO_R4_MINIMA + bool "Arduino Uno R4 Minima board" + depends on SOC_R7FA4M1AB3CFM diff --git a/boards/arm/arduino_uno_r4/Kconfig.defconfig b/boards/arm/arduino_uno_r4/Kconfig.defconfig new file mode 100644 index 000000000000000..2d483f3bb384ba6 --- /dev/null +++ b/boards/arm/arduino_uno_r4/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2023 TOKITA Hiroshi +# 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 diff --git a/boards/arm/arduino_uno_r4/arduino_uno_r4_common.dtsi b/boards/arm/arduino_uno_r4/arduino_uno_r4_common.dtsi new file mode 100644 index 000000000000000..472e1092f5f8153 --- /dev/null +++ b/boards/arm/arduino_uno_r4/arduino_uno_r4_common.dtsi @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Arduino Uno R4 Board"; + compatible = "renesas,r7fa4m1aB3cfm"; +}; diff --git a/boards/arm/arduino_uno_r4/arduino_uno_r4_minima-pinctrl.dtsi b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima-pinctrl.dtsi new file mode 100644 index 000000000000000..267f1168aa2f53b --- /dev/null +++ b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima-pinctrl.dtsi @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 TOKITA Hiroshi + * + * 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>; + }; + }; +}; diff --git a/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.dts b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.dts new file mode 100644 index 000000000000000..f775dcfed8ef6b1 --- /dev/null +++ b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.dts @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include + +#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>; +}; diff --git a/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.yaml b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.yaml new file mode 100644 index 000000000000000..81f3a94866a7a5f --- /dev/null +++ b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima.yaml @@ -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 diff --git a/boards/arm/arduino_uno_r4/arduino_uno_r4_minima_defconfig b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima_defconfig new file mode 100644 index 000000000000000..8d44c120b3e8c89 --- /dev/null +++ b/boards/arm/arduino_uno_r4/arduino_uno_r4_minima_defconfig @@ -0,0 +1,25 @@ +# Copyright (c) 2023 TOKITA Hiroshi +# 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 diff --git a/boards/arm/arduino_uno_r4/board.cmake b/boards/arm/arduino_uno_r4/board.cmake new file mode 100644 index 000000000000000..90546cdb66d297e --- /dev/null +++ b/boards/arm/arduino_uno_r4/board.cmake @@ -0,0 +1,6 @@ +# Copyright (c) 2023 TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +board_runner_Args(pyocd "--target=r7fa4m1ab") + +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) diff --git a/boards/arm/arduino_uno_r4/doc/index.rst b/boards/arm/arduino_uno_r4/doc/index.rst new file mode 100644 index 000000000000000..485d7b694435c53 --- /dev/null +++ b/boards/arm/arduino_uno_r4/doc/index.rst @@ -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 :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