This is an automated email from the ASF dual-hosted git repository. simbit18 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ff5ebcac85b275e4ca0972560b8c222d7599e584 Author: Alan Carvalho de Assis <[email protected]> AuthorDate: Tue Sep 1 17:14:06 2026 -0300 boards/gd32vm55x: Add support to GD32VW553-HMQ This commit add support to GD32VW553-HMQ board based on GigaDevice GD32VM553K_START as base. No AI used for this board, the but GD32VM553K_START was developed by Jorge Guzman with help from Claude Code. Signed-off-by: Alan C. Assis <[email protected]> --- boards/Kconfig | 14 + boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig | 24 ++ .../gd32vw55x/gd32vw553-hmq/configs/ble/defconfig | 83 ++++++ .../gd32vw55x/gd32vw553-hmq/configs/nsh/defconfig | 51 ++++ .../gd32vw553-hmq/configs/ostest/defconfig | 52 ++++ .../gd32vw553-hmq/configs/sta_softap/defconfig | 85 ++++++ .../gd32vw55x/gd32vw553-hmq/configs/wapi/defconfig | 81 ++++++ .../include/board.h | 58 ++-- .../gd32vw55x/gd32vw553-hmq/scripts/Make.defs | 52 ++++ .../gd32vw55x/gd32vw553-hmq/scripts/ld.script | 122 ++++++++ boards/risc-v/gd32vw55x/gd32vw553-hmq/src/Makefile | 41 +++ .../gd32vw55x/gd32vw553-hmq/src/gd32_appinit.c | 58 ++++ .../gd32vw55x/gd32vw553-hmq/src/gd32_autoleds.c | 139 +++++++++ .../risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_boot.c | 73 +++++ .../gd32vw55x/gd32vw553-hmq/src/gd32_bringup.c | 323 +++++++++++++++++++++ .../gd32vw55x/gd32vw553-hmq/src/gd32_reset.c | 79 +++++ .../gd32vw55x/gd32vw553-hmq/src/gd32_userleds.c | 101 +++++++ .../gd32vw55x/gd32vw553-hmq/src/gd32vw553-hmq.h | 52 ++++ .../gd32vw55x/gd32vw553k-start/include/board.h | 10 +- 19 files changed, 1459 insertions(+), 39 deletions(-) diff --git a/boards/Kconfig b/boards/Kconfig index 4b633217d0f..07dd1583209 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -126,6 +126,16 @@ config ARCH_BOARD_GD32VW553K_START GigaDevice GD32VW553K-START devkit (GD32VW553KMQ7, QFN32, 4 MB flash, on-board GD-Link with VCP wired to UART2). +config ARCH_BOARD_GD32VW553_HMQ + bool "GD32VW553-HMQ Board" + depends on ARCH_CHIP_GD32VW55X + select ARCH_HAVE_LEDS + select ARCH_HAVE_RESET + ---help--- + This is the board configuration for the port of NuttX to the + GD32VW553K-HMQ devkit (GD32VW553HMQ6, QFN40, + 4 MB flash, on-board USB/Serial to UART0). + config ARCH_BOARD_C5471EVM bool "Spectrum Digital C5471 evaluation board" depends on ARCH_CHIP_C5471 @@ -3943,6 +3953,7 @@ config ARCH_BOARD default "gd32f470zk-aiotbox" if ARCH_BOARD_GD32F470ZK_AIOTBOX default "gd32f470ik-eval" if ARCH_BOARD_GD32F470IK_EVAL default "gd32vw553k-start" if ARCH_BOARD_GD32VW553K_START + default "gd32vw553-hmq" if ARCH_BOARD_GD32VW553_HMQ default "hifive1-revb" if ARCH_BOARD_HIFIVE1_REVB default "hymini-stm32v" if ARCH_BOARD_HYMINI_STM32V default "imxrt1020-evk" if ARCH_BOARD_IMXRT1020_EVK @@ -5424,6 +5435,9 @@ endif if ARCH_BOARD_GD32VW553K_START source "boards/risc-v/gd32vw55x/gd32vw553k-start/Kconfig" endif +if ARCH_BOARD_GD32VW553_HMQ +source "boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig" +endif if ARCH_BOARD_PHY6222 source "boards/arm/phy62xx/phy6222/Kconfig" endif diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig new file mode 100644 index 00000000000..fb88d13ddbd --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig @@ -0,0 +1,24 @@ +# ############################################################################## +# boards/risc-v/gd32vw55x/gd32vw553-hmq/Kconfig +# +# 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. +# +# ############################################################################## + +if ARCH_BOARD_GD32VW553_HMQ +endif diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ble/defconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ble/defconfig new file mode 100644 index 00000000000..ed16ef6229f --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ble/defconfig @@ -0,0 +1,83 @@ +# +# 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="risc-v" +CONFIG_ARCH_BOARD="gd32vw553-hmq" +CONFIG_ARCH_BOARD_GD32VW553_HMQ=y +CONFIG_ARCH_CHIP="gd32vw55x" +CONFIG_ARCH_CHIP_GD32VW553HM=y +CONFIG_ARCH_CHIP_GD32VW55X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_INITTHREAD_STACKSIZE=2048 +CONFIG_BOARD_LOOPSPERMSEC=16000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DEV_URANDOM=y +CONFIG_DHCPC_RENEW_STACKSIZE=2048 +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_GD32VW55X_BLE=y +CONFIG_GD32VW55X_BLE_GATT_DEMO=y +CONFIG_GD32VW55X_UART2=y +CONFIG_GD32VW55X_WIFI=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_NBUFFERS=64 +CONFIG_IOB_THROTTLE=8 +CONFIG_IRQ_WORK_STACKSIZE=2048 +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_MM_REGIONS=2 +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETINIT_NETLOCAL=y +CONFIG_NETUTILS_DHCPC_BOOTP_FLAGS=0x8000 +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_RAM_SIZE=294400 +CONFIG_RAM_START=0x20000200 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_RTC=y +CONFIG_RTC_DATETIME=y +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=13 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DD_STACKSIZE=2048 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=2048 +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_PING_STACKSIZE=2048 +CONFIG_TASK_NAME_SIZE=15 +CONFIG_UART2_SERIAL_CONSOLE=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y +CONFIG_WIRELESS_WAPI_STACKSIZE=2048 diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/nsh/defconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/nsh/defconfig new file mode 100644 index 00000000000..0545db2e855 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/nsh/defconfig @@ -0,0 +1,51 @@ +# +# 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="risc-v" +CONFIG_ARCH_BOARD="gd32vw553-hmq" +CONFIG_ARCH_BOARD_GD32VW553_HMQ=y +CONFIG_ARCH_CHIP="gd32vw55x" +CONFIG_ARCH_CHIP_GD32VW553HM=y +CONFIG_ARCH_CHIP_GD32VW55X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=16000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_GD32VW55X_UART2=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_RAM_SIZE=294400 +CONFIG_RAM_START=0x20000200 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=13 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=12 +CONFIG_UART2_RXBUFSIZE=128 +CONFIG_UART2_SERIAL_CONSOLE=y +CONFIG_UART2_TXBUFSIZE=128 diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ostest/defconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ostest/defconfig new file mode 100644 index 00000000000..82ad70b75f5 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/ostest/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="risc-v" +CONFIG_ARCH_BOARD="gd32vw553-hmq" +CONFIG_ARCH_BOARD_GD32VW553_HMQ=y +CONFIG_ARCH_CHIP="gd32vw55x" +CONFIG_ARCH_CHIP_GD32VW553HM=y +CONFIG_ARCH_CHIP_GD32VW55X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=16000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_GD32VW55X_UART2=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_RAM_SIZE=294400 +CONFIG_RAM_START=0x20000200 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=13 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=12 +CONFIG_TESTING_OSTEST=y +CONFIG_UART2_RXBUFSIZE=128 +CONFIG_UART2_SERIAL_CONSOLE=y +CONFIG_UART2_TXBUFSIZE=128 diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/sta_softap/defconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/sta_softap/defconfig new file mode 100644 index 00000000000..1241fc50f16 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/sta_softap/defconfig @@ -0,0 +1,85 @@ +# +# 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="risc-v" +CONFIG_ARCH_BOARD="gd32vw553-hmq" +CONFIG_ARCH_BOARD_GD32VW553_HMQ=y +CONFIG_ARCH_CHIP="gd32vw55x" +CONFIG_ARCH_CHIP_GD32VW553HM=y +CONFIG_ARCH_CHIP_GD32VW55X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_INITTHREAD_STACKSIZE=2048 +CONFIG_BOARD_LOOPSPERMSEC=16000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DEV_URANDOM=y +CONFIG_DHCPC_RENEW_STACKSIZE=2048 +CONFIG_EXAMPLES_DHCPD=y +CONFIG_FS_PROCFS=y +CONFIG_GD32VW55X_UART2=y +CONFIG_GD32VW55X_WIFI=y +CONFIG_GD32VW55X_WIFI_MGMT_STACKSIZE=8192 +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_NBUFFERS=64 +CONFIG_IOB_THROTTLE=8 +CONFIG_IRQ_WORK_STACKSIZE=2048 +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_MM_REGIONS=2 +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETINIT_NETLOCAL=y +CONFIG_NETUTILS_DHCPC_BOOTP_FLAGS=0x8000 +CONFIG_NETUTILS_DHCPD=y +CONFIG_NETUTILS_DHCPD_STACKSIZE=2048 +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_RAM_SIZE=294400 +CONFIG_RAM_START=0x20000200 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_RTC=y +CONFIG_RTC_DATETIME=y +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=13 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DD_STACKSIZE=2048 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=2048 +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_PING_STACKSIZE=2048 +CONFIG_TASK_NAME_SIZE=15 +CONFIG_UART2_SERIAL_CONSOLE=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y +CONFIG_WIRELESS_WAPI_STACKSIZE=2048 diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/wapi/defconfig b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/wapi/defconfig new file mode 100644 index 00000000000..207d1741483 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/configs/wapi/defconfig @@ -0,0 +1,81 @@ +# +# 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="risc-v" +CONFIG_ARCH_BOARD="gd32vw553-hmq" +CONFIG_ARCH_BOARD_GD32VW553_HMQ=y +CONFIG_ARCH_CHIP="gd32vw55x" +CONFIG_ARCH_CHIP_GD32VW553HM=y +CONFIG_ARCH_CHIP_GD32VW55X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RISCV=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_INITTHREAD_STACKSIZE=2048 +CONFIG_BOARD_LOOPSPERMSEC=16000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DEV_URANDOM=y +CONFIG_DHCPC_RENEW_STACKSIZE=2048 +CONFIG_FS_PROCFS=y +CONFIG_GD32VW55X_UART2=y +CONFIG_GD32VW55X_WIFI=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_NBUFFERS=64 +CONFIG_IOB_THROTTLE=8 +CONFIG_IRQ_WORK_STACKSIZE=2048 +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_MM_REGIONS=2 +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETINIT_NETLOCAL=y +CONFIG_NETUTILS_DHCPC_BOOTP_FLAGS=0x8000 +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=64 +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_RAM_SIZE=294400 +CONFIG_RAM_START=0x20000200 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_RTC=y +CONFIG_RTC_DATETIME=y +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=13 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DD_STACKSIZE=2048 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=2048 +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_PING_STACKSIZE=2048 +CONFIG_TASK_NAME_SIZE=15 +CONFIG_UART2_SERIAL_CONSOLE=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y +CONFIG_WIRELESS_WAPI_STACKSIZE=2048 diff --git a/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h b/boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h similarity index 75% copy from boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h copy to boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h index 1e7b41f9bf8..e5d14dda989 100644 --- a/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h + * boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_RISCV_GD32VW55X_GD32VW553K_START_INCLUDE_BOARD_H -#define __BOARDS_RISCV_GD32VW55X_GD32VW553K_START_INCLUDE_BOARD_H +#ifndef __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_INCLUDE_BOARD_H +#define __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_INCLUDE_BOARD_H /**************************************************************************** * Pre-processor Definitions @@ -35,8 +35,8 @@ #define BOARD_IRC32K_FREQUENCY 32000 /* Internal 32 kHz RC (FWDGT, RTC) */ #define BOARD_SYSCLK_FREQUENCY 160000000 -/* UART pin muxing. The GD32VW553K-START wires UART2 (PA6/PA7) to the - * on-board GD-Link virtual COM port. Pin/AF assignments follow the +/* UART pin muxing. The GD32VW553-HMQ wires UART0 (PA8/PB15) to the + * on-board UBS/Serial port. Pin/AF assignments follow the * vendor SDK (plf/src/uart/uart.h, ASIC boards). */ @@ -54,12 +54,14 @@ #define BOARD_UART1_RX_PIN 8 #define BOARD_UART1_RX_AF 3 -#define BOARD_USART0_TX_GPIO GD32VW55X_GPIOA_BASE -#define BOARD_USART0_TX_PIN 0 -#define BOARD_USART0_TX_AF 0 +/* This is the console: PA8 as RX and PB15 ad TX */ + +#define BOARD_USART0_TX_GPIO GD32VW55X_GPIOB_BASE +#define BOARD_USART0_TX_PIN 15 +#define BOARD_USART0_TX_AF 8 #define BOARD_USART0_RX_GPIO GD32VW55X_GPIOA_BASE -#define BOARD_USART0_RX_PIN 1 -#define BOARD_USART0_RX_AF 0 +#define BOARD_USART0_RX_PIN 8 +#define BOARD_USART0_RX_AF 2 /* Peripheral pin selection *************************************************/ @@ -129,38 +131,26 @@ /* LEDs *********************************************************************/ -/* The GD32VW553K-START has three LEDs on GPIOC, driven push-pull and +/* The GD32VW553-HMQ has one LED on GPIO PC13, driven push-pull and * active HIGH (the vendor demo turns them on with gpio_bit_set(); see * MSDK/plf/src/gd32vw55x_platform.h, where they are named LED_RUN, * LED_SLEEP and LED_RX). * - * LED1 PC0 - * LED2 PC1 - * LED3 PC2 + * LED1 PC13 */ #define GPIO_LED1 (GPIO_CFG_MODE_OUTPUT | GPIO_CFG_PUPD_NONE | GPIO_CFG_PP | \ GPIO_CFG_SPEED_MAX | GPIO_CFG_OUTPUT_RESET | \ GPIO_CFG_PORT_C | GPIO_CFG_PIN_0) -#define GPIO_LED2 (GPIO_CFG_MODE_OUTPUT | GPIO_CFG_PUPD_NONE | GPIO_CFG_PP | \ - GPIO_CFG_SPEED_MAX | GPIO_CFG_OUTPUT_RESET | \ - GPIO_CFG_PORT_C | GPIO_CFG_PIN_1) -#define GPIO_LED3 (GPIO_CFG_MODE_OUTPUT | GPIO_CFG_PUPD_NONE | GPIO_CFG_PP | \ - GPIO_CFG_SPEED_MAX | GPIO_CFG_OUTPUT_RESET | \ - GPIO_CFG_PORT_C | GPIO_CFG_PIN_2) /* LED index values for use with board_userled() */ #define BOARD_LED1 0 -#define BOARD_LED2 1 -#define BOARD_LED3 2 -#define BOARD_NLEDS 3 +#define BOARD_NLEDS 1 /* LED bits for use with board_userled_all() */ #define BOARD_LED1_BIT (1 << BOARD_LED1) -#define BOARD_LED2_BIT (1 << BOARD_LED2) -#define BOARD_LED3_BIT (1 << BOARD_LED3) /* If CONFIG_ARCH_LEDS is defined, the LEDs are used by the OS to signal * its state, and are not available to the application. Otherwise they are @@ -170,13 +160,13 @@ * ------------------ ------------------------ ---- ---- ---- */ -#define LED_STARTED 0 /* NuttX has been started ON OFF OFF */ -#define LED_HEAPALLOCATE 1 /* Heap has been allocated ON OFF OFF */ -#define LED_IRQSENABLED 2 /* Interrupts enabled ON OFF OFF */ -#define LED_STACKCREATED 3 /* Idle stack created ON ON OFF */ -#define LED_INIRQ 4 /* In an interrupt N/C N/C N/C */ -#define LED_SIGNAL 5 /* In a signal handler N/C N/C N/C */ -#define LED_ASSERTION 6 /* An assertion failed N/C N/C ON */ -#define LED_PANIC 7 /* The system has crashed N/C N/C BLINK */ +#define LED_STARTED 0 /* NuttX has been started ON */ +#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF */ +#define LED_IRQSENABLED 2 /* Interrupts enabled OFF */ +#define LED_STACKCREATED 3 /* Idle stack created OFF */ +#define LED_INIRQ 4 /* In an interrupt OFF */ +#define LED_SIGNAL 5 /* In a signal handler OFF */ +#define LED_ASSERTION 6 /* An assertion failed OFF */ +#define LED_PANIC 7 /* The system has crashed BLINK */ -#endif /* __BOARDS_RISCV_GD32VW55X_GD32VW553K_START_INCLUDE_BOARD_H */ +#endif /* __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_INCLUDE_BOARD_H */ diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/Make.defs b/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/Make.defs new file mode 100644 index 00000000000..b2eb4b42d86 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/Make.defs @@ -0,0 +1,52 @@ +############################################################################ +# boards/risc-v/gd32vw55x/gd32vw553-hmq/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/risc-v/src/common/Toolchain.defs + +ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +ARCH_INCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)include + +LDSCRIPT = ld.script +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +# The Wi-Fi/BLE prebuilt libraries are built with -march=rv32imafcbp and +# -mabi=ilp32f. NuttX code is compiled rv32imafc/ilp32f (B/P extensions +# are not used by the kernel) which links cleanly against them. + +ARCHCPUFLAGS += -mno-relax + +ifeq ($(CONFIG_STACK_OVERFLOW_CHECK),y) + ARCHCFLAGS += -finstrument-functions -ffixed-s11 +endif + +ARCHDEFINES += -DARCH_RISCV + +CFLAGS = $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS += $(CFLAGS) -D__ASSEMBLY__ + +LDELFFLAGS += -melf32lriscv diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/ld.script b/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/ld.script new file mode 100644 index 00000000000..0147fe6a63b --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/ld.script @@ -0,0 +1,122 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/scripts/ld.script + * + * 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. + * + ****************************************************************************/ + +/* NuttX is flashed directly at the start of the SIP flash (MBL bypassed). + * + * FLASH: the part has 4096K, but this board does not give all of it to the + * firmware. Two regions sit at the top and must survive a firmware update, + * so the linker only gets what is left below them: + * + * 0x083db000 progmem (128K): the MTD device / LittleFS. This split is a + * DECISION OF THIS BOARD, not a property of the chip -- another + * board may size it differently, or not carve it out at all. + * It must match CONFIG_GD32VW55X_PROGMEM_START_ADDR/_SIZE. + * 0x083fb000 Wi-Fi NVDS (20K): RF calibration data and the MAC address. + * This one IS fixed by the chip's radio firmware. + * + * That leaves 3948K (0x3db000) for the firmware. Overflowing it is a link + * error, which is the point: a firmware that grew over these regions would + * take the filesystem, or the radio calibration, with it at the next flash. + * + * SRAM: the first 0x200 bytes belong to the boot ROM runtime data (the + * ROM mbedtls/IBL state) and must stay untouched - the vendor SDK links + * applications at 0x20000200 for the same reason. The top 32 KB shared + * SRAM is reserved for the Wi-Fi firmware RX buffers, so the region has to + * end at 0x20048000: the origin goes up by 0x200 and the length goes down + * by the same 0x200. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08000000, LENGTH = 3948K + sram (rwx) : ORIGIN = 0x20000200, LENGTH = 288K - 0x200 +} + +OUTPUT_ARCH("riscv") + +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.srodata .srodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .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(.); + } > flash + + _eronly = ABSOLUTE(.); + + .data : ALIGN(4) { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.sdata .sdata.* .sdata2.*) + *(.gnu.linkonce.d.*) + *(.gnu.linkonce.s.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + PROVIDE(__global_pointer$ = _sdata + ((_edata - _sdata) / 2)); + + .bss : ALIGN(4) { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.sbss .sbss.*) + *(.gnu.linkonce.b.*) + *(.gnu.linkonce.sb.*) + *(COMMON) + . = ALIGN(32); + _ebss = ABSOLUTE(.); + } > sram + + /* 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/risc-v/gd32vw55x/gd32vw553-hmq/src/Makefile b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/Makefile new file mode 100644 index 00000000000..67584a8190f --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/Makefile @@ -0,0 +1,41 @@ +############################################################################ +# boards/risc-v/gd32vw55x/gd32vw553-hmq/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 + +CSRCS = gd32_boot.c gd32_bringup.c + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += gd32_autoleds.c +else ifeq ($(CONFIG_USERLED),y) +CSRCS += gd32_userleds.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += gd32_appinit.c +endif + +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += gd32_reset.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_appinit.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_appinit.c new file mode 100644 index 00000000000..e5b280b37ea --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_appinit.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_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 "gd32vw553-hmq.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. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + return gd32_bringup(); +#endif +} diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_autoleds.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_autoleds.c new file mode 100644 index 00000000000..8de8f33bf84 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_autoleds.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_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 <nuttx/board.h> +#include <arch/board/board.h> + +#include "gd32vw55x_gpio.h" +#include "gd32vw553-hmq.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* The three LEDs are on GPIOC and are active HIGH. When CONFIG_ARCH_LEDS is + * selected they show the OS state and are not available to the application; + * the meaning of each state is tabulated in board.h. + */ + +static const uint32_t g_led_map[BOARD_NLEDS] = +{ + GPIO_LED1, + GPIO_LED2, + GPIO_LED3 +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static void led_set(int led, bool ledon) +{ + gd32_gpio_write(g_led_map[led], ledon); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + int i; + + for (i = 0; i < BOARD_NLEDS; i++) + { + gd32_gpio_config(g_led_map[i]); + } +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + switch (led) + { + case LED_STARTED: + case LED_HEAPALLOCATE: + case LED_IRQSENABLED: + led_set(BOARD_LED1, true); + break; + + case LED_STACKCREATED: + led_set(BOARD_LED1, true); + led_set(BOARD_LED2, true); + break; + + case LED_ASSERTION: + case LED_PANIC: + led_set(BOARD_LED3, true); + break; + + case LED_INIRQ: + case LED_SIGNAL: + default: + + /* These states leave the LEDs alone: toggling them on every + * interrupt would make the display useless. + */ + + break; + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + switch (led) + { + case LED_ASSERTION: + case LED_PANIC: + led_set(BOARD_LED3, false); + break; + + case LED_INIRQ: + case LED_SIGNAL: + default: + break; + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_boot.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_boot.c new file mode 100644 index 00000000000..c731bcced65 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_boot.c @@ -0,0 +1,73 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_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 <nuttx/board.h> +#include <arch/board/board.h> + +#include "gd32vw55x.h" +#include "gd32vw553-hmq.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gd32vw55x_boardinitialize + * + * Description: + * All GD32VW55x architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have + * been initialized. + * + ****************************************************************************/ + +void gd32vw55x_boardinitialize(void) +{ +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() + * will be called after up_initialize() is called and just before the + * initial application is started. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + gd32_bringup(); +} +#endif diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_bringup.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_bringup.c new file mode 100644 index 00000000000..f2235dfd331 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_bringup.c @@ -0,0 +1,323 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_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 <debug.h> + +#include <nuttx/fs/fs.h> + +#ifdef CONFIG_I2C_DRIVER +# include <nuttx/i2c/i2c_master.h> +#endif +#ifdef CONFIG_SPI_DRIVER +# include <nuttx/spi/spi_transfer.h> +#endif +#ifdef CONFIG_MMCSD_SPI +# include <nuttx/mmcsd.h> +#endif +#ifdef CONFIG_GD32VW55X_ADC +# include <nuttx/analog/adc.h> +#endif +#ifdef CONFIG_GD32VW55X_PWM +# include <nuttx/timers/pwm.h> +#endif +#ifdef CONFIG_GD32VW55X_CAPTURE +# include <nuttx/timers/capture.h> +#endif +#ifdef CONFIG_USERLED_LOWER +# include <nuttx/leds/userled.h> +#endif +#ifdef CONFIG_SENSORS_SHT3X +# include <nuttx/sensors/sht3x.h> +#endif +#ifdef CONFIG_MTD_PROGMEM +# include <nuttx/mtd/mtd.h> +#endif + +#include "gd32vw55x_i2c.h" +#include "gd32vw55x_spi.h" +#include "gd32vw55x_adc.h" +#include "gd32vw55x_pwm.h" +#include "gd32vw55x_capture.h" +#include "gd32vw55x_fwdgt.h" +#include "gd32vw55x_wwdgt.h" + +#include <arch/board/board.h> + +#include "gd32vw553-hmq.h" + +#ifdef CONFIG_GD32VW55X_WIFI +/* Brings the radio up at boot and registers wlan0 -- same pattern as the + * board_wlan_init() of the Espressif boards. It must happen before the NSH + * netinit, which looks for the interface. + */ + +int gdwifi_start(void); +#endif + +#ifdef CONFIG_GD32VW55X_BLE +int gd32_ble_initialize(void); +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gd32_bringup + ****************************************************************************/ + +int gd32_bringup(void) +{ +#ifdef CONFIG_GD32VW55X_I2C0 + struct i2c_master_s *i2c; +#endif +#ifdef CONFIG_GD32VW55X_SPI + struct spi_dev_s *spi; +#endif +#ifdef CONFIG_GD32VW55X_ADC + static const uint8_t chanlist[1] = + { +#ifdef GPIO_ADC_IN8 + 8 /* ADC_IN8 (PB0) on J1, routed by the adc example */ +#else + 0 /* ADC_IN0 (PA0); no analog pin routed, registers the device only */ +#endif + }; + + struct adc_dev_s *adc; +#endif +#ifdef CONFIG_GD32VW55X_PWM + struct pwm_lowerhalf_s *pwm; +#endif +#ifdef CONFIG_GD32VW55X_CAPTURE + struct cap_lowerhalf_s *cap; +#endif +#ifdef CONFIG_MTD_PROGMEM + struct mtd_dev_s *mtd; +#endif + int ret = OK; + +#ifdef CONFIG_GD32VW55X_WIFI + /* Initialize the platform + the SDK Wi-Fi stack. The SDK calls + * net_if_add() when it creates the VIF, and that is where wlan0 is + * registered. + */ + + if (gdwifi_start() != 0) + { + ferr("ERROR: failed to start Wi-Fi\n"); + } +#endif + +#ifdef CONFIG_GD32VW55X_BLE + /* After Wi-Fi: the platform (clocks, RF, NVDS) is brought up there, and + * the BLE controller reuses it. + */ + + if (gd32_ble_initialize() < 0) + { + ferr("ERROR: failed to start BLE\n"); + } +#endif + +#ifdef CONFIG_GD32VW55X_I2C0 + i2c = gd32_i2cbus_initialize(0); + if (i2c == NULL) + { + ferr("ERROR: failed to initialize I2C0\n"); + } + else + { +#ifdef CONFIG_I2C_DRIVER + /* Expose the bus as /dev/i2c0 for the i2ctool (i2c dev/get/set...) */ + + if (i2c_register(i2c, 0) < 0) + { + ferr("ERROR: failed to register /dev/i2c0\n"); + } +#endif + +#ifdef CONFIG_SENSORS_SHT3X + /* Sensirion SHT3x on I2C0 -> /dev/temp0. The default I2C address is + * 0x44 (0x45 with ADDR tied high); confirm it first with + * "i2c dev 0x44 0x45" from NSH. + */ + + if (sht3x_register("/dev/temp0", i2c, 0x44) < 0) + { + ferr("ERROR: failed to register SHT3x at 0x44 on I2C0\n"); + } +#endif + } +#endif + +#ifdef CONFIG_GD32VW55X_SPI + /* The family has a single SPI instance: bus 0. Configure the chip select + * GPIOs first, then bring the bus up. + */ + + gd32_spidev_initialize(); + + spi = gd32_spibus_initialize(0); + if (spi == NULL) + { + ferr("ERROR: failed to initialize SPI0\n"); + } + else + { +#ifdef CONFIG_SPI_DRIVER + if (spi_register(spi, 0) < 0) + { + ferr("ERROR: failed to register /dev/spi0\n"); + } +#endif + +#ifdef CONFIG_MMCSD_SPI + /* Bind SPI0 to the MMC/SD SPI slot (/dev/mmcsd0) and mount it as FAT. + * The SD card is wired to SPI0 (SCK PA2, MISO PA1, MOSI PA0) with the + * chip select on PA4 -- all on the J1 header. + */ + + ret = mmcsd_spislotinitialize(0, 0, spi); + if (ret < 0) + { + ferr("ERROR: failed to bind SPI0 to the MMC/SD slot: %d\n", ret); + } + else + { + ret = nx_mount("/dev/mmcsd0", "/mnt/sd", "vfat", 0, NULL); + if (ret < 0) + { + ferr("ERROR: failed to mount /mnt/sd: %d\n", ret); + } + } +#endif + } +#endif + +#ifdef CONFIG_GD32VW55X_ADC + adc = gd32_adc_initialize(0, chanlist, 1); + if (adc == NULL) + { + ferr("ERROR: failed to initialize the ADC\n"); + } + else if (adc_register("/dev/adc0", adc) < 0) + { + ferr("ERROR: failed to register /dev/adc0\n"); + } +#endif + +#ifdef CONFIG_GD32VW55X_PWM + pwm = gd32_pwminitialize(1); + if (pwm == NULL) + { + ferr("ERROR: failed to initialize PWM on TIMER1\n"); + } + else if (pwm_register("/dev/pwm0", pwm) < 0) + { + ferr("ERROR: failed to register /dev/pwm0\n"); + } +#endif + +#ifdef CONFIG_GD32VW55X_CAPTURE + cap = gd32_cap_initialize(2); + if (cap == NULL) + { + ferr("ERROR: failed to initialize capture on TIMER2\n"); + } + else if (cap_register("/dev/capture0", cap) < 0) + { + ferr("ERROR: failed to register /dev/capture0\n"); + } +#endif + +#ifdef CONFIG_MTD_PROGMEM + /* The progmem region of the internal flash as an MTD device. It sits + * below the Wi-Fi NVDS -- see CONFIG_GD32VW55X_PROGMEM_START_ADDR. + */ + + mtd = progmem_initialize(); + if (mtd == NULL) + { + ferr("ERROR: progmem_initialize failed\n"); + } + else + { + ret = register_mtddriver("/dev/gd32flash", mtd, 0750, NULL); + if (ret < 0) + { + ferr("ERROR: failed to register /dev/gd32flash: %d\n", ret); + } + +#ifdef CONFIG_FS_LITTLEFS + /* Mount it as LittleFS, formatting it on the first boot */ + + else + { + ret = nx_mount("/dev/gd32flash", "/data", "littlefs", 0, + "autoformat"); + if (ret < 0) + { + ferr("ERROR: failed to mount /data: %d\n", ret); + } + } +#endif + } +#endif + +#ifdef CONFIG_USERLED_LOWER + /* The three board LEDs -> /dev/userleds */ + + ret = userled_lower_initialize("/dev/userleds"); + if (ret < 0) + { + ferr("ERROR: failed to register /dev/userleds: %d\n", ret); + } +#endif + +#ifdef CONFIG_GD32VW55X_FWDGT + gd32_fwdgt_initialize("/dev/watchdog0", BOARD_IRC32K_FREQUENCY); +#endif + +#ifdef CONFIG_GD32VW55X_WWDGT + gd32_wwdgt_initialize("/dev/watchdog1"); +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + + return ret; +} diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_reset.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_reset.c new file mode 100644 index 00000000000..f88c137b5ec --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_reset.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_reset.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 <nuttx/board.h> + +#include "riscv_internal.h" +#include "gd32vw55x_memorymap.h" + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The Nuclei SysTimer carries the software reset request register. Writing + * the key asks the SoC for a reset; the core is reset a few cycles later, + * so the write never returns. + */ + +#define GD32VW55X_SYSTIMER_MSFTRST (GD32VW55X_SYSTIMER_BASE + 0x0ff0) +#define SYSTIMER_MSFTRST_KEY 0x80000a5f + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset the board. Called by the "reset" NSH command and by + * boardctl(BOARDIOC_RESET). + * + * Input Parameters: + * status - Reset status, ignored here. + * + * Returned Value: + * Does not return. + * + ****************************************************************************/ + +int board_reset(int status) +{ + putreg32(SYSTIMER_MSFTRST_KEY, GD32VW55X_SYSTIMER_MSFTRST); + + for (; ; ) + { + /* Wait for the reset to arrive */ + } + + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_userleds.c b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_userleds.c new file mode 100644 index 00000000000..a197e258630 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_userleds.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32_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/board.h> +#include <arch/board/board.h> + +#include "gd32vw55x_gpio.h" +#include "gd32vw553-hmq.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* The three LEDs are on GPIOC and are active HIGH: driving the pin high + * lights the LED. + */ + +static const uint32_t g_led_map[BOARD_NLEDS] = +{ + GPIO_LED1, + GPIO_LED2, + GPIO_LED3 +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + int i; + + for (i = 0; i < BOARD_NLEDS; i++) + { + gd32_gpio_config(g_led_map[i]); + } + + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if ((unsigned int)led < BOARD_NLEDS) + { + gd32_gpio_write(g_led_map[led], ledon); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + int i; + + for (i = 0; i < BOARD_NLEDS; i++) + { + gd32_gpio_write(g_led_map[i], (ledset & (1 << i)) != 0); + } +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32vw553-hmq.h b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32vw553-hmq.h new file mode 100644 index 00000000000..92af7ff31be --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32vw553-hmq.h @@ -0,0 +1,52 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/src/gd32vw553-hmq.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_RISCV_GD32VW55X_GD32VW553_HMQ_SRC_GD32VW553_HMQ_H +#define __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_SRC_GD32VW553_HMQ_H + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: gd32_bringup + * + * Description: + * Perform architecture-specific initialization + * + ****************************************************************************/ + +int gd32_bringup(void); + +/**************************************************************************** + * Name: gd32_spidev_initialize + * + * Description: + * Configure the SPI chip select GPIO(s) used by the board. + * + ****************************************************************************/ + +#ifdef CONFIG_GD32VW55X_SPI +void gd32_spidev_initialize(void); +#endif + +#endif /* __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_SRC_GD32VW553_HMQ_H */ diff --git a/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h b/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h index 1e7b41f9bf8..6ae5fc8545c 100644 --- a/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h +++ b/boards/risc-v/gd32vw55x/gd32vw553k-start/include/board.h @@ -54,12 +54,12 @@ #define BOARD_UART1_RX_PIN 8 #define BOARD_UART1_RX_AF 3 -#define BOARD_USART0_TX_GPIO GD32VW55X_GPIOA_BASE -#define BOARD_USART0_TX_PIN 0 -#define BOARD_USART0_TX_AF 0 +#define BOARD_USART0_TX_GPIO GD32VW55X_GPIOB_BASE +#define BOARD_USART0_TX_PIN 15 +#define BOARD_USART0_TX_AF 8 #define BOARD_USART0_RX_GPIO GD32VW55X_GPIOA_BASE -#define BOARD_USART0_RX_PIN 1 -#define BOARD_USART0_RX_AF 0 +#define BOARD_USART0_RX_PIN 8 +#define BOARD_USART0_RX_AF 2 /* Peripheral pin selection *************************************************/
