From 7f79466d0b385587f24ae70e14a0292a370c22a3 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sun, 18 Sep 2022 13:05:46 +0200 Subject: [PATCH] boards: initial support for nrf5340-audio-dk - NSH boots on the app core --- boards/Kconfig | 9 ++ boards/arm/nrf53/nrf5340-audio-dk/Kconfig | 8 + boards/arm/nrf53/nrf5340-audio-dk/README.txt | 23 +++ .../configs/nsh_cpuapp/defconfig | 43 +++++ .../nrf53/nrf5340-audio-dk/include/board.h | 112 +++++++++++++ .../nrf53/nrf5340-audio-dk/scripts/Make.defs | 46 ++++++ .../scripts/flash_config_app.ld | 106 +++++++++++++ .../scripts/flash_config_net.ld | 108 +++++++++++++ .../arm/nrf53/nrf5340-audio-dk/src/Makefile | 35 +++++ .../nrf5340-audio-dk/src/nrf5340-audio-dk.h | 86 ++++++++++ .../nrf5340-audio-dk/src/nrf53_appinit.c | 74 +++++++++ .../nrf5340-audio-dk/src/nrf53_autoleds.c | 127 +++++++++++++++ .../nrf53/nrf5340-audio-dk/src/nrf53_boot.c | 79 ++++++++++ .../nrf5340-audio-dk/src/nrf53_bringup.c | 68 ++++++++ .../nrf5340-audio-dk/src/nrf53_userleds.c | 148 ++++++++++++++++++ 15 files changed, 1072 insertions(+) create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/Kconfig create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/README.txt create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/configs/nsh_cpuapp/defconfig create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/include/board.h create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/scripts/Make.defs create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_app.ld create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/Makefile create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf5340-audio-dk.h create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_appinit.c create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_autoleds.c create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_boot.c create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_bringup.c create mode 100644 boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_userleds.c diff --git a/boards/Kconfig b/boards/Kconfig index 364fd022f5..3c73d79aef 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -961,6 +961,14 @@ config ARCH_BOARD_NRF52840_DONGLE ---help--- This option selects the Nordic nRF52840 Dongle (PCA10059) +config ARCH_BOARD_NRF5340_AUDIO_DK + bool "Nordic nRF5340 Audio Development Kit (PCA10121)" + depends on ARCH_CHIP_NRF53 + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + ---help--- + This option selects the nRF5340 Audio Development Kit (PCA10121) + config ARCH_BOARD_NUTINY_NUC120 bool "Nuvoton NuTiny NUC120" depends on ARCH_CHIP_NUC120LE3AN @@ -2688,6 +2696,7 @@ config ARCH_BOARD default "nrf52832-dk" if ARCH_BOARD_NRF52832_DK default "nrf52840-dk" if ARCH_BOARD_NRF52840_DK default "nrf52840-dongle" if ARCH_BOARD_NRF52840_DONGLE + default "nrf5340-audio-dk" if ARCH_BOARD_NRF5340_AUDIO_DK default "ntosd-dm320" if ARCH_BOARD_NTOSD_DM320 default "nucleo-144" if ARCH_BOARD_NUCLEO_144 default "nucleo-f072rb" if ARCH_BOARD_NUCLEO_F072RB diff --git a/boards/arm/nrf53/nrf5340-audio-dk/Kconfig b/boards/arm/nrf53/nrf5340-audio-dk/Kconfig new file mode 100644 index 0000000000..50d9c41ea0 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NRF5340_AUDIO_DK + +endif diff --git a/boards/arm/nrf53/nrf5340-audio-dk/README.txt b/boards/arm/nrf53/nrf5340-audio-dk/README.txt new file mode 100644 index 0000000000..cf22d6cf4e --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/README.txt @@ -0,0 +1,23 @@ +nRF5340-DONGLE +=============== + +README for NuttX port to NRF5340 Audio DK (PCA10121) boards. + +Tool Issues +=========== + + OpenOCD + ------------- + There is no support official support for Nordic Cortex M33 chips (nRF9160 or nRF5340). + + Segger J-Link + ------------- + To start the GDB servers for the application core and the network core, use these commands: + + JLinkGDBServer -device nRF5340_xxAA_APP -autoconnect 1 -if SWD -speed 4000 -port 2331 -swoport 2332 -telnetport 2333 + JLinkGDBServer -device nRF5340_xxAA_NET -autoconnect 1 -if SWD -speed 4000 -port 2334 -swoport 2335 -telnetport 2336 + + Then you can connect GDB to targets: + + (gdb_app) target remote localhost:2331 + (gdb_net) target remote localhost:2334 diff --git a/boards/arm/nrf53/nrf5340-audio-dk/configs/nsh_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-audio-dk/configs/nsh_cpuapp/defconfig new file mode 100644 index 0000000000..9613fea063 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/configs/nsh_cpuapp/defconfig @@ -0,0 +1,43 @@ +# +# 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_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-audio-dk" +CONFIG_ARCH_BOARD_NRF5340_AUDIO_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_EXPERIMENTAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf53/nrf5340-audio-dk/include/board.h b/boards/arm/nrf53/nrf5340-audio-dk/include/board.h new file mode 100644 index 0000000000..0a0d341211 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/include/board.h @@ -0,0 +1,112 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_INCLUDE_BOARD_H +#define __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NRF53_GPIOTE) +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#define BOARD_SYSTICK_CLOCK (64000000) + +/* LED definitions **********************************************************/ + +/* A low output illuminates the LED. + * + * LED index values for use with board_userled() + */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_LED3 2 +#define BOARD_NLEDS 3 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) +#define BOARD_LED3_BIT (1 << BOARD_LED3) + +/* If CONFIG_ARCH_LEDS is defined, the LED will be controlled as follows + * for NuttX debug functionality (where NC means "No Change"). + */ + +#define LED_STARTED 0 /* OFF */ +#define LED_HEAPALLOCATE 0 /* OFF */ +#define LED_IRQSENABLED 0 /* OFF */ +#define LED_STACKCREATED 1 /* ON */ +#define LED_INIRQ 2 /* NC */ +#define LED_SIGNAL 2 /* NC */ +#define LED_ASSERTION 2 /* NC */ +#define LED_PANIC 3 /* Flashing */ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * uint32_t board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint32_t ledset); + */ + +/* Button definitions *******************************************************/ + +/* Board supports 5 buttons. */ + +#define BUTTON_BTN1 0 +#define BUTTON_BTN2 1 +#define BUTTON_BTN3 2 +#define BUTTON_BTN4 3 +#define BUTTON_BTN5 4 +#define NUM_BUTTONS 5 + +#define BUTTON_BTN1_BIT (1 << BUTTON_BTN1) +#define BUTTON_BTN2_BIT (1 << BUTTON_BTN2) +#define BUTTON_BTN3_BIT (1 << BUTTON_BTN3) +#define BUTTON_BTN4_BIT (1 << BUTTON_BTN4) +#define BUTTON_BTN5_BIT (1 << BUTTON_BTN5) + +/* UART Pins ****************************************************************/ + +/* The following definitions must be provided so that the NRF53 serial + * driver can set up the UART for the serial console properly. + */ + +#define BOARD_UART0_RX_PIN (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(4)) +#define BOARD_UART0_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(5)) + +#define BOARD_UART1_RX_PIN (GPIO_INPUT | GPIO_PORT1 | GPIO_PIN(8)) +#define BOARD_UART1_TX_PIN (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(9)) + +#endif /* __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_INCLUDE_BOARD_H */ diff --git a/boards/arm/nrf53/nrf5340-audio-dk/scripts/Make.defs b/boards/arm/nrf53/nrf5340-audio-dk/scripts/Make.defs new file mode 100644 index 0000000000..98794567d0 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/scripts/Make.defs @@ -0,0 +1,46 @@ +############################################################################ +# boards/arm/nrf53/nrf5340-audio-dk/scripts/Make.defs +# +# 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/armv8-m/Toolchain.defs + +ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUAPP),y) +LDSCRIPT = flash_config_app.ld +endif + +ifeq ($(CONFIG_ARCH_CHIP_NRF5340_CPUNET),y) +LDSCRIPT = flash_config_net.ld +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +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/nrf53/nrf5340-audio-dk/scripts/flash_config_app.ld b/boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_app.ld new file mode 100644 index 0000000000..437a2b74da --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_app.ld @@ -0,0 +1,106 @@ +/**************************************************************************** +* boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld + * + * 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. + * + ****************************************************************************/ + +MEMORY +{ + progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +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.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* 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/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld b/boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld new file mode 100644 index 0000000000..7e2026edbf --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld @@ -0,0 +1,108 @@ +/**************************************************************************** +* boards/arm/nrf53/nrf5340-audio-dk/scripts/flash_config_net.ld + * + * 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. + * + ****************************************************************************/ + +MEMORY +{ + app_progmem (rx) : ORIGIN = 0x00000000, LENGTH = 1024K + app_datamem (rwx) : ORIGIN = 0x20000000, LENGTH = 512K + progmem (rx) : ORIGIN = 0x01000000, LENGTH = 256K + datamem (rwx) : ORIGIN = 0x21000000, LENGTH = 64K +} + +OUTPUT_ARCH(arm) +ENTRY(__start) /* Treat __start as the anchor for dead code stripping */ +EXTERN(_vectors) /* Force the vectors to be included in the output */ +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.*) + _etext = ABSOLUTE(.); + } > progmem + + .init_section : + { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > progmem + + .ARM.extab : + { + *(.ARM.extab*) + } > progmem + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : + { + *(.ARM.exidx*) + } > progmem + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : + { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > datamem AT > progmem + + /* BSS */ + + .bss : + { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > datamem + + /* 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/nrf53/nrf5340-audio-dk/src/Makefile b/boards/arm/nrf53/nrf5340-audio-dk/src/Makefile new file mode 100644 index 0000000000..b3608c8888 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/Makefile @@ -0,0 +1,35 @@ +############################################################################ +# boards/arm/nrf53/nrf5340-audio-dk/src/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = nrf53_boot.c nrf53_bringup.c + +ifeq ($(CONFIG_BOARDCTL),y) +CSRCS += nrf53_appinit.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += nrf53_autoleds.c +else +CSRCS += nrf53_userleds.c +endif + +include $(TOPDIR)/boards/Board.mk diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf5340-audio-dk.h b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf5340-audio-dk.h new file mode 100644 index 0000000000..4e55a4c0a4 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf5340-audio-dk.h @@ -0,0 +1,86 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf5340-audio-dk.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_SRC_NRF53_NRF5340_AUDIO_DK_H +#define __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_SRC_NRF53_NRF5340_AUDIO_DK_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "nrf53_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* Definitions to configure LED GPIO as outputs */ + +#define GPIO_LED1 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(31)) +#define GPIO_LED2 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(1)) +#define GPIO_LED3 (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN(2)) + +/* Button definitions *******************************************************/ + +/* Board supports four buttons. */ + +#define GPIO_BUTTON1 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(2)) +#define GPIO_BUTTON2 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(3)) +#define GPIO_BUTTON3 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(4)) +#define GPIO_BUTTON4 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(5)) +#define GPIO_BUTTON5 (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT0 | GPIO_PIN(6)) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf53_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_NRF53_NRF5340_AUDIO_DK_SRC_NRF53_NRF5340_AUDIO_DK_H */ diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_appinit.c b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_appinit.c new file mode 100644 index 0000000000..5011e71b01 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_appinit.c @@ -0,0 +1,74 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "chip.h" +#include "nrf5340-audio-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform architecture specific initialization + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return nrf53_bringup(); +#endif +} diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_autoleds.c b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_autoleds.c new file mode 100644 index 0000000000..36740ee04b --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_autoleds.c @@ -0,0 +1,127 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_autoleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "arm_internal.h" +#include "nrf5340-audio-dk.h" + +#ifdef CONFIG_ARCH_LEDS + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(const char *msg) +{ + nrf53_pin_dump(PINCONFIG_LED, msg); + nrf53_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_autoled_initialize() Entry)"); + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf53_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_autoled_initialize() Exit"); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf53_gpio_write(g_ledcfg[led], LED_ON); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf53_gpio_write(g_ledcfg[led], LED_OFF); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_boot.c b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_boot.c new file mode 100644 index 0000000000..63fdab5121 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_boot.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_boot.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "arm_internal.h" +#include "nrf5340-audio-dk.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_board_initialize + * + * Description: + * All NRF53xxx 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 nrf53_board_initialize(void) +{ + /* Configure on-board LEDs if LED support has been selected. */ + +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will be + * called immediately after up_initialize() is called and just before the + * initial application is started. This additional initialization phase + * may be used, for example, to initialize board-specific device drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + nrf53_bringup(); +} +#endif diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_bringup.c new file mode 100644 index 0000000000..f6614ae5c8 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_bringup.c @@ -0,0 +1,68 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_USERLED +# include +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int nrf53_bringup(void) +{ + int ret; + +#ifdef CONFIG_USERLED + /* Register the LED driver */ + + ret = userled_lower_initialize(CONFIG_EXAMPLES_LEDS_DEVPATH); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_userleds.c b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_userleds.c new file mode 100644 index 0000000000..78609bacac --- /dev/null +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_userleds.c @@ -0,0 +1,148 @@ +/**************************************************************************** + * boards/arm/nrf53/nrf5340-audio-dk/src/nrf53_userleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "chip.h" +#include "arm_internal.h" +#include "nrf5340-audio-dk.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LED definitions **********************************************************/ + +/* If CONFIG_ARCH_LEDS is not defined, then the LEDs are completely under + * control of the application. The following interfaces are then available + * for application control of the LEDs: + * + * uint32_t board_userled_initialize(void); + * void board_userled(int led, bool ledon); + * void board_userled_all(uint32_t ledset); + */ + +#define LED_ON 0 +#define LED_OFF 1 + +/* This array maps an LED number to GPIO pin configuration */ + +static const uint32_t g_ledcfg[BOARD_NLEDS] = +{ +#if 0 < BOARD_NLEDS + GPIO_LED1, +#endif +#if 1 < BOARD_NLEDS + GPIO_LED2, +#endif +#if 2 < BOARD_NLEDS + GPIO_LED3, +#endif +#if 3 < BOARD_NLEDS + GPIO_LED4, +#endif +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: led_dumppins + ****************************************************************************/ + +#ifdef LED_VERBOSE +static void led_dumppins(const char *msg) +{ + nrf53_pin_dump(PINCONFIG_LED, msg); + nrf53_gpio_dump(GPIO_LED, msg); +} +#else +# define led_dumppins(m) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + int i; + + /* Configure LED pin as a GPIO outputs */ + + led_dumppins("board_userled_initialize() Entry)"); + + /* Configure GPIO as an outputs */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf53_gpio_config(g_ledcfg[i]); + } + + led_dumppins("board_userled_initialize() Exit"); + return BOARD_NLEDS; +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if ((unsigned)led < BOARD_NLEDS) + { + nrf53_gpio_write(g_ledcfg[led], ledon ? LED_ON : LED_OFF); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint32_t ledset) +{ + int i; + + /* Configure LED1-8 GPIOs for output */ + + for (i = 0; i < BOARD_NLEDS; i++) + { + nrf53_gpio_write(g_ledcfg[i], (ledset & (1 << i)) ? LED_ON : LED_OFF); + } +} + +#endif /* !CONFIG_ARCH_LEDS */