This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 7355393fcdd4464681d9350225dd553cecaa9ce8 Author: raul_chen <[email protected]> AuthorDate: Wed Jul 1 16:06:39 2026 +0800 boards: add Realtek RTL8721Dx and RTL8720F board configurations Add board-level support for two Realtek Ameba WHC evaluation boards: - pke8721daf (RTL8721Dx) - rtl8720f_evb (RTL8720F) Each board provides: - defconfig for NSH with WiFi networking support - CMakeLists.txt (make-only build helper that fails fast on cmake) - Board-specific bring-up and initialization (leds, SDIO, flash) - Scripts/Make.defs including the IC-level build fragment and the make flash target (tools/ameba/Config.mk) Signed-off-by: raul_chen <[email protected]> --- boards/Kconfig | 24 +++ boards/arm/rtl8720f/rtl8720f_evb/CMakeLists.txt | 36 ++++ boards/arm/rtl8720f/rtl8720f_evb/Kconfig | 7 + .../rtl8720f/rtl8720f_evb/configs/nsh/defconfig | 81 ++++++++ boards/arm/rtl8720f/rtl8720f_evb/include/board.h | 66 +++++++ .../arm/rtl8720f/rtl8720f_evb/prebuilt/.gitignore | 22 +++ boards/arm/rtl8720f/rtl8720f_evb/scripts/Make.defs | 33 ++++ .../arm/rtl8720f/rtl8720f_evb/src/CMakeLists.txt | 27 +++ boards/arm/rtl8720f/rtl8720f_evb/src/Makefile | 27 +++ .../arm/rtl8720f/rtl8720f_evb/src/rtl8720f_boot.c | 69 +++++++ .../rtl8720f/rtl8720f_evb/src/rtl8720f_bringup.c | 203 +++++++++++++++++++++ .../rtl8720f_evb/src/rtl8720f_rtl8720f_evb.h | 100 ++++++++++ boards/arm/rtl8721dx/pke8721daf/CMakeLists.txt | 36 ++++ boards/arm/rtl8721dx/pke8721daf/Kconfig | 7 + .../arm/rtl8721dx/pke8721daf/configs/nsh/defconfig | 81 ++++++++ boards/arm/rtl8721dx/pke8721daf/include/board.h | 66 +++++++ .../arm/rtl8721dx/pke8721daf/prebuilt/.gitignore | 22 +++ boards/arm/rtl8721dx/pke8721daf/scripts/Make.defs | 33 ++++ boards/arm/rtl8721dx/pke8721daf/src/CMakeLists.txt | 27 +++ boards/arm/rtl8721dx/pke8721daf/src/Makefile | 27 +++ .../arm/rtl8721dx/pke8721daf/src/rtl8721dx_boot.c | 69 +++++++ .../rtl8721dx/pke8721daf/src/rtl8721dx_bringup.c | 190 +++++++++++++++++++ .../pke8721daf/src/rtl8721dx_pke8721daf.h | 86 +++++++++ 23 files changed, 1339 insertions(+) diff --git a/boards/Kconfig b/boards/Kconfig index fee8d033474..ad047a75f11 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2452,6 +2452,22 @@ config ARCH_BOARD_MPS3_AN547 This options selects support for NuttX on the MPS3 AN547 board featuring the Cortex-M55. +config ARCH_BOARD_PKE8721DAF + bool "Realtek pke8721daf" + depends on ARCH_CHIP_RTL8721DX + ---help--- + This options selects support for NuttX on the pke8721daf + board featuring the Realtek RTL8721Dx (KM4, + Cortex-M33). + +config ARCH_BOARD_RTL8720F_EVB + bool "Realtek RTL8720F_EVB" + depends on ARCH_CHIP_RTL8720F + ---help--- + This options selects support for NuttX on the RTL8720F_EVB + board featuring the Realtek RTL8720F (km4tz application/host + core, Cortex-M33). + config ARCH_BOARD_SABRE_6QUAD bool "NXP/Freescale i.MX6 Sabre-6Quad board" depends on ARCH_CHIP_IMX6_6QUAD @@ -3899,6 +3915,8 @@ config ARCH_BOARD default "mps2-an500" if ARCH_BOARD_MPS2_AN500 default "mps2-an521" if ARCH_BOARD_MPS2_AN521 default "mps3-an547" if ARCH_BOARD_MPS3_AN547 + default "pke8721daf" if ARCH_BOARD_PKE8721DAF + default "rtl8720f_evb" if ARCH_BOARD_RTL8720F_EVB default "rv32m1-vega" if ARCH_BOARD_RV32M1_VEGA default "rv-virt" if ARCH_BOARD_QEMU_RV_VIRT default "star64" if ARCH_BOARD_JH7110_STAR64 @@ -4143,6 +4161,12 @@ endif if ARCH_BOARD_MPS3_AN547 source "boards/arm/mps/mps3-an547/Kconfig" endif +if ARCH_BOARD_PKE8721DAF +source "boards/arm/rtl8721dx/pke8721daf/Kconfig" +endif +if ARCH_BOARD_RTL8720F_EVB +source "boards/arm/rtl8720f/rtl8720f_evb/Kconfig" +endif if ARCH_BOARD_QEMU_ARMV7A source "boards/arm/qemu/qemu-armv7a/Kconfig" endif diff --git a/boards/arm/rtl8720f/rtl8720f_evb/CMakeLists.txt b/boards/arm/rtl8720f/rtl8720f_evb/CMakeLists.txt new file mode 100644 index 00000000000..7a85cd7244c --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/CMakeLists.txt @@ -0,0 +1,36 @@ +# ############################################################################## +# boards/arm/rtl8720f/rtl8720f_evb/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +# The RTL8720F (Ameba WHC) port currently builds via the make-based build only. +# The CMake path does not yet wire up the vendor-SDK machinery (SDK fetch, +# libameba_fwlib.a/libameba_wifi.a, the image2 entry ameba_app_start.c, the SDK +# image2 linker-script generation, the NP-image build and the app.bin packaging) +# that boards/.../scripts/Make.defs -> arch/.../ameba_board.mk provides, so a +# CMake configure would not produce a flashable image. Fail fast with a clear +# message instead of half-building. +message( + FATAL_ERROR + "rtl8720f_evb (RTL8720F, Ameba WHC) currently supports the make build " + "only; CMake is not yet supported. Build with:\n" + " ./tools/configure.sh rtl8720f_evb:nsh && make") + +add_subdirectory(src) diff --git a/boards/arm/rtl8720f/rtl8720f_evb/Kconfig b/boards/arm/rtl8720f/rtl8720f_evb/Kconfig new file mode 100644 index 00000000000..aa0240ab340 --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_RTL8720F_EVB +endif diff --git a/boards/arm/rtl8720f/rtl8720f_evb/configs/nsh/defconfig b/boards/arm/rtl8720f/rtl8720f_evb/configs/nsh/defconfig new file mode 100644 index 00000000000..73734b6145c --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/configs/nsh/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_DEBUG_WARN is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="rtl8720f_evb" +CONFIG_ARCH_BOARD_RTL8720F_EVB=y +CONFIG_ARCH_CHIP="rtl8720f" +CONFIG_ARCH_CHIP_RTL8720F=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV8M_SYSTICK=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DRIVERS_IEEE80211=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EXAMPLES_DHCPD=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_TMPFS=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_IOB_BUFSIZE=400 +CONFIG_IOB_NBUFFERS=100 +CONFIG_IOB_NCHAINS=36 +CONFIG_IOB_THROTTLE=40 +CONFIG_LIBC_MEMFD_ERROR=y +CONFIG_MM_DEFAULT_ALIGNMENT=32 +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETDEV_WIRELESS_IOCTL=y +CONFIG_NETUTILS_DHCPD=y +CONFIG_NETUTILS_DHCPD_ROUTERIP=0xc0a80401 +CONFIG_NETUTILS_DHCPD_STARTIP=0xc0a80402 +CONFIG_NETUTILS_IPERF=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_TCP=y +CONFIG_NET_TCP_DELAYED_ACK=y +CONFIG_NET_TCP_KEEPALIVE=y +CONFIG_NET_TCP_NOTIFIER=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_VCONFIG=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=262144 +CONFIG_RAM_START=0x30008000 +CONFIG_RR_INTERVAL=200 +CONFIG_RTL8720F_FLASH_FS=y +CONFIG_RTL8720F_WIFI=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_LPWORK=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=16 +CONFIG_START_MONTH=6 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=2500 +CONFIG_SYSTEM_PING=y +CONFIG_TIMER=y +CONFIG_TIMER_ARCH=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_WIRELESS=y +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y diff --git a/boards/arm/rtl8720f/rtl8720f_evb/include/board.h b/boards/arm/rtl8720f/rtl8720f_evb/include/board.h new file mode 100644 index 00000000000..b53f790d2ff --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/include/board.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * boards/arm/rtl8720f/rtl8720f_evb/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RTL8720F_RTL8720F_EVB_INCLUDE_BOARD_H +#define __BOARDS_ARM_RTL8720F_RTL8720F_EVB_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The SysTick/core clock is taken from the SDK's SystemCoreClock global at + * runtime (see arch/arm/src/rtl8720f/ameba_timerisr.c), so no board-level + * clock constant is needed here. + */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RTL8720F_RTL8720F_EVB_INCLUDE_BOARD_H */ diff --git a/boards/arm/rtl8720f/rtl8720f_evb/prebuilt/.gitignore b/boards/arm/rtl8720f/rtl8720f_evb/prebuilt/.gitignore new file mode 100644 index 00000000000..3f71fa4902e --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/prebuilt/.gitignore @@ -0,0 +1,22 @@ +# Realtek RTL8720F vendor blobs and build artefacts. +# +# These are NOT NuttX source and must never be committed upstream (vendor +# blobs are kept out of the NuttX tree). They are vendor outputs from the +# ameba-rtos SDK, placed here by the integrator: +# +# libs/*.a pre-compiled chip archives (fwlib/hal/swlib/misc/...) +# km4ns_image2_all.bin prebuilt NP (WiFi/LP core, km4ns) image2 blob +# platform_autoconf.h regenerated each build from the SDK menuconfig by +# ameba_gen_autoconf.sh (single source of truth) +# config_km4 / config_fw vendored SDK kconfig snapshots for axf2bin packaging +# +# Generated at build time: +# +# ld.script.gen[.tmp] combined image2 linker script +# project_km4tz/ staged include dir for ld preprocessing +# pkg/ axf2bin / firmware_package staging area +# +# Everything in this directory is ignored. + +* +!.gitignore diff --git a/boards/arm/rtl8720f/rtl8720f_evb/scripts/Make.defs b/boards/arm/rtl8720f/rtl8720f_evb/scripts/Make.defs new file mode 100644 index 00000000000..5a8cd1ed539 --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/scripts/Make.defs @@ -0,0 +1,33 @@ +############################################################################ +# boards/arm/rtl8720f/rtl8720f_evb/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. +# +############################################################################ + +# All RTL8720F board-build definitions (SDK include sets, fwlib/WiFi source +# lists, image2 linker-script generation, PREBUILD/POSTBUILD) live in the +# shared per-IC fragment so every board on this IC uses one copy. This board's +# own paths (prebuilt/ staging) derive from $(BOARD_DIR) inside it. + +include $(TOPDIR)/arch/arm/src/rtl8720f/ameba_board.mk + +# Flashing via the SDK AmebaFlash.py (make flash AMEBA_PORT=/dev/ttyUSB0) + +AMEBA_FLASH_PROFILE = RTL8720F +include $(TOPDIR)/tools/ameba/Config.mk diff --git a/boards/arm/rtl8720f/rtl8720f_evb/src/CMakeLists.txt b/boards/arm/rtl8720f/rtl8720f_evb/src/CMakeLists.txt new file mode 100644 index 00000000000..97130bd6be5 --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/src/CMakeLists.txt @@ -0,0 +1,27 @@ +# ############################################################################## +# boards/arm/rtl8720f/rtl8720f_evb/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +set(SRCS rtl8720f_boot.c rtl8720f_bringup.c) + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script") diff --git a/boards/arm/rtl8720f/rtl8720f_evb/src/Makefile b/boards/arm/rtl8720f/rtl8720f_evb/src/Makefile new file mode 100644 index 00000000000..66f8c7b9f15 --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/src/Makefile @@ -0,0 +1,27 @@ +############################################################################ +# boards/arm/rtl8720f/rtl8720f_evb/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 = rtl8720f_boot.c rtl8720f_bringup.c + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_boot.c b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_boot.c new file mode 100644 index 00000000000..ac11472c98d --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_boot.c @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_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 <nuttx/arch.h> +#include <nuttx/board.h> + +#include "rtl8720f_rtl8720f_evb.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rtl8720f_boardinitialize + * + * Description: + * All RTL8720F 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 rtl8720f_boardinitialize(void) +{ + /* Board-specific early initialization. Nothing to do here. */ +} + +/**************************************************************************** + * Name: board_initialize + * + * Description: + * If CONFIG_BOARD_EARLY_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_initialize(). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_EARLY_INITIALIZE +void board_early_initialize(void) +{ + rtl8720f_boardinitialize(); +} +#endif diff --git a/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_bringup.c b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_bringup.c new file mode 100644 index 00000000000..6099467567d --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_bringup.c @@ -0,0 +1,203 @@ +/**************************************************************************** + * boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_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 <syslog.h> + +#include <nuttx/fs/fs.h> +#include <nuttx/board.h> + +#include "rtl8720f_rtl8720f_evb.h" + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* SDK ROM inter-core IPC-semaphore RTOS hooks. rtos_* come from the NuttX + * os_wrapper (ameba_os_wrap.c); IPC_* are SDK ROM symbols. + */ + +extern void rtos_critical_enter(uint32_t component_id); +extern void rtos_critical_exit(uint32_t component_id); +extern void rtos_time_delay_ms(uint32_t ms); +extern void IPC_patch_function(void (*enter)(uint32_t), + void (*leave)(uint32_t), uint32_t lock_id); +extern void IPC_SEMDelayStub(void (*delay)(uint32_t)); + +/* RTOS_CRITICAL_SEMA in the SDK os_wrapper_critical.h enum. Our + * rtos_critical_enter/exit ignore the component id, so the value is only + * passed through to satisfy the ROM signature. + */ + +#define AMEBA_RTOS_CRITICAL_SEMA 9 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rtl8720f_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int rtl8720f_bringup(void) +{ + int ret = 0; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmp file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at /tmp: %d\n", ret); + } +#endif + +#ifdef CONFIG_RTL8720F_FLASH_FS + /* Mount the persistent data filesystem (littlefs on the SPI NOR VFS1 + * partition) at /data before WiFi, so the WiFi KV store is available. + */ + + /* The SDK flash erase/program path IPC-pauses the NP (km4ns) while the AP + * writes the shared XIP flash, so the IPC transport must be up first. + */ + + ameba_ipc_initialize(); + + ret = ameba_flash_fs_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: ameba_flash_fs_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_RTL8720F_WIFI + /* Bring up the KM4 IPC transport and start the WHC host WiFi stack. */ + + ret = rtl8720f_wifi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rtl8720f_wifi_initialize failed: %d\n", ret); + } +#endif + + /* Install the inter-core HW IPC-semaphore RTOS hooks LAST -- after all the + * flash / WHC bring-up above, and just before this (board_late_initialize) + * path returns and nx_start() hands off to the init task. + * + * The shared-flash / WHC paths take the hardware IPC semaphore to + * serialize against the NP; the ROM semaphore code then calls an RTOS + * critical-section pair plus a delay callback while a contended waiter + * waits. That delay callback rtos_time_delay_ms() blocks, so it is only + * safe from a real task. Registering it here means the bring-up flash + * access above (which runs in this pre-task context) uses the ROM default + * (busy-spin, no callback), while every runtime IPC-semaphore user that + * follows runs in a task and yields properly. + */ + + IPC_patch_function(rtos_critical_enter, rtos_critical_exit, + AMEBA_RTOS_CRITICAL_SEMA); + IPC_SEMDelayStub(rtos_time_delay_ms); + + return ret; +} + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL +int board_app_initialize(uintptr_t arg) +{ +#ifndef CONFIG_BOARD_LATE_INITIALIZE + /* Perform board initialization */ + + return rtl8720f_bringup(); +#else + return OK; +#endif +} +#endif /* CONFIG_BOARDCTL */ + +/**************************************************************************** + * 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 immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization */ + + rtl8720f_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_rtl8720f_evb.h b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_rtl8720f_evb.h new file mode 100644 index 00000000000..5582da98f09 --- /dev/null +++ b/boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_rtl8720f_evb.h @@ -0,0 +1,100 @@ +/**************************************************************************** + * boards/arm/rtl8720f/rtl8720f_evb/src/rtl8720f_rtl8720f_evb.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RTL8720F_RTL8720F_EVB_SRC_RTL8720F_RTL8720F_EVB_H +#define __BOARDS_ARM_RTL8720F_RTL8720F_EVB_SRC_RTL8720F_RTL8720F_EVB_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Name: rtl8720f_boardinitialize + * + * Description: + * Perform board-specific early initialization. + * + ****************************************************************************/ + +void rtl8720f_boardinitialize(void); + +/**************************************************************************** + * Name: rtl8720f_bringup + * + * Description: + * Bring up board features. + * + ****************************************************************************/ + +int rtl8720f_bringup(void); + +#ifdef CONFIG_RTL8720F_WIFI +/**************************************************************************** + * Name: rtl8720f_wifi_initialize + * + * Description: + * Bring up the KM4 IPC transport and start the WHC host WiFi stack + * (arch/arm/src/rtl8720f/ameba_wifi_init.c). + * + ****************************************************************************/ + +int rtl8720f_wifi_initialize(void); +#endif + +#if defined(CONFIG_RTL8720F_FLASH_FS) || defined(CONFIG_RTL8720F_WIFI) +/**************************************************************************** + * Name: ameba_ipc_initialize + * + * Description: + * Bring up the km4tz<->km4ns IPC transport once (idempotent). Required by + * the SDK flash erase/program path (inter-core XIP pause) and by WiFi + * (arch/arm/src/rtl8720f/ameba_ipc.c). + * + ****************************************************************************/ + +void ameba_ipc_initialize(void); +#endif + +#ifdef CONFIG_RTL8720F_FLASH_FS +/**************************************************************************** + * Name: ameba_flash_fs_initialize + * + * Description: + * Register the on-chip SPI NOR data partition as an MTD device and mount + * a littlefs filesystem on it at /data + * (arch/arm/src/rtl8720f/ameba_flash_mtd.c). + * + ****************************************************************************/ + +int ameba_flash_fs_initialize(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RTL8720F_RTL8720F_EVB_SRC_RTL8720F_RTL8720F_EVB_H */ diff --git a/boards/arm/rtl8721dx/pke8721daf/CMakeLists.txt b/boards/arm/rtl8721dx/pke8721daf/CMakeLists.txt new file mode 100644 index 00000000000..e0ad07f4636 --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/CMakeLists.txt @@ -0,0 +1,36 @@ +# ############################################################################## +# boards/arm/rtl8721dx/pke8721daf/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +# The RTL8721Dx (Ameba WHC) port currently builds via the make-based build only. +# The CMake path does not yet wire up the vendor-SDK machinery (SDK fetch, +# libameba_fwlib.a/libameba_wifi.a, the image2 entry ameba_app_start.c, the SDK +# image2 linker-script generation, the NP-image build and the app.bin packaging) +# that boards/.../scripts/Make.defs -> arch/.../ameba_board.mk provides, so a +# CMake configure would not produce a flashable image. Fail fast with a clear +# message instead of half-building. +message( + FATAL_ERROR + "pke8721daf (RTL8721Dx, Ameba WHC) currently supports the make build " + "only; CMake is not yet supported. Build with:\n" + " ./tools/configure.sh pke8721daf:nsh && make") + +add_subdirectory(src) diff --git a/boards/arm/rtl8721dx/pke8721daf/Kconfig b/boards/arm/rtl8721dx/pke8721daf/Kconfig new file mode 100644 index 00000000000..b4557bbc0b3 --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_PKE8721DAF +endif diff --git a/boards/arm/rtl8721dx/pke8721daf/configs/nsh/defconfig b/boards/arm/rtl8721dx/pke8721daf/configs/nsh/defconfig new file mode 100644 index 00000000000..2f53e98bbcd --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/configs/nsh/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_DEBUG_WARN is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="pke8721daf" +CONFIG_ARCH_BOARD_PKE8721DAF=y +CONFIG_ARCH_CHIP="rtl8721dx" +CONFIG_ARCH_CHIP_RTL8721DX=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV8M_SYSTICK=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DRIVERS_IEEE80211=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EXAMPLES_DHCPD=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_TMPFS=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_IOB_BUFSIZE=400 +CONFIG_IOB_NBUFFERS=100 +CONFIG_IOB_NCHAINS=36 +CONFIG_IOB_THROTTLE=40 +CONFIG_LIBC_MEMFD_ERROR=y +CONFIG_MM_DEFAULT_ALIGNMENT=32 +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETDEV_WIRELESS_IOCTL=y +CONFIG_NETUTILS_DHCPD=y +CONFIG_NETUTILS_DHCPD_ROUTERIP=0xc0a80401 +CONFIG_NETUTILS_DHCPD_STARTIP=0xc0a80402 +CONFIG_NETUTILS_IPERF=y +CONFIG_NET_ARP_IPIN=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_PKTSIZE=1514 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_TCP=y +CONFIG_NET_TCP_DELAYED_ACK=y +CONFIG_NET_TCP_KEEPALIVE=y +CONFIG_NET_TCP_NOTIFIER=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_VCONFIG=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=294912 +CONFIG_RAM_START=0x20020000 +CONFIG_RR_INTERVAL=200 +CONFIG_RTL8721DX_FLASH_FS=y +CONFIG_RTL8721DX_WIFI=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_LPWORK=y +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=16 +CONFIG_START_MONTH=6 +CONFIG_START_YEAR=2026 +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=2500 +CONFIG_SYSTEM_PING=y +CONFIG_TIMER=y +CONFIG_TIMER_ARCH=y +CONFIG_USEC_PER_TICK=1000 +CONFIG_WIRELESS=y +CONFIG_WIRELESS_WAPI=y +CONFIG_WIRELESS_WAPI_CMDTOOL=y diff --git a/boards/arm/rtl8721dx/pke8721daf/include/board.h b/boards/arm/rtl8721dx/pke8721daf/include/board.h new file mode 100644 index 00000000000..0a22dd96b35 --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/include/board.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * boards/arm/rtl8721dx/pke8721daf/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RTL8721DX_PKE8721DAF_INCLUDE_BOARD_H +#define __BOARDS_ARM_RTL8721DX_PKE8721DAF_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The SysTick/core clock is taken from the SDK's SystemCoreClock global at + * runtime (see arch/arm/src/rtl8721dx/ameba_timerisr.c), so no board-level + * clock constant is needed here. + */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RTL8721DX_PKE8721DAF_INCLUDE_BOARD_H */ diff --git a/boards/arm/rtl8721dx/pke8721daf/prebuilt/.gitignore b/boards/arm/rtl8721dx/pke8721daf/prebuilt/.gitignore new file mode 100644 index 00000000000..9c6c7a2acc3 --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/prebuilt/.gitignore @@ -0,0 +1,22 @@ +# Realtek RTL8721Dx vendor blobs and build artefacts. +# +# These are NOT NuttX source and must never be committed upstream (vendor +# blobs are kept out of the NuttX tree). They are vendor outputs from the +# ameba-rtos SDK, placed here by the integrator: +# +# libs/*.a pre-compiled chip archives (fwlib/hal/swlib/misc/...) +# km0_image2_all.bin prebuilt NP (WiFi/LP core) image2 blob +# platform_autoconf.h regenerated each build from the SDK menuconfig by +# ameba_gen_autoconf.sh (single source of truth) +# config_km4 / config_fw vendored SDK kconfig snapshots for axf2bin packaging +# +# Generated at build time: +# +# ld.script.gen[.tmp] combined image2 linker script +# project_km4/ staged include dir for ld preprocessing +# pkg/ axf2bin / firmware_package staging area +# +# Everything in this directory is ignored. + +* +!.gitignore diff --git a/boards/arm/rtl8721dx/pke8721daf/scripts/Make.defs b/boards/arm/rtl8721dx/pke8721daf/scripts/Make.defs new file mode 100644 index 00000000000..b3f0a24bd1d --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/scripts/Make.defs @@ -0,0 +1,33 @@ +############################################################################ +# boards/arm/rtl8721dx/pke8721daf/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. +# +############################################################################ + +# All RTL8721Dx board-build definitions (SDK include sets, fwlib/WiFi source +# lists, image2 linker-script generation, PREBUILD/POSTBUILD) live in the +# shared per-IC fragment so every board on this IC uses one copy. This board's +# own paths (prebuilt/ staging) derive from $(BOARD_DIR) inside it. + +include $(TOPDIR)/arch/arm/src/rtl8721dx/ameba_board.mk + +# Flashing via the SDK AmebaFlash.py (make flash AMEBA_PORT=/dev/ttyUSB0) + +AMEBA_FLASH_PROFILE = RTL8721Dx +include $(TOPDIR)/tools/ameba/Config.mk diff --git a/boards/arm/rtl8721dx/pke8721daf/src/CMakeLists.txt b/boards/arm/rtl8721dx/pke8721daf/src/CMakeLists.txt new file mode 100644 index 00000000000..dc5d6650e71 --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/src/CMakeLists.txt @@ -0,0 +1,27 @@ +# ############################################################################## +# boards/arm/rtl8721dx/pke8721daf/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +set(SRCS rtl8721dx_boot.c rtl8721dx_bringup.c) + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script") diff --git a/boards/arm/rtl8721dx/pke8721daf/src/Makefile b/boards/arm/rtl8721dx/pke8721daf/src/Makefile new file mode 100644 index 00000000000..957c553ddbe --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/src/Makefile @@ -0,0 +1,27 @@ +############################################################################ +# boards/arm/rtl8721dx/pke8721daf/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 = rtl8721dx_boot.c rtl8721dx_bringup.c + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_boot.c b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_boot.c new file mode 100644 index 00000000000..64fd6928cee --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_boot.c @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_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 <nuttx/arch.h> +#include <nuttx/board.h> + +#include "rtl8721dx_pke8721daf.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rtl8721dx_boardinitialize + * + * Description: + * All RTL8721Dx 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 rtl8721dx_boardinitialize(void) +{ + /* Board-specific early initialization. Nothing to do here. */ +} + +/**************************************************************************** + * Name: board_initialize + * + * Description: + * If CONFIG_BOARD_EARLY_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_initialize(). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_EARLY_INITIALIZE +void board_early_initialize(void) +{ + rtl8721dx_boardinitialize(); +} +#endif diff --git a/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_bringup.c b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_bringup.c new file mode 100644 index 00000000000..e091d1b96fe --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_bringup.c @@ -0,0 +1,190 @@ +/**************************************************************************** + * boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_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 <syslog.h> + +#include <nuttx/fs/fs.h> +#include <nuttx/board.h> + +#include "rtl8721dx_pke8721daf.h" + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* SDK ROM inter-core IPC-semaphore RTOS hooks. rtos_* come from the NuttX + * os_wrapper (ameba_os_wrap.c); IPC_* are SDK ROM symbols. RTL8721Dx's + * IPC_patch_function takes no lock-id argument. + */ + +extern void rtos_critical_enter(uint32_t component_id); +extern void rtos_critical_exit(uint32_t component_id); +extern void rtos_time_delay_ms(uint32_t ms); +extern void IPC_patch_function(void (*enter)(uint32_t), + void (*leave)(uint32_t)); +extern void IPC_SEMDelay(void (*delay)(uint32_t)); + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rtl8721dx_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int rtl8721dx_bringup(void) +{ + int ret = 0; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmp file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at /tmp: %d\n", ret); + } +#endif + +#ifdef CONFIG_RTL8721DX_FLASH_FS + /* Mount the persistent data filesystem (littlefs on the SPI NOR VFS1 + * partition) at /data before WiFi, so the WiFi KV store is available. + */ + + ret = ameba_flash_fs_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: ameba_flash_fs_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_RTL8721DX_WIFI + /* Bring up the KM4 IPC transport and start the WHC host WiFi stack. */ + + ret = rtl8721dx_wifi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rtl8721dx_wifi_initialize failed: %d\n", ret); + } +#endif + + /* Install the inter-core HW IPC-semaphore RTOS hooks LAST -- after all the + * flash / WHC bring-up above, and just before this (board_late_initialize) + * path returns and nx_start() hands off to the init task. + * + * The shared-flash / WHC paths take the hardware IPC semaphore to + * serialize against the NP; the ROM semaphore code then calls an RTOS + * critical-section pair plus a delay callback while a contended waiter + * waits. That delay callback rtos_time_delay_ms() blocks, so it is only + * safe from a real task. Registering it here means the bring-up flash + * access above (which runs in this pre-task context) uses the ROM default + * (busy-spin, no callback), while every runtime IPC-semaphore user that + * follows runs in a task and yields properly. + */ + + IPC_patch_function(rtos_critical_enter, rtos_critical_exit); + IPC_SEMDelay(rtos_time_delay_ms); + + return ret; +} + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL +int board_app_initialize(uintptr_t arg) +{ +#ifndef CONFIG_BOARD_LATE_INITIALIZE + /* Perform board initialization */ + + return rtl8721dx_bringup(); +#else + return OK; +#endif +} +#endif /* CONFIG_BOARDCTL */ + +/**************************************************************************** + * 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 immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board initialization */ + + rtl8721dx_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_pke8721daf.h b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_pke8721daf.h new file mode 100644 index 00000000000..a8f1906edcf --- /dev/null +++ b/boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_pke8721daf.h @@ -0,0 +1,86 @@ +/**************************************************************************** + * boards/arm/rtl8721dx/pke8721daf/src/rtl8721dx_pke8721daf.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RTL8721DX_PKE8721DAF_SRC_RTL8721DX_PKE8721DAF_H +#define __BOARDS_ARM_RTL8721DX_PKE8721DAF_SRC_RTL8721DX_PKE8721DAF_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Name: rtl8721dx_boardinitialize + * + * Description: + * Perform board-specific early initialization. + * + ****************************************************************************/ + +void rtl8721dx_boardinitialize(void); + +/**************************************************************************** + * Name: rtl8721dx_bringup + * + * Description: + * Bring up board features. + * + ****************************************************************************/ + +int rtl8721dx_bringup(void); + +#ifdef CONFIG_RTL8721DX_WIFI +/**************************************************************************** + * Name: rtl8721dx_wifi_initialize + * + * Description: + * Bring up the KM4 IPC transport and start the WHC host WiFi stack + * (arch/arm/src/rtl8721dx/ameba_wifi_init.c). + * + ****************************************************************************/ + +int rtl8721dx_wifi_initialize(void); +#endif + +#ifdef CONFIG_RTL8721DX_FLASH_FS +/**************************************************************************** + * Name: ameba_flash_fs_initialize + * + * Description: + * Register the on-chip SPI NOR data partition as an MTD device and mount + * a littlefs filesystem on it at /data + * (arch/arm/src/rtl8721dx/ameba_flash_mtd.c). + * + ****************************************************************************/ + +int ameba_flash_fs_initialize(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RTL8721DX_PKE8721DAF_SRC_RTL8721DX_PKE8721DAF_H */
