From cf6781efade76f7f369673d7e83c3f9728de408e Mon Sep 17 00:00:00 2001 From: Lup Yuen Lee Date: Mon, 17 Mar 2025 16:36:23 +0800 Subject: [PATCH] boards/arm64/a527/avaota-a1: Add support for PINE64 Yuzuki Avaota-A1 SBC (Allwinner A527 SoC) This PR adds support for the PINE64 Yuzuki Avaota-A1 SBC, based on Allwinner A527 Arm64 SoC. Most of the code was derived from NuttX for QEMU Arm64 Kernel Build qemu-armv8a:knsh. The modified code is explained here: https://lupyuen.github.io/articles/avaota#appendix-port-nuttx-to-avaota-a1 Modified Files: boards/Kconfig: Added Avaota-A1 board New Files in boards/arm64/a527/avaota-a1: src/a527_appinit.c: Startup Code src/a527_boardinit.c: Init Code src/a527_bringup.c: Bringup Code src/a527_power.c: Power Off and Reset src/avaota-a1.h: Board Declarations include/board.h: Board Definitions include/board_memorymap.h: Memory Map scripts/ld.script, gnu-elf.ld: Linker Scripts Makefile, scripts/Make.defs: Makefiles CMakeLists.txt, src/CMakeLists.txt: CMakefiles Kconfig: Avaota-A1 Config configs/nsh/defconfig: Build Config for avaota-a1:nsh Signed-off-by: Lup Yuen Lee --- boards/Kconfig | 12 ++ boards/arm64/a527/avaota-a1/CMakeLists.txt | 25 +++ boards/arm64/a527/avaota-a1/Kconfig | 0 .../a527/avaota-a1/configs/nsh/defconfig | 108 ++++++++++++ boards/arm64/a527/avaota-a1/include/board.h | 61 +++++++ .../a527/avaota-a1/include/board_memorymap.h | 66 +++++++ boards/arm64/a527/avaota-a1/scripts/Make.defs | 57 ++++++ .../arm64/a527/avaota-a1/scripts/gnu-elf.ld | 134 ++++++++++++++ boards/arm64/a527/avaota-a1/scripts/ld.script | 163 ++++++++++++++++++ .../arm64/a527/avaota-a1/src/CMakeLists.txt | 28 +++ boards/arm64/a527/avaota-a1/src/Makefile | 31 ++++ .../arm64/a527/avaota-a1/src/a527_appinit.c | 75 ++++++++ .../arm64/a527/avaota-a1/src/a527_boardinit.c | 115 ++++++++++++ .../arm64/a527/avaota-a1/src/a527_bringup.c | 136 +++++++++++++++ boards/arm64/a527/avaota-a1/src/a527_power.c | 72 ++++++++ boards/arm64/a527/avaota-a1/src/avaota-a1.h | 60 +++++++ 16 files changed, 1143 insertions(+) create mode 100644 boards/arm64/a527/avaota-a1/CMakeLists.txt create mode 100644 boards/arm64/a527/avaota-a1/Kconfig create mode 100644 boards/arm64/a527/avaota-a1/configs/nsh/defconfig create mode 100644 boards/arm64/a527/avaota-a1/include/board.h create mode 100644 boards/arm64/a527/avaota-a1/include/board_memorymap.h create mode 100644 boards/arm64/a527/avaota-a1/scripts/Make.defs create mode 100644 boards/arm64/a527/avaota-a1/scripts/gnu-elf.ld create mode 100644 boards/arm64/a527/avaota-a1/scripts/ld.script create mode 100644 boards/arm64/a527/avaota-a1/src/CMakeLists.txt create mode 100644 boards/arm64/a527/avaota-a1/src/Makefile create mode 100644 boards/arm64/a527/avaota-a1/src/a527_appinit.c create mode 100644 boards/arm64/a527/avaota-a1/src/a527_boardinit.c create mode 100644 boards/arm64/a527/avaota-a1/src/a527_bringup.c create mode 100644 boards/arm64/a527/avaota-a1/src/a527_power.c create mode 100644 boards/arm64/a527/avaota-a1/src/avaota-a1.h diff --git a/boards/Kconfig b/boards/Kconfig index 356d8d80af..caed909e28 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2319,6 +2319,14 @@ config ARCH_BOARD_IMX93_EVK This options selects support for NuttX on the NXP i.MX93 CPUs EVK board with ARM Cortex-A55. +config ARCH_BOARD_AVAOTA_A1 + bool "PINE64 Yuzuki Avaota-A1" + depends on ARCH_CHIP_SUNXI_A527 + select ARCH_HAVE_IRQBUTTONS + ---help--- + This option selects support for NuttX on PINE64 Yuzuki Avaota-A1 + based on Allwinner A527 SoC with ARM Cortex-A55. + config ARCH_BOARD_ZCU111 bool "XilinX ZCU111 development board" depends on ARCH_CHIP_ZYNQ_MPSOC @@ -3574,6 +3582,7 @@ config ARCH_BOARD default "fvp-armv8r-aarch32" if ARCH_BOARD_FVP_ARMV8R_AARCH32 default "imx8qm-mek" if ARCH_BOARD_IMX8QM_MEK default "imx93-evk" if ARCH_BOARD_IMX93_EVK + default "avaota-a1" if ARCH_BOARD_AVAOTA_A1 default "zcu111" if ARCH_BOARD_ZCU111 default "sama5d2-xult" if ARCH_BOARD_SAMA5D2_XULT default "giant-board" if ARCH_BOARD_GIANT_BOARD @@ -3809,6 +3818,9 @@ endif if ARCH_BOARD_IMX93_EVK source "boards/arm64/imx9/imx93-evk/Kconfig" endif +if ARCH_BOARD_AVAOTA_A1 +source "boards/arm64/a527/avaota-a1/Kconfig" +endif if ARCH_BOARD_ZCU111 source "boards/arm64/zynq-mpsoc/zcu111/Kconfig" endif diff --git a/boards/arm64/a527/avaota-a1/CMakeLists.txt b/boards/arm64/a527/avaota-a1/CMakeLists.txt new file mode 100644 index 0000000000..4d7ebdaa5e --- /dev/null +++ b/boards/arm64/a527/avaota-a1/CMakeLists.txt @@ -0,0 +1,25 @@ +# ############################################################################## +# boards/arm64/a527/avaota-a1/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_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script") + +add_subdirectory(src) diff --git a/boards/arm64/a527/avaota-a1/Kconfig b/boards/arm64/a527/avaota-a1/Kconfig new file mode 100644 index 0000000000..e69de29bb2 diff --git a/boards/arm64/a527/avaota-a1/configs/nsh/defconfig b/boards/arm64/a527/avaota-a1/configs/nsh/defconfig new file mode 100644 index 0000000000..fba87e794f --- /dev/null +++ b/boards/arm64/a527/avaota-a1/configs/nsh/defconfig @@ -0,0 +1,108 @@ +# +# 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_16550_ADDRWIDTH=0 +CONFIG_16550_REGINCR=4 +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x02500000 +CONFIG_16550_UART0_CLOCK=23040000 +CONFIG_16550_UART0_IRQ=34 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART=y +CONFIG_16550_WAIT_LCR=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ADDRENV=y +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD="avaota-a1" +CONFIG_ARCH_BOARD_AVAOTA_A1=y +CONFIG_ARCH_CHIP="a527" +CONFIG_ARCH_CHIP_SUNXI=y +CONFIG_ARCH_CHIP_SUNXI_A527=y +CONFIG_ARCH_DATA_NPAGES=0 +CONFIG_ARCH_DATA_VBASE=0xC0000000 +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_HEAP_NPAGES=0 +CONFIG_ARCH_HEAP_VBASE=0x00000000 +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_KERNEL_STACKSIZE=8192 +CONFIG_ARCH_KMAP_NPAGES=4096 +CONFIG_ARCH_KMAP_VBASE=0x7F000000 +CONFIG_ARCH_PGPOOL_MAPPING=y +CONFIG_ARCH_PGPOOL_PBASE=0x40A00000 +CONFIG_ARCH_PGPOOL_SIZE=4194304 +CONFIG_ARCH_PGPOOL_VBASE=0x40A00000 +CONFIG_ARCH_SHM_NPAGES=4096 +CONFIG_ARCH_SHM_VBASE=0xFF000000 +CONFIG_ARCH_TEXT_NPAGES=0 +CONFIG_ARCH_TEXT_VBASE=0x00000000 +CONFIG_ARCH_USE_MMU=y +CONFIG_ARM64_STRING_FUNCTION=y +CONFIG_BOARDCTL_ROMDISK=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BUILD_KERNEL=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_DEVICE_TREE=y +CONFIG_ELF=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_FS_ROMFS=y +CONFIG_FS_SHMFS=y +CONFIG_HAVE_CXX=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_FILEPATH="/system/bin/init" +CONFIG_INIT_MOUNT=y +CONFIG_INIT_MOUNT_FLAGS=0x1 +CONFIG_INIT_MOUNT_TARGET="/system/bin" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_ENVPATH=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBC_MAX_EXITFUNS=16 +CONFIG_LIBC_PERROR_STDOUT=y +CONFIG_LIBC_STRERROR=y +CONFIG_LIBM=y +CONFIG_MM_KMAP=y +CONFIG_MM_PGALLOC=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_FILE_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_PATH_INITIAL="/system/bin" +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=134217728 +CONFIG_RAM_START=0x40000000 +CONFIG_RAM_VSTART=0x40000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SIG_DEFAULT=y +CONFIG_SPINLOCK=y +CONFIG_STACK_COLORATION=y +CONFIG_START_MONTH=3 +CONFIG_START_YEAR=2022 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_PROGNAME="init" +CONFIG_SYSTEM_TIME64=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm64/a527/avaota-a1/include/board.h b/boards/arm64/a527/avaota-a1/include/board.h new file mode 100644 index 0000000000..24321e53f6 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/include/board.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/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_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_H +#define __BOARDS_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * 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_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_H */ diff --git a/boards/arm64/a527/avaota-a1/include/board_memorymap.h b/boards/arm64/a527/avaota-a1/include/board_memorymap.h new file mode 100644 index 0000000000..cba5c426b4 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/include/board_memorymap.h @@ -0,0 +1,66 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/include/board_memorymap.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_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/* Memory Region for RAM Disk */ + +extern uint8_t __ramdisk_start[]; +extern uint8_t __ramdisk_size[]; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM64_A527_AVAOTA_A1_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/arm64/a527/avaota-a1/scripts/Make.defs b/boards/arm64/a527/avaota-a1/scripts/Make.defs new file mode 100644 index 0000000000..0de7ee42fa --- /dev/null +++ b/boards/arm64/a527/avaota-a1/scripts/Make.defs @@ -0,0 +1,57 @@ +############################################################################ +# boards/arm64/a527/avaota-a1/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 = ld.script +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 + +# ELF module definitions + +CMODULEFLAGS = $(CFLAGS) + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +SHMODULEFLAGS = -Bsymbolic -G -Bdynamic + +CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs +CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs diff --git a/boards/arm64/a527/avaota-a1/scripts/gnu-elf.ld b/boards/arm64/a527/avaota-a1/scripts/gnu-elf.ld new file mode 100644 index 0000000000..e0e981c9dd --- /dev/null +++ b/boards/arm64/a527/avaota-a1/scripts/gnu-elf.ld @@ -0,0 +1,134 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/scripts/gnu-elf.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. + * + ****************************************************************************/ + +SECTIONS +{ + .text : + { + _stext = . ; + *(.text) + *(.text.*) + *(.gnu.warning) + *(.stub) + *(.glue_7) + *(.glue_7t) + *(.jcr) + + /* C++ support: The .init and .fini sections contain specific logic + * to manage static constructors and destructors. + */ + + *(.gnu.linkonce.t.*) + *(.init) /* Old ABI */ + *(.fini) /* Old ABI */ + _etext = . ; + } + + .rodata : + { + _srodata = . ; + *(.rodata) + *(.rodata1) + *(.rodata.*) + *(.gnu.linkonce.r*) + _erodata = . ; + } + + .data : + { + _sdata = . ; + *(.data) + *(.data1) + *(.data.*) + *(.gnu.linkonce.d*) + . = ALIGN(4); + _edata = . ; + } + + /* C++ support. For each global and static local C++ object, + * GCC creates a small subroutine to construct the object. Pointers + * to these routines (not the routines themselves) are stored as + * simple, linear arrays in the .ctors section of the object file. + * Similarly, pointers to global/static destructor routines are + * stored in .dtors. + */ + + .ctors : + { + _sctors = . ; + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _ectors = . ; + } + + .dtors : + { + _sdtors = . ; + KEEP (*(.dtors)) /* Old ABI: Unallocated */ + KEEP (*(.fini_array)) /* New ABI: Allocated */ + KEEP (*(SORT(.fini_array.*))) + _edtors = . ; + } + + .bss : + { + _sbss = . ; + *(.bss) + *(.bss.*) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.b*) + *(COMMON) + _ebss = . ; + } + + /* Thread local storage support */ + + .tdata : + { + _stdata = ABSOLUTE(.); + KEEP (*(.tdata .tdata.* .gnu.linkonce.td.*)); + _etdata = ABSOLUTE(.); + } + + .tbss : + { + _stbss = ABSOLUTE(.); + KEEP (*(.tbss .tbss.* .gnu.linkonce.tb.* .tcommon)); + _etbss = ABSOLUTE(.); + } + + /* Stabs debugging sections */ + + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm64/a527/avaota-a1/scripts/ld.script b/boards/arm64/a527/avaota-a1/scripts/ld.script new file mode 100644 index 0000000000..caf0047d03 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/scripts/ld.script @@ -0,0 +1,163 @@ +/**************************************************************************** + * boards/risc-v/a527-rv/rv-virt/scripts/ld.script + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +OUTPUT_ARCH(aarch64) + +ENTRY(__start) +EXTERN(__start) + +MEMORY +{ + dram (rwx) : ORIGIN = 0x40800000, LENGTH = 2M + pgram (rwx) : ORIGIN = 0x40A00000, LENGTH = 4M /* w/ cache */ + ramdisk (rwx) : ORIGIN = 0x40E00000, LENGTH = 16M /* w/ cache */ +} + +/* Application RAM Disk */ + +__ramdisk_start = ORIGIN(ramdisk); +__ramdisk_size = LENGTH(ramdisk); +__ramdisk_end = ORIGIN(ramdisk) + LENGTH(ramdisk); + +PHDRS +{ + /* R = 100, W = 010, X = 001 */ + + text PT_LOAD FLAGS(5); /* RX */ + rodata PT_LOAD FLAGS(4); /* R */ + data PT_LOAD FLAGS(6); /* RW */ +} + +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); /* Text section */ + *(.start .start.*) /* Place __start here */ + *(.text .text.*) + *(.text.cold) + *(.text.unlikely) + *(.fixup) + *(.gnu.warning) + } > dram :text + + .init_section : + { + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array .ctors)) + _einit = ABSOLUTE(.); + } > dram :text + + /* Vector table must be page aligned */ + + .vector : ALIGN(4096) + { + _vector_start = ABSOLUTE(.); + KEEP(*(.exc_vector_table)) + KEEP(*(".exc_vector_table.*")) + KEEP(*(.vectors)) + _vector_end = ABSOLUTE(.); + } > dram :text + + /* End of text data must be aligned to page boundary */ + + . = ALIGN(4096); + _etext = .; + _sztext = _etext - _stext; + + /* Start of RO data must be page aligned (mapped as read only) */ + + .rodata : ALIGN(4096) + { + _srodata = ABSOLUTE(.); /* Read-only data */ + *(.rodata .rodata.*) + *(.data.rel.ro) + *(.data.rel.ro.*) + } > dram :rodata + + /* End of RO data must be page aligned */ + + . = ALIGN(4096); + + _erodata = .; /* End of read-only data */ + _szrodata = _erodata - _srodata; + _eronly = .; + + .data : ALIGN(4096) + { + _sdata = ABSOLUTE(.); + *(.data.page_aligned) + *(.data .data.*) + . = ALIGN(8); + *(.data.rel) + *(.data.rel.*) + CONSTRUCTORS + . = ALIGN(8); + _edata = ABSOLUTE(.); + } > dram :data + + .bss : + { + . = ALIGN(8); + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + . = ALIGN(8); + _ebss = ABSOLUTE(.); + } > dram :data + + _szbss = _ebss - _sbss; + + .initstack : + { + _s_initstack = ABSOLUTE(.); + *(.initstack) + } > dram :data + + /* End of data must be page aligned */ + + . = ALIGN(4096); + + g_idle_topstack = .; + _e_initstack = .; + _szdata = _e_initstack - _sdata; + + /* Sections to be discarded */ + + /DISCARD/ : + { + *(.exit.text) + *(.exit.data) + *(.exitcall.exit) + *(.eh_frame) + } + + /* 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/arm64/a527/avaota-a1/src/CMakeLists.txt b/boards/arm64/a527/avaota-a1/src/CMakeLists.txt new file mode 100644 index 0000000000..5d5787cb95 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/CMakeLists.txt @@ -0,0 +1,28 @@ +# ############################################################################## +# boards/arm64/a527/avaota-a1/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 a527_boardinit.c a527_bringup.c) + +if(CONFIG_BOARDCTL) + list(APPEND SRCS a527_appinit.c a527_power.c) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm64/a527/avaota-a1/src/Makefile b/boards/arm64/a527/avaota-a1/src/Makefile new file mode 100644 index 0000000000..850462fddf --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/Makefile @@ -0,0 +1,31 @@ +############################################################################ +# boards/arm64/a527/avaota-a1/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 = a527_boardinit.c a527_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += a527_appinit.c a527_power.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm64/a527/avaota-a1/src/a527_appinit.c b/boards/arm64/a527/avaota-a1/src/a527_appinit.c new file mode 100644 index 0000000000..19d758eedc --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/a527_appinit.c @@ -0,0 +1,75 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/src/a527_appinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include "avaota-a1.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); +#ifndef CONFIG_BOARD_LATE_INITIALIZE + /* Perform board initialization */ + + return a527_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/arm64/a527/avaota-a1/src/a527_boardinit.c b/boards/arm64/a527/avaota-a1/src/a527_boardinit.c new file mode 100644 index 0000000000..979a35c049 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/a527_boardinit.c @@ -0,0 +1,115 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/src/a527_boardinit.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include "avaota-a1.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: a527_memory_initialize + * + * Description: + * All A527 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 memory. + * + * Logic in a527_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 a527_memory_initialize(void) +{ + /* SDRAM is already initialized by the bootloader */ +} + +/**************************************************************************** + * Name: a527_board_initialize + * + * Description: + * All A527 architectures must provide the following entry point. This + * entry point is called in the initialization phase -- after + * a527_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 a527_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected */ + +#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_intitialize() 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 */ + + a527_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm64/a527/avaota-a1/src/a527_bringup.c b/boards/arm64/a527/avaota-a1/src/a527_bringup.c new file mode 100644 index 0000000000..afb542d160 --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/a527_bringup.c @@ -0,0 +1,136 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/src/a527_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include "avaota-a1.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* RAM Disk Definition */ + +#define SECTORSIZE 512 +#define NSECTORS(b) (((b) + SECTORSIZE - 1) / SECTORSIZE) +#define RAMDISK_DEVICE_MINOR 0 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: mount_ramdisk + * + * Description: + * Mount a RAM Disk defined in ld.script to /dev/ramX. The RAM Disk + * contains a ROMFS filesystem with applications that can be spawned at + * runtime. + * + * Returned Value: + * OK is returned on success. + * -ERRORNO is returned on failure. + * + ****************************************************************************/ + +static int mount_ramdisk(void) +{ + int ret; + struct boardioc_romdisk_s desc; + + desc.minor = RAMDISK_DEVICE_MINOR; + desc.nsectors = NSECTORS((ssize_t)__ramdisk_size); + desc.sectsize = SECTORSIZE; + desc.image = __ramdisk_start; + + ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc); + if (ret < 0) + { + syslog(LOG_ERR, "Ramdisk register failed: %s\n", strerror(errno)); + syslog(LOG_ERR, "Ramdisk mountpoint /dev/ram%d\n", + RAMDISK_DEVICE_MINOR); + syslog(LOG_ERR, "Ramdisk length %lu, origin %lx\n", + (ssize_t)__ramdisk_size, (uintptr_t)__ramdisk_start); + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: a527_bringup + * + * Description: + * Bring up the board features. + * + ****************************************************************************/ + +int a527_bringup(void) +{ + int ret; + +#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_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 + + /* Mount the RAM Disk */ + + ret = mount_ramdisk(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount RAM Disk: %d\n", ret); + } + + return OK; +} diff --git a/boards/arm64/a527/avaota-a1/src/a527_power.c b/boards/arm64/a527/avaota-a1/src/a527_power.c new file mode 100644 index 0000000000..ee0e4c824d --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/a527_power.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/src/a527_power.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifdef CONFIG_BOARDCTL_POWEROFF +int board_power_off(int status) +{ + up_systempoweroff(); + return 0; +} +#endif + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * 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. The + * 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/arm64/a527/avaota-a1/src/avaota-a1.h b/boards/arm64/a527/avaota-a1/src/avaota-a1.h new file mode 100644 index 0000000000..d97445273d --- /dev/null +++ b/boards/arm64/a527/avaota-a1/src/avaota-a1.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * boards/arm64/a527/avaota-a1/src/avaota-a1.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_ARM64_A527_AVAOTA_A1_SRC_AVAOTA_A1_H +#define __BOARDS_ARM64_A527_AVAOTA_A1_SRC_AVAOTA_A1_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: a527_bringup + * + * Description: + * Bring up the board features. + * + ****************************************************************************/ + +#if defined(CONFIG_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE) +int a527_bringup(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM64_A527_AVAOTA_A1_SRC_AVAOTA_A1_H */