diff --git a/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/gd35vw553-hmq.png b/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/gd35vw553-hmq.png new file mode 100644 index 0000000000000..e096140eb12c0 Binary files /dev/null and b/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/gd35vw553-hmq.png differ diff --git a/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/index.rst b/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/index.rst new file mode 100644 index 0000000000000..b2e9a3ad5cdb4 --- /dev/null +++ b/Documentation/platforms/risc-v/gd32vw55x/boards/gd32vw553-hmq/index.rst @@ -0,0 +1,254 @@ +============= +GD32VW553-HMQ +============= + +The GD32VW553-HMQ is the generic evaluation board for the GD32VW553HMQ6 +(Nuclei N307, Wi-Fi 6 + BLE 5.3). It carries an on-board USB/Serial port +provides the USB serial console. + +.. figure:: gd35vw553-hmq.png + :align: center + :width: 500px + + The GD32VW553-HMQ board. + +Features +======== + +- GD32VW553HMQ (QFN40, 4096 KB flash, + 320 KB SRAM) and a PCB antenna +- USB/Serial COM port over the USB Type-C connector +- One LED on PC13 +- BOOT0/BOOT1 buttons, a power jumper and a reset button (NRST) + +Serial Console +============== + +The console is UART0 (PB15 TX / PA8 RX), wired to the USB/Serial port. +It shows up on the host as ``/dev/ttyUSB0`` at 115200 8N1. + +LEDs +==== + +One LED sit on GPIO PC13 and is driven push-pull, active HIGH. + +====== ==== ========================================= +LED Pin Meaning in the vendor SDK +====== ==== ========================================= +LED1 PC13 CPU running +====== ==== ========================================= + +With ``CONFIG_USERLED`` they belong to the application and are exposed as +``/dev/userleds``. With ``CONFIG_ARCH_LEDS`` the OS takes them over instead +and uses them to show its state: LED1 comes on once NuttX has started. + +Flashing +======== + +The board is programmed with OpenOCD through a JTAG Probe. The GigaDevice +OpenOCD fork (shipped with the vendor SDK) is required:: + + $ openocd -f openocd_gdlink.cfg \ + -c "program nuttx.bin 0x08000000 verify reset exit" + +NuttX is linked at 0x08000000, bypassing the vendor MBL bootloader. + +.. note:: + The chip mask ROM uses the first 0x200 bytes of SRAM. The linker script + starts the application at 0x20000200 for that reason; do not move it. + +If you prefer to use JLink, you wire this way: + +========= ===================== +JLink Pin GD32VW553 board Pin +========= ===================== +1 Vref 3V3 +5 TDI DI +7 TMS MS +9 TCK CK +13 TDO DO +15 RESET RST +25 GND GND +========= ===================== + +You can run JLinkExe on Linux this way:: + + $ sudo JLinkExe -if jtag + J-Link> connect + Device position in JTAG chain (IRPre,DRPre) : -1,-1 => Auto-detect + JTAGConf> + Specify target interface speed [kHz]. : 4000 kHz + Speed> + The selected device "GD32VW533HMQ6" is unknown to this software version. + Device "GD32VW553HMQ6" selected. + J-Link> loadbin nuttx.hex, 0 + +Flash layout +============ + +The full map is in the :doc:`chip documentation <../../index>`. What matters +when flashing this board: + +======================== ============== ==================================== +Range Size Purpose +======================== ============== ==================================== +0x08000000 -- 0x083db000 3948 KiB Available to the firmware. This is + what the linker script gives out; + overflowing it is a link error +0x083db000 -- 0x083fb000 128 KiB progmem / LittleFS +0x083fb000 -- 0x08400000 20 KiB **Wi-Fi NVDS** -- do not erase +======================== ============== ==================================== + +For reference, the configurations use a small part of that budget: ``nsh`` +135 KiB (3%), ``wifi`` 610 KiB (15%) and ``sta_softap`` 613 KiB (16%). +The ``ble`` config (BLE on top of ``wifi``) brings the image to about 971 KiB (25%). + +.. warning:: + The **last** pages of the flash are not free: the Wi-Fi NVDS holds the RF + calibration data and the MAC address, and erasing it breaks the radio. The + progmem region ends exactly where the NVDS begins. + +The region handed to progmem is set with +``CONFIG_GD32VW55X_PROGMEM_START_ADDR`` and ``CONFIG_GD32VW55X_PROGMEM_SIZE``; +nothing outside it is ever erased or written. + +Configurations +============== + +Each configuration is built with:: + + $ ./tools/configure.sh gd32vw553k-start: + $ make + +nsh +--- + +Basic NuttShell configuration over the UART2 console. No radio. + +wifi +---- + +NSH plus the Wi-Fi station support. The interface is registered as ``wlan0`` +with the MAC address read from the chip eFuse, and is driven with the standard +network tools:: + + nsh> wapi scan wlan0 + nsh> wapi psk wlan0 3 + nsh> wapi essid wlan0 1 + nsh> ifup wlan0 + nsh> renew wlan0 + nsh> ifconfig + nsh> ping 8.8.8.8 + +.. note:: + Use ``ifup wlan0``, not ``ifconfig wlan0 up``: ``ifconfig`` interprets its + second argument as an IP address. + +.. note:: + The station is WPA2-only. A WPA3-transition network (WPA2/WPA3 mixed + mode) associates through WPA2-PSK; a WPA3(SAE)-only network is refused + up front with ``ENOTSUP`` and a console message naming the unsupported + AKM, instead of letting the prebuilt supplicant attempt the SAE + handshake (which faults). + +The RTC and the SNTP client are enabled, so the clock can be set from the +network:: + + nsh> ntpcstart + nsh> date + +sta_softap +---------- + +NSH plus the Wi-Fi softAP: the board becomes an access point and a DHCP server. +The single-VIF firmware does station *or* AP at a time (not both at once), so +this is a softAP, not the simultaneous STA+AP of some other parts. + +Bring it up with the standard tools:: + + nsh> wapi mode wlan0 3 # 3 = master (softAP) + nsh> wapi psk wlan0 12345678 3 # WPA2-PSK + nsh> wapi essid wlan0 nuttxwifi 1 # start the AP + nsh> dhcpd_start wlan0 # DHCP server, in the background + +A client then sees ``nuttxwifi``, associates with WPA2, and gets an address +from the 10.0.0.0/24 pool (the AP is 10.0.0.1). + +.. note:: + Use WPA2, not WPA3. The SAE (WPA3) handshake on the AP side is deep on the + stack; with the default task stacks it overflows inside the elliptic-curve + crypto and faults. This configuration raises ``CONFIG_INIT_STACKSIZE`` to + 8192 and ``CONFIG_DEFAULT_TASK_STACKSIZE`` to 4096 for the same reason -- the + radio tasks need the headroom. + +.. note:: + ``dhcpd_start`` spawns the server as a background task and returns. The + plain ``dhcpd`` command, confusingly, runs the server *blocking* in the + foreground. + +ble +--- + +``wapi`` plus BLE (``CONFIG_GD32VW55X_BLE``) and the demo GATT service +(``CONFIG_GD32VW55X_BLE_GATT_DEMO``). The board advertises a connectable set +named ``NuttX`` and registers a minimal "transparent UART" service (16-bit +UUIDs ``0xffe0`` / RX ``0xffe1`` / TX ``0xffe2``). Advertising restarts on +every disconnection, so the device stays discoverable across connections. A +central connects, discovers the service, and a write to the RX characteristic +is logged on the board console:: + + nsh> BLE RX (11): Hello world + +.. note:: + The central -> board write is exercised with a write command + (write-without-response), which is reliable. The prebuilt vendor + controller does not complete a write-request (write-with-response) or the + CCCD subscribe issued by a Linux BlueZ host, so the TX **notification** echo + (board -> central) is best exercised from a phone app such as nRF Connect. + This is why BLE keeps ``CONFIG_EXPERIMENTAL``. + +ostest +------ + +``nsh`` plus the NuttX OS test suite (``CONFIG_TESTING_OSTEST``). Run it from +the shell to exercise the scheduler, synchronisation primitives and the FPU +context switch:: + + nsh> ostest + ... + ostest_main: Exiting with status 0 + +The ``rr_test`` (round-robin with a 30000-prime workload) makes the full run +take a couple of minutes on this core; every sub-test reports ``nerrors=0``. + +Status +====== + +All seven configurations were validated on hardware: + +- ``nsh``: boots, console, heap and task list are healthy. +- ``wifi``: full station path over a live AP -- ``wapi scan`` lists the nearby + networks, WPA2 associates through the four-way handshake, DHCP obtains an + address, and ``ping`` reaches the internet. +- ``sta_softap``: the board's own AP -- a client sees the SSID, associates with + WPA2, gets an address from the board's DHCP server, and pings the board. +- ``ble``: advertises ``NuttX``, a central connects, the demo GATT service + enumerates, and a write to the RX characteristic is received on the board + console (central -> board). +- ``ostest``: the OS test suite runs to completion (every sub-test reports + ``nerrors=0`` and it ends with ``ostest_main: Exiting with status 0``). + +BLE (``CONFIG_GD32VW55X_BLE``) is marked EXPERIMENTAL and off by default. The +prebuilt ``libble`` is an all-in-one controller plus RivieraWaves host with no +HCI transport, so the port drives the vendor host directly (it does not +register a NuttX ``bt_driver_s``). The ``ble`` configuration enables it along +with a demo GATT service; see that section above for what is validated and the +notification caveat. A reusable test tool for this is kept with the +out-of-tree port notes. + +.. note:: + ``CONFIG_ARCH_LEDS`` must stay off on this board. With the OS driving the + LEDs, the serial console dies in the Wi-Fi configurations (the console UART + shares the work queue path); the LEDs belong to the application + (``CONFIG_USERLED``), and every defconfig here disables ``ARCH_LEDS`` + explicitly. diff --git a/boards/Kconfig b/boards/Kconfig index 132459811f9a6..76bb2fbfcd994 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 @@ -3932,6 +3942,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 @@ -5412,6 +5423,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 0000000000000..fb88d13ddbde1 --- /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 0000000000000..ed16ef6229f7c --- /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 0000000000000..0545db2e8557e --- /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 0000000000000..82ad70b75f59b --- /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 0000000000000..1241fc50f1656 --- /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 0000000000000..207d174148314 --- /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/gd32vw553-hmq/include/board.h b/boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h new file mode 100644 index 0000000000000..e5d14dda989c0 --- /dev/null +++ b/boards/risc-v/gd32vw55x/gd32vw553-hmq/include/board.h @@ -0,0 +1,172 @@ +/**************************************************************************** + * boards/risc-v/gd32vw55x/gd32vw553-hmq/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_RISCV_GD32VW55X_GD32VW553_HMQ_INCLUDE_BOARD_H +#define __BOARDS_RISCV_GD32VW55X_GD32VW553_HMQ_INCLUDE_BOARD_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking: 40 MHz HXTAL -> PLLDIG -> 160 MHz SYSCLK (see + * gd32vw55x_clockconfig.c). These are informational for board code. + */ + +#define BOARD_HXTAL_FREQUENCY 40000000 +#define BOARD_IRC32K_FREQUENCY 32000 /* Internal 32 kHz RC (FWDGT, RTC) */ +#define BOARD_SYSCLK_FREQUENCY 160000000 + +/* 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). + */ + +#define BOARD_UART2_TX_GPIO GD32VW55X_GPIOA_BASE +#define BOARD_UART2_TX_PIN 6 +#define BOARD_UART2_TX_AF 10 +#define BOARD_UART2_RX_GPIO GD32VW55X_GPIOA_BASE +#define BOARD_UART2_RX_PIN 7 +#define BOARD_UART2_RX_AF 8 + +#define BOARD_UART1_TX_GPIO GD32VW55X_GPIOB_BASE +#define BOARD_UART1_TX_PIN 15 +#define BOARD_UART1_TX_AF 7 +#define BOARD_UART1_RX_GPIO GD32VW55X_GPIOA_BASE +#define BOARD_UART1_RX_PIN 8 +#define BOARD_UART1_RX_AF 3 + +/* 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 8 +#define BOARD_USART0_RX_AF 2 + +/* Peripheral pin selection *************************************************/ + +/* The pin options come from arch/risc-v/src/gd32vw55x/hardware/ + * gd32vw55x_pinmap.h. Avoid PA6/PA7: they are the UART2 console. + */ + +#ifdef CONFIG_GD32VW55X_SPI +# define GPIO_SPI_SCK GPIO_SPI_SCK_1 /* PA2, AF5 */ +# define GPIO_SPI_MISO GPIO_SPI_MISO_1 /* PA1, AF5 */ +# define GPIO_SPI_MOSI GPIO_SPI_MOSI_1 /* PA0, AF5 */ + +/* SPI0 chip select for the SD card: a plain GPIO output on PA4 (J1), + * driven by gd32_spi0select(). Active low, idles high. + */ + +# define GPIO_SPI0_CSPIN (GPIO_CFG_MODE_OUTPUT | GPIO_CFG_PUPD_NONE | \ + GPIO_CFG_PP | GPIO_CFG_SPEED_MAX | \ + GPIO_CFG_OUTPUT_SET | GPIO_CFG_PORT_A | \ + GPIO_CFG_PIN_4) +#endif + +/* I2C0 uses PA2 (SCL) / PA3 (SDA) on AF4, the pins broken out on the J1 + * header (datasheet Table 2-5), so a sensor such as the SHT3x can be wired + * there directly. When SPI is enabled it claims PA2 (SPI SCK), so I2C0 + * falls back to PB0/PB1 (AF6); PB1 (SDA) is not broken out on J1/J2, so that + * pairing only registers the bus (the periph case). + */ + +#ifdef CONFIG_GD32VW55X_I2C0 +# ifdef CONFIG_GD32VW55X_SPI +# define GPIO_I2C0_SCL GPIO_I2C0_SCL_3 /* PB0, AF6 */ +# define GPIO_I2C0_SDA GPIO_I2C0_SDA_3 /* PB1, AF6 (not on a header) */ +# else +# define GPIO_I2C0_SCL GPIO_I2C0_SCL_1 /* PA2, AF4 (J1) */ +# define GPIO_I2C0_SDA GPIO_I2C0_SDA_1 /* PA3, AF4 (J1) */ +# endif +#endif + +#ifdef CONFIG_GD32VW55X_I2C1 +# define GPIO_I2C1_SCL GPIO_I2C1_SCL_4 /* PB12, AF6 */ +# define GPIO_I2C1_SDA GPIO_I2C1_SDA_4 /* PB13, AF6 */ +#endif + +/* PWM. The board bringup registers /dev/pwm0 on TIMER1. Route its channel + * 0 (TIMER1_CH0) to PA0 on the J1 header (AF1; TIMER1 lives on AF1) so the + * output can be probed there. The other channels stay unrouted. + */ + +#ifdef CONFIG_GD32VW55X_PWM +# define GPIO_TIMER1_CH0OUT (GPIO_CFG_MODE_AF | GPIO_CFG_PUPD_NONE | \ + GPIO_CFG_PP | GPIO_CFG_SPEED_MAX | \ + GPIO_CFG_AF_1 | GPIO_CFG_PORT_A | GPIO_CFG_PIN_0) +#endif + +/* ADC. Route ADC channel 8 (ADC_IN8) to PB0 on the J1 header (datasheet + * Table 2-5) so an analog signal can be applied there. When SPI is enabled + * PB0 is instead claimed by the I2C0 fallback (see above), so the analog pin + * is only routed when SPI is off. The board bringup samples this channel + * when the macro is defined. + */ + +#if defined(CONFIG_GD32VW55X_ADC) && !defined(CONFIG_GD32VW55X_SPI) +# define GPIO_ADC_IN8 (GPIO_CFG_MODE_ANALOG | GPIO_CFG_PUPD_NONE | \ + GPIO_CFG_PORT_B | GPIO_CFG_PIN_0) +#endif + +/* LEDs *********************************************************************/ + +/* 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 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) + +/* LED index values for use with board_userled() */ + +#define BOARD_LED1 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) + +/* 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 + * fully under application control. + * + * SYMBOL MEANING LED1 LED2 LED3 + * ------------------ ------------------------ ---- ---- ---- + */ + +#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_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 0000000000000..b2eb4b42d86e8 --- /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 0000000000000..0147fe6a63b68 --- /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 0000000000000..67584a8190f56 --- /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 0000000000000..e5b280b37ea0a --- /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 + +#include + +#include + +#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 0000000000000..8de8f33bf84b3 --- /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 + +#include +#include + +#include +#include + +#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 0000000000000..c731bcced65a3 --- /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 + +#include + +#include +#include + +#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 0000000000000..f2235dfd331d6 --- /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 + +#include +#include + +#include + +#ifdef CONFIG_I2C_DRIVER +# include +#endif +#ifdef CONFIG_SPI_DRIVER +# include +#endif +#ifdef CONFIG_MMCSD_SPI +# include +#endif +#ifdef CONFIG_GD32VW55X_ADC +# include +#endif +#ifdef CONFIG_GD32VW55X_PWM +# include +#endif +#ifdef CONFIG_GD32VW55X_CAPTURE +# include +#endif +#ifdef CONFIG_USERLED_LOWER +# include +#endif +#ifdef CONFIG_SENSORS_SHT3X +# include +#endif +#ifdef CONFIG_MTD_PROGMEM +# include +#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 + +#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 0000000000000..f88c137b5ecce --- /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 + +#include + +#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 0000000000000..a197e258630b5 --- /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 + +#include +#include + +#include +#include + +#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 0000000000000..92af7ff31bedd --- /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 1e7b41f9bf8cf..6ae5fc8545c58 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 *************************************************/