This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fe718b397dc0b5dfeec41646d78b93b8c26b0eaf Author: Piyush Patle <[email protected]> AuthorDate: Wed May 20 08:01:01 2026 +0530 boards/arm64/am62x: add BeaglePlay and PocketBeagle2 Add initial board support for BeaglePlay and PocketBeagle2, including defconfigs, linker scripts, board initialization, procfs bring-up, and LED stubs. BeaglePlay provides the validated runtime target for this bring-up series. Signed-off-by: Piyush Patle <[email protected]> --- boards/Kconfig | 26 +++ boards/arm64/am62x/beagleplay/CMakeLists.txt | 23 +++ boards/arm64/am62x/beagleplay/Kconfig | 9 + .../arm64/am62x/beagleplay/configs/nsh/defconfig | 63 +++++++ .../am62x/beagleplay/configs/ostest/defconfig | 60 ++++++ boards/arm64/am62x/beagleplay/include/board.h | 76 ++++++++ .../am62x/beagleplay/include/board_memorymap.h | 30 +++ boards/arm64/am62x/beagleplay/scripts/Make.defs | 44 +++++ boards/arm64/am62x/beagleplay/scripts/dramboot.ld | 96 ++++++++++ boards/arm64/am62x/beagleplay/src/CMakeLists.txt | 29 +++ boards/arm64/am62x/beagleplay/src/Makefile | 35 ++++ boards/arm64/am62x/beagleplay/src/beagleplay.h | 80 ++++++++ .../am62x/beagleplay/src/beagleplay_autoleds.c | 82 +++++++++ .../am62x/beagleplay/src/beagleplay_boardinit.c | 94 ++++++++++ .../am62x/beagleplay/src/beagleplay_bringup.c | 77 ++++++++ boards/arm64/am62x/pocketbeagle2/CMakeLists.txt | 23 +++ boards/arm64/am62x/pocketbeagle2/Kconfig | 12 ++ .../am62x/pocketbeagle2/configs/nsh/defconfig | 65 +++++++ .../am62x/pocketbeagle2/configs/ostest/defconfig | 60 ++++++ boards/arm64/am62x/pocketbeagle2/include/board.h | 97 ++++++++++ .../am62x/pocketbeagle2/include/board_memorymap.h | 60 ++++++ boards/arm64/am62x/pocketbeagle2/scripts/Make.defs | 44 +++++ .../arm64/am62x/pocketbeagle2/scripts/dramboot.ld | 202 +++++++++++++++++++++ boards/arm64/am62x/pocketbeagle2/scripts/uEnv.txt | 10 + .../arm64/am62x/pocketbeagle2/src/CMakeLists.txt | 29 +++ boards/arm64/am62x/pocketbeagle2/src/Makefile | 35 ++++ .../arm64/am62x/pocketbeagle2/src/pocketbeagle2.h | 80 ++++++++ .../pocketbeagle2/src/pocketbeagle2_autoleds.c | 82 +++++++++ .../pocketbeagle2/src/pocketbeagle2_boardinit.c | 94 ++++++++++ .../pocketbeagle2/src/pocketbeagle2_bringup.c | 86 +++++++++ 30 files changed, 1803 insertions(+) diff --git a/boards/Kconfig b/boards/Kconfig index c0bcea97ea6..2a6a401dd15 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -2501,6 +2501,24 @@ config ARCH_BOARD_PINEPHONE This options selects support for NuttX on PINE64 PinePhone based on Allwinner A64 SoC with ARM Cortex-A53. +config ARCH_BOARD_POCKETBEAGLE2 + bool "BeagleBoard.org PocketBeagle 2" + depends on ARCH_CHIP_AM62X + select ARCH_HAVE_LEDS + ---help--- + BeagleBoard.org PocketBeagle 2 based on TI AM6254 SoC. + Quad Cortex-A53, 512 MB DDR4, USB-UART console on UART0. + https://docs.beagleboard.org/boards/pocketbeagle-2/ + +config ARCH_BOARD_BEAGLEPLAY + bool "BeagleBoard.org BeaglePlay" + depends on ARCH_CHIP_AM62X + select ARCH_HAVE_LEDS + ---help--- + BeagleBoard.org BeaglePlay based on TI AM6254 SoC. + Quad Cortex-A53, 2 GB LPDDR4, GbE, WiFi/BT, mikro-BUS. + https://docs.beagleboard.org/boards/beagleplay/ + config ARCH_BOARD_PINEPHONE_PRO bool "PINE64 PinePhonePro" depends on ARCH_CHIP_RK3399 @@ -3887,6 +3905,8 @@ config ARCH_BOARD default "qemu-armv8a" if ARCH_BOARD_QEMU_ARMV8A default "pinephone" if ARCH_BOARD_PINEPHONE default "pinephonepro" if ARCH_BOARD_PINEPHONE_PRO + default "pocketbeagle2" if ARCH_BOARD_POCKETBEAGLE2 + default "beagleplay" if ARCH_BOARD_BEAGLEPLAY default "nanopi_m4" if ARCH_BOARD_NANOPI_M4 default "fvp-armv8r" if ARCH_BOARD_FVP_ARMV8R default "fvp-armv8r-aarch32" if ARCH_BOARD_FVP_ARMV8R_AARCH32 @@ -4126,6 +4146,12 @@ endif if ARCH_BOARD_PINEPHONE_PRO source "boards/arm64/rk3399/pinephonepro/Kconfig" endif +if ARCH_BOARD_POCKETBEAGLE2 +source "boards/arm64/am62x/pocketbeagle2/Kconfig" +endif +if ARCH_BOARD_BEAGLEPLAY +source "boards/arm64/am62x/beagleplay/Kconfig" +endif if ARCH_BOARD_FVP_ARMV8R source "boards/arm64/fvp-v8r/fvp-armv8r/Kconfig" endif diff --git a/boards/arm64/am62x/beagleplay/CMakeLists.txt b/boards/arm64/am62x/beagleplay/CMakeLists.txt new file mode 100644 index 00000000000..25c7af7ab7b --- /dev/null +++ b/boards/arm64/am62x/beagleplay/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm64/am62x/pocketbeagle2/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. +# +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/arm64/am62x/beagleplay/Kconfig b/boards/arm64/am62x/beagleplay/Kconfig new file mode 100644 index 00000000000..fc242919478 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/Kconfig @@ -0,0 +1,9 @@ +# +# boards/arm64/am62x/beagleplay/Kconfig +# + +if ARCH_BOARD_BEAGLEPLAY + +comment "BeaglePlay Configuration" + +endif # ARCH_BOARD_BEAGLEPLAY diff --git a/boards/arm64/am62x/beagleplay/configs/nsh/defconfig b/boards/arm64/am62x/beagleplay/configs/nsh/defconfig new file mode 100644 index 00000000000..649e9eefff8 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/configs/nsh/defconfig @@ -0,0 +1,63 @@ +# +# 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_POLLING=y +CONFIG_16550_SET_MCR_OUT2=y +CONFIG_16550_SUPRESS_INITIAL_CONFIG=y +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x02800000 +CONFIG_16550_UART0_CLOCK=48000000 +CONFIG_16550_UART0_IRQ=210 +CONFIG_16550_UART0_RX_TRIGGER=0 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD="beagleplay" +CONFIG_ARCH_BOARD_BEAGLEPLAY=y +CONFIG_ARCH_CHIP="am62x" +CONFIG_ARCH_CHIP_AM62X=y +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQPRIO=y +CONFIG_BOARD_LOOPSPERMSEC=100000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SCHED=y +CONFIG_DEBUG_SCHED_ERROR=y +CONFIG_DEBUG_SCHED_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=536870912 +CONFIG_RAM_START=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SPINLOCK=y +CONFIG_STACK_COLORATION=y +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm64/am62x/beagleplay/configs/ostest/defconfig b/boards/arm64/am62x/beagleplay/configs/ostest/defconfig new file mode 100644 index 00000000000..b176934628a --- /dev/null +++ b/boards/arm64/am62x/beagleplay/configs/ostest/defconfig @@ -0,0 +1,60 @@ +# +# 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_POLLING=y +CONFIG_16550_SET_MCR_OUT2=y +CONFIG_16550_SUPRESS_INITIAL_CONFIG=y +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x02800000 +CONFIG_16550_UART0_CLOCK=48000000 +CONFIG_16550_UART0_IRQ=210 +CONFIG_16550_UART0_RX_TRIGGER=0 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD="beagleplay" +CONFIG_ARCH_BOARD_BEAGLEPLAY=y +CONFIG_ARCH_CHIP="am62x" +CONFIG_ARCH_CHIP_AM62X=y +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQPRIO=y +CONFIG_BOARD_LOOPSPERMSEC=100000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SCHED=y +CONFIG_DEBUG_SCHED_ERROR=y +CONFIG_DEBUG_SCHED_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="ostest_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=536870912 +CONFIG_RAM_START=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SPINLOCK=y +CONFIG_STACK_COLORATION=y +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_STACKSIZE=16384 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm64/am62x/beagleplay/include/board.h b/boards/arm64/am62x/beagleplay/include/board.h new file mode 100644 index 00000000000..deb50cf9177 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/include/board.h @@ -0,0 +1,76 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/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. + * + ****************************************************************************/ + +/* BeaglePlay board definitions */ + +#ifndef __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_H +#define __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#define BOARD_UART_SCLK 48000000ul /* 48 MHz UART functional clock */ +#define BOARD_ARCH_TIMER_FREQ 200000000ul /* 200 MHz ARM generic timer */ + +/* LED definitions ********************************************************* + * + * BeaglePlay user LEDs + * + * LED index Net name GPIO + * 0 USR0 GPIO1_22 (green) + * 1 USR1 GPIO1_23 (yellow) + * 2 USR2 GPIO1_24 (red) + * 3 USR3 GPIO1_25 (blue) + */ + +#define BOARD_LED_USR0 0 +#define BOARD_LED_USR1 1 +#define BOARD_LED_USR2 2 +#define BOARD_LED_USR3 3 +#define BOARD_NLEDS 4 + +#define BOARD_LED_USR0_BIT (1 << BOARD_LED_USR0) +#define BOARD_LED_USR1_BIT (1 << BOARD_LED_USR1) +#define BOARD_LED_USR2_BIT (1 << BOARD_LED_USR2) +#define BOARD_LED_USR3_BIT (1 << BOARD_LED_USR3) + +/* LED encoded OS states */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 1 +#define LED_IRQSENABLED 2 +#define LED_STACKCREATED 3 +#define LED_INIRQ 4 +#define LED_SIGNAL 5 +#define LED_ASSERTION 6 +#define LED_PANIC 7 + +#endif /* __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_H */ diff --git a/boards/arm64/am62x/beagleplay/include/board_memorymap.h b/boards/arm64/am62x/beagleplay/include/board_memorymap.h new file mode 100644 index 00000000000..feae2717055 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/include/board_memorymap.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/include/board_memorymap.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * BeaglePlay (AM6254) — 2 GB LPDDR4 at 0x8000_0000. + * NuttX load address = 0x8200_0000 to avoid the DDR region reserved by + * the BeagleBoard.org U-Boot environment. + * Device space = 0x0000_0000 – 0x7FFF_FFFF (2 GB). + * + * defconfig uses only the first 512 MB so images are portable between + * BeaglePlay and PocketBeagle 2. Increase CONFIG_RAM_SIZE to use more. + ****************************************************************************/ + +#ifndef __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#define BEAGLEPLAY_DEVICEIO_BASE 0x00000000ul +#define BEAGLEPLAY_DEVICEIO_SIZE 0x80000000ul +#define BEAGLEPLAY_DDR_BASE 0x80000000ul +#define BEAGLEPLAY_DDR_SIZE 0x20000000ul /* 512 MB window */ +#define BEAGLEPLAY_LOAD_ADDR 0x82000000ul + +#endif /* __BOARDS_ARM64_AM62X_BEAGLEPLAY_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/arm64/am62x/beagleplay/scripts/Make.defs b/boards/arm64/am62x/beagleplay/scripts/Make.defs new file mode 100644 index 00000000000..eabe705e9e2 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/scripts/Make.defs @@ -0,0 +1,44 @@ +############################################################################ +# boards/arm64/am62x/pocketbeagle2/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__ + +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/arm64/am62x/beagleplay/scripts/dramboot.ld b/boards/arm64/am62x/beagleplay/scripts/dramboot.ld new file mode 100644 index 00000000000..36a47d4aba6 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/scripts/dramboot.ld @@ -0,0 +1,96 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/scripts/dramboot.ld + * + * SPDX-License-Identifier: Apache-2.0 + * + * BeaglePlay (AM6254) linker script. + * Load address 0x8200_0000 avoids U-Boot reserved region at DDR base. + * Identical in structure to the PocketBeagle 2 script; kept separate so + * each board can diverge independently. + * + ****************************************************************************/ + +OUTPUT_ARCH(aarch64) +ENTRY(__start) + +PHDRS { text PT_LOAD ; } + +SECTIONS +{ + . = 0x82000000; + _start = .; + + .text : + { + _stext = .; + *(.start .start.*) + *(.text) *(.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(.); + } :text + + . = ALIGN(4096); + + .vector : + { + _vector_start = .; + KEEP(*(.exc_vector_table)) KEEP(*(.exc_vector_table.*)) KEEP(*(.vectors)) + _vector_end = .; + } :text + + . = ALIGN(4096); + _etext = .; _sztext = _etext - _stext; + + . = ALIGN(4096); + .rodata : + { + _srodata = .; + *(.rodata) *(.rodata.*) *(.data.rel.ro) *(.data.rel.ro.*) + } :text + . = ALIGN(4096); + _erodata = .; _szrodata = _erodata - _srodata; _eronly = .; + + . = ALIGN(4096); + .data : + { + _sdata = .; + *(.data.page_aligned) *(.data) *(.data.*) + . = ALIGN(8); + *(.data.rel) *(.data.rel.*) + CONSTRUCTORS + } :text + _edata = .; + + .bss : + { + . = ALIGN(8); _sbss = .; + *(.bss) *(.bss.*) *(COMMON) + . = ALIGN(8); + } :text + . = ALIGN(4096); + _ebss = .; _szbss = _ebss - _sbss; + + .initstack : + { + _s_initstack = .; + *(.initstack) + . = ALIGN(16); + } :text + . = ALIGN(4096); + _e_initstack = .; g_idle_topstack = .; + _szdata = _e_initstack - _sdata; + + /DISCARD/ : { *(.exit.text) *(.exit.data) *(.exitcall.exit) *(.eh_frame) } + + .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } + .comment 0 : { *(.comment) } +} diff --git a/boards/arm64/am62x/beagleplay/src/CMakeLists.txt b/boards/arm64/am62x/beagleplay/src/CMakeLists.txt new file mode 100644 index 00000000000..f89fba7c2af --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/CMakeLists.txt @@ -0,0 +1,29 @@ +# ############################################################################## +# boards/arm64/am62x/beagleplay/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. +# +# ############################################################################## + +list(APPEND SRCS beagleplay_boardinit.c beagleplay_bringup.c) + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS beagleplay_autoleds.c) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm64/am62x/beagleplay/src/Makefile b/boards/arm64/am62x/beagleplay/src/Makefile new file mode 100644 index 00000000000..dd2af2cd73d --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/Makefile @@ -0,0 +1,35 @@ +############################################################################ +# boards/arm64/am62x/beagleplay/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 + +# Board-specific C sources (always compiled) + +CSRCS = beagleplay_boardinit.c beagleplay_bringup.c + +# Automatic LED support + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += beagleplay_autoleds.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm64/am62x/beagleplay/src/beagleplay.h b/boards/arm64/am62x/beagleplay/src/beagleplay.h new file mode 100644 index 00000000000..60bbbfd7e61 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/beagleplay.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/src/beagleplay.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_AM62X_BEAGLEPLAY_SRC_BEAGLEPLAY_H +#define __BOARDS_ARM64_AM62X_BEAGLEPLAY_SRC_BEAGLEPLAY_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: beagleplay_bringup + * + * Description: + * Bring up board-level drivers and subsystems. Called from + * board_late_initialize(). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +int beagleplay_bringup(void); +#endif + +/**************************************************************************** + * Name: beagleplay_led_initialize + * + * Description: + * Configure the user LEDs as GPIO outputs. Called from + * am62x_board_initialize() when CONFIG_ARCH_LEDS is set. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void beagleplay_led_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM64_AM62X_BEAGLEPLAY_SRC_BEAGLEPLAY_H */ diff --git a/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c b/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c new file mode 100644 index 00000000000..f1fdaddef92 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/src/beagleplay_autoleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* GPIO-backed LED support is not implemented yet for the AM62x boards. + * Keep the ARCH_LEDS hooks as explicit no-ops until the GPIO work lands. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/board.h> +#include <arch/board/board.h> +#include "beagleplay.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: beagleplay_led_initialize + * + * Description: + * Configure LED GPIO pins as outputs, all OFF initially. + * Stubbed until the GPIO driver is available. + * + ****************************************************************************/ + +void beagleplay_led_initialize(void) +{ + /* TODO: configure GPIO pins for the user LEDs once GPIO support exists. */ +} + +/**************************************************************************** + * Name: board_autoled_on + * + * Description: + * Turn ON the LED(s) associated with the OS event 'led'. + * + ****************************************************************************/ + +void board_autoled_on(int led) +{ + UNUSED(led); +} + +/**************************************************************************** + * Name: board_autoled_off + * + * Description: + * Turn OFF the LED(s) associated with the OS event 'led'. + * + ****************************************************************************/ + +void board_autoled_off(int led) +{ + UNUSED(led); +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm64/am62x/beagleplay/src/beagleplay_boardinit.c b/boards/arm64/am62x/beagleplay/src/beagleplay_boardinit.c new file mode 100644 index 00000000000..5b9b6c4992d --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/beagleplay_boardinit.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/src/beagleplay_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 <nuttx/config.h> +#include <stdint.h> +#include <nuttx/board.h> +#include "beagleplay.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: am62x_memory_initialize + * + * Description: + * Called from the very early boot path (before .bss is zeroed or .data + * is initialised) to perform any board-level memory bring-up such as + * DRAM training. + * + * On BeaglePlay, U-Boot trains and initialises the 512 MB DDR4 + * before loading NuttX, so there is nothing left to do here. + * + * IMPORTANT: This function must not use any global variables because + * they are not yet initialised when it is called. + * + ****************************************************************************/ + +void am62x_memory_initialize(void) +{ + /* DRAM has been initialised by U-Boot / SYSFW before NuttX is loaded. */ +} + +/**************************************************************************** + * Name: am62x_board_initialize + * + * Description: + * Called from am62x_boot.c (arm64_chip_boot) after the MMU is enabled + * and the C runtime is ready, but before any device drivers are + * registered. Use this hook to configure on-board resources that must + * be ready before up_initialize() runs. + * + ****************************************************************************/ + +void am62x_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Initialise the user LED GPIO outputs. LEDs are left OFF. */ + + beagleplay_led_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * When CONFIG_BOARD_LATE_INITIALIZE is selected this function is called + * immediately after up_initialize() completes and just before the initial + * application task is created. All device drivers are available at this + * point so we use it to bring up higher-level board subsystems (procfs, + * I2C bus registration, etc.). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + beagleplay_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm64/am62x/beagleplay/src/beagleplay_bringup.c b/boards/arm64/am62x/beagleplay/src/beagleplay_bringup.c new file mode 100644 index 00000000000..545242ba0b8 --- /dev/null +++ b/boards/arm64/am62x/beagleplay/src/beagleplay_bringup.c @@ -0,0 +1,77 @@ +/**************************************************************************** + * boards/arm64/am62x/beagleplay/src/beagleplay_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/kmalloc.h> +#include <sys/types.h> +#include <syslog.h> +#include <errno.h> +#include "beagleplay.h" + +#ifdef CONFIG_FS_PROCFS +# include <nuttx/fs/fs.h> +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: beagleplay_bringup + * + * Description: + * Bring up board features after the scheduler and device drivers are + * initialised. This is the right place to: + * - Mount pseudo file systems (procfs, etc.) + * - Register I2C / SPI bus instances + * - Attach sensor drivers + * + * Phase 1 only mounts procfs — additional drivers will be added as the + * port matures. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure. Non-fatal errors + * are logged but do not abort the boot. + * + ****************************************************************************/ + +int beagleplay_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the process filesystem at /proc */ + + 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 + + return ret; +} diff --git a/boards/arm64/am62x/pocketbeagle2/CMakeLists.txt b/boards/arm64/am62x/pocketbeagle2/CMakeLists.txt new file mode 100644 index 00000000000..25c7af7ab7b --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm64/am62x/pocketbeagle2/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. +# +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/arm64/am62x/pocketbeagle2/Kconfig b/boards/arm64/am62x/pocketbeagle2/Kconfig new file mode 100644 index 00000000000..f2eb65f7fbd --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/Kconfig @@ -0,0 +1,12 @@ +# +# boards/arm64/am62x/pocketbeagle2/Kconfig +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_POCKETBEAGLE2 + +comment "PocketBeagle 2 Configuration" + +endif # ARCH_BOARD_POCKETBEAGLE2 diff --git a/boards/arm64/am62x/pocketbeagle2/configs/nsh/defconfig b/boards/arm64/am62x/pocketbeagle2/configs/nsh/defconfig new file mode 100644 index 00000000000..49c8c45affd --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/configs/nsh/defconfig @@ -0,0 +1,65 @@ +# +# 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_POLLING=y +CONFIG_16550_REGWIDTH=32 +CONFIG_16550_SET_MCR_OUT2=y +CONFIG_16550_SUPRESS_INITIAL_CONFIG=y +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x02860000 +CONFIG_16550_UART0_CLOCK=48000000 +CONFIG_16550_UART0_IRQ=216 +CONFIG_16550_UART0_RX_TRIGGER=0 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD="pocketbeagle2" +CONFIG_ARCH_BOARD_POCKETBEAGLE2=y +CONFIG_ARCH_CHIP="am62x" +CONFIG_ARCH_CHIP_AM62X=y +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQPRIO=y +CONFIG_BOARD_LOOPSPERMSEC=100000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SCHED=y +CONFIG_DEBUG_SCHED_ERROR=y +CONFIG_DEBUG_SCHED_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=536870912 +CONFIG_RAM_START=0x80000000 +CONFIG_RAM_VSTART=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SPINLOCK=y +CONFIG_STACK_COLORATION=y +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm64/am62x/pocketbeagle2/configs/ostest/defconfig b/boards/arm64/am62x/pocketbeagle2/configs/ostest/defconfig new file mode 100644 index 00000000000..762343f5c51 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/configs/ostest/defconfig @@ -0,0 +1,60 @@ +# +# 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_POLLING=y +CONFIG_16550_REGWIDTH=32 +CONFIG_16550_SUPRESS_CONFIG=y +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x02860000 +CONFIG_16550_UART0_CLOCK=48000000 +CONFIG_16550_UART0_IRQ=216 +CONFIG_16550_UART0_RX_TRIGGER=0 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART=y +CONFIG_ARCH="arm64" +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_BOARD="pocketbeagle2" +CONFIG_ARCH_BOARD_POCKETBEAGLE2=y +CONFIG_ARCH_CHIP="am62x" +CONFIG_ARCH_CHIP_AM62X=y +CONFIG_ARCH_EARLY_PRINT=y +CONFIG_ARCH_INTERRUPTSTACK=4096 +CONFIG_ARCH_IRQPRIO=y +CONFIG_BOARD_LOOPSPERMSEC=100000 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SCHED=y +CONFIG_DEBUG_SCHED_ERROR=y +CONFIG_DEBUG_SCHED_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="ostest_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_STACK_MIN=8192 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=536870912 +CONFIG_RAM_START=0x80000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SCHED_WAITPID=y +CONFIG_SERIAL_UART_ARCH_MMIO=y +CONFIG_SPINLOCK=y +CONFIG_STACK_COLORATION=y +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_STACKSIZE=16384 +CONFIG_USEC_PER_TICK=1000 diff --git a/boards/arm64/am62x/pocketbeagle2/include/board.h b/boards/arm64/am62x/pocketbeagle2/include/board.h new file mode 100644 index 00000000000..a89fe5ddc18 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/include/board.h @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/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. + * + ****************************************************************************/ + +/* PocketBeagle 2 board definitions */ + +#ifndef __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_H +#define __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* UART functional clock, sourced from HSDIV4_CLKOUT1 as configured by the + * R5 SYSFW. Matches AM62X_UART_SCLK in hardware/am62x_uart.h. + */ + +#define BOARD_UART_SCLK 48000000ul /* 48 MHz */ + +/* ARM Generic Timer (CNTPCT_EL0) reference clock. + * On AM62x this is driven by the 200 MHz SYSCLK0 / 4 path. + * Configured in defconfig via CONFIG_ARCH_TIMER_FREQ. + */ + +#define BOARD_ARCH_TIMER_FREQ 200000000ul /* 200 MHz */ + +/* LED definitions ********************************************************* + * + * PocketBeagle 2 user LEDs are connected to GPIO pins on the AM6254. + * The exact GPIO numbers will be finalised when the GPIO driver is added; + * these defines are placeholders so board code can compile now. + * + * LED index Colour Net name + * 0 USR0 Green + * 1 USR1 Yellow/Amber + * 2 USR2 Red + */ + +#define BOARD_LED_USR0 0 +#define BOARD_LED_USR1 1 +#define BOARD_LED_USR2 2 +#define BOARD_NLEDS 3 + +#define BOARD_LED_USR0_BIT (1 << BOARD_LED_USR0) +#define BOARD_LED_USR1_BIT (1 << BOARD_LED_USR1) +#define BOARD_LED_USR2_BIT (1 << BOARD_LED_USR2) + +/* LED encoded OS states (used when CONFIG_ARCH_LEDS is set) *************** + * + * SYMBOL Meaning USR0 USR1 USR2 + * ---------------------- -------------------------- ---- ---- ---- + * LED_STARTED NuttX has been started ON OFF OFF + * LED_HEAPALLOCATE Heap has been allocated ON ON OFF + * LED_IRQSENABLED Interrupts enabled ON ON ON + * LED_STACKCREATED Idle stack created OFF ON OFF + * LED_INIRQ In an interrupt (no change) + * LED_SIGNAL In a signal handler (no change) + * LED_ASSERTION Assertion failed OFF OFF ON + * LED_PANIC Board panicked Blinking USR2 + */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 1 +#define LED_IRQSENABLED 2 +#define LED_STACKCREATED 3 +#define LED_INIRQ 4 +#define LED_SIGNAL 5 +#define LED_ASSERTION 6 +#define LED_PANIC 7 + +#endif /* __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_H */ diff --git a/boards/arm64/am62x/pocketbeagle2/include/board_memorymap.h b/boards/arm64/am62x/pocketbeagle2/include/board_memorymap.h new file mode 100644 index 00000000000..4325563b852 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/include/board_memorymap.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/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. + * + ****************************************************************************/ + +/* Board memory map */ + +#ifndef __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Device I/O flat-map region — covers all AM62x peripheral space. + * Must be page-aligned. Used by CONFIG_DEVICEIO_BASEADDR / SIZE in + * defconfig and by g_mmu_regions in am62x_boot.c. + */ + +#define POCKETBEAGLE2_DEVICEIO_BASE 0x00000000ul +#define POCKETBEAGLE2_DEVICEIO_SIZE 0x80000000ul /* 2 GB peripheral space */ + +/* DDR region — 512 MB on PocketBeagle 2. + * RAM_START and RAM_SIZE go into defconfig as CONFIG_RAMBANK1_ADDR/SIZE + * and are also used by the linker script to place the heap. + */ + +#define POCKETBEAGLE2_DDR_BASE 0x80000000ul +#define POCKETBEAGLE2_DDR_SIZE 0x20000000ul /* 512 MB */ + +/* NuttX load address — must match U-Boot's kernel_addr_r. + * The linker script uses this as the origin of the .text section. + */ + +#define POCKETBEAGLE2_LOAD_ADDR 0x82000000ul + +#endif /* __BOARDS_ARM64_AM62X_POCKETBEAGLE2_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/arm64/am62x/pocketbeagle2/scripts/Make.defs b/boards/arm64/am62x/pocketbeagle2/scripts/Make.defs new file mode 100644 index 00000000000..eabe705e9e2 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/scripts/Make.defs @@ -0,0 +1,44 @@ +############################################################################ +# boards/arm64/am62x/pocketbeagle2/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__ + +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/arm64/am62x/pocketbeagle2/scripts/dramboot.ld b/boards/arm64/am62x/pocketbeagle2/scripts/dramboot.ld new file mode 100644 index 00000000000..6bb0f4e35e9 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/scripts/dramboot.ld @@ -0,0 +1,202 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/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. + * + ****************************************************************************/ + +/* PocketBeagle 2 — NuttX loaded into DDR by U-Boot. + * + * Memory layout: + * 0x8000_0000 DDR start (512 MB physically installed) + * 0x8200_0000 NuttX load address (avoids U-Boot reserved region) + * 0x9FFF_FFFF DDR end + * + * U-Boot loads the raw binary and jumps to the first instruction + * (_start in arm64_head.S which is placed in the .start section). + * + * The heap begins at _e_initstack and extends upward; its size is + * determined by CONFIG_RAM_SIZE minus the image footprint. + */ + +OUTPUT_ARCH(aarch64) + +ENTRY(__start) + +PHDRS +{ + text PT_LOAD ; +} + +SECTIONS +{ + /* NuttX is loaded at the kernel_addr_r address */ + + . = 0x82000000; + + _start = .; + + /* ----------------------------------------------------------------------- + * Read-only / executable sections + * --------------------------------------------------------------------- */ + + .text : + { + _stext = .; + *(.start .start.*) /* arm64_head.S __start must be first */ + *(.text) + *(.text.*) + *(.text.cold) + *(.text.unlikely) + *(.fixup) + *(.gnu.warning) + } :text = 0x9090 + + . = ALIGN(4096); + + /* C++ constructor / destructor init arrays */ + + .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(.); + } :text + + . = ALIGN(4096); + + /* Exception vector table — must be 4 KB aligned per AArch64 spec */ + + .vector : + { + _vector_start = .; + KEEP(*(.exc_vector_table)) + KEEP(*(.exc_vector_table.*)) + KEEP(*(.vectors)) + _vector_end = .; + } :text + + . = ALIGN(4096); + + _etext = .; + _sztext = _etext - _stext; + + /* ----------------------------------------------------------------------- + * Read-only data + * --------------------------------------------------------------------- */ + + . = ALIGN(4096); + + .rodata : + { + _srodata = .; + *(.rodata) + *(.rodata.*) + *(.data.rel.ro) + *(.data.rel.ro.*) + } :text + + . = ALIGN(4096); + + _erodata = .; + _szrodata = _erodata - _srodata; + _eronly = .; + + /* ----------------------------------------------------------------------- + * Initialised data (copied from flash / loaded image at boot) + * --------------------------------------------------------------------- */ + + . = ALIGN(4096); + + .data : + { + _sdata = .; + *(.data.page_aligned) + *(.data) + *(.data.*) + . = ALIGN(8); + *(.data.rel) + *(.data.rel.*) + CONSTRUCTORS + } :text + + _edata = .; + + /* ----------------------------------------------------------------------- + * Zero-initialised data (BSS) + * --------------------------------------------------------------------- */ + + .bss : + { + . = ALIGN(8); + _sbss = .; + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(8); + } :text + + . = ALIGN(4096); + + _ebss = .; + _szbss = _ebss - _sbss; + + /* ----------------------------------------------------------------------- + * Boot/idle stack (placed immediately after BSS) + * --------------------------------------------------------------------- */ + + .initstack : + { + _s_initstack = .; + *(.initstack) + . = ALIGN(16); + } :text + + . = ALIGN(4096); + + _e_initstack = .; + g_idle_topstack = .; /* arm64 common layer uses this symbol */ + + _szdata = _e_initstack - _sdata; + + /* ----------------------------------------------------------------------- + * Discarded sections + * --------------------------------------------------------------------- */ + + /DISCARD/ : + { + *(.exit.text) + *(.exit.data) + *(.exitcall.exit) + *(.eh_frame) + } + + /* 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/am62x/pocketbeagle2/scripts/uEnv.txt b/boards/arm64/am62x/pocketbeagle2/scripts/uEnv.txt new file mode 100644 index 00000000000..7d09c1812da --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/scripts/uEnv.txt @@ -0,0 +1,10 @@ +# uEnv.txt -- NuttX boot script for PocketBeagle 2 +# +# Copy this file and nuttx.bin to the root of a FAT32-formatted microSD card. +# U-Boot reads uEnv.txt automatically on boot; no manual commands are needed. +# +# Load address 0x82000000 matches the NuttX linker script origin and +# CONFIG_LOAD_BASE in arch/arm64/include/am62x/chip.h. +# 0x82000000 avoids U-Boot's reserved region at the DDR base. + +uenvcmd=fatload mmc 1:1 0x82000000 nuttx.bin; go 0x82000000 diff --git a/boards/arm64/am62x/pocketbeagle2/src/CMakeLists.txt b/boards/arm64/am62x/pocketbeagle2/src/CMakeLists.txt new file mode 100644 index 00000000000..597a32711ed --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/CMakeLists.txt @@ -0,0 +1,29 @@ +# ############################################################################## +# boards/arm64/am62x/pocketbeagle2/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. +# +# ############################################################################## + +list(APPEND SRCS pocketbeagle2_boardinit.c pocketbeagle2_bringup.c) + +if(CONFIG_ARCH_LEDS) + list(APPEND SRCS pocketbeagle2_autoleds.c) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm64/am62x/pocketbeagle2/src/Makefile b/boards/arm64/am62x/pocketbeagle2/src/Makefile new file mode 100644 index 00000000000..4b1f0e1cb4b --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/Makefile @@ -0,0 +1,35 @@ +############################################################################ +# boards/arm64/am62x/pocketbeagle2/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 + +# Board-specific C sources (always compiled) + +CSRCS = pocketbeagle2_boardinit.c pocketbeagle2_bringup.c + +# Automatic LED support + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += pocketbeagle2_autoleds.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2.h b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2.h new file mode 100644 index 00000000000..fe1f462d65d --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2.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_AM62X_POCKETBEAGLE2_SRC_POCKETBEAGLE2_H +#define __BOARDS_ARM64_AM62X_POCKETBEAGLE2_SRC_POCKETBEAGLE2_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <stdint.h> + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: pocketbeagle2_bringup + * + * Description: + * Bring up board-level drivers and subsystems. Called from + * board_late_initialize(). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +int pocketbeagle2_bringup(void); +#endif + +/**************************************************************************** + * Name: pocketbeagle2_led_initialize + * + * Description: + * Configure the user LEDs as GPIO outputs. Called from + * am62x_board_initialize() when CONFIG_ARCH_LEDS is set. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void pocketbeagle2_led_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM64_AM62X_POCKETBEAGLE2_SRC_POCKETBEAGLE2_H */ diff --git a/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c new file mode 100644 index 00000000000..216c61d63a4 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_autoleds.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* GPIO-backed LED support is not implemented yet for the AM62x boards. + * Keep the ARCH_LEDS hooks as explicit no-ops until the GPIO work lands. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/board.h> +#include <arch/board/board.h> +#include "pocketbeagle2.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pocketbeagle2_led_initialize + * + * Description: + * Configure LED GPIO pins as outputs, all OFF initially. + * Stubbed until the GPIO driver is available. + * + ****************************************************************************/ + +void pocketbeagle2_led_initialize(void) +{ + /* TODO: configure GPIO pins for the user LEDs once GPIO support exists. */ +} + +/**************************************************************************** + * Name: board_autoled_on + * + * Description: + * Turn ON the LED(s) associated with the OS event 'led'. + * + ****************************************************************************/ + +void board_autoled_on(int led) +{ + UNUSED(led); +} + +/**************************************************************************** + * Name: board_autoled_off + * + * Description: + * Turn OFF the LED(s) associated with the OS event 'led'. + * + ****************************************************************************/ + +void board_autoled_off(int led) +{ + UNUSED(led); +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_boardinit.c b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_boardinit.c new file mode 100644 index 00000000000..34b46415d16 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_boardinit.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_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 <nuttx/config.h> +#include <stdint.h> +#include <nuttx/board.h> +#include "pocketbeagle2.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: am62x_memory_initialize + * + * Description: + * Called from the very early boot path (before .bss is zeroed or .data + * is initialised) to perform any board-level memory bring-up such as + * DRAM training. + * + * On PocketBeagle 2, U-Boot trains and initialises the 512 MB DDR4 + * before loading NuttX, so there is nothing left to do here. + * + * IMPORTANT: This function must not use any global variables because + * they are not yet initialised when it is called. + * + ****************************************************************************/ + +void am62x_memory_initialize(void) +{ + /* DRAM has been initialised by U-Boot / SYSFW before NuttX is loaded. */ +} + +/**************************************************************************** + * Name: am62x_board_initialize + * + * Description: + * Called from am62x_boot.c (arm64_chip_boot) after the MMU is enabled + * and the C runtime is ready, but before any device drivers are + * registered. Use this hook to configure on-board resources that must + * be ready before up_initialize() runs. + * + ****************************************************************************/ + +void am62x_board_initialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Initialise the user LED GPIO outputs. LEDs are left OFF. */ + + pocketbeagle2_led_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * When CONFIG_BOARD_LATE_INITIALIZE is selected this function is called + * immediately after up_initialize() completes and just before the initial + * application task is created. All device drivers are available at this + * point so we use it to bring up higher-level board subsystems (procfs, + * I2C bus registration, etc.). + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + pocketbeagle2_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_bringup.c b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_bringup.c new file mode 100644 index 00000000000..60334ad1566 --- /dev/null +++ b/boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_bringup.c @@ -0,0 +1,86 @@ +/**************************************************************************** + * boards/arm64/am62x/pocketbeagle2/src/pocketbeagle2_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/kmalloc.h> +#include <sys/types.h> +#include <syslog.h> +#include <errno.h> + +#include "pocketbeagle2.h" + +#ifdef CONFIG_FS_PROCFS +# include <nuttx/fs/fs.h> +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: pocketbeagle2_bringup + * + * Description: + * Bring up board features after the scheduler and device drivers are + * initialised. This is the right place to: + * - Mount pseudo file systems (procfs, etc.) + * - Register I2C / SPI bus instances + * - Attach sensor drivers + * + * Phase 1 only mounts procfs — additional drivers will be added as the + * port matures. + * + * Returned Value: + * Zero (OK) on success; a negated errno on failure. Non-fatal errors + * are logged but do not abort the boot. + * + ****************************************************************************/ + +int pocketbeagle2_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the process filesystem at /proc */ + + 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 + + /* TODO Phase 2: + * I2C bus registration (am62x I2C0/I2C1) + * SPI bus registration (am62x SPI0) + * MMC/SD registration (am62x MMCSD0 / MMCSD1) + * GPIO driver registration + * USB device/host registration + */ + + return ret; +}
