This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 6ded4d2bc78f695710486b5c74462d6c599c9dcd Author: Hoa Bui <[email protected]> AuthorDate: Wed Nov 11 09:45:01 2026 +0000 boards/arm/rzv2h: Add Renesas RZV2H-EVK and RZV2H-RDK board support Add board support for the Renesas RZV2H-EVK and RZV2H-RDK boards Signed-off-by: Hoa Bui <[email protected]> Signed-off-by: Binh Nguyen <[email protected]> --- boards/Kconfig | 22 ++ boards/arm/rzv2h/rzv2h-evk/CMakeLists.txt | 23 ++ boards/arm/rzv2h/rzv2h-evk/Kconfig | 22 ++ .../arm/rzv2h/rzv2h-evk/configs/nsh-leds/defconfig | 52 ++++ boards/arm/rzv2h/rzv2h-evk/configs/nsh/defconfig | 52 ++++ boards/arm/rzv2h/rzv2h-evk/include/board.h | 151 +++++++++ boards/arm/rzv2h/rzv2h-evk/scripts/Make.defs | 98 ++++++ .../arm/rzv2h/rzv2h-evk/scripts/rzv2h-evk_cr8_0.ld | 224 ++++++++++++++ boards/arm/rzv2h/rzv2h-evk/src/CMakeLists.txt | 58 ++++ boards/arm/rzv2h/rzv2h-evk/src/Makefile | 69 +++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h-evk.h | 113 +++++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appexamples.c | 47 +++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appinit.c | 72 +++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_autoleds.c | 172 +++++++++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_boot.c | 145 +++++++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_bringup.c | 91 ++++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_gpio.c | 337 +++++++++++++++++++++ boards/arm/rzv2h/rzv2h-evk/src/rzv2h_userleds.c | 103 +++++++ boards/arm/rzv2h/rzv2h-rdk/CMakeLists.txt | 23 ++ boards/arm/rzv2h/rzv2h-rdk/Kconfig | 22 ++ .../arm/rzv2h/rzv2h-rdk/configs/nsh-leds/defconfig | 52 ++++ boards/arm/rzv2h/rzv2h-rdk/configs/nsh/defconfig | 52 ++++ boards/arm/rzv2h/rzv2h-rdk/include/board.h | 151 +++++++++ boards/arm/rzv2h/rzv2h-rdk/scripts/Make.defs | 98 ++++++ .../arm/rzv2h/rzv2h-rdk/scripts/rzv2h-rdk_cr8_0.ld | 224 ++++++++++++++ boards/arm/rzv2h/rzv2h-rdk/src/CMakeLists.txt | 58 ++++ boards/arm/rzv2h/rzv2h-rdk/src/Makefile | 69 +++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h-rdk.h | 113 +++++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appexamples.c | 47 +++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appinit.c | 72 +++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_autoleds.c | 172 +++++++++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_boot.c | 145 +++++++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_bringup.c | 87 ++++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_gpio.c | 337 +++++++++++++++++++++ boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_userleds.c | 103 +++++++ 35 files changed, 3676 insertions(+) diff --git a/boards/Kconfig b/boards/Kconfig index cc419463550..6ce1b23620d 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -3839,6 +3839,20 @@ config ARCH_BOARD_TMS570LS31X_USB_KIT TI Hercules TMS570LS31xx Evaluation Kit (TMDS570ls31xx USB Kit) featuring the Hercules TMS570LS3137ZWT chip. +config ARCH_BOARD_RZV2H_EVK + bool "Renesas RZV2H-EVK" + depends on ARCH_CHIP_R9A09G057 + select ARCH_HAVE_LEDS + ---help--- + Renesas RZV2H Evaluation Kit featuring the R9A09G057 (Cortex-R8) chip. + +config ARCH_BOARD_RZV2H_RDK + bool "Renesas RZV2H-RDK" + depends on ARCH_CHIP_R9A09G057 + select ARCH_HAVE_LEDS + ---help--- + Renesas RZV2H Development Kit featuring the R9A09G057 (Cortex-R8) chip. + config ARCH_BOARD_TWR_K60N512 bool "FreeScale TWR-K60N512 development board" depends on ARCH_CHIP_MK60N512VMD100 @@ -4543,6 +4557,8 @@ config ARCH_BOARD default "tm4c1294-launchpad" if ARCH_BOARD_TM4C1294_LAUNCHPAD default "tm4c129e-launchpad" if ARCH_BOARD_TM4C129E_LAUNCHPAD default "tms570ls31x-usb-kit" if ARCH_BOARD_TMS570LS31X_USB_KIT + default "rzv2h-evk" if ARCH_BOARD_RZV2H_EVK + default "rzv2h-rdk" if ARCH_BOARD_RZV2H_RDK default "lilygo_tbeam_lora_gps" if ARCH_BOARD_LILYGO_TBEAM_LORA_GPS default "ttgo_lora_esp32" if ARCH_BOARD_TTGO_LORA_ESP32 default "ttgo_t_display_esp32" if ARCH_BOARD_TTGO_T_DISPLAY_ESP32 @@ -5472,6 +5488,12 @@ endif if ARCH_BOARD_TMS570LS31X_USB_KIT source "boards/arm/tms570/tms570ls31x-usb-kit/Kconfig" endif +if ARCH_BOARD_RZV2H_EVK +source "boards/arm/rzv2h/rzv2h-evk/Kconfig" +endif +if ARCH_BOARD_RZV2H_RDK +source "boards/arm/rzv2h/rzv2h-rdk/Kconfig" +endif if ARCH_BOARD_RM57L843_LAUNCHXL2 source "boards/arm/rm57/rm57l843-launchxl2/Kconfig" endif diff --git a/boards/arm/rzv2h/rzv2h-evk/CMakeLists.txt b/boards/arm/rzv2h/rzv2h-evk/CMakeLists.txt new file mode 100644 index 00000000000..2b87d842fa8 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm/rzv/rzv2h-evk/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/arm/rzv2h/rzv2h-evk/Kconfig b/boards/arm/rzv2h/rzv2h-evk/Kconfig new file mode 100644 index 00000000000..2631c19046a --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/Kconfig @@ -0,0 +1,22 @@ +# ############################################################################## +# boards/arm/rzv/rzv2h-evk/Kconfig +# +# Kconfig for the RZV2H_EVK board support package for the RZV2H MPU. +# +if ARCH_BOARD_RZV2H_EVK + +config BOARD_RZV2H_EVK + bool "RZV2H-EVK Board Support" + help + Enable support for the RZV2H-EVK board based on the RZV2H MPU. + +endif + +config RZV2H_EXAMPLE_SUPPORT + bool "RZV2H-EVK Example Support" + default y + depends on ARCH_BOARD_RZV2H_EVK + help + Enable support for various application examples for the RZV2H-EVK board. + +# ############################################################################## diff --git a/boards/arm/rzv2h/rzv2h-evk/configs/nsh-leds/defconfig b/boards/arm/rzv2h/rzv2h-evk/configs/nsh-leds/defconfig new file mode 100644 index 00000000000..68a54577f6a --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/configs/nsh-leds/defconfig @@ -0,0 +1,52 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="rzv2h-evk" +CONFIG_ARCH_BOARD_RZV2H_EVK=y +CONFIG_ARCH_CHIP="rzv2h" +CONFIG_ARCH_CHIP_R9A09G057=y +CONFIG_ARCH_CHIP_RZV2H=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7R_DCACHE_DISABLE=y +CONFIG_ARMV7R_ICACHE_DISABLE=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_NREGIONS=6 +CONFIG_ARM_THUMB=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=200000 +CONFIG_BUILTIN=y +CONFIG_DEV_GPIO=y +CONFIG_EXAMPLES_LEDS=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x08180000 +CONFIG_RAW_BINARY=y +CONFIG_RZV2H_CORTEXR8_0=y +CONFIG_RZV2H_SCI_B_UART0=y +CONFIG_SCHED_WAITPID=y +CONFIG_SCI0_SERIAL_CONSOLE=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SERIAL_TIOCGICOUNT=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TTY_SIGINT=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_USERLED=y +CONFIG_USERLED_LOWER=y diff --git a/boards/arm/rzv2h/rzv2h-evk/configs/nsh/defconfig b/boards/arm/rzv2h/rzv2h-evk/configs/nsh/defconfig new file mode 100644 index 00000000000..30e77da4ced --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/configs/nsh/defconfig @@ -0,0 +1,52 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="rzv2h-evk" +CONFIG_ARCH_BOARD_RZV2H_EVK=y +CONFIG_ARCH_CHIP="rzv2h" +CONFIG_ARCH_CHIP_R9A09G057=y +CONFIG_ARCH_CHIP_RZV2H=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7R_DCACHE_DISABLE=y +CONFIG_ARMV7R_ICACHE_DISABLE=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_NREGIONS=6 +CONFIG_ARM_THUMB=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=200000 +CONFIG_BUILTIN=y +CONFIG_DEV_GPIO=y +CONFIG_EXAMPLES_GPIO=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x08180000 +CONFIG_RAW_BINARY=y +CONFIG_RZV2H_CORTEXR8_0=y +CONFIG_RZV2H_SCI_B_UART0=y +CONFIG_SCHED_WAITPID=y +CONFIG_SCI0_SERIAL_CONSOLE=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SERIAL_TIOCGICOUNT=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3 +CONFIG_TESTING_OSTEST_STACKSIZE=2048 +CONFIG_TTY_SIGINT=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm/rzv2h/rzv2h-evk/include/board.h b/boards/arm/rzv2h/rzv2h-evk/include/board.h new file mode 100644 index 00000000000..bcb10095859 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/include/board.h @@ -0,0 +1,151 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RZV2H_RZV2H_EVK_INCLUDE_BOARD_H +#define __BOARDS_ARM_RZV2H_RZV2H_EVK_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* GPIO definitions *********************************************************/ + +#define BOARD_NGPIOOUT 2 +#define BOARD_NGPIOIN 1 + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_0 0 +#define BOARD_LED_1 1 +#define BOARD_NLEDS 2 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_0_BIT (1 << BOARD_LED_0) +#define BOARD_LED_1_BIT (1 << BOARD_LED_1) + +/* LED pins - aliases to existing NuttX LED macros */ + +#define BOARD_P0_0_GPIO GPIO_P0_0_OUTPUT_LOW +#define BOARD_P0_1_GPIO GPIO_P0_1_OUTPUT_LOW + +/* Button pins - using Pmod at CN1 */ + +#define BOARD_P8_2_BUTTON GPIO_P8_2_INPUT_PULLDOWN + +/* GPIO Configuration */ + +#define GPIO_P0_0_OUTPUT_LOW (gpio_pinset_t){BSP_IO_PORT_00_PIN_00, (IOPORT_CFG_DRIVE_B01 | IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_LOW | IOPORT_CFG_SLEW_RATE_FAST)} +#define GPIO_P0_1_OUTPUT_LOW (gpio_pinset_t){BSP_IO_PORT_00_PIN_01, (IOPORT_CFG_DRIVE_B01 | IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_LOW | IOPORT_CFG_SLEW_RATE_FAST)} +#define GPIO_P8_2_INPUT_PULLDOWN (gpio_pinset_t){BSP_IO_PORT_08_PIN_02, (IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_SPECIAL_PURPOSE_PORT_INPUT_ENABLE | IOPORT_CFG_PULLDOWN_ENABLE)} + +/* In this stage, autoled is not supported */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 0 +#define LED_INIRQ 0 +#define LED_SIGNAL 0 +#define LED_ASSERTION 0 +#define LED_PANIC 0 + +/* Peripheral definitions ***************************************************/ + +/* SCI0 is used as the default NSH console interface */ + +#define BOARD_CONSOLE_UART 0 /* Use SCI0 for console */ +#define BOARD_CONSOLE_BAUD 115200 +#define BOARD_CONSOLE_BITS 8 +#define BOARD_CONSOLE_PARITY 0 +#define BOARD_CONSOLE_2STOP 0 + +/* SCI-B UART pins */ + +#define BOARD_SCI0_TXD_GPIO GPIO_TXD0_MOSI0_DA0_P5_0_M1 +#define BOARD_SCI0_RXD_GPIO GPIO_RXD0_MISO0_SCL0_P5_1_M1 +#define BOARD_SCI1_TXD_GPIO GPIO_TXD1_MOSI1_SDA1_P5_2_M1 +#define BOARD_SCI1_RXD_GPIO GPIO_RXD1_MISO1_SCL1_P5_3_M1 +#define BOARD_SCI2_TXD_GPIO GPIO_TXD2_MOSI2_SDA2_P5_4_M1 +#define BOARD_SCI2_RXD_GPIO GPIO_RXD2_MISO2_SCL2_P5_5_M1 +#define BOARD_SCI3_TXD_GPIO GPIO_TXD3_MOSI3_SDA3_P5_6_M1 +#define BOARD_SCI3_RXD_GPIO GPIO_RXD3_MISO3_SCL3_P5_7_M1 + +#define BOARD_SCI4_TXD_GPIO GPIO_TXD4_MOSI4_SDA4_P8_4_M6 +#define BOARD_SCI4_RXD_GPIO GPIO_RXD4_MISO4_SCL4_P8_5_M6 +#define BOARD_SCI5_TXD_GPIO GPIO_TXD5_MOSI5_SDA5_P7_2_M1 +#define BOARD_SCI5_RXD_GPIO GPIO_RXD5_MISO5_SCL5_P7_3_M1 +#define BOARD_SCI6_TXD_GPIO GPIO_TXD6_MOSI6_SDA6_P7_4_M1 +#define BOARD_SCI6_RXD_GPIO GPIO_RXD6_MISO6_SCL6_P7_5_M1 +#define BOARD_SCI7_TXD_GPIO GPIO_TXD7_MOSI7_SDA7_P7_6_M1 +#define BOARD_SCI7_RXD_GPIO GPIO_RXD7_MISO7_SCL7_P7_7_M1 +#define BOARD_SCI8_TXD_GPIO GPIO_TXD8_MOSI8_SDA6_P9_0_M2 +#define BOARD_SCI8_RXD_GPIO GPIO_RXD8_MISO8_SCL6_P9_1_M2 +#define BOARD_SCI9_TXD_GPIO GPIO_TXD9_MOSI9_SDA9_P8_2_M6 +#define BOARD_SCI9_RXD_GPIO GPIO_RXD9_MISO9_SCL9_P8_3_M6 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/**************************************************************************** + * Name: rzv2h_board_initialize + * + * Description: + * All RZV2H architectures must provide the following entry point. This + * entry point is called early in the initialization -- after clocking + * and memory have been configured but before caches have been enabled + * and before any devices have been initialized. + * + ****************************************************************************/ + +void rzv2h_board_initialize(void); + +/**************************************************************************** + * Name: rzv2h_serial_setup + * + * Description: + * Configure the board used by the enabled SCI UART channels. + * + ****************************************************************************/ + +void rzv2h_serial_setup(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RZV2H_RZV2H_EVK_INCLUDE_BOARD_H */ diff --git a/boards/arm/rzv2h/rzv2h-evk/scripts/Make.defs b/boards/arm/rzv2h/rzv2h-evk/scripts/Make.defs new file mode 100644 index 00000000000..41acf8a42c3 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/scripts/Make.defs @@ -0,0 +1,98 @@ +############################################################################ +# boards/arm/rzv2h/rzv2h-evk/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-r/Toolchain.defs + +# Determine linker script based on build type +ifeq ($(CONFIG_RZV2H_CORTEXR8_0),y) + LDSCRIPT = rzv2h-evk_cr8_0.ld +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +# Compile flags +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe -Wno-undef +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +# Linker flags +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# ELF module flags +LDELFFLAGS = -r -e main +ifeq ($(CONFIG_CYGWIN_WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld}" +else + LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld +endif + +# Board-specific flags +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + +#hal renesas include +HAL_INDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)common$(DELIM)renesas$(DELIM)hal_renesas +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)instances +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)instances$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)api +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)rzv2h +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)all +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)all$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)cmsis$(DELIM)Device$(DELIM)RENESAS$(DELIM)Include +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp$(DELIM)rzv2h +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp$(DELIM)rzv2h$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)portable$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)portable$(DELIM)rzv$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)cmsis +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)cmsis$(DELIM)include$(DELIM)cr + +# Generate the raw image U-Boot loads at CONFIG_RAM_START before starting +# CR8_0 from reset. Select the SRAM sections explicitly so distant NOLOAD +# OpenAMP regions can never create padding in the raw binary. .vectors runs +# from ITCM, but its load copy is the first thing in RAM and the U-Boot reset +# trampoline in ITCM jumps to it, so it has to be in the image; without it +# nuttx_uboot.bin would also start at .text instead of at CONFIG_RAM_START. + +ifeq ($(CONFIG_RZV2H_UBOOT_IMAGE),y) +define POSTBUILD + @echo "CP: nuttx_uboot.bin" + $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary \ + --only-section=.vectors --only-section=.text \ + --only-section=.init_section \ + --only-section=.ARM.extab --only-section=.ARM.exidx \ + --only-section=.data $(BIN) nuttx_uboot.bin + $(Q) echo nuttx_uboot.bin >> nuttx.manifest +endef +endif diff --git a/boards/arm/rzv2h/rzv2h-evk/scripts/rzv2h-evk_cr8_0.ld b/boards/arm/rzv2h/rzv2h-evk/scripts/rzv2h-evk_cr8_0.ld new file mode 100644 index 00000000000..a67fc45131d --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/scripts/rzv2h-evk_cr8_0.ld @@ -0,0 +1,224 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/scripts/rzv2h-evk_cr8_0.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#include <nuttx/config.h> + +/* + * RZ/V2H Cortex-R8_0 linker script for NuttX. + * + */ + +/* Core-local TCM map of the RZ/V2H CR8, from the Renesas HAL + * [FSP: bsp_slave_address.h:19-25]: + * + * ITCM core 0x00000000, 128 KB, AXI alias 0x12040000 + * DTCM core 0x00020000, 128 KB, AXI alias 0x12060000 + * + * Both build types keep a load copy of the vector table at the start of + * RAM, which arm_boot() copies to ITCM. CR8_0 takes its reset vector from + * ITCM, so before releasing CR8_0 from reset U-Boot writes a fixed two-word + * trampoline there through the AXI alias: + * + * 0x0: 0xe51ff004 ldr pc, [pc, #-4] + * 0x4: 0x08180000 ORIGIN(RAM), the load copy of the table + * + * The reset slot of the load copy then branches to __start. A + * debugger-loaded image is entered at __start directly; ITCM is not mapped + * until arm_boot() programs the ATCM region register. + */ + +MEMORY +{ + ITCM (rwx) : ORIGIN = 0x00000000, LENGTH = 128K + DTCM (rwx) : ORIGIN = 0x00020000, LENGTH = 128K + RAM (rwx) : ORIGIN = 0x08180000, LENGTH = 512K +} + +OUTPUT_ARCH(arm) +EXTERN(_vector_start) +ENTRY(__start) + +/* Start of the read-only SRAM part of the image. Everything from here up to + * __mpu_code_end (the vector load image, .text, .rodata, .init_section and + * .ARM.exidx) is covered by one MPU region programmed + * RO + executable; see g_mpu_region_table[] in + * arch/arm/src/rzv2h/rzv2h_mpu_region.c. + */ + +__mpu_code_start = ABSOLUTE(ORIGIN(RAM)); + +SECTIONS +{ + + /* The table always has a load copy at the start of RAM, at + * _vector_load, which arm_boot() copies to VECTOR_ADDRESS (ITCM). + * + * The U-Boot image links the table at its ITCM run address and stores + * it in RAM (AT> RAM), so nuttx_uboot.bin starts with it. CR8_0 + * reaches it at reset through the U-Boot trampoline described at the + * top of this file, so the load copy has to stay at ORIGIN(RAM). + * + * The debugger image links the table in RAM. That works because the + * table is position independent: its branch slots are PC-relative and + * its handler entries contain absolute addresses. + */ + + .vectors : + { + . = ALIGN(32); + _vector_start = ABSOLUTE(.); + KEEP(*(.vectors)) + _vector_end = ABSOLUTE(.); +#ifdef CONFIG_RZV2H_UBOOT_IMAGE + } > ITCM AT> RAM +#else + } > RAM +#endif + + /* Where the table is stored in the image, as opposed to _vector_start, + * where it runs. The two are equal in debugger builds. + */ + + _vector_load = LOADADDR(.vectors); + +#ifdef CONFIG_RZV2H_UBOOT_IMAGE + ASSERT(_vector_load == ORIGIN(RAM), + "U-Boot reset trampoline expects .vectors at ORIGIN(RAM)") +#endif + .text : + { + . = ALIGN(4); + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > RAM + + .init_section : + { + . = ALIGN(4); + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) + _einit = ABSOLUTE(.); + } > RAM + + .dtcm (NOLOAD) : + { + __HeapBase = .; + KEEP(*(.heap)) + __HeapLimit = .; + KEEP(*(.stack)) + KEEP(*(.stack.*)) + } > DTCM + + .ARM.extab : + { + *(.ARM.extab*) + } > RAM + + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > RAM + PROVIDE_HIDDEN (__exidx_end = .); + + /* Round the read-only part of the image up to a power of two. + * + * The MPU region that makes this range executable and read-only has to + * obey PMSAv7: the size must be 2^n and the base must be a multiple of + * that size. Padding to 2^n here means mpu_modify_region() finds an + * exact fit and needs no sub-region disable mask, so the region cannot + * silently spill over into .data - which would make every write to a + * global fault. The base needs no work: ORIGIN(RAM) is 512 KB aligned, + * so it is aligned to any 2^n <= 512 KB. + * + * The padding has to happen inside an output section attached to RAM. + * Assignments to "." outside of an output section move the location + * counter but do NOT move the allocation pointer of the memory region, + * so the next "> RAM" section would be placed back at the unpadded + * address and only the symbols would move. + * + * (NOLOAD) keeps the padding out of the ELF file itself; it still + * occupies address space, which is all that is needed here. + * + * LOG2CEIL() is a GNU ld builtin (binutils >= 2.29). + */ + + .rom_region_pad (NOLOAD) : + { + . = ALIGN(32); + . = ALIGN(1 << LOG2CEIL(ABSOLUTE(.) - __mpu_code_start)); + } > RAM + + __mpu_code_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > RAM + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > RAM + + /* The padding above is not linear: crossing 128 KB of code costs another + * 128 KB of SRAM, taken straight out of the heap. Fail the link instead + * of losing a quarter of the RAM silently. + */ + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rzv2h/rzv2h-evk/src/CMakeLists.txt b/boards/arm/rzv2h/rzv2h-evk/src/CMakeLists.txt new file mode 100644 index 00000000000..a14522415cc --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/CMakeLists.txt @@ -0,0 +1,58 @@ +# ############################################################################## +# boards/arm/rzv2h/rzv2h-evk/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +# Core board initialization files +set(SRCS rzv2h_boot.c rzv2h_bringup.c) + +# Application examples support +if(CONFIG_RZV2H_EXAMPLE_SUPPORT) + list(APPEND SRCS rzv2h_appexamples.c) +endif() + +# Board-specific initialization +if(CONFIG_BOARDCTL) + list(APPEND SRCS rzv2h_appinit.c) +endif() + +if(CONFIG_ARCH_BUTTONS) + list(APPEND SRCS rzv2h_buttons.c) +endif() + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS rzv2h_autoleds.c) +else() + list(APPEND SRCS rzv2h_userleds.c) +endif() + +if(CONFIG_DEV_GPIO) + list(APPEND SRCS rzv2h_gpio.c) +endif() + +# Peripheral driver initialization + +target_sources(board PRIVATE ${SRCS}) + +# Set linker script based on core configuration +if(CONFIG_RZV2H_CORTEXR8_0) + set_property(GLOBAL PROPERTY LD_SCRIPT + "${NUTTX_BOARD_DIR}/scripts/rzv2h-evk_cr8_0.ld") +endif() diff --git a/boards/arm/rzv2h/rzv2h-evk/src/Makefile b/boards/arm/rzv2h/rzv2h-evk/src/Makefile new file mode 100644 index 00000000000..c2c6b1484af --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/Makefile @@ -0,0 +1,69 @@ +############################################################################ +# boards/arm/rzv2h/rzv2h-evk/src/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +############################################################################ +# Core board initialization files +############################################################################ + +CSRCS = rzv2h_boot.c rzv2h_bringup.c + +# Application examples support +ifeq ($(CONFIG_RZV2H_EXAMPLE_SUPPORT),y) +CSRCS += rzv2h_appexamples.c +endif + +############################################################################ +# Board-specific initialization +############################################################################ + +# Application initialization +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += rzv2h_appinit.c +endif + +# Button/Switch support +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += rzv2h_buttons.c +endif + +# LED support +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += rzv2h_autoleds.c +else +CSRCS += rzv2h_userleds.c +endif + +ifeq ($(CONFIG_DEV_GPIO),y) +CSRCS += rzv2h_gpio.c +endif + +############################################################################ +# Peripheral driver initialization +############################################################################ + +############################################################################ +# Example applications +############################################################################ + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h-evk.h b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h-evk.h new file mode 100644 index 00000000000..07a73aeed21 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h-evk.h @@ -0,0 +1,113 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h-evk.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RZV2H_RZV2H_EVK_SRC_H +#define __BOARDS_ARM_RZV2H_RZV2H_EVK_SRC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LED_DRIVER_PATH "/dev/userleds" + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_bringup + ****************************************************************************/ + +int rzv2h_bringup(void); + +/**************************************************************************** + * Name: rzv2h_gpio_initialize + * + * Description: + * Initialize GPIO drivers for use with /apps/examples/gpio + * + * Return Value: + * OK on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_GPIO +int rzv2h_gpio_initialize(void); +#endif + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * Initialize buttons + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_BUTTONS +void board_button_initialize(void); +#endif + +/**************************************************************************** + * Name: rzv2h_appexamples + * + * Description: + * Run all enabled board example applications + * + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_serial_setup + * + * Description: + * Configure serial pins for UART operation + * + ****************************************************************************/ + +void rzv2h_serial_setup(void); + +#ifdef CONFIG_RZV2H_EXAMPLE_SUPPORT +int rzv2h_appexamples(void); +#endif + +/**************************************************************************** + * Example application initialization functions + ****************************************************************************/ + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RZV2H_RZV2H_EVK_SRC_H */ diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appexamples.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appexamples.c new file mode 100644 index 00000000000..3c9c5285af7 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appexamples.c @@ -0,0 +1,47 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appexamples.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <errno.h> + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_appexamples + * + * Description: + * Run all enabled board example applications + * + ****************************************************************************/ + +int rzv2h_appexamples(void) +{ + /* Placeholder for board-specific examples */ + + return 0; +} diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appinit.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appinit.c new file mode 100644 index 00000000000..5187a7d0ea3 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appinit.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/types.h> +#include <nuttx/board.h> +#include "rzv2h-evk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a pointer + * to configuration data read from a file or serial FLASH, or + * whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return rzv2h_bringup(); +#endif +} diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_autoleds.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_autoleds.c new file mode 100644 index 00000000000..cd4446af433 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_autoleds.c @@ -0,0 +1,172 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_autoleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <assert.h> +#include <debug.h> + +#include <nuttx/board.h> +#include <arch/board/board.h> + +#include "chip.h" +#include "arm_internal.h" +#include "rzv2h_gpio.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This array maps LED numbers to GPIO configurations */ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(const char *msg) +{ + (void)msg; +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + * + * Description: + * Initialize LED GPIOs so that LEDs can be controlled. + * + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + ; +} + +/**************************************************************************** + * Name: board_autoled_on + * + * Description: + * Set the LED configuration into the ON condition for the state provided + * by the led parameter. This may be one of: + * + * LED_STARTED - NuttX has been started + * LED_HEAPALLOCATE - Heap has been allocated + * LED_IRQSENABLED - Interrupts enabled + * LED_STACKCREATED - Idle stack created + * LED_INIRQ - In an interrupt handler + * LED_SIGNAL - In a signal handler + * LED_ASSERTION - An assertion failed + * LED_PANIC - The system has crashed + * + ****************************************************************************/ + +void board_autoled_on(int led) +{ + /* Active low LEDs: write 0 to turn ON */ + + (void)led; +} + +/**************************************************************************** + * Name: board_autoled_off + * + * Description: + * Set the LED configuration into the OFF condition for the state provided + * by the led parameter. + * + ****************************************************************************/ + +void board_autoled_off(int led) +{ + /* Active low LEDs: write 1 to turn OFF */ + + (void)led; +} + +#endif /* CONFIG_ARCH_LEDS */ + +/**************************************************************************** + * Name: board_userled_initialize + * + * Description: + * If CONFIG_ARCH_LEDS is not defined, then the board can provide + * application-controlled LED functionality via these functions. + * + ****************************************************************************/ + +#ifndef CONFIG_ARCH_LEDS +uint32_t board_userled_initialize(void) +{ + return 0; +} + +/**************************************************************************** + * Name: board_userled + * + * Description: + * Set the LED to the on or off state + * + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + (void)led; + (void)ledon; +} + +/**************************************************************************** + * Name: board_userled_all + * + * Description: + * Set the state of all LEDs + * + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + (void)ledset; +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_boot.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_boot.c new file mode 100644 index 00000000000..924ebbc43df --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_boot.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_boot.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <debug.h> +#include <stdint.h> + +#include <nuttx/board.h> +#include <arch/board/board.h> + +#include "arm_internal.h" +#include <arch/rzv2h/rzv2h_gpio.h> +#include "rzv2h-evk.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* GPIO Port Security Control registers base - RZV2H specific */ +#define RZV2H_GPIO_PMSAR_BASE 0x14030800 /* Port Mode Security Attribution */ +#define RZV2H_GPIO_PSCU_BASE 0x14030C00 /* Port Security Control Unit */ + +/* Number of GPIO ports in RZV2H (ports 0x20-0x2B = 12 ports) */ +#define RZV2H_GPIO_NPORTS 12 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_gpio_security_init + * + * Description: + * Initialize GPIO port security attributes to secure mode (default). + * Must be called before configuring any GPIO pins. + * Based on FSP r_ioport security initialization. + * + ****************************************************************************/ + +static void rzv2h_gpio_security_init(void) +{ +#ifdef CONFIG_ARM_TRUSTZONE + volatile uint32_t *pmsar; + volatile uint32_t *pscu; + int port; + + /* Initialize PMSAR (Port Mode Security Attribution Register) + * Set all pins to secure mode (0 = secure, 1 = non-secure) + */ + + pmsar = (volatile uint32_t *)RZV2H_GPIO_PMSAR_BASE; + for (port = 0; port < RZV2H_GPIO_NPORTS; port++) + { + pmsar[port] = 0x00000000; /* All pins secure */ + } + + /* Initialize PSCU (Port Security Control Unit) + * Configure security control for each port + */ + + pscu = (volatile uint32_t *)RZV2H_GPIO_PSCU_BASE; + for (port = 0; port < RZV2H_GPIO_NPORTS; port++) + { + pscu[port] = 0x00000000; /* Default security settings */ + } + + ARM_DSB(); +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_board_initialize + * + * Description: + * All RZV architectures must provide the following entry point. This + * entry point is called early in the initialization -- after clocks and + * memory have been configured but before any devices have been + * initialized. + * + * This function is called from rzv_start.c during the boot sequence. + * + ****************************************************************************/ + +void rzv2h_board_initialize(void) +{ + /* Initialize GPIO security attributes (TrustZone) */ + + rzv2h_gpio_security_init(); + + /* Configure SCI/UART pins for serial communication */ + +#ifdef CONFIG_RZV2H_UART_SCI + rzv2h_serial_setup(); +#endif + + /* Configure on-board LEDs if LED support has been selected */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif + + /* Initialize any board-specific GPIO configurations */ + +#ifdef CONFIG_BOARDCTL_IOCTL + /* Additional board-specific initialization can be done via ioctl */ +#endif +} + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + rzv2h_bringup(); +} + +#endif diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_bringup.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_bringup.c new file mode 100644 index 00000000000..622ea33148a --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_bringup.c @@ -0,0 +1,91 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <sys/mount.h> +#include <syslog.h> + +#include <arch/barriers.h> +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/leds/userled.h> + +#include "rzv2h-evk.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_bringup + ****************************************************************************/ + +int rzv2h_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, "/proc", "procfs", 0, NULL); + UP_DSB(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#if defined(CONFIG_DEV_GPIO) + ret = rzv2h_gpio_initialize(); + UP_DSB(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rzv2h_gpio_initialize() failed: %d\n", ret); + return ret; + } +#endif + +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) + /* Register the user LED driver. The generic lower half calls + * board_userled_initialize() before registering /dev/userleds. + */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + return ret; + } +#endif + + return OK; +} diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_gpio.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_gpio.c new file mode 100644 index 00000000000..0577818a6a8 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_gpio.c @@ -0,0 +1,337 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_gpio.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <assert.h> +#include <nuttx/debug.h> +#include <errno.h> + +#include <arch/board/board.h> +#include <nuttx/ioexpander/gpio.h> + +#include "rzv2h_gpio.h" +#include "hardware/rzv2h_pinmap.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#ifdef CONFIG_RZV2H_GPIO + +struct rzv2hgpio_dev_s +{ + struct gpio_dev_s gpio; + uint8_t id; +}; + +struct rzv2hgpint_dev_s +{ + struct rzv2hgpio_dev_s rzv2hgpio; + pin_interrupt_t callback; +}; + +/**************************************************************************** + * Private Functions Prototypes + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value); +static int gpin_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); +static int gpin_enable(struct gpio_dev_s *dev, bool enable); + +#endif +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); + +#endif +static int gpio_setpintype(struct gpio_dev_s *dev, + enum gpio_pintype_e gpio_pintype); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static const struct gpio_operations_s gpin_ops = +{ + .go_read = gpin_read, .go_write = NULL, + .go_attach = gpin_attach, + .go_enable = gpin_enable, .go_setpintype = gpio_setpintype, +}; +#endif + +#if BOARD_NGPIOOUT > 0 +static const struct gpio_operations_s gpout_ops = +{ + .go_read = gpout_read, .go_write = gpout_write, + .go_attach = NULL, + .go_enable = NULL, .go_setpintype = gpio_setpintype, +}; +#endif + +#if BOARD_NGPIOIN > 0 + +/* This array maps the GPIO pins used as INPUT */ + +static const gpio_pinset_t g_gpioinputs[BOARD_NGPIOIN] = +{ + BOARD_P8_2_BUTTON +}; + +static struct rzv2hgpio_dev_s g_gpin[BOARD_NGPIOIN]; +#endif + +#if BOARD_NGPIOOUT > 0 + +/* This array maps the GPIO pins used as OUTPUT */ + +static const gpio_pinset_t g_gpiooutputs[BOARD_NGPIOOUT] = +{ + BOARD_P0_0_GPIO, BOARD_P0_1_GPIO +}; + +static struct rzv2hgpio_dev_s g_gpout[BOARD_NGPIOOUT]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 + +/**************************************************************************** + * Name: gpin_read + * + * Description: + * Read the current logic state of an input GPIO pin and store the result + * in the caller-provided boolean output value. + ****************************************************************************/ + +static int gpin_read(struct gpio_dev_s *dev, bool *value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL && value != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOIN); + gpioinfo("Reading..."); + + *value = rzv2h_gpioread(g_gpioinputs[rzv2hgpio->id]); + + return OK; +} + +/**************************************************************************** + * Name: gpin_attach + * + * Description: + * Register an interrupt callback for a GPIO input pin. The callback is + * stored for later use when the interrupt is enabled. + * Refer to drivers/ioexpander/gpio.c for the reference implementation. + ****************************************************************************/ + +static int gpin_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) +{ + struct rzv2hgpint_dev_s *rzv2hgpint = (struct rzv2hgpint_dev_s *)dev; + + gpioinfo("Attaching the callback\n"); + + /* Make sure the interrupt is disabled */ + + /* Assign Callback function */ + + gpioinfo("Attach %p\n", callback); + rzv2hgpint->callback = callback; + return OK; +} + +/**************************************************************************** + * Name: gpin_enable + * + * Description: + * Enable or disable the interrupt handling for an input GPIO pin. + * The current implementation only tracks the requested state. + ****************************************************************************/ + +static int gpin_enable(struct gpio_dev_s *dev, bool enable) +{ + struct rzv2hgpint_dev_s *rzv2hgpint = (struct rzv2hgpint_dev_s *)dev; + + if (enable && rzv2hgpint->callback != NULL) + { + gpioinfo("Enabling the interrupt\n"); + } + else + { + gpioinfo("Disable the interrupt\n"); + } + + return OK; +} + +#endif + +#if BOARD_NGPIOOUT > 0 + +/**************************************************************************** + * Name: gpout_read + * + * Description: + * Read the current logic state of an output GPIO pin and return it through + * the caller-provided boolean output value. + ****************************************************************************/ + +static int gpout_read(struct gpio_dev_s *dev, bool *value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL && value != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOOUT); + gpioinfo("Reading..."); + + *value = rzv2h_gpioread(g_gpiooutputs[rzv2hgpio->id]); + + return OK; +} + +/**************************************************************************** + * Name: gpout_write + * + * Description: + * Drive an output GPIO pin to the requested logic state. + ****************************************************************************/ + +static int gpout_write(struct gpio_dev_s *dev, bool value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOOUT); + gpioinfo("Writing %d", (int)value); + + return rzv2h_gpiowrite(g_gpiooutputs[rzv2hgpio->id], value); +} + +#endif + +/**************************************************************************** + * Name: gpio_setpintype + * + * Description: + * Set the pin type for a GPIO device. This implementation is currently + * unsupported and returns success without changing hardware state. + ****************************************************************************/ + +static int gpio_setpintype(struct gpio_dev_s *dev, + enum gpio_pintype_e gpio_pintype) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + UNUSED(rzv2hgpio); + UNUSED(gpio_pintype); + + gpioinfo("setpintype is not supported. \n"); + + return 0; +} + +/**************************************************************************** + * Name: rzv2h_gpio_initialize + * + * Description: + * Initialize GPIO drivers for use with /apps/examples/gpio + ****************************************************************************/ + +int rzv2h_gpio_initialize(void) +{ + int pincount = 0; + int i; + int ret = 0; + +#if BOARD_NGPIOIN > 0 + for (i = 0; i < BOARD_NGPIOIN; i++, pincount++) + { + /* Setup and register the GPIO pin */ + + g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; + g_gpin[i].gpio.gp_ops = &gpin_ops; + g_gpin[i].id = i; + ret = + gpio_pin_register(&g_gpin[i].gpio, pincount); + if (ret < 0) + { + gpioerr("GPIOIN(%d): gpio_pin_register failed: %d", i, ret); + return ret; + } + + /* Configure the pin that will be used as input */ + + ret = rzv2h_configgpio(g_gpioinputs[i]); + if (ret < 0) + { + gpioerr("GPIOIN(%d): rzv2h_configgpio failed: %d", i, ret); + return ret; + } + } +#endif + +#if BOARD_NGPIOOUT > 0 + for (i = 0; i < BOARD_NGPIOOUT; i++, pincount++) + { + /* Setup and register the GPIO pin */ + + g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gpout[i].gpio.gp_ops = &gpout_ops; + g_gpout[i].id = i; + ret = gpio_pin_register(&g_gpout[i].gpio, + pincount); + if (ret < 0) + { + gpioerr("GPIOOUT(%d): gpio_pin_register failed: %d", i, ret); + return ret; + } + + /* Configure the pin that will be used as output */ + + ret = rzv2h_configgpio(g_gpiooutputs[i]); + if (ret < 0) + { + gpioerr("GPIOOUT(%d): rzv2h_configgpio failed: %d", i, ret); + return ret; + } + } +#endif + + return ret; +} + +#endif /* CONFIG_RZV2H_GPIO */ diff --git a/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_userleds.c b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_userleds.c new file mode 100644 index 00000000000..90390ccf72e --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-evk/src/rzv2h_userleds.c @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-evk/src/rzv2h_userleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <nuttx/debug.h> + +#include "chip.h" +#include "rzv2h_gpio.h" +#include "rzv2h-evk.h" + +#include <arch/board/board.h> + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Configure LED GPIOs for output */ + + rzv2h_configgpio(BOARD_P0_0_GPIO); + rzv2h_configgpio(BOARD_P0_1_GPIO); + + /* The LEDs are active low. Leave both LEDs off after initialization. */ + + rzv2h_gpiowrite(BOARD_P0_0_GPIO, true); + rzv2h_gpiowrite(BOARD_P0_1_GPIO, true); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + gpio_pinset_t ledcfg; + + if (led == BOARD_LED_0) + { + ledcfg = BOARD_P0_0_GPIO; + } + else if (led == BOARD_LED_1) + { + ledcfg = BOARD_P0_1_GPIO; + } + else + { + return; + } + + /* Low illuminates. */ + + rzv2h_gpiowrite(ledcfg, !ledon); +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + /* Low illuminates. */ + + rzv2h_gpiowrite(BOARD_P0_0_GPIO, + (ledset & BOARD_LED_0_BIT) == 0); + rzv2h_gpiowrite(BOARD_P0_1_GPIO, + (ledset & BOARD_LED_1_BIT) == 0); +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/rzv2h/rzv2h-rdk/CMakeLists.txt b/boards/arm/rzv2h/rzv2h-rdk/CMakeLists.txt new file mode 100644 index 00000000000..f541d094be4 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm/rzv/rzv2h-rdk/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/arm/rzv2h/rzv2h-rdk/Kconfig b/boards/arm/rzv2h/rzv2h-rdk/Kconfig new file mode 100644 index 00000000000..99147eed1ca --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/Kconfig @@ -0,0 +1,22 @@ +# ############################################################################## +# boards/arm/rzv/rzv2h-rdk/Kconfig +# +# Kconfig for the RZV2H_RDK board support package for the RZV2H MPU. +# +if ARCH_BOARD_RZV2H_RDK + +config BOARD_RZV2H_RDK + bool "RZV2H-RDK Board Support" + help + Enable support for the RZV2H-RDK board based on the RZV2H MPU. + +endif + +config RZV2H_EXAMPLE_SUPPORT + bool "RZV2H-RDK Example Support" + default y + depends on ARCH_BOARD_RZV2H_RDK + help + Enable support for various application examples for the RZV2H-RDK board. + +# ############################################################################## diff --git a/boards/arm/rzv2h/rzv2h-rdk/configs/nsh-leds/defconfig b/boards/arm/rzv2h/rzv2h-rdk/configs/nsh-leds/defconfig new file mode 100644 index 00000000000..d33b63f3c6d --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/configs/nsh-leds/defconfig @@ -0,0 +1,52 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="rzv2h-rdk" +CONFIG_ARCH_BOARD_RZV2H_RDK=y +CONFIG_ARCH_CHIP="rzv2h" +CONFIG_ARCH_CHIP_R9A09G057=y +CONFIG_ARCH_CHIP_RZV2H=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7R_DCACHE_DISABLE=y +CONFIG_ARMV7R_ICACHE_DISABLE=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_NREGIONS=6 +CONFIG_ARM_THUMB=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=200000 +CONFIG_BUILTIN=y +CONFIG_DEV_GPIO=y +CONFIG_EXAMPLES_LEDS=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x08180000 +CONFIG_RAW_BINARY=y +CONFIG_RZV2H_CORTEXR8_0=y +CONFIG_RZV2H_SCI_B_UART0=y +CONFIG_SCHED_WAITPID=y +CONFIG_SCI0_SERIAL_CONSOLE=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SERIAL_TIOCGICOUNT=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TTY_SIGINT=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_USERLED=y +CONFIG_USERLED_LOWER=y diff --git a/boards/arm/rzv2h/rzv2h-rdk/configs/nsh/defconfig b/boards/arm/rzv2h/rzv2h-rdk/configs/nsh/defconfig new file mode 100644 index 00000000000..e6842622f67 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/configs/nsh/defconfig @@ -0,0 +1,52 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="rzv2h-rdk" +CONFIG_ARCH_BOARD_RZV2H_RDK=y +CONFIG_ARCH_CHIP="rzv2h" +CONFIG_ARCH_CHIP_R9A09G057=y +CONFIG_ARCH_CHIP_RZV2H=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7R_DCACHE_DISABLE=y +CONFIG_ARMV7R_ICACHE_DISABLE=y +CONFIG_ARM_MPU=y +CONFIG_ARM_MPU_NREGIONS=6 +CONFIG_ARM_THUMB=y +CONFIG_BINFMT_DISABLE=y +CONFIG_BOARD_LOOPSPERMSEC=200000 +CONFIG_BUILTIN=y +CONFIG_DEV_GPIO=y +CONFIG_EXAMPLES_GPIO=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x08180000 +CONFIG_RAW_BINARY=y +CONFIG_RZV2H_CORTEXR8_0=y +CONFIG_RZV2H_SCI_B_UART0=y +CONFIG_SCHED_WAITPID=y +CONFIG_SCI0_SERIAL_CONSOLE=y +CONFIG_SERIAL_TERMIOS=y +CONFIG_SERIAL_TIOCGICOUNT=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=29 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_NBARRIER_THREADS=3 +CONFIG_TESTING_OSTEST_STACKSIZE=2048 +CONFIG_TTY_SIGINT=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm/rzv2h/rzv2h-rdk/include/board.h b/boards/arm/rzv2h/rzv2h-rdk/include/board.h new file mode 100644 index 00000000000..0a34e0462d4 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/include/board.h @@ -0,0 +1,151 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RZV2H_RZV2H_RDK_INCLUDE_BOARD_H +#define __BOARDS_ARM_RZV2H_RZV2H_RDK_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* GPIO definitions *********************************************************/ + +#define BOARD_NGPIOOUT 2 +#define BOARD_NGPIOIN 1 + +/* LED index values for use with board_userled() */ + +#define BOARD_LED_0 0 +#define BOARD_LED_1 1 +#define BOARD_NLEDS 2 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED_0_BIT (1 << BOARD_LED_0) +#define BOARD_LED_1_BIT (1 << BOARD_LED_1) + +/* LED pins */ + +#define BOARD_P11_4_GPIO GPIO_P11_4_OUTPUT_LOW +#define BOARD_P11_5_GPIO GPIO_P11_5_OUTPUT_LOW + +/* Button pin */ + +#define BOARD_P10_0_BUTTON GPIO_P10_0_INPUT_PULLDOWN + +/* GPIO Configuration */ + +#define GPIO_P11_4_OUTPUT_LOW (gpio_pinset_t){BSP_IO_PORT_11_PIN_04, (IOPORT_CFG_DRIVE_B01 | IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_LOW | IOPORT_CFG_SLEW_RATE_FAST)} +#define GPIO_P11_5_OUTPUT_LOW (gpio_pinset_t){BSP_IO_PORT_11_PIN_05, (IOPORT_CFG_DRIVE_B01 | IOPORT_CFG_PORT_DIRECTION_OUTPUT | IOPORT_CFG_PORT_OUTPUT_LOW | IOPORT_CFG_SLEW_RATE_FAST)} +#define GPIO_P10_0_INPUT_PULLDOWN (gpio_pinset_t){BSP_IO_PORT_10_PIN_00, (IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_SPECIAL_PURPOSE_PORT_INPUT_ENABLE | IOPORT_CFG_PULLDOWN_ENABLE)} + +/* In this stage, autoled is not supported */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 0 +#define LED_INIRQ 0 +#define LED_SIGNAL 0 +#define LED_ASSERTION 0 +#define LED_PANIC 0 + +/* Peripheral definitions ***************************************************/ + +/* SCI0 is used as the default NSH console interface */ + +#define BOARD_CONSOLE_UART 0 /* Use SCI0 for console */ +#define BOARD_CONSOLE_BAUD 115200 +#define BOARD_CONSOLE_BITS 8 +#define BOARD_CONSOLE_PARITY 0 +#define BOARD_CONSOLE_2STOP 0 + +/* SCI-B UART pins */ + +#define BOARD_SCI0_TXD_GPIO GPIO_TXD0_MOSI0_DA0_P5_0_M1 +#define BOARD_SCI0_RXD_GPIO GPIO_RXD0_MISO0_SCL0_P5_1_M1 +#define BOARD_SCI1_TXD_GPIO GPIO_TXD1_MOSI1_SDA1_P5_2_M1 +#define BOARD_SCI1_RXD_GPIO GPIO_RXD1_MISO1_SCL1_P5_3_M1 +#define BOARD_SCI2_TXD_GPIO GPIO_TXD2_MOSI2_SDA2_P5_4_M1 +#define BOARD_SCI2_RXD_GPIO GPIO_RXD2_MISO2_SCL2_P5_5_M1 +#define BOARD_SCI3_TXD_GPIO GPIO_TXD3_MOSI3_SDA3_P5_6_M1 +#define BOARD_SCI3_RXD_GPIO GPIO_RXD3_MISO3_SCL3_P5_7_M1 + +#define BOARD_SCI4_TXD_GPIO GPIO_TXD4_MOSI4_SDA4_P8_4_M6 +#define BOARD_SCI4_RXD_GPIO GPIO_RXD4_MISO4_SCL4_P8_5_M6 +#define BOARD_SCI5_TXD_GPIO GPIO_TXD5_MOSI5_SDA5_P7_2_M1 +#define BOARD_SCI5_RXD_GPIO GPIO_RXD5_MISO5_SCL5_P7_3_M1 +#define BOARD_SCI6_TXD_GPIO GPIO_TXD6_MOSI6_SDA6_P7_4_M1 +#define BOARD_SCI6_RXD_GPIO GPIO_RXD6_MISO6_SCL6_P7_5_M1 +#define BOARD_SCI7_TXD_GPIO GPIO_TXD7_MOSI7_SDA7_P7_6_M1 +#define BOARD_SCI7_RXD_GPIO GPIO_RXD7_MISO7_SCL7_P7_7_M1 +#define BOARD_SCI8_TXD_GPIO GPIO_TXD8_MOSI8_SDA6_P9_0_M2 +#define BOARD_SCI8_RXD_GPIO GPIO_RXD8_MISO8_SCL6_P9_1_M2 +#define BOARD_SCI9_TXD_GPIO GPIO_TXD9_MOSI9_SDA9_P8_2_M6 +#define BOARD_SCI9_RXD_GPIO GPIO_RXD9_MISO9_SCL9_P8_3_M6 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/**************************************************************************** + * Name: rzv2h_board_initialize + * + * Description: + * All RZV2H architectures must provide the following entry point. This + * entry point is called early in the initialization -- after clocking + * and memory have been configured but before caches have been enabled + * and before any devices have been initialized. + * + ****************************************************************************/ + +void rzv2h_board_initialize(void); + +/**************************************************************************** + * Name: rzv2h_serial_setup + * + * Description: + * Configure the board used by the enabled SCI UART channels. + * + ****************************************************************************/ + +void rzv2h_serial_setup(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RZV2H_RZV2H_RDK_INCLUDE_BOARD_H */ diff --git a/boards/arm/rzv2h/rzv2h-rdk/scripts/Make.defs b/boards/arm/rzv2h/rzv2h-rdk/scripts/Make.defs new file mode 100644 index 00000000000..c8e62680d7a --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/scripts/Make.defs @@ -0,0 +1,98 @@ +############################################################################ +# boards/arm/rzv2h/rzv2h-rdk/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/arch/arm/src/armv7-r/Toolchain.defs + +# Determine linker script based on build type +ifeq ($(CONFIG_RZV2H_CORTEXR8_0),y) + LDSCRIPT = rzv2h-rdk_cr8_0.ld +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +# Compile flags +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe -Wno-undef +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +# Linker flags +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# ELF module flags +LDELFFLAGS = -r -e main +ifeq ($(CONFIG_CYGWIN_WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld}" +else + LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld +endif + +# Board-specific flags +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + +#hal renesas include +HAL_INDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)common$(DELIM)renesas$(DELIM)hal_renesas +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)instances +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)instances$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)inc$(DELIM)api +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)rzv2h +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)all +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)mcu$(DELIM)all$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)drivers$(DELIM)rz$(DELIM)fsp$(DELIM)src$(DELIM)rzv$(DELIM)bsp$(DELIM)cmsis$(DELIM)Device$(DELIM)RENESAS$(DELIM)Include +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp$(DELIM)rzv2h +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)bsp$(DELIM)rzv2h$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)rz_cfg$(DELIM)fsp_cfg$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)portable$(DELIM)rzv +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)rz$(DELIM)portable$(DELIM)rzv$(DELIM)cr +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)cmsis +CFLAGS += $(INCDIR_PREFIX)$(HAL_INDIR)$(DELIM)nuttx$(DELIM)cmsis$(DELIM)include$(DELIM)cr + +# Generate the raw image U-Boot loads at CONFIG_RAM_START before starting +# CR8_0 from reset. Select the SRAM sections explicitly so distant NOLOAD +# OpenAMP regions can never create padding in the raw binary. .vectors runs +# from ITCM, but its load copy is the first thing in RAM and the U-Boot reset +# trampoline in ITCM jumps to it, so it has to be in the image; without it +# nuttx_uboot.bin would also start at .text instead of at CONFIG_RAM_START. + +ifeq ($(CONFIG_RZV2H_UBOOT_IMAGE),y) +define POSTBUILD + @echo "CP: nuttx_uboot.bin" + $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary \ + --only-section=.vectors --only-section=.text \ + --only-section=.init_section \ + --only-section=.ARM.extab --only-section=.ARM.exidx \ + --only-section=.data $(BIN) nuttx_uboot.bin + $(Q) echo nuttx_uboot.bin >> nuttx.manifest +endef +endif diff --git a/boards/arm/rzv2h/rzv2h-rdk/scripts/rzv2h-rdk_cr8_0.ld b/boards/arm/rzv2h/rzv2h-rdk/scripts/rzv2h-rdk_cr8_0.ld new file mode 100644 index 00000000000..7647ad51166 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/scripts/rzv2h-rdk_cr8_0.ld @@ -0,0 +1,224 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/scripts/rzv2h-rdk_cr8_0.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#include <nuttx/config.h> + +/* + * RZ/V2H Cortex-R8_0 linker script for NuttX. + * + */ + +/* Core-local TCM map of the RZ/V2H CR8, from the Renesas HAL + * [FSP: bsp_slave_address.h:19-25]: + * + * ITCM core 0x00000000, 128 KB, AXI alias 0x12040000 + * DTCM core 0x00020000, 128 KB, AXI alias 0x12060000 + * + * Both build types keep a load copy of the vector table at the start of + * RAM, which arm_boot() copies to ITCM. CR8_0 takes its reset vector from + * ITCM, so before releasing CR8_0 from reset U-Boot writes a fixed two-word + * trampoline there through the AXI alias: + * + * 0x0: 0xe51ff004 ldr pc, [pc, #-4] + * 0x4: 0x08180000 ORIGIN(RAM), the load copy of the table + * + * The reset slot of the load copy then branches to __start. A + * debugger-loaded image is entered at __start directly; ITCM is not mapped + * until arm_boot() programs the ATCM region register. + */ + +MEMORY +{ + ITCM (rwx) : ORIGIN = 0x00000000, LENGTH = 128K + DTCM (rwx) : ORIGIN = 0x00020000, LENGTH = 128K + RAM (rwx) : ORIGIN = 0x08180000, LENGTH = 512K +} + +OUTPUT_ARCH(arm) +EXTERN(_vector_start) +ENTRY(__start) + +/* Start of the read-only SRAM part of the image. Everything from here up to + * __mpu_code_end (the vector load image, .text, .rodata, .init_section and + * .ARM.exidx) is covered by one MPU region programmed + * RO + executable; see g_mpu_region_table[] in + * arch/arm/src/rzv2h/rzv2h_mpu_region.c. + */ + +__mpu_code_start = ABSOLUTE(ORIGIN(RAM)); + +SECTIONS +{ + + /* The table always has a load copy at the start of RAM, at + * _vector_load, which arm_boot() copies to VECTOR_ADDRESS (ITCM). + * + * The U-Boot image links the table at its ITCM run address and stores + * it in RAM (AT> RAM), so nuttx_uboot.bin starts with it. CR8_0 + * reaches it at reset through the U-Boot trampoline described at the + * top of this file, so the load copy has to stay at ORIGIN(RAM). + * + * The debugger image links the table in RAM. That works because the + * table is position independent: its branch slots are PC-relative and + * its handler entries contain absolute addresses. + */ + + .vectors : + { + . = ALIGN(32); + _vector_start = ABSOLUTE(.); + KEEP(*(.vectors)) + _vector_end = ABSOLUTE(.); +#ifdef CONFIG_RZV2H_UBOOT_IMAGE + } > ITCM AT> RAM +#else + } > RAM +#endif + + /* Where the table is stored in the image, as opposed to _vector_start, + * where it runs. The two are equal in debugger builds. + */ + + _vector_load = LOADADDR(.vectors); + +#ifdef CONFIG_RZV2H_UBOOT_IMAGE + ASSERT(_vector_load == ORIGIN(RAM), + "U-Boot reset trampoline expects .vectors at ORIGIN(RAM)") +#endif + .text : + { + . = ALIGN(4); + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > RAM + + .init_section : + { + . = ALIGN(4); + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) + _einit = ABSOLUTE(.); + } > RAM + + .dtcm (NOLOAD) : + { + __HeapBase = .; + KEEP(*(.heap)) + __HeapLimit = .; + KEEP(*(.stack)) + KEEP(*(.stack.*)) + } > DTCM + + .ARM.extab : + { + *(.ARM.extab*) + } > RAM + + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > RAM + PROVIDE_HIDDEN (__exidx_end = .); + + /* Round the read-only part of the image up to a power of two. + * + * The MPU region that makes this range executable and read-only has to + * obey PMSAv7: the size must be 2^n and the base must be a multiple of + * that size. Padding to 2^n here means mpu_modify_region() finds an + * exact fit and needs no sub-region disable mask, so the region cannot + * silently spill over into .data - which would make every write to a + * global fault. The base needs no work: ORIGIN(RAM) is 512 KB aligned, + * so it is aligned to any 2^n <= 512 KB. + * + * The padding has to happen inside an output section attached to RAM. + * Assignments to "." outside of an output section move the location + * counter but do NOT move the allocation pointer of the memory region, + * so the next "> RAM" section would be placed back at the unpadded + * address and only the symbols would move. + * + * (NOLOAD) keeps the padding out of the ELF file itself; it still + * occupies address space, which is all that is needed here. + * + * LOG2CEIL() is a GNU ld builtin (binutils >= 2.29). + */ + + .rom_region_pad (NOLOAD) : + { + . = ALIGN(32); + . = ALIGN(1 << LOG2CEIL(ABSOLUTE(.) - __mpu_code_start)); + } > RAM + + __mpu_code_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > RAM + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > RAM + + /* The padding above is not linear: crossing 128 KB of code costs another + * 128 KB of SRAM, taken straight out of the heap. Fail the link instead + * of losing a quarter of the RAM silently. + */ + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/CMakeLists.txt b/boards/arm/rzv2h/rzv2h-rdk/src/CMakeLists.txt new file mode 100644 index 00000000000..24497a91e4b --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/CMakeLists.txt @@ -0,0 +1,58 @@ +# ############################################################################## +# boards/arm/rzv2h/rzv2h-rdk/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +# Core board initialization files +set(SRCS rzv2h_boot.c rzv2h_bringup.c) + +# Application examples support +if(CONFIG_RZV2H_EXAMPLE_SUPPORT) + list(APPEND SRCS rzv2h_appexamples.c) +endif() + +# Board-specific initialization +if(CONFIG_BOARDCTL) + list(APPEND SRCS rzv2h_appinit.c) +endif() + +if(CONFIG_ARCH_BUTTONS) + list(APPEND SRCS rzv2h_buttons.c) +endif() + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS rzv2h_autoleds.c) +else() + list(APPEND SRCS rzv2h_userleds.c) +endif() + +if(CONFIG_DEV_GPIO) + list(APPEND SRCS rzv2h_gpio.c) +endif() + +# Peripheral driver initialization + +target_sources(board PRIVATE ${SRCS}) + +# Set linker script based on core configuration +if(CONFIG_RZV2H_CORTEXR8_0) + set_property(GLOBAL PROPERTY LD_SCRIPT + "${NUTTX_BOARD_DIR}/scripts/rzv2h-rdk_cr8_0.ld") +endif() diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/Makefile b/boards/arm/rzv2h/rzv2h-rdk/src/Makefile new file mode 100644 index 00000000000..5d1115d19b3 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/Makefile @@ -0,0 +1,69 @@ +############################################################################ +# boards/arm/rzv2h/rzv2h-rdk/src/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +############################################################################ +# Core board initialization files +############################################################################ + +CSRCS = rzv2h_boot.c rzv2h_bringup.c + +# Application examples support +ifeq ($(CONFIG_RZV2H_EXAMPLE_SUPPORT),y) +CSRCS += rzv2h_appexamples.c +endif + +############################################################################ +# Board-specific initialization +############################################################################ + +# Application initialization +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += rzv2h_appinit.c +endif + +# Button/Switch support +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += rzv2h_buttons.c +endif + +# LED support +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += rzv2h_autoleds.c +else +CSRCS += rzv2h_userleds.c +endif + +ifeq ($(CONFIG_DEV_GPIO),y) +CSRCS += rzv2h_gpio.c +endif + +############################################################################ +# Peripheral driver initialization +############################################################################ + +############################################################################ +# Example applications +############################################################################ + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h-rdk.h b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h-rdk.h new file mode 100644 index 00000000000..2304ee389b7 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h-rdk.h @@ -0,0 +1,113 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h-rdk.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RZV2H_RZV2H_RDK_SRC_H +#define __BOARDS_ARM_RZV2H_RZV2H_RDK_SRC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define LED_DRIVER_PATH "/dev/userleds" + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_bringup + ****************************************************************************/ + +int rzv2h_bringup(void); + +/**************************************************************************** + * Name: rzv2h_gpio_initialize + * + * Description: + * Initialize GPIO drivers for use with /apps/examples/gpio + * + * Return Value: + * OK on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_GPIO +int rzv2h_gpio_initialize(void); +#endif + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * Initialize buttons + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_BUTTONS +void board_button_initialize(void); +#endif + +/**************************************************************************** + * Name: rzv2h_appexamples + * + * Description: + * Run all enabled board example applications + * + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_serial_setup + * + * Description: + * Configure serial pins for UART operation + * + ****************************************************************************/ + +void rzv2h_serial_setup(void); + +#ifdef CONFIG_RZV2H_EXAMPLE_SUPPORT +int rzv2h_appexamples(void); +#endif + +/**************************************************************************** + * Example application initialization functions + ****************************************************************************/ + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RZV2H_RZV2H_RDK_SRC_H */ diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appexamples.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appexamples.c new file mode 100644 index 00000000000..2db8ff3497c --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appexamples.c @@ -0,0 +1,47 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appexamples.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <errno.h> + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_appexamples + * + * Description: + * Run all enabled board example applications + * + ****************************************************************************/ + +int rzv2h_appexamples(void) +{ + /* Placeholder for board-specific examples */ + + return 0; +} diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appinit.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appinit.c new file mode 100644 index 00000000000..6b404c5ce88 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appinit.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <sys/types.h> +#include <nuttx/board.h> +#include "rzv2h-rdk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a pointer + * to configuration data read from a file or serial FLASH, or + * whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return rzv2h_bringup(); +#endif +} diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_autoleds.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_autoleds.c new file mode 100644 index 00000000000..c7db443da84 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_autoleds.c @@ -0,0 +1,172 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_autoleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <assert.h> +#include <debug.h> + +#include <nuttx/board.h> +#include <arch/board/board.h> + +#include "chip.h" +#include "arm_internal.h" +#include "rzv2h_gpio.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This array maps LED numbers to GPIO configurations */ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(const char *msg) +{ + (void)msg; +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + * + * Description: + * Initialize LED GPIOs so that LEDs can be controlled. + * + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + ; +} + +/**************************************************************************** + * Name: board_autoled_on + * + * Description: + * Set the LED configuration into the ON condition for the state provided + * by the led parameter. This may be one of: + * + * LED_STARTED - NuttX has been started + * LED_HEAPALLOCATE - Heap has been allocated + * LED_IRQSENABLED - Interrupts enabled + * LED_STACKCREATED - Idle stack created + * LED_INIRQ - In an interrupt handler + * LED_SIGNAL - In a signal handler + * LED_ASSERTION - An assertion failed + * LED_PANIC - The system has crashed + * + ****************************************************************************/ + +void board_autoled_on(int led) +{ + /* Active low LEDs: write 0 to turn ON */ + + (void)led; +} + +/**************************************************************************** + * Name: board_autoled_off + * + * Description: + * Set the LED configuration into the OFF condition for the state provided + * by the led parameter. + * + ****************************************************************************/ + +void board_autoled_off(int led) +{ + /* Active low LEDs: write 1 to turn OFF */ + + (void)led; +} + +#endif /* CONFIG_ARCH_LEDS */ + +/**************************************************************************** + * Name: board_userled_initialize + * + * Description: + * If CONFIG_ARCH_LEDS is not defined, then the board can provide + * application-controlled LED functionality via these functions. + * + ****************************************************************************/ + +#ifndef CONFIG_ARCH_LEDS +uint32_t board_userled_initialize(void) +{ + return 0; +} + +/**************************************************************************** + * Name: board_userled + * + * Description: + * Set the LED to the on or off state + * + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + (void)led; + (void)ledon; +} + +/**************************************************************************** + * Name: board_userled_all + * + * Description: + * Set the state of all LEDs + * + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + (void)ledset; +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_boot.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_boot.c new file mode 100644 index 00000000000..042309f1f75 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_boot.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_boot.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <debug.h> +#include <stdint.h> + +#include <nuttx/board.h> +#include <arch/board/board.h> + +#include "arm_internal.h" +#include <arch/rzv2h/rzv2h_gpio.h> +#include "rzv2h-rdk.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* GPIO Port Security Control registers base - RZV2H specific */ +#define RZV2H_GPIO_PMSAR_BASE 0x14030800 /* Port Mode Security Attribution */ +#define RZV2H_GPIO_PSCU_BASE 0x14030C00 /* Port Security Control Unit */ + +/* Number of GPIO ports in RZV2H (ports 0x20-0x2B = 12 ports) */ +#define RZV2H_GPIO_NPORTS 12 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_gpio_security_init + * + * Description: + * Initialize GPIO port security attributes to secure mode (default). + * Must be called before configuring any GPIO pins. + * Based on FSP r_ioport security initialization. + * + ****************************************************************************/ + +static void rzv2h_gpio_security_init(void) +{ +#ifdef CONFIG_ARM_TRUSTZONE + volatile uint32_t *pmsar; + volatile uint32_t *pscu; + int port; + + /* Initialize PMSAR (Port Mode Security Attribution Register) + * Set all pins to secure mode (0 = secure, 1 = non-secure) + */ + + pmsar = (volatile uint32_t *)RZV2H_GPIO_PMSAR_BASE; + for (port = 0; port < RZV2H_GPIO_NPORTS; port++) + { + pmsar[port] = 0x00000000; /* All pins secure */ + } + + /* Initialize PSCU (Port Security Control Unit) + * Configure security control for each port + */ + + pscu = (volatile uint32_t *)RZV2H_GPIO_PSCU_BASE; + for (port = 0; port < RZV2H_GPIO_NPORTS; port++) + { + pscu[port] = 0x00000000; /* Default security settings */ + } + + ARM_DSB(); +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_board_initialize + * + * Description: + * All RZV architectures must provide the following entry point. This + * entry point is called early in the initialization -- after clocks and + * memory have been configured but before any devices have been + * initialized. + * + * This function is called from rzv_start.c during the boot sequence. + * + ****************************************************************************/ + +void rzv2h_board_initialize(void) +{ + /* Initialize GPIO security attributes (TrustZone) */ + + rzv2h_gpio_security_init(); + + /* Configure SCI/UART pins for serial communication */ + +#ifdef CONFIG_RZV2H_UART_SCI + rzv2h_serial_setup(); +#endif + + /* Configure on-board LEDs if LED support has been selected */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif + + /* Initialize any board-specific GPIO configurations */ + +#ifdef CONFIG_BOARDCTL_IOCTL + /* Additional board-specific initialization can be done via ioctl */ +#endif +} + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + rzv2h_bringup(); +} + +#endif diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_bringup.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_bringup.c new file mode 100644 index 00000000000..20734a82d0d --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_bringup.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <sys/mount.h> +#include <syslog.h> + +#include <nuttx/board.h> +#include <nuttx/leds/userled.h> + +#include "rzv2h-rdk.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rzv2h_bringup + ****************************************************************************/ + +int rzv2h_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#if defined(CONFIG_DEV_GPIO) + ret = rzv2h_gpio_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rzv2h_gpio_initialize() failed: %d\n", ret); + return ret; + } +#endif + +#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER) + /* Register the user LED driver. The generic lower half calls + * board_userled_initialize() before registering /dev/userleds. + */ + + ret = userled_lower_initialize(LED_DRIVER_PATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + return ret; + } +#endif + + return OK; +} diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_gpio.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_gpio.c new file mode 100644 index 00000000000..69fa1adeb48 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_gpio.c @@ -0,0 +1,337 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_gpio.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <assert.h> +#include <nuttx/debug.h> +#include <errno.h> + +#include <arch/board/board.h> +#include <nuttx/ioexpander/gpio.h> + +#include "rzv2h_gpio.h" +#include "hardware/rzv2h_pinmap.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#ifdef CONFIG_RZV2H_GPIO + +struct rzv2hgpio_dev_s +{ + struct gpio_dev_s gpio; + uint8_t id; +}; + +struct rzv2hgpint_dev_s +{ + struct rzv2hgpio_dev_s rzv2hgpio; + pin_interrupt_t callback; +}; + +/**************************************************************************** + * Private Functions Prototypes + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value); +static int gpin_attach(struct gpio_dev_s *dev, pin_interrupt_t callback); +static int gpin_enable(struct gpio_dev_s *dev, bool enable); + +#endif +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); + +#endif +static int gpio_setpintype(struct gpio_dev_s *dev, + enum gpio_pintype_e gpio_pintype); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static const struct gpio_operations_s gpin_ops = +{ + .go_read = gpin_read, .go_write = NULL, + .go_attach = gpin_attach, + .go_enable = gpin_enable, .go_setpintype = gpio_setpintype, +}; +#endif + +#if BOARD_NGPIOOUT > 0 +static const struct gpio_operations_s gpout_ops = +{ + .go_read = gpout_read, .go_write = gpout_write, + .go_attach = NULL, + .go_enable = NULL, .go_setpintype = gpio_setpintype, +}; +#endif + +#if BOARD_NGPIOIN > 0 + +/* This array maps the GPIO pins used as INPUT */ + +static const gpio_pinset_t g_gpioinputs[BOARD_NGPIOIN] = +{ + BOARD_P10_0_BUTTON +}; + +static struct rzv2hgpio_dev_s g_gpin[BOARD_NGPIOIN]; +#endif + +#if BOARD_NGPIOOUT > 0 + +/* This array maps the GPIO pins used as OUTPUT */ + +static const gpio_pinset_t g_gpiooutputs[BOARD_NGPIOOUT] = +{ + BOARD_P11_4_GPIO, BOARD_P11_5_GPIO +}; + +static struct rzv2hgpio_dev_s g_gpout[BOARD_NGPIOOUT]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 + +/**************************************************************************** + * Name: gpin_read + * + * Description: + * Read the current logic state of an input GPIO pin and store the result + * in the caller-provided boolean output value. + ****************************************************************************/ + +static int gpin_read(struct gpio_dev_s *dev, bool *value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL && value != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOIN); + gpioinfo("Reading..."); + + *value = rzv2h_gpioread(g_gpioinputs[rzv2hgpio->id]); + + return OK; +} + +/**************************************************************************** + * Name: gpin_attach + * + * Description: + * Register an interrupt callback for a GPIO input pin. The callback is + * stored for later use when the interrupt is enabled. + * Refer to drivers/ioexpander/gpio.c for the reference implementation. + ****************************************************************************/ + +static int gpin_attach(struct gpio_dev_s *dev, pin_interrupt_t callback) +{ + struct rzv2hgpint_dev_s *rzv2hgpint = (struct rzv2hgpint_dev_s *)dev; + + gpioinfo("Attaching the callback\n"); + + /* Make sure the interrupt is disabled */ + + /* Assign Callback function */ + + gpioinfo("Attach %p\n", callback); + rzv2hgpint->callback = callback; + return OK; +} + +/**************************************************************************** + * Name: gpin_enable + * + * Description: + * Enable or disable the interrupt handling for an input GPIO pin. + * The current implementation only tracks the requested state. + ****************************************************************************/ + +static int gpin_enable(struct gpio_dev_s *dev, bool enable) +{ + struct rzv2hgpint_dev_s *rzv2hgpint = (struct rzv2hgpint_dev_s *)dev; + + if (enable && rzv2hgpint->callback != NULL) + { + gpioinfo("Enabling the interrupt\n"); + } + else + { + gpioinfo("Disable the interrupt\n"); + } + + return OK; +} + +#endif + +#if BOARD_NGPIOOUT > 0 + +/**************************************************************************** + * Name: gpout_read + * + * Description: + * Read the current logic state of an output GPIO pin and return it through + * the caller-provided boolean output value. + ****************************************************************************/ + +static int gpout_read(struct gpio_dev_s *dev, bool *value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL && value != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOOUT); + gpioinfo("Reading..."); + + *value = rzv2h_gpioread(g_gpiooutputs[rzv2hgpio->id]); + + return OK; +} + +/**************************************************************************** + * Name: gpout_write + * + * Description: + * Drive an output GPIO pin to the requested logic state. + ****************************************************************************/ + +static int gpout_write(struct gpio_dev_s *dev, bool value) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + DEBUGASSERT(rzv2hgpio != NULL); + DEBUGASSERT(rzv2hgpio->id < BOARD_NGPIOOUT); + gpioinfo("Writing %d", (int)value); + + return rzv2h_gpiowrite(g_gpiooutputs[rzv2hgpio->id], value); +} + +#endif + +/**************************************************************************** + * Name: gpio_setpintype + * + * Description: + * Set the pin type for a GPIO device. This implementation is currently + * unsupported and returns success without changing hardware state. + ****************************************************************************/ + +static int gpio_setpintype(struct gpio_dev_s *dev, + enum gpio_pintype_e gpio_pintype) +{ + struct rzv2hgpio_dev_s *rzv2hgpio = (struct rzv2hgpio_dev_s *)dev; + + UNUSED(rzv2hgpio); + UNUSED(gpio_pintype); + + gpioinfo("setpintype is not supported. \n"); + + return 0; +} + +/**************************************************************************** + * Name: rzv2h_gpio_initialize + * + * Description: + * Initialize GPIO drivers for use with /apps/examples/gpio + ****************************************************************************/ + +int rzv2h_gpio_initialize(void) +{ + int pincount = 0; + int i; + int ret = 0; + +#if BOARD_NGPIOIN > 0 + for (i = 0; i < BOARD_NGPIOIN; i++, pincount++) + { + /* Setup and register the GPIO pin */ + + g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; + g_gpin[i].gpio.gp_ops = &gpin_ops; + g_gpin[i].id = i; + ret = + gpio_pin_register(&g_gpin[i].gpio, pincount); + if (ret < 0) + { + gpioerr("GPIOIN(%d): gpio_pin_register failed: %d", i, ret); + return ret; + } + + /* Configure the pin that will be used as input */ + + ret = rzv2h_configgpio(g_gpioinputs[i]); + if (ret < 0) + { + gpioerr("GPIOIN(%d): rzv2h_configgpio failed: %d", i, ret); + return ret; + } + } +#endif + +#if BOARD_NGPIOOUT > 0 + for (i = 0; i < BOARD_NGPIOOUT; i++, pincount++) + { + /* Setup and register the GPIO pin */ + + g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gpout[i].gpio.gp_ops = &gpout_ops; + g_gpout[i].id = i; + ret = gpio_pin_register(&g_gpout[i].gpio, + pincount); + if (ret < 0) + { + gpioerr("GPIOOUT(%d): gpio_pin_register failed: %d", i, ret); + return ret; + } + + /* Configure the pin that will be used as output */ + + ret = rzv2h_configgpio(g_gpiooutputs[i]); + if (ret < 0) + { + gpioerr("GPIOOUT(%d): rzv2h_configgpio failed: %d", i, ret); + return ret; + } + } +#endif + + return ret; +} + +#endif /* CONFIG_RZV2H_GPIO */ diff --git a/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_userleds.c b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_userleds.c new file mode 100644 index 00000000000..5d22359d602 --- /dev/null +++ b/boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_userleds.c @@ -0,0 +1,103 @@ +/**************************************************************************** + * boards/arm/rzv2h/rzv2h-rdk/src/rzv2h_userleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <nuttx/debug.h> + +#include "chip.h" +#include "rzv2h_gpio.h" +#include "rzv2h-rdk.h" + +#include <arch/board/board.h> + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Configure LED GPIOs for output */ + + rzv2h_configgpio(BOARD_P11_4_GPIO); + rzv2h_configgpio(BOARD_P11_5_GPIO); + + /* The LEDs are active low. Leave both LEDs off after initialization. */ + + rzv2h_gpiowrite(BOARD_P11_4_GPIO, true); + rzv2h_gpiowrite(BOARD_P11_5_GPIO, true); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + gpio_pinset_t ledcfg; + + if (led == BOARD_LED_0) + { + ledcfg = BOARD_P11_4_GPIO; + } + else if (led == BOARD_LED_1) + { + ledcfg = BOARD_P11_5_GPIO; + } + else + { + return; + } + + /* Low illuminates. */ + + rzv2h_gpiowrite(ledcfg, !ledon); +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + /* Low illuminates. */ + + rzv2h_gpiowrite(BOARD_P11_4_GPIO, + (ledset & BOARD_LED_0_BIT) == 0); + rzv2h_gpiowrite(BOARD_P11_5_GPIO, + (ledset & BOARD_LED_1_BIT) == 0); +} + +#endif /* !CONFIG_ARCH_LEDS */
