diff --git a/Documentation/platforms/arm/am335x/boards/beaglebone/beaglebone.jpg b/Documentation/platforms/arm/am335x/boards/beaglebone/beaglebone.jpg new file mode 100644 index 00000000000..371d69fe74e Binary files /dev/null and b/Documentation/platforms/arm/am335x/boards/beaglebone/beaglebone.jpg differ diff --git a/Documentation/platforms/arm/am335x/boards/beaglebone/index.rst b/Documentation/platforms/arm/am335x/boards/beaglebone/index.rst new file mode 100644 index 00000000000..efe414b980c --- /dev/null +++ b/Documentation/platforms/arm/am335x/boards/beaglebone/index.rst @@ -0,0 +1,184 @@ +========== +BeagleBone +========== + +.. tags:: arch:arm, chip:am335x + +.. figure:: beaglebone.jpg + :figwidth: 100% + :align: center + :alt: The BeagleBone + + The BeagleBone + +This directory contains the port of NuttX to the original (white) BeagleBone. +See https://www.beagleboard.org/boards/beaglebone-original for more information. +This board is based around the TI AM335x Sitara Cortex-A8 CPU. + +=================== ============================================================= +ITEMS DETAILS +=================== ============================================================= +CPU 720MHz ARM Cortex-A8 +FPU NEON SIMD Coprocessor +I-Cache 32KB +D-Cache 32KB +L2 Cache 256KB L2 Cache with ECC +DRAM 256MB DDR2 +On-Chip SRAM 64KB +Dedicated SRAM 64KB +On-Chip Boot ROM 176KB +Onboard Storage microSD card (TF) slot +Extension Interface 2.54mm Headers, 92 pins +Network interface 10/100Mbps RJ45 +Power 5V, 1000mA +=================== ============================================================= + + +Peripheral Support +================== + +The following list indicates the state of peripherals' support in NuttX: + +=========== ======= ==================== +Peripheral Support NOTES +=========== ======= ==================== +ADC No +Ethernet No +CAN No +DMA No +GPIO Yes +I2C Yes +I2S No +LED Yes +SD No +SPI No +Timers Yes +UART Yes +USB Client No +USB Host No +Watchdog Yes +=========== ======= ==================== + +Serial Console +============== + +By default, the serial console will be provided on UART0 in all of these +configurations. + +UART0 is available on the USB client port. + +Booting NuttX from a microSD card +================================= + +It is assumed that the microSD already boots to the U-Boot prompt. + +These are the steps to run nuttx.bin from the microSD Card: + +#. Configure and build the NuttX BeagleBone configuration. You + should have a file called nuttx.bin when the build completes. + +#. Insert a microSD into the host PC. + +#. Copy nuttx.bin into the microSD. + +#. Remove the microSD from the host PC and insert into the BeagleBone + microSD slot. + +#. Connect a Mini-USB cable to the BeagleBone and open a serial + terminal on the host PC to communicate with the target. + +#. Reset and stop the BeagleBone boot. You should see output from + U-boot in the serial console. + +#. Load NuttX into memory from the U-Boot prompt and run NuttX as shown + below. + +.. code-block:: console + + => load mmc 0 0x80300000 nuttx.bin + 414356 bytes read in 37 ms (10.7 MiB/s) + => go 0x80300000 + ## Starting application at 0x80300000 ... + + NuttShell (NSH) NuttX-13.0.1-RC0 + nsh> + +Configurations +============== + +Information Common to All Configurations +---------------------------------------- + +Each BeagleBone configuration is maintained in a sub-directory and +can be selected as follow: + + *tools/configure.sh [OPTIONS] beaglebone:* + +Where [OPTIONS] include -l to configure for a Linux host platform. +-h will give you the list of all options. + +Before building, make sure the PATH environment variable includes the +correct path to the directory that holds your toolchain binaries. + +Build NuttX by typing the following: + + *make* + +At the conclusion of the make, the nuttx binary will reside in an ELF file +called nuttx. + +The ```` that is provided above as an argument to the tools/configure.sh +must be one of the following. + +Configuration Sub-directories +----------------------------- + +nsh +--- + +This configuration directory provides the NuttShell (NSH). + +knsh +---- + +This is the kernel build configuration. User applications are included in the +final nuttx.bin image. + +Steps to build the kernel image with userspace apps in ROMFS: + +.. code-block:: console + + ./tools/configure.sh -l beaglebone/knsh + make && make export + pushd ../apps + tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz + make import + cp -a bin /tmp + tools/mkromfsimg.sh + mv boot_romfsimg.h ../nuttx/boards/arm/am335x/beaglebone/include/bin_romfsimg.h + popd + make clean clean_context + make + +Run the nuttx.bin as previously described. + +.. code-block:: console + + => load mmc 0 0x80300000 knsh.bin + 414356 bytes read in 41 ms (9.6 MiB/s) + => go 0x80300000 + ## Starting application at 0x80300000 ... + + NuttShell (NSH) NuttX-13.0.1-RC0 + knsh> uname -a + NuttX 13.0.1-RC0 3b7e453012-dirty Aug 17 2026 20:07:55 arm beaglebone + knsh> ls /bin + /bin: + dd + getprime + hello + init + sh + knsh> /bin/hello + Hello, World!! + knsh> diff --git a/Documentation/platforms/arm/am335x/index.rst b/Documentation/platforms/arm/am335x/index.rst index 1430fed1cc6..a4208c702b6 100644 --- a/Documentation/platforms/arm/am335x/index.rst +++ b/Documentation/platforms/arm/am335x/index.rst @@ -2,27 +2,6 @@ TI/Sitara AM335x ================ -These following boards are based on the TI/Sitara -AM335x are supported by NuttX: - -- **Beaglebone Black**. A port of NuttX to the Beaglebone Black board - was first released in NuttX-7.28. This port was contributed by Petro - Karashchenko. This board is based on the TI/Sitara AM3358 Cortex-A8 - CPU running 1GHz. - - - **NuttX-7.28**. This initial port in NuttX-7.28 is very sparse. - While not ready for production use, the Beaglebone Black port is - functional and will be the basis for a more extensive development. - Additional work in progress to extend this port and more capable - is anticipated in NuttX-7.29. - - **NuttX-9.0** CAN support was added. Clock Configuration was - added. - - **NuttX-7.31**. An LCD driver was added in NuttX-7.31. - - Refer to the Beaglebone Black board - `README `__ - file for further, up-to-date information. - Supported Boards ================ diff --git a/arch/arm/src/am335x/CMakeLists.txt b/arch/arm/src/am335x/CMakeLists.txt index 45e786b93c4..51c65b757f3 100644 --- a/arch/arm/src/am335x/CMakeLists.txt +++ b/arch/arm/src/am335x/CMakeLists.txt @@ -47,4 +47,8 @@ if(CONFIG_AM335X_LCDC) list(APPEND SRCS am335x_lcdc.c am335x_edid.c) endif() +if(CONFIG_MM_PGALLOC) + list(APPEND SRCS am335x_pgalloc.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/arm/src/am335x/Make.defs b/arch/arm/src/am335x/Make.defs index e2d9a0d16f0..560222c7574 100644 --- a/arch/arm/src/am335x/Make.defs +++ b/arch/arm/src/am335x/Make.defs @@ -39,3 +39,7 @@ endif ifeq ($(CONFIG_AM335X_LCDC),y) CHIP_CSRCS += am335x_lcdc.c am335x_edid.c endif + +ifeq ($(CONFIG_MM_PGALLOC),y) +CHIP_CSRCS += am335x_pgalloc.c +endif diff --git a/arch/arm/src/am335x/am335x_pgalloc.c b/arch/arm/src/am335x/am335x_pgalloc.c new file mode 100644 index 00000000000..e8b488478d8 --- /dev/null +++ b/arch/arm/src/am335x/am335x_pgalloc.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * arch/arm/src/am335x/am335x_pgalloc.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 "arm_internal.h" + +#ifdef CONFIG_MM_PGALLOC + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_allocate_pgheap + * + * Description: + * If there is a page allocator in the configuration, then this function + * must be provided by the platform-specific code. The OS initialization + * logic will call this function early in the initialization sequence to + * get the page heap information needed to configure the page allocator. + * + ****************************************************************************/ + +void up_allocate_pgheap(void **pool_start, size_t *pool_size) +{ + DEBUGASSERT(pool_start && pool_size); + + *pool_start = (void *)CONFIG_ARCH_PGPOOL_PBASE; + *pool_size = (size_t)CONFIG_ARCH_PGPOOL_SIZE; +} + +#endif /* CONFIG_MM_PGALLOC */ diff --git a/boards/Kconfig b/boards/Kconfig index 31653133202..add123751e1 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -1702,6 +1702,15 @@ config ARCH_BOARD_PCDUINO_A10 the differences are cosmetic. This port was developed on the v1 board, but the others may be compatible. +config ARCH_BOARD_BEAGLEBONE + bool "beaglebone" + depends on ARCH_CHIP_AM335X + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + ---help--- + This is the port of NuttX to the original TI Beaglebone board. + config ARCH_BOARD_BEAGLEBONE_BLACK bool "beaglebone black" depends on ARCH_CHIP_AM335X @@ -4009,6 +4018,7 @@ config ARCH_BOARD default "or1k" if ARCH_BOARD_OR1K default "p112" if ARCH_BOARD_P112 default "pcduino-a10" if ARCH_BOARD_PCDUINO_A10 + default "beaglebone" if ARCH_BOARD_BEAGLEBONE default "beaglebone-black" if ARCH_BOARD_BEAGLEBONE_BLACK default "pic32mx-starterkit" if ARCH_BOARD_PIC32MX_STARTERKIT default "pic32mx7mmb" if ARCH_BOARD_PIC32MX7MMB @@ -4236,6 +4246,9 @@ comment "Board-Specific Options" if ARCH_BOARD_PCDUINO_A10 source "boards/arm/a1x/pcduino-a10/Kconfig" endif +if ARCH_BOARD_BEAGLEBONE +source "boards/arm/am335x/beaglebone/Kconfig" +endif if ARCH_BOARD_BEAGLEBONE_BLACK source "boards/arm/am335x/beaglebone-black/Kconfig" endif diff --git a/boards/arm/am335x/beaglebone/CMakeLists.txt b/boards/arm/am335x/beaglebone/CMakeLists.txt new file mode 100644 index 00000000000..41258b1e714 --- /dev/null +++ b/boards/arm/am335x/beaglebone/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm/am335x/beaglebone/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/arm/am335x/beaglebone/Kconfig b/boards/arm/am335x/beaglebone/Kconfig new file mode 100644 index 00000000000..df70d8c73f1 --- /dev/null +++ b/boards/arm/am335x/beaglebone/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_BEAGLEBONE +endif # ARCH_BOARD_BEAGLEBONE diff --git a/boards/arm/am335x/beaglebone/configs/knsh/defconfig b/boards/arm/am335x/beaglebone/configs/knsh/defconfig new file mode 100644 index 00000000000..5f1ecdd37e4 --- /dev/null +++ b/boards/arm/am335x/beaglebone/configs/knsh/defconfig @@ -0,0 +1,88 @@ +# +# 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_NSH_CMDOPT_HEXDUMP is not set +CONFIG_AM335X_UART0=y +CONFIG_ARCH="arm" +CONFIG_ARCH_ADDRENV=y +CONFIG_ARCH_BOARD="beaglebone" +CONFIG_ARCH_BOARD_BEAGLEBONE=y +CONFIG_ARCH_CHIP="am335x" +CONFIG_ARCH_CHIP_AM3358=y +CONFIG_ARCH_CHIP_AM335X=y +CONFIG_ARCH_DATA_NPAGES=256 +CONFIG_ARCH_DATA_VBASE=0x80100000 +CONFIG_ARCH_HEAP_NPAGES=256 +CONFIG_ARCH_HEAP_VBASE=0x80200000 +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_PGPOOL_MAPPING=y +CONFIG_ARCH_PGPOOL_PBASE=0x88000000 +CONFIG_ARCH_PGPOOL_SIZE=134217728 +CONFIG_ARCH_PGPOOL_VBASE=0x88000000 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_TEXT_NPAGES=256 +CONFIG_ARCH_TEXT_VBASE=0x0000000 +CONFIG_ARM_THUMB=y +CONFIG_BOARD_LOOPSPERMSEC=70000 +CONFIG_BOOT_RUNFROMSDRAM=y +CONFIG_BUILD_KERNEL=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ELF=y +CONFIG_ELF_STACKSIZE=4096 +CONFIG_EXAMPLES_HELLO=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_MOUNT=y +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_ENVPATH=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBC_MAX_EXITFUNS=16 +CONFIG_LIBC_STRERROR=y +CONFIG_LIBC_USRWORK=y +CONFIG_LIBC_USRWORKSTACKSIZE=4096 +CONFIG_MM_PGALLOC=y +CONFIG_NSH_DISABLE_DMESG=y +CONFIG_NSH_DISABLE_EXIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_FILE_APPS=y +CONFIG_NSH_PROMPT_STRING="knsh> " +CONFIG_NSH_READLINE=y +CONFIG_NSH_STRERROR=y +CONFIG_NSH_VARS=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=131072000 +CONFIG_RAM_START=0x80300000 +CONFIG_RAM_VSTART=0x80300000 +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_TERMIOS=y +CONFIG_STACK_COLORATION=y +CONFIG_START_MONTH=8 +CONFIG_START_YEAR=2026 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSLOG_TIMESTAMP=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_PROGNAME="init" +CONFIG_TESTING_GETPRIME=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/am335x/beaglebone/configs/nsh/defconfig b/boards/arm/am335x/beaglebone/configs/nsh/defconfig new file mode 100644 index 00000000000..eb363aae742 --- /dev/null +++ b/boards/arm/am335x/beaglebone/configs/nsh/defconfig @@ -0,0 +1,47 @@ +# +# 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_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_AM335X_UART0=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="beaglebone" +CONFIG_ARCH_BOARD_BEAGLEBONE=y +CONFIG_ARCH_CHIP="am335x" +CONFIG_ARCH_CHIP_AM3358=y +CONFIG_ARCH_CHIP_AM335X=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=70000 +CONFIG_BOOT_RUNFROMSDRAM=y +CONFIG_BUILTIN=y +CONFIG_DISABLE_ENVIRON=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_HOST_WINDOWS=y +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_RAM_SIZE=131072000 +CONFIG_RAM_START=0x80300000 +CONFIG_RAM_VSTART=0x80300000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_MONTH=8 +CONFIG_START_YEAR=2026 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/am335x/beaglebone/include/bin_romfsimg.h b/boards/arm/am335x/beaglebone/include/bin_romfsimg.h new file mode 100644 index 00000000000..57b949ead8c --- /dev/null +++ b/boards/arm/am335x/beaglebone/include/bin_romfsimg.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/include/bin_romfsimg.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_SAMA5_SAMA5D3_XPLAINED_BOOT_ROMFSIMG_H +#define __BOARDS_ARM_SAMA5_SAMA5D3_XPLAINED_BOOT_ROMFSIMG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +const unsigned char aligned_data(4) romfs_img[] = +{ + 0x00 +}; +unsigned int romfs_img_len = 1; + +#endif /* __BOARDS_ARM_SAMA5_SAMA5D3_XPLAINED_BOOT_ROMFSIMG_H */ diff --git a/boards/arm/am335x/beaglebone/include/board.h b/boards/arm/am335x/beaglebone/include/board.h new file mode 100644 index 00000000000..b348862e3c9 --- /dev/null +++ b/boards/arm/am335x/beaglebone/include/board.h @@ -0,0 +1,143 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_AM335X_BEAGLEBONE_INCLUDE_BOARD_H +#define __BOARDS_ARM_AM335X_BEAGLEBONE_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* Since NuttX is booted from a loader on the AM335X, clocking should already + * be setup when NuttX starts. + */ + +/* LED definitions **********************************************************/ + +/* The beaglebone black has four user LEDs; all four can be controlled from + * software. + * All are tied to ground and, hence, illuminated by driving the output pins + * to a high value: + * + * 1. LED0 GPMC_A5 GPMC_A5/GMII2_TXD0/RGMII2_TD0/RMII2_TXD0/GPMC_A21/ + * PR1_MII1_RXD3/eQEP1B_IN/GPIO1_21 + * 2. LED1 GPMC_A6 GPMC_A6/GMII2_TXCLK/RGMII2_TCLK/MMC2_DAT4/GPMC_A22/ + * PR1_MII1_RXD2/eQEP1_INDEX/GPIO1_22 + * 3. LED2 GPMC_A7 GPMC_A7/GMII2_RXCLK/RGMII2_RCLK/MMC2_DAT5/GPMC_A23/ + * PR1_MII1_RXD1/eQEP1_STROBE/GPIO1_23 + * 4. LED3 GPMC_A8 GPMC_A8/GMII2_RXD3/RGMII2_RD3/MMC2_DAT6/GPMC_A24/ + * PR1_MII1_RXD0/MCASP0_ACLKX/GPIO1_24 + */ + +/* LED index values for use with board_userled() */ + +#define USER_LED0 0 +#define USER_LED1 1 +#define USER_LED2 2 +#define USER_LED3 3 +#define BOARD_NLEDS 4 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED0_BIT (1 << USER_LED0) +#define BOARD_LED1_BIT (1 << USER_LED1) +#define BOARD_LED2_BIT (1 << USER_LED2) +#define BOARD_LED3_BIT (1 << USER_LED3) + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/am335x_leds.c. + * The LEDs are used to encode OS-related events as follows: + * + * SYMBOL Value Meaning LED state + * LED0 LED1 LED2 + * ----------------- ----- ----------------------- ---- ---- --------- + */ + +#define LED_STARTED 0 /* NuttX has been started ON OFF OFF */ +#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF ON OFF */ +#define LED_IRQSENABLED 2 /* Interrupts enabled ON ON OFF */ +#define LED_STACKCREATED 2 /* Idle stack created ON ON OFF */ +#define LED_INIRQ 3 /* In an interrupt N/C N/C Soft glow */ +#define LED_SIGNAL 3 /* In a signal handler N/C N/C Soft glow */ +#define LED_ASSERTION 3 /* An assertion failed N/C N/C Soft glow */ +#define LED_PANIC 3 /* The system has crashed N/C N/C 2Hz Flashing */ + +/* LED_IDLE --- MCU is in sleep mode Not used + * + * After booting, LED0 and 1 are not longer used by the system and can be + * used for other purposes by the application (Of course, all LEDs are + * available to the application if CONFIG_ARCH_LEDS is not defined. + */ + +/* NAND *********************************************************************/ + +/* GPIO pin disambiguation **************************************************/ + +/* UARTs ********************************************************************/ + +/* One UART connections is available: + * + * 1. UART0 is available on FT2232H USB to Serial Adapter. + * + * FT2232H BDBUS1 Pin UART0-RXD UART0_RXD/SPI1_CS0/DCAN0_TX/I2C2_SDA/ + * eCAP2_IN_PWM2_OUT/PR1_PRU1_PRU_R30_14/ + * PR1_PRU1_PRU_R31_14/GPIO1_10 + * FT2232H BDBUS0 Pin UART0-TXD UART0_TXD/SPI1_CS1/DCAN0_RX/I2C2_SCL/ + * eCAP1_IN_PWM1_OUT/PR1_PRU1_PRU_R30_15/ + * PR1_PRU1_PRU_R31_15/GPIO1_11 + */ + +/* I2Cs *********************************************************************/ + +#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2 +#define GPIO_I2C1_SCL GPIO_I2C1_SDA_2 + +#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1 +#define GPIO_I2C2_SCL GPIO_I2C2_SDA_1 + +/* CANs *********************************************************************/ + +#define GPIO_DCAN0_RX GPIO_DCAN0_RX_3 +#define GPIO_DCAN0_TX GPIO_DCAN0_TX_3 + +#define GPIO_DCAN1_RX GPIO_DCAN1_RX_3 +#define GPIO_DCAN1_TX GPIO_DCAN1_TX_3 + +/**************************************************************************** + * Assembly Language Macros + ****************************************************************************/ + +#ifdef __ASSEMBLY__ + .macro config_sdram + .endm +#endif /* __ASSEMBLY__ */ + +#endif /* __BOARDS_ARM_AM335X_BEAGLEBONE_INCLUDE_BOARD_H */ diff --git a/boards/arm/am335x/beaglebone/include/board_memorymap.h b/boards/arm/am335x/beaglebone/include/board_memorymap.h new file mode 100644 index 00000000000..62044647b0f --- /dev/null +++ b/boards/arm/am335x/beaglebone/include/board_memorymap.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/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_ARM_AM335X_BEAGLEBONE_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_ARM_AM335X_BEAGLEBONE_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 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_AM335X_BEAGLEBONE_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/arm/am335x/beaglebone/scripts/Make.defs b/boards/arm/am335x/beaglebone/scripts/Make.defs new file mode 100644 index 00000000000..70b3a50e2c4 --- /dev/null +++ b/boards/arm/am335x/beaglebone/scripts/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# boards/arm/am335x/beaglebone/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/arm/src/armv7-a/Toolchain.defs + +# Setup for the kind of memory that we are executing from + +LDSCRIPT = sdram.ld +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/arm/am335x/beaglebone/scripts/sdram.ld b/boards/arm/am335x/beaglebone/scripts/sdram.ld new file mode 100644 index 00000000000..ffd996b6498 --- /dev/null +++ b/boards/arm/am335x/beaglebone/scripts/sdram.ld @@ -0,0 +1,126 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/scripts/sdram.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. + * + ****************************************************************************/ + +/* The Beaglebone Black and 512MB of SDRAM beginning at virtual address + * 0x8000:0000. Execution begins at address 0x8a00000, leaving 352MB for NuttX. + * + * Vectors in low memory are assumed and 16KB of OCMC0 is reserved at the + * high end of OCMC0 for the page table. + */ + +MEMORY +{ + isram (W!RX) : ORIGIN = 0x402F0400, LENGTH = 63K + ocmc0 (W!RX) : ORIGIN = 0x40300000, LENGTH = 64K -16K + ddr (W!RX) : ORIGIN = 0x80300000, LENGTH = 128M - 3M +} + +ENTRY(entry) +ENTRY(_stext) + +SECTIONS +{ + .text : + { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + *(.ARM.extab*) + *(.gnu.linkonce.armextab.*) + _etext = ABSOLUTE(.); + } > ddr + + .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(.); + } > ddr + + .ARM.extab : + { + *(.ARM.extab*) + } > ddr + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > ddr + PROVIDE_HIDDEN (__exidx_end = .); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > ddr + + /* Uninitialized data */ + + .noinit : + { + _snoinit = ABSOLUTE(.); + *(.noinit*) + _enoinit = ABSOLUTE(.); + } > ddr + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > ddr + + /* 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/arm/am335x/beaglebone/src/CMakeLists.txt b/boards/arm/am335x/beaglebone/src/CMakeLists.txt new file mode 100644 index 00000000000..6535abe117d --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/CMakeLists.txt @@ -0,0 +1,27 @@ +# ############################################################################## +# boards/arm/am335x/beaglebone/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 am335x_boot.c am335x_bringup.c am335x_leds.c) + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/sdram.ld") diff --git a/boards/arm/am335x/beaglebone/src/Makefile b/boards/arm/am335x/beaglebone/src/Makefile new file mode 100644 index 00000000000..036a23e6c2c --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/Makefile @@ -0,0 +1,27 @@ +############################################################################ +# boards/arm/am335x/beaglebone/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 = am335x_boot.c am335x_bringup.c am335x_leds.c + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/am335x/beaglebone/src/am335x_boot.c b/boards/arm/am335x/beaglebone/src/am335x_boot.c new file mode 100644 index 00000000000..48ff236d56f --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/am335x_boot.c @@ -0,0 +1,111 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/src/am335x_boot.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "beaglebone.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: am335x_memory_initialize + * + * Description: + * All AM335X architectures must provide the following entry point. This + * entry point is called early in the initialization before memory has + * been configured. This board-specific function is responsible for + * configuring any on-board memories. + * + * Logic in am335x_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 am335x_memory_initialize(void) +{ + /* SDRAM was initialized by a bootloader in the supported configurations. */ +} + +/**************************************************************************** + * Name: am335x_board_initialize + * + * Description: + * All AM335x architectures must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void am335x_board_initialize(void) +{ + /* Configure on-board LEDs. */ + + am335x_led_initialize(); +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + am335x_bringup(); +} +#endif /* CONFIG_BOARD_LATE_INITIALIZE */ diff --git a/boards/arm/am335x/beaglebone/src/am335x_bringup.c b/boards/arm/am335x/beaglebone/src/am335x_bringup.c new file mode 100644 index 00000000000..94754fc877f --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/am335x_bringup.c @@ -0,0 +1,196 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/src/am335x_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 + +#ifdef CONFIG_USERLED +# include +#endif + +#include "beaglebone.h" + +#include "am335x_i2c.h" +#include "am335x_can.h" + +#ifdef CONFIG_FS_ROMFS +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define SECTORSIZE 512 +#define NSECTORS(b) (((b) + SECTORSIZE - 1) / SECTORSIZE) +#endif /* CONFIG_FS_ROMFS */ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#if defined(CONFIG_I2C_DRIVER) && (defined(CONFIG_AM335X_I2C0) || \ + defined(CONFIG_AM335X_I2C1) || defined(CONFIG_AM335X_I2C2)) +static void am335x_i2c_register(int bus) +{ + struct i2c_master_s *i2c; + int ret; + + i2c = am335x_i2cbus_initialize(bus); + if (i2c == NULL) + { + syslog(LOG_ERR, "Failed to get I2C%d interface\n", bus); + } + else + { + ret = i2c_register(i2c, bus); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to register I2C%d driver: %d\n", bus, ret); + am335x_i2cbus_uninitialize(i2c); + } + } +} +#endif + +#if defined(CONFIG_CAN) && (defined(CONFIG_AM335X_CAN0) || defined(CONFIG_AM335X_CAN1)) +static void am335x_can_register(void) +{ + struct can_dev_s *can; + int ret; + +#ifdef CONFIG_AM335X_CAN0 + can = am335x_can_initialize(0); + if (can == NULL) + { + syslog(LOG_ERR, "Failed to get DCAN0 interface\n"); + } + else + { + ret = can_register("/dev/can0", can); + if (ret < 0) + { + syslog(LOG_ERR, "can_register failed: %d\n", ret); + am335x_can_uninitialize(can); + } + } +#endif + +#ifdef CONFIG_AM335X_CAN1 + can = am335x_can_initialize(1); + if (can == NULL) + { + syslog(LOG_ERR, "Failed to get DCAN1 interface\n"); + } + else + { +#ifdef CONFIG_AM335X_CAN0 + ret = can_register("/dev/can1", can); +#else + ret = can_register("/dev/can0", can); +#endif + if (ret < 0) + { + syslog(LOG_ERR, "can_register failed: %d\n", ret); + am335x_can_uninitialize(can); + } + } +#endif +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: am335x_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + ****************************************************************************/ + +int am335x_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_USERLED + /* Register the LED driver */ + + ret = userled_lower_initialize("/dev/userleds"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %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 + +#ifdef CONFIG_FS_ROMFS + /* Create a ROM disk for the ?/bin filesystem */ + + ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); + + if (ret < 0) + { + syslog(LOG_ERR, "Failed to register ROMFS at /dev/ram0: %d\n", ret); + } +#endif + +#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C0) + am335x_i2c_register(0); +#endif + +#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C1) + am335x_i2c_register(1); +#endif + +#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C2) + am335x_i2c_register(2); +#endif + +#if defined(CONFIG_CAN) && (defined(CONFIG_AM335X_CAN0) || defined(CONFIG_AM335X_CAN1)) + am335x_can_register(); +#endif + + UNUSED(ret); + return ret; +} diff --git a/boards/arm/am335x/beaglebone/src/am335x_leds.c b/boards/arm/am335x/beaglebone/src/am335x_leds.c new file mode 100644 index 00000000000..5ebc94e69fe --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/am335x_leds.c @@ -0,0 +1,241 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/src/am335x_leds.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 "chip.h" +#include "arm_internal.h" +#include "beaglebone.h" + +/* The beaglebone black has four user LEDs; all four can be controlled from + * software. All are tied to ground and, hence, illuminated by driving the + * output pins to a high value: + * + * 1. LED0 GPMC_A5 GPMC_A5/GMII2_TXD0/RGMII2_TD0/RMII2_TXD0/GPMC_A21/ + * PR1_MII1_RXD3/eQEP1B_IN/GPIO1_21 + * 2. LED1 GPMC_A6 GPMC_A6/GMII2_TXCLK/RGMII2_TCLK/MMC2_DAT4/GPMC_A22/ + * PR1_MII1_RXD2/eQEP1_INDEX/GPIO1_22 + * 3. LED2 GPMC_A7 GPMC_A7/GMII2_RXCLK/RGMII2_RCLK/MMC2_DAT5/GPMC_A23/ + * PR1_MII1_RXD1/eQEP1_STROBE/GPIO1_23 + * 4. LED3 GPMC_A8 GPMC_A8/GMII2_RXD3/RGMII2_RD3/MMC2_DAT6/GPMC_A24/ + * PR1_MII1_RXD0/MCASP0_ACLKX/GPIO1_24 + + * These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/am335x_leds.c. The LEDs are used to encode OS- + * related events as follows: + * + * SYMBOL Meaning LED state + * LED1 LED3 LED4 + * ----------------- ----------------------- ---- ---- ---- ------------ + * LED_STARTED NuttX has been started ON OFF OFF + * LED_HEAPALLOCATE Heap has been allocated OFF ON OFF + * LED_IRQSENABLED Interrupts enabled ON ON OFF + * LED_STACKCREATED Idle stack created ON ON OFF + * LED_INIRQ In an interrupt N/C N/C Soft glow + * LED_SIGNAL In a signal handler N/C N/C Soft glow + * LED_ASSERTION An assertion failed N/C N/C Soft glow + * LED_PANIC The system has crashed N/C N/C 2Hz Flashing + * LED_IDLE MCU is in sleep mode Not used + * + * After booting, LED0 and 1 are not longer used by the system and can be + * used for other purposes by the application (Of course, all LEDs are + * available to the application if CONFIG_ARCH_LEDS is not defined. + */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: am335x_led_initialize + * + * Description: + * Configure LEDs. LEDs are left in the OFF state. + * + ****************************************************************************/ + +void am335x_led_initialize(void) +{ + am335x_gpio_config(GPIO_LED0); + am335x_gpio_config(GPIO_LED1); + am335x_gpio_config(GPIO_LED2); + am335x_gpio_config(GPIO_LED3); +} + +/**************************************************************************** + * Name: board_autoled_on + * + * Description: + * Select the "logical" ON state: + * + * SYMBOL Value Meaning LED state + * LED1 LED3 LED4 + * ----------------- ----- ----------------------- ---- ---- ------------ + * LED_STARTED 0 NuttX has been started ON OFF OFF + * LED_HEAPALLOCATE 1 Heap has been allocated OFF ON OFF + * LED_IRQSENABLED 2 Interrupts enabled ON ON OFF + * LED_STACKCREATED 2 Idle stack created ON ON OFF + * LED_INIRQ 3 In an interrupt N/C N/C Soft glow + * LED_SIGNAL 3 In a signal handler N/C N/C Soft glow + * LED_ASSERTION 3 An assertion failed N/C N/C Soft glow + * LED_PANIC 3 The system has crashed N/C N/C 2Hz Flashing + * LED_IDLE --- MCU is in sleep mode Not used + * + * LED1 is illuminated by driving the output pins to a high value + * LED3 and LED 4 are illuminated by taking the output to ground. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void board_autoled_on(int led) +{ + switch (led) + { + case 0: + am335x_gpio_write(GPIO_LED0, true); + am335x_gpio_write(GPIO_LED1, true); + am335x_gpio_write(GPIO_LED3, true); + break; + + case 1: + am335x_gpio_write(GPIO_LED0, false); + am335x_gpio_write(GPIO_LED1, false); + am335x_gpio_write(GPIO_LED3, true); + break; + + case 2: + am335x_gpio_write(GPIO_LED0, false); + am335x_gpio_write(GPIO_LED1, true); + am335x_gpio_write(GPIO_LED3, true); + break; + + case 3: + am335x_gpio_write(GPIO_LED3, false); + break; + } +} +#endif + +/**************************************************************************** + * Name: board_autoled_off + * + * Description: + * Select the "logical" OFF state: + * + * SYMBOL Value Meaning LED state + * LED1 LED3 LED4 + * ----------------- ----- ----------------------- ---- ---- ------------ + * LED_STARTED 0 NuttX has been started ON OFF OFF + * LED_HEAPALLOCATE 1 Heap has been allocated OFF ON OFF + * LED_IRQSENABLED 2 Interrupts enabled ON ON OFF + * LED_STACKCREATED 2 Idle stack created ON ON OFF + * LED_INIRQ 3 In an interrupt N/C N/C Soft glow + * LED_SIGNAL 3 In a signal handler N/C N/C Soft glow + * LED_ASSERTION 3 An assertion failed N/C N/C Soft glow + * LED_PANIC 3 The system has crashed N/C N/C 2Hz Flashing + * LED_IDLE --- MCU is in sleep mode Not used + * + * LED1 is illuminated by driving the output pins to a high value + * LED3 and LED 4 are illuminated by taking the output to ground. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_LEDS +void board_autoled_off(int led) +{ + switch (led) + { + case 0: + case 1: + case 2: + break; + + case 3: + am335x_gpio_write(GPIO_LED3, true); + break; + } +} +#endif + +/**************************************************************************** + * Name: board_userled_initialize, board_userled, and board_userled_all + * + * Description: + * These interfaces allow user control of the board LEDs. + * + * If CONFIG_ARCH_LEDS is defined, then NuttX will control both on-board + * LEDs up until the completion of boot. + * Then it will continue to control LED1; LED0 is available for + * application use. + * + * If CONFIG_ARCH_LEDS is not defined, then both LEDs are available for + * application use. + * + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + /* Initialization already performed in am335x_led_initialize */ + + return BOARD_NLEDS; +} + +void board_userled(int led, bool ledon) +{ + switch (led) + { + case USER_LED0: + am335x_gpio_write(GPIO_LED0, ledon); + break; + + case USER_LED1: + am335x_gpio_write(GPIO_LED1, ledon); + break; + +#ifndef CONFIG_ARCH_LEDS + case USER_LED3: + am335x_gpio_write(GPIO_LED3, ledon); + break; +#endif + } +} + +void board_userled_all(uint32_t ledset) +{ + board_userled(USER_LED0, (ledset & USER_LED0) != 0); + board_userled(USER_LED1, (ledset & USER_LED1) != 0); +#ifndef CONFIG_ARCH_LEDS + board_userled(USER_LED3, (ledset & USER_LED3) != 0); +#endif +} diff --git a/boards/arm/am335x/beaglebone/src/beaglebone.h b/boards/arm/am335x/beaglebone/src/beaglebone.h new file mode 100644 index 00000000000..6564ca4f6f5 --- /dev/null +++ b/boards/arm/am335x/beaglebone/src/beaglebone.h @@ -0,0 +1,127 @@ +/**************************************************************************** + * boards/arm/am335x/beaglebone/src/beaglebone.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_BEAGLEBONE_SRC_BEAGLEBONE_H +#define __BOARDS_ARM_BEAGLEBONE_SRC_BEAGLEBONE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +#include +#include + +#include "am335x_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LEDs *********************************************************************/ + +/* The beaglebone has four user LEDs; all four can be controlled from + * software. + * All are tied to ground and, hence, illuminated by driving the output pins + * to a high value: + * + * 1. LED0 GPMC_A5 GPMC_A5/GMII2_TXD0/RGMII2_TD0/RMII2_TXD0/GPMC_A21/ + * PR1_MII1_RXD3/eQEP1B_IN/GPIO1_21 + * 2. LED1 GPMC_A6 GPMC_A6/GMII2_TXCLK/RGMII2_TCLK/MMC2_DAT4/GPMC_A22/ + * PR1_MII1_RXD2/eQEP1_INDEX/GPIO1_22 + * 3. LED2 GPMC_A7 GPMC_A7/GMII2_RXCLK/RGMII2_RCLK/MMC2_DAT5/GPMC_A23/ + * PR1_MII1_RXD1/eQEP1_STROBE/GPIO1_23 + * 4. LED3 GPMC_A8 GPMC_A8/GMII2_RXD3/RGMII2_RD3/MMC2_DAT6/GPMC_A24/ + * PR1_MII1_RXD0/MCASP0_ACLKX/GPIO1_24 + */ + +#define GPIO_LED0 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN21) +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN22) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN23) +#define GPIO_LED3 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN24) + +/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is + * defined. In that case, the usage by the board port is defined in + * include/board.h and src/am335x_leds.c. + * The LEDs are used to encode OS-related events as follows: + * + * SYMBOL Meaning LED state + * LED1 LED3 LED4 + * ----------------- ----------------------- ---- ---- ---- ------------ + * LED_STARTED NuttX has been started ON OFF OFF + * LED_HEAPALLOCATE Heap has been allocated OFF ON OFF + * LED_IRQSENABLED Interrupts enabled ON ON OFF + * LED_STACKCREATED Idle stack created ON ON OFF + * LED_INIRQ In an interrupt N/C N/C Soft glow + * LED_SIGNAL In a signal handler N/C N/C Soft glow + * LED_ASSERTION An assertion failed N/C N/C Soft glow + * LED_PANIC The system has crashed N/C N/C 2Hz Flashing + * LED_IDLE MCU is in sleep mode Not used + * + * After booting, LED1 and 3 are not longer used by the system and can be + * used for other purposes by the application (Of course, all LEDs are + * available to the application if CONFIG_ARCH_LEDS is not defined. + */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ + +/**************************************************************************** + * Name: am335x_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + ****************************************************************************/ + +int am335x_bringup(void); + +/**************************************************************************** + * Name: am335x_led_initialize + * + * Description: + * Configure LEDs. LEDs are left in the OFF state. + * + ****************************************************************************/ + +void am335x_led_initialize(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_BEAGLEBONE_SRC_BEAGLEBONE_H */