From e462f3e4f59118a760d7c1092648f07a524d1da5 Mon Sep 17 00:00:00 2001 From: singdoudu <1787825118@qq.com> Date: Mon, 23 Nov 2026 23:18:01 +0800 Subject: [PATCH 1/2] boards/h616: add Yuzuki Chameleon (H616) board support Board-level port of the Yuzuki Chameleon (Allwinner H616, quad-core Cortex-A53, 1 GB DDR3, on-board eMMC) to the vendor tree, following the layout of the r528 boards: - Kconfig with ARCH_BOARD_YUZUKI_H616 (depends on ARCH_CHIP_H616) - configs/nsh: SMP 4-core NSH defconfig; the board is selected through CONFIG_ARCH_BOARD_CUSTOM_* so no nuttx-side board list entry is needed - include/board.h, scripts/{Make.defs,dramboot.ld}: DRAM boot at 0x40000000 - src/: board init/bringup, reset, eMMC slot wiring (sdc2, 4-bit, HS400 capable), rcS/rc.sysinit packed into the /etc romfs via RCRAWS (GNU make) and nuttx_add_romfs (CMake) Depends on the H616 chip support (arch/arm64/src/h616) contributed to the open-vela nuttx repository; built and hardware-verified against that tree (boot, SMP, eMMC FAT on /mnt with files persisting across reboots). --- boards/h616/yuzuki-h616/.gitignore | 9 + boards/h616/yuzuki-h616/CMakeLists.txt | 23 ++ boards/h616/yuzuki-h616/Kconfig | 12 + boards/h616/yuzuki-h616/configs/nsh/defconfig | 110 ++++++ boards/h616/yuzuki-h616/include/board.h | 61 ++++ boards/h616/yuzuki-h616/scripts/Make.defs | 42 +++ boards/h616/yuzuki-h616/scripts/dramboot.ld | 137 +++++++ boards/h616/yuzuki-h616/src/CMakeLists.txt | 51 +++ boards/h616/yuzuki-h616/src/Makefile | 43 +++ .../yuzuki-h616/src/etc/init.d/rc.sysinit | 48 +++ boards/h616/yuzuki-h616/src/etc/init.d/rcS | 29 ++ boards/h616/yuzuki-h616/src/yuzuki-h616.h | 69 ++++ .../yuzuki-h616/src/yuzuki-h616_appinit.c | 74 ++++ .../yuzuki-h616/src/yuzuki-h616_boardinit.c | 110 ++++++ .../yuzuki-h616/src/yuzuki-h616_bringup.c | 337 ++++++++++++++++++ .../h616/yuzuki-h616/src/yuzuki-h616_reset.c | 62 ++++ .../h616/yuzuki-h616/src/yuzuki-h616_sdhci.c | 93 +++++ 17 files changed, 1310 insertions(+) create mode 100644 boards/h616/yuzuki-h616/.gitignore create mode 100644 boards/h616/yuzuki-h616/CMakeLists.txt create mode 100644 boards/h616/yuzuki-h616/Kconfig create mode 100644 boards/h616/yuzuki-h616/configs/nsh/defconfig create mode 100644 boards/h616/yuzuki-h616/include/board.h create mode 100644 boards/h616/yuzuki-h616/scripts/Make.defs create mode 100644 boards/h616/yuzuki-h616/scripts/dramboot.ld create mode 100644 boards/h616/yuzuki-h616/src/CMakeLists.txt create mode 100644 boards/h616/yuzuki-h616/src/Makefile create mode 100644 boards/h616/yuzuki-h616/src/etc/init.d/rc.sysinit create mode 100644 boards/h616/yuzuki-h616/src/etc/init.d/rcS create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616.h create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616_appinit.c create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616_boardinit.c create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616_bringup.c create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616_reset.c create mode 100644 boards/h616/yuzuki-h616/src/yuzuki-h616_sdhci.c diff --git a/boards/h616/yuzuki-h616/.gitignore b/boards/h616/yuzuki-h616/.gitignore new file mode 100644 index 00000000..5ec98a90 --- /dev/null +++ b/boards/h616/yuzuki-h616/.gitignore @@ -0,0 +1,9 @@ +*.o +*.depend +Make.dep +libboard.a +tags +cscope.* +.built +etctmp.c +etctmp diff --git a/boards/h616/yuzuki-h616/CMakeLists.txt b/boards/h616/yuzuki-h616/CMakeLists.txt new file mode 100644 index 00000000..e332040d --- /dev/null +++ b/boards/h616/yuzuki-h616/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/h616/yuzuki-h616/CMakeLists.txt +# +# 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_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/dramboot.ld") + +add_subdirectory(src) diff --git a/boards/h616/yuzuki-h616/Kconfig b/boards/h616/yuzuki-h616/Kconfig new file mode 100644 index 00000000..f39b6ab7 --- /dev/null +++ b/boards/h616/yuzuki-h616/Kconfig @@ -0,0 +1,12 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config ARCH_BOARD_YUZUKI_H616 + bool "Allwinner H616 based Yuzuki board" + depends on ARCH_CHIP_H616 + ---help--- + NuttX port for the Allwinner H616 based Yuzuki board. + On-board peripherals: 1GB/2GB/4GB DDR3L, eMMC (HS400 on 4-bit + bus), 4x 16550 UART, USB, HDMI. diff --git a/boards/h616/yuzuki-h616/configs/nsh/defconfig b/boards/h616/yuzuki-h616/configs/nsh/defconfig new file mode 100644 index 00000000..2b0f0ee4 --- /dev/null +++ b/boards/h616/yuzuki-h616/configs/nsh/defconfig @@ -0,0 +1,110 @@ +# +# 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_FACTORY_TEST is not set +# CONFIG_NSH_DISABLE_DATE is not set +CONFIG_16550_ADDRWIDTH=32 +CONFIG_16550_REGINCR=4 +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x05000000 +CONFIG_16550_UART0_CLOCK=24000000 +CONFIG_16550_UART0_DMA=y +CONFIG_16550_UART0_DMA_RX=1 +CONFIG_16550_UART0_DMA_RXBUFSIZE=4 +CONFIG_16550_UART0_DMA_TX=0 +CONFIG_16550_UART0_IRQ=32 +CONFIG_16550_UART0_RX_TRIGGER=0 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART1=y +CONFIG_16550_UART1_BASE=0x05000400 +CONFIG_16550_UART1_CLOCK=24000000 +CONFIG_16550_UART1_IRQ=33 +CONFIG_16550_UART2=y +CONFIG_16550_UART2_BASE=0x05000800 +CONFIG_16550_UART2_CLOCK=24000000 +CONFIG_16550_UART2_IRQ=34 +CONFIG_16550_UART3=y +CONFIG_16550_UART3_BASE=0x05000c00 +CONFIG_16550_UART3_CLOCK=24000000 +CONFIG_16550_UART3_IRQ=35 +CONFIG_16550_UART=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD_CUSTOM=y +CONFIG_ARCH_BOARD_CUSTOM_DIR="../vendor/allwinnertech/boards/h616/yuzuki-h616" +CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y +CONFIG_ARCH_BOARD_CUSTOM_NAME="nsh" +CONFIG_ARCH_BOARD_YUZUKI_H616=y +CONFIG_ARCH_CHIP="h616" +CONFIG_ARCH_CHIP_H616=y +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQPRIO=y +CONFIG_BCH_READAHEAD=64 +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=116524 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_ETC_ROMFS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_MMCDIAG=y +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_LFN=y +CONFIG_FRAME_POINTER=y +CONFIG_FS_BINFS=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_FS_TMPFS=y +CONFIG_H616_DMA=y +CONFIG_H616_SDHCI=y +CONFIG_H616_SDMMC_IRQ=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MMCSD=y +CONFIG_MMCSD_CHECK_READY_STATUS_WITHOUT_SLEEP=y +CONFIG_MMCSD_MULTIBLOCK_LIMIT=4096 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CMDOPT_DD_STATS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAMLOG_BUFSIZE=32768 +CONFIG_RAMLOG_SYSLOG=y +CONFIG_RAM_SIZE=1073741824 +CONFIG_RAM_START=0x40000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_BACKTRACE=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SMP=y +CONFIG_STACK_COLORATION=y +CONFIG_START_MONTH=9 +CONFIG_START_YEAR=2026 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSLOG_DEFAULT=y +CONFIG_SYSLOG_MAX_CHANNELS=2 +CONFIG_SYSLOG_TIMESTAMP=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_SYSTEM_TIME64=y +CONFIG_TESTING_GETPRIME=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/h616/yuzuki-h616/include/board.h b/boards/h616/yuzuki-h616/include/board.h new file mode 100644 index 00000000..d56edb0c --- /dev/null +++ b/boards/h616/yuzuki-h616/include/board.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/include/board.h + * + * 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_ARM64_H616_YUZUKI_H616_INCLUDE_BOARD_H +#define __BOARDS_ARM64_H616_YUZUKI_H616_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#define BOARD_SYSCLK_FREQUENCY 1008000000 /* CPU 1.008GHz (default) */ + +/* UART0 (console) **********************************************************/ + +#define BOARD_UART0_BASE 0x05000000 /* H616 UART0, DW 16550 */ +#define BOARD_UART0_IRQ 32 /* GIC SPI 0 + 32 */ +#define BOARD_UART0_CLOCK 24000000 /* OSC24M */ + +/* LED definitions **********************************************************/ + +/* Yuzuki H616 has a power LED; no user LED by default. */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 0 +#define LED_INIRQ 0 +#define LED_SIGNAL 0 +#define LED_ASSERTION 0 +#define LED_PANIC 0 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#endif /* __BOARDS_ARM64_H616_YUZUKI_H616_INCLUDE_BOARD_H */ diff --git a/boards/h616/yuzuki-h616/scripts/Make.defs b/boards/h616/yuzuki-h616/scripts/Make.defs new file mode 100644 index 00000000..34691111 --- /dev/null +++ b/boards/h616/yuzuki-h616/scripts/Make.defs @@ -0,0 +1,42 @@ +############################################################################ +# boards/h616/yuzuki-h616/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/arm64/src/Toolchain.defs + +LDSCRIPT = dramboot.ld + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +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__ + +# NXFLAT module definitions + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/h616/yuzuki-h616/scripts/dramboot.ld b/boards/h616/yuzuki-h616/scripts/dramboot.ld new file mode 100644 index 00000000..b4108167 --- /dev/null +++ b/boards/h616/yuzuki-h616/scripts/dramboot.ld @@ -0,0 +1,137 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/scripts/dramboot.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +OUTPUT_ARCH(aarch64) + +ENTRY(__start) + +PHDRS +{ + text PT_LOAD ; +} + +SECTIONS +{ + . = 0x40080000; /* U-Boot loads NuttX at this address (kernel_addr_r) */ + _start = .; + .text : { + _stext = .; /* Text section */ + *(.start .start.*) /* Place __start here */ + *(.text) + *(.text.cold) + *(.text.unlikely) + *(.fixup) + *(.gnu.warning) + } :text = 0x9090 + + . = ALIGN(4096); + + .init_section : { + _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(.); + } + + . = ALIGN(4096); + + .vector : { + _vector_start = .; + KEEP(*(.exc_vector_table)) + KEEP(*(".exc_vector_table.*")) + KEEP(*(.vectors)) + _vector_end = .; + } :text + . = ALIGN(4096); + _etext = .; /* End_1 of .text */ + _sztext = _etext - _stext; + + . = ALIGN(4096); + .rodata : { + _srodata = .; /* Read-only data */ + *(.rodata) + *(.rodata.*) + *(.data.rel.ro) + *(.data.rel.ro.*) + } :text + . = ALIGN(4096); + _erodata = .; /* End of read-only data */ + _szrodata = _erodata - _srodata; + _eronly = .; /* End of read-only data */ + + . = ALIGN(4096); + .data : { /* Data */ + _sdata = .; + *(.data.page_aligned) + *(.data) + . = ALIGN(8); + *(.data.rel) + *(.data.rel.*) + CONSTRUCTORS + } :text + _edata = .; /* End+1 of .data */ + + .bss (NOLOAD) : { /* BSS (cleared by arm64_data_initialize at boot) */ + . = ALIGN(8); + _sbss = .; + *(.bss) + /* -ffunction-sections/-fdata-sections emit .bss.; + * without this glob they become orphan PROGBITS output sections + * and get zero-padded into the load image. */ + *(.bss.*) + *(COMMON) + . = ALIGN(8); + } :text + . = ALIGN(4096); + _ebss = .; + _szbss = _ebss - _sbss; + + .initstack (NOLOAD) : { /* INIT STACK (no image content; only symbols) */ + _s_initstack = .; + *(.initstack) + . = ALIGN(16); + } :text + . = ALIGN(4096); + _e_initstack = . ; + g_idle_topstack = . ; + + _szdata = _e_initstack - _sdata; + + /* Sections to be discarded */ + /DISCARD/ : { + *(.exit.text) + *(.exit.data) + *(.exitcall.exit) + *(.eh_frame) + *(.note) + *(.note.*) + } + + /* 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) } +} diff --git a/boards/h616/yuzuki-h616/src/CMakeLists.txt b/boards/h616/yuzuki-h616/src/CMakeLists.txt new file mode 100644 index 00000000..8945b1ce --- /dev/null +++ b/boards/h616/yuzuki-h616/src/CMakeLists.txt @@ -0,0 +1,51 @@ +# ############################################################################## +# boards/h616/yuzuki-h616/src/CMakeLists.txt +# +# 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 yuzuki-h616_boardinit.c yuzuki-h616_bringup.c) + +if(CONFIG_H616_SDHCI) + list(APPEND SRCS yuzuki-h616_sdhci.c) +endif() + +if(CONFIG_BOARDCTL) + list(APPEND SRCS yuzuki-h616_appinit.c) + if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS yuzuki-h616_reset.c) + endif() +endif() + +if(CONFIG_ETC_ROMFS) + # rcS/rc.sysinit are NSH scripts, NOT C sources: they go into romfs verbatim + # via RCRAWS (RCSRCS would run them through the C preprocessor, and '# + # comment' lines then break the build). Keep them NSH-clean. + set(RCRAWS etc/init.d/rc.sysinit etc/init.d/rcS) + + nuttx_add_romfs( + NAME + etc + MOUNTPOINT + etc + RCRAWS + ${RCRAWS} + PATH + ${CMAKE_CURRENT_LIST_DIR}/etc) + target_link_libraries(board PRIVATE romfs_etc) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/h616/yuzuki-h616/src/Makefile b/boards/h616/yuzuki-h616/src/Makefile new file mode 100644 index 00000000..17de2973 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/Makefile @@ -0,0 +1,43 @@ +############################################################################ +# boards/h616/yuzuki-h616/src/Makefile +# +# 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 = yuzuki-h616_boardinit.c yuzuki-h616_bringup.c + +ifeq ($(CONFIG_H616_SDHCI),y) +CSRCS += yuzuki-h616_sdhci.c +endif + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += yuzuki-h616_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += yuzuki-h616_reset.c +endif +endif + +# rcS/rc.sysinit are shell scripts: use RCRAWS so they are copied verbatim +# instead of being run through the C preprocessor like RCSRCS files are. + +ifeq ($(CONFIG_ETC_ROMFS),y) +RCRAWS = etc/init.d/rcS etc/init.d/rc.sysinit +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/h616/yuzuki-h616/src/etc/init.d/rc.sysinit b/boards/h616/yuzuki-h616/src/etc/init.d/rc.sysinit new file mode 100644 index 00000000..6ea54d70 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/etc/init.d/rc.sysinit @@ -0,0 +1,48 @@ +# ############################################################################ +# boards/h616/yuzuki-h616/src/etc/init.d/rc.sysinit +# +# 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. +# +# ############################################################################ + +# rc.sysinit - openvela H616 system init (NSH executes line by line) +# '#' lines are ignored by NSH. This file goes into romfs verbatim. + +set +e +set TZ Asia/Shanghai + +# /proc is mounted by the board bringup and /etc by NSH itself; only the +# pseudo file systems the kernel does not provide are mounted here. +mount -t tmpfs none /tmp +mount -t binfs none /bin + +# Mount the eMMC vfat partition registered by the board bringup. The volume +# spans the whole eMMC above the raw boot regions; on the very first boot +# (or after a partition layout change) it has no file system yet, so format +# it once and retry the mount. +mkdir /mnt +mount -t vfat /dev/mmcsd0p1 /mnt +if [ $? -ne 0 ] +then + mkfatfs -F 32 /dev/mmcsd0p1 + mount -t vfat /dev/mmcsd0p1 /mnt +fi + +# Self check: listing the volume is what tells a working bus from a +# silently broken one. +ls /mnt diff --git a/boards/h616/yuzuki-h616/src/etc/init.d/rcS b/boards/h616/yuzuki-h616/src/etc/init.d/rcS new file mode 100644 index 00000000..d759654b --- /dev/null +++ b/boards/h616/yuzuki-h616/src/etc/init.d/rcS @@ -0,0 +1,29 @@ +# ############################################################################ +# boards/h616/yuzuki-h616/src/etc/init.d/rcS +# +# 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. +# +# ############################################################################ + +# rcS - openvela H616 startup script (NSH executes line by line) +# '#' lines are ignored by NSH. This file goes into romfs verbatim. + +set +e + +# To start a program automatically at boot, append: & +# For example: hello & diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616.h b/boards/h616/yuzuki-h616/src/yuzuki-h616.h new file mode 100644 index 00000000..befb140c --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616.h @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616.h + * + * 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_ARM64_H616_YUZUKI_H616_SRC_YUZUKI_H616_H +#define __BOARDS_ARM64_H616_YUZUKI_H616_SRC_YUZUKI_H616_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: yuzuki_h616_bringup + * + * Description: + * Perform architecture-specific initialization + * + ****************************************************************************/ + +int yuzuki_h616_bringup(void); + +/**************************************************************************** + * Name: yuzuki_h616_sdhci_initialize + * + * Description: + * Initialize the SDIO interface for the on-board eMMC (sdc2) and bind it + * to the MMC/SD driver. + * + ****************************************************************************/ + +#ifdef CONFIG_H616_SDHCI +int yuzuki_h616_sdhci_initialize(void); +#endif + +#endif /* __BOARDS_ARM64_H616_YUZUKI_H616_SRC_YUZUKI_H616_H */ diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616_appinit.c b/boards/h616/yuzuki-h616/src/yuzuki-h616_appinit.c new file mode 100644 index 00000000..46fd5fe4 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616_appinit.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616_appinit.c + * + * 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 "yuzuki-h616.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ + UNUSED(arg); + + /* Bring up the board peripherals late, once the system is fully up + * (NSH time): the eMMC needs the full scheduler, syslog and clock tree + * to complete the bus-speed ladder safely. + */ + + return yuzuki_h616_bringup(); +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616_boardinit.c b/boards/h616/yuzuki-h616/src/yuzuki-h616_boardinit.c new file mode 100644 index 00000000..42afd615 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616_boardinit.c @@ -0,0 +1,110 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616_boardinit.c + * + * 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 "yuzuki-h616.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: h616_memory_initialize + * + * Description: + * All H616 architectures must provide the following entry point. This + * entry point is called early in the initialization before memory has + * been configured. This board-specific function is responsible for + * configuring any on-board memories. + * + * Logic in h616_memory_initialize must be careful to avoid using any + * global variables because those will be uninitialized at the time this + * function is called. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void h616_memory_initialize(void) +{ + /* DRAM was initialized by the bootloader (boot0 / U-Boot) in the + * supported configurations. + */ +} + +/**************************************************************************** + * Name: h616_board_initialize + * + * Description: + * All H616 architectures must provide the following entry point. This + * entry point is called in the initialization phase -- after + * h616_memory_initialize and after all memory has been configured and + * mapped but before any devices have been initialized. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void h616_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * 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) +{ + /* The eMMC is brought up from board_app_initialize (NSH time) instead: + * bringing it up earlier was not reliable before the system was fully + * up. Nothing to do here. + */ +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616_bringup.c b/boards/h616/yuzuki-h616/src/yuzuki-h616_bringup.c new file mode 100644 index 00000000..093b58b1 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616_bringup.c @@ -0,0 +1,337 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616_bringup.c + * + * 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 +#include +#include +#include +#include + +#include "yuzuki-h616.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The vfat partition covers the whole eMMC above the raw boot regions + * (sectors of 512 bytes). Everything the boot chain needs lives below the + * start: the GPT at LBA 0, boot0 at LBA 16 (96 sectors), the U-Boot + * environment at LBA 98304 (256 sectors) and boot.img at LBA 131072 (1044 + * sectors, so it ends at 132116). 133120 is the next 1 MiB boundary and + * leaves a small guard gap after boot.img. + */ + +#define H616_EMMC_VFAT_START_SECTORS 133120 + +#define H616_EMMC_VFAT_DEV "/dev/mmcsd0p1" +#define H616_EMMC_DEV "/dev/mmcsd0" + +/* IDMAC probe. Once the AHB data path has brought the card all the way + * up, try the internal DMA path: read a block and byte compare + * against the AHB result, write/read/compare a scratch sector, measure + * multiblock read throughput. Any failure flips back to AHB so the mount + * below can never be taken down by the probe. + * + * Scratch sector: the guard gap between boot.img (ends ~LBA 132116) and the + * vfat partition (starts at LBA 133120); nothing lives there. + */ + +#define H616_IDMA_PROBE_LBA 0x20000u /* boot.img header (ANDROID! magic) */ +#define H616_IDMA_SCRATCH_LBA 0x20600u /* guard gap, safe to clobber */ +#define H616_IDMA_SPEED_CHUNK 64 /* sectors per timed read */ + +/* Provided by the H616 SDHCI driver (arch/arm64/src/h616/h616_sdhci.c). */ + +extern void h616_sdhci_set_datapath(int use_ahb); +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: yuzuki_h616_idma_probe + * + * Description: + * Try the internal DMA (IDMAC) data path once the AHB path has the card + * working: read a block and byte compare against the AHB result, do a + * write/read/compare on a scratch sector in the guard gap, then measure + * multiblock read throughput. Any failure flips back to AHB so the mount + * below can never be taken down by the probe. + * + * Input Parameters: + * None + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure. + * + ****************************************************************************/ + +static int yuzuki_h616_idma_probe(void) +{ + static uint8_t ctl[512] __attribute__((aligned(16))); + static uint8_t dma[512] __attribute__((aligned(16))); + static uint8_t save[512] __attribute__((aligned(16))); + static uint8_t + big[512 * H616_IDMA_SPEED_CHUNK] __attribute__((aligned(16))); + FAR struct inode *inode; + clock_t start; + clock_t ticks; + uint32_t sectors = 0; + uint32_t kbs; + uint32_t i; + int ret; + + ret = open_blockdriver(H616_EMMC_DEV, 0, &inode); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: no block driver: %d\n", ret); + return ret; + } + + /* Control read on the AHB path (the one the boot verified) */ + + ret = inode->u.i_bops->read(inode, ctl, H616_IDMA_PROBE_LBA, 1); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: AHB control read failed: %d\n", ret); + goto out; + } + + /* Switch to the IDMAC and read the same block */ + + h616_sdhci_set_datapath(0); + ret = inode->u.i_bops->read(inode, dma, H616_IDMA_PROBE_LBA, 1); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: DMA read failed: %d, back to AHB\n", ret); + goto fail; + } + + if (memcmp(ctl, dma, 512) != 0) + { + syslog(LOG_ERR, "IDMAC: DMA read data mismatch, back to AHB\n"); + goto fail; + } + + syslog(LOG_INFO, "IDMAC: single block read verified (lba %08x)\n", + H616_IDMA_PROBE_LBA); + + /* Save the scratch sector, write a pattern through the IDMAC, read it + * back, then restore the original content. + */ + + ret = inode->u.i_bops->read(inode, save, H616_IDMA_SCRATCH_LBA, 1); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: scratch save failed: %d\n", ret); + goto fail; + } + + for (i = 0; i < 512; i += 4) + { + dma[i] = 0xa5; dma[i + 1] = 0x5a; dma[i + 2] = i; dma[i + 3] = i >> 8; + } + + ret = inode->u.i_bops->write(inode, dma, H616_IDMA_SCRATCH_LBA, 1); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: DMA write failed: %d, back to AHB\n", ret); + goto restore; + } + + memset(ctl, 0, sizeof(ctl)); + ret = inode->u.i_bops->read(inode, ctl, H616_IDMA_SCRATCH_LBA, 1); + if (ret < 0 || memcmp(ctl, dma, 512) != 0) + { + syslog(LOG_ERR, "IDMAC: DMA write verify failed: %d, back to AHB\n", + ret); + goto restore; + } + + syslog(LOG_INFO, "IDMAC: single block write verified (lba %08x)\n", + H616_IDMA_SCRATCH_LBA); + +restore: + /* Restore the scratch sector whatever happened above (AHB path is fine + * for the restore if the IDMAC write path is the broken one). + */ + + h616_sdhci_set_datapath(1); + ret = inode->u.i_bops->write(inode, save, H616_IDMA_SCRATCH_LBA, 1); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: scratch restore failed: %d\n", ret); + } + + /* Multiblock throughput on the IDMAC path */ + + h616_sdhci_set_datapath(0); + start = clock_systime_ticks(); + while (clock_systime_ticks() - start < 1000) + { + ret = inode->u.i_bops->read(inode, big, + H616_IDMA_PROBE_LBA, + H616_IDMA_SPEED_CHUNK); + if (ret < 0) + { + syslog(LOG_ERR, "IDMAC: multiblock read failed: %d, back to AHB\n", + ret); + goto fail; + } + + sectors += H616_IDMA_SPEED_CHUNK; + } + + ticks = clock_systime_ticks() - start; + kbs = ticks > 0 ? (uint32_t)(((uint64_t)sectors * 512u / 1024u) * 1000u / + (uint64_t)ticks) : 0; + syslog(LOG_INFO, "IDMAC: %u sectors in %ld ticks = %u KB/s " + "-- IDMAC left enabled\n", (unsigned)sectors, (long)ticks, + (unsigned)kbs); + goto out; + +fail: + h616_sdhci_set_datapath(1); + syslog(LOG_INFO, "IDMAC: probe failed, eMMC stays on the AHB path\n"); +out: + close_blockdriver(inode); + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: yuzuki_h616_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_LIB_BOARDCTL=y: + * Called from the NSH library + * + * CONFIG_BOARD_LATE_INITIALIZE=y: + * Called from board_late_initialize + * + ****************************************************************************/ + +int yuzuki_h616_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount("procfs", "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#if defined(CONFIG_H616_SDHCI) && defined(CONFIG_H616_SDHCI_INIT_AT_BOOT) + /* Initialize the on-board eMMC (sdc2) and bind it to the MMC/SD driver. + * CONFIG_H616_SDHCI_INIT_AT_BOOT can be disabled for eMMC debugging so + * that boot issues no data command and 'mmcdiag k 0' becomes the first + * data command after a power-on reset. + */ + + ret = yuzuki_h616_sdhci_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize eMMC: %d\n", ret); + } + else + { + /* Carve the last H616_EMMC_VFAT_SECTORS sectors of the eMMC out as a + * block partition and register it as /dev/mmcsd0p1. A block device + * node can not be written through open() (see fs_open.c: the VFS + * returns -ENXIO for a block inode), so a file system has to be + * mounted on it; rc.sysinit mounts /dev/mmcsd0p1 on /mnt as vfat. + */ + + FAR struct inode *inode; + struct geometry geo; + + ret = open_blockdriver(H616_EMMC_DEV, MS_RDONLY, &inode); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: No block driver at %s: %d\n", + H616_EMMC_DEV, ret); + } + else + { + ret = (inode->u.i_bops->geometry != NULL) ? + inode->u.i_bops->geometry(inode, &geo) : -ENOSYS; + close_blockdriver(inode); + + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: No geometry for %s: %d\n", + H616_EMMC_DEV, ret); + } + else if (geo.geo_nsectors <= H616_EMMC_VFAT_START_SECTORS) + { + syslog(LOG_ERR, "ERROR: eMMC too small: %ld sectors\n", + (long)geo.geo_nsectors); + } + else + { + off_t nsectors = (off_t)geo.geo_nsectors; + off_t first = H616_EMMC_VFAT_START_SECTORS; + off_t length = nsectors - first; + + syslog(LOG_INFO, + "eMMC: %ld sectors, vfat partition %s = [%ld, %ld)\n", + (long)nsectors, H616_EMMC_VFAT_DEV, (long)first, + (long)nsectors); + + ret = register_blockpartition(H616_EMMC_VFAT_DEV, 0666, + H616_EMMC_DEV, first, length); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to register %s: %d\n", + H616_EMMC_VFAT_DEV, ret); + } + else + { + /* Try the IDMAC data path now that the card is up on AHB; + * it flips back to AHB by itself on any failure. + */ + + yuzuki_h616_idma_probe(); + } + } + } + } +#endif + + return ret; +} diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616_reset.c b/boards/h616/yuzuki-h616/src/yuzuki-h616_reset.c new file mode 100644 index 00000000..d7a4172d --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616_reset.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616_reset.c + * + * 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 + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/h616/yuzuki-h616/src/yuzuki-h616_sdhci.c b/boards/h616/yuzuki-h616/src/yuzuki-h616_sdhci.c new file mode 100644 index 00000000..87bbe026 --- /dev/null +++ b/boards/h616/yuzuki-h616/src/yuzuki-h616_sdhci.c @@ -0,0 +1,93 @@ +/**************************************************************************** + * boards/h616/yuzuki-h616/src/yuzuki-h616_sdhci.c + * + * Board-level wiring for the H616 eMMC (sdc2) SDIO controller. + * + * 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 "yuzuki-h616.h" +#include "h616_sdhci.h" + +#ifdef CONFIG_H616_SDHCI + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define H616_SDIO_SLOTNO 0 /* sdc2 = slot 0 */ +#define H616_SDIO_MINOR 0 /* /dev/mmcsd0 */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: yuzuki_h616_sdhci_initialize + * + * Description: + * Initialize the SDIO interface for the on-board eMMC (sdc2) and bind it + * to the MMC/SD driver. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure. + * + ****************************************************************************/ + +int yuzuki_h616_sdhci_initialize(void) +{ + FAR struct sdio_dev_s *sdio_dev; + int ret; + + _info("Initializing SDIO slot %d\n", H616_SDIO_SLOTNO); + + sdio_dev = sdio_initialize(H616_SDIO_SLOTNO); + if (sdio_dev == NULL) + { + _err("ERROR: Failed to initialize SDIO slot %d\n", H616_SDIO_SLOTNO); + return -ENODEV; + } + + _info("Bind SDIO to the MMC/SD driver, minor=%d\n", H616_SDIO_MINOR); + + ret = mmcsd_slotinitialize(H616_SDIO_MINOR, sdio_dev); + if (ret != OK) + { + _err("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + return ret; + } + + /* eMMC is non-removable and always present */ + + sdio_mediachange(sdio_dev, true); + + _info("Successfully bound SDIO to the MMC/SD driver\n"); + return OK; +} + +#endif /* CONFIG_H616_SDHCI */ From cd0110e09cb1c9071213933117745157ab42b858 Mon Sep 17 00:00:00 2001 From: singdoudu <1787825118@qq.com> Date: Mon, 23 Nov 2026 23:18:01 +0800 Subject: [PATCH 2/2] docs(h616): add bilingual README for the Yuzuki H616 board Describe the hardware, directory layout, build entry point and the DRAM/FEL boot flow, mirroring the r528s3-gemini-s1 README structure. --- boards/h616/yuzuki-h616/README.md | 74 +++++++++++++++++++++++++ boards/h616/yuzuki-h616/README_zh-cn.md | 68 +++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 boards/h616/yuzuki-h616/README.md create mode 100644 boards/h616/yuzuki-h616/README_zh-cn.md diff --git a/boards/h616/yuzuki-h616/README.md b/boards/h616/yuzuki-h616/README.md new file mode 100644 index 00000000..3c832c16 --- /dev/null +++ b/boards/h616/yuzuki-h616/README.md @@ -0,0 +1,74 @@ +# Yuzuki Chameleon (H616) Board Support for openvela + +\[ English | [简体中文](README_zh-cn.md) \] + +## Overview + +This directory provides the openvela board support package (BSP) for the +**Yuzuki Chameleon** development board (Allwinner H616 platform). + +Key hardware specifications: + +- **SoC**: Allwinner H616, quad-core Arm Cortex-A53 (SMP, 4 cores online) +- **Memory**: 1 GB DDR3 (2 GB/4 GB variants exist) +- **Storage**: on-board eMMC (29 GB on the tested board), 4-bit bus with + interrupt-driven CIU + IDMAC transfers +- **Console**: 16550 UART0, 115200 8N1, with optional DMA on Tx/Rx +- **Interfaces**: 4x 16550 UART, USB, HDMI, GPIO + +The port boots NuttX from DRAM: the board's boot0/U-Boot (or the FEL +boot chain) loads `nuttx.bin` into DRAM and jumps to it, so the port does +not depend on any on-board bootloader bits. + +> **Note**: this board depends on the Allwinner H616 chip support +> (`arch/arm64/src/h616`) contributed to the openvela nuttx repository. +> Please make sure your nuttx source tree contains the H616 chip port +> before building this board. + +## Directory Structure + +``` +yuzuki-h616/ +├── Kconfig # Board-level Kconfig options +├── include/ # Board headers (board.h) +├── src/ # Board bring-up sources (init, reset, eMMC slot, etc) +├── scripts/ # Linker script and build rules (Make.defs, dramboot.ld) +└── configs/ # Build configurations + └── nsh # NSH shell configuration (SMP 4 cores, eMMC at /mnt) +``` + +## Build + +The `build.sh` script at the openvela project root is the unified build +entry point: + +```bash +# Optional: only needed when switching configs or after menuconfig changes +./build.sh vendor/allwinnertech/boards/h616/yuzuki-h616/configs/nsh -j8 distclean + +# Build +./build.sh vendor/allwinnertech/boards/h616/yuzuki-h616/configs/nsh -j8 +``` + +The resulting image is `nuttx/nuttx.bin`. + +## Firmware Packaging and Deployment + +The board boots `nuttx.bin` directly from DRAM. Wrap it with the +Allwinner boot chain (boot0/U-Boot) into a `boot.img` and flash it over +FEL, or load it over the FEL/UART download path. For the general +porting and flashing flow, refer to: + +- [Development Board adaptation cases](https://github.com/open-vela/docs/blob/dev-ai-contest-2026/en/dev_board/Development_Board.md) +- [Chip Porting guide](https://github.com/open-vela/docs/blob/dev-ai-contest-2026/en/chip_porting/porting_guide.md) + +## Verified behaviour + +- SMP: `ps` shows CPU0..CPU3 idle threads, affinity mask 0x0f. +- eMMC: FAT filesystem on `/dev/mmcsd0p1` mounted at `/mnt`; files + persist across reboots; sequential write ~15 MB/s, read ~75 MB/s. +- Console: UART0, 115200 8N1; boot log also available via `dmesg`. + +## License + +Files in this directory follow the license declared in each file's header. diff --git a/boards/h616/yuzuki-h616/README_zh-cn.md b/boards/h616/yuzuki-h616/README_zh-cn.md new file mode 100644 index 00000000..a05690d8 --- /dev/null +++ b/boards/h616/yuzuki-h616/README_zh-cn.md @@ -0,0 +1,68 @@ +# 百变龙 Yuzuki Chameleon(H616)开发板对 openvela 的支持 + +\[ [English](README.md) | 简体中文 \] + +## 简介 + +本目录为 **Yuzuki Chameleon**(全志 H616 平台)开发板提供 openvela 板级支持(BSP)。 + +主要硬件规格: + +- **主控**:全志 H616,四核 Arm Cortex-A53(SMP,4 核在线) +- **内存**:1 GB DDR3(另有 2 GB/4 GB 版本) +- **存储**:板载 eMMC(实测板为 29 GB),4-bit 总线,中断驱动 CIU + IDMAC 传输 +- **控制台**:16550 UART0,115200 8N1,Tx/Rx 可选 DMA +- **接口**:4 路 16550 UART、USB、HDMI、GPIO + +本移植从 DRAM 启动 NuttX:板载 boot0/U-Boot(或 FEL 下载链)将 +`nuttx.bin` 载入 DRAM 后跳转执行,不依赖任何板载 bootloader 专用位。 + +> **注意**:本板依赖提交到 openvela nuttx 仓库的全志 H616 芯片层支持 +> (`arch/arm64/src/h616`)。编译本板前,请确认 nuttx 源码树中已包含 +> H616 芯片移植。 + +## 目录结构 + +``` +yuzuki-h616/ +├── Kconfig # 板级 Kconfig 选项 +├── include/ # 板级头文件(board.h) +├── src/ # 板级 bring-up 源码(初始化、复位、eMMC 插槽等) +├── scripts/ # 链接脚本与构建规则(Make.defs、dramboot.ld) +└── configs/ # 编译配置 + └── nsh # NSH 命令行配置(SMP 4 核,eMMC 挂载于 /mnt) +``` + +## 编译 + +openvela 工程根目录的 `build.sh` 是统一编译入口: + +```bash +# 可选:仅在切换配置或修改 menuconfig 后需要清理 +./build.sh vendor/allwinnertech/boards/h616/yuzuki-h616/configs/nsh -j8 distclean + +# 编译 +./build.sh vendor/allwinnertech/boards/h616/yuzuki-h616/configs/nsh -j8 +``` + +编译产物为 `nuttx/nuttx.bin`。 + +## 固件打包与部署 + +本板直接从 DRAM 启动 `nuttx.bin`:可将其与全志启动链 +(boot0/U-Boot)封装为 `boot.img` 后经 FEL 烧录,或经 FEL/UART +下载路径载入。通用移植与烧录流程请参考: + +- [开发板适配案例](https://github.com/open-vela/docs/blob/dev-ai-contest-2026/zh-cn/dev_board/Development_Board.md) +- [芯片移植(Chip Porting)章节](https://github.com/open-vela/docs/blob/dev-ai-contest-2026/zh-cn/chip_porting/porting_guide.md) + +## 已验证行为 + +- SMP:`ps` 显示 CPU0..CPU3 idle 线程,affinity 掩码 0x0f。 +- eMMC:`/dev/mmcsd0p1` 上的 FAT 文件系统挂载于 `/mnt`;文件重启后 + 保留;顺序写约 15 MB/s,读约 75 MB/s。 +- 控制台:UART0,115200 8N1;启动日志可通过 `dmesg` 回看。 + +## 许可协议 + +本目录下文件遵循各自文件头部声明的许可协议。