From 2a555d1165985244c949f1e8cb19e9c9280f8c74 Mon Sep 17 00:00:00 2001 From: Nobuto Kobayashi Date: Mon, 22 Apr 2019 08:31:02 -0600 Subject: [PATCH] configs/spresense: Add Spresense board support. --- Documentation/README.html | 4 +- README.txt | 2 + configs/Kconfig | 14 ++ configs/spresense/Kconfig | 8 + configs/spresense/README.txt | 20 ++ configs/spresense/include/board.h | 248 +++++++++++++++++++++++++ configs/spresense/nsh/.gdbinit | 15 ++ configs/spresense/nsh/defconfig | 49 +++++ configs/spresense/scripts/Make.defs | 150 +++++++++++++++ configs/spresense/scripts/ramconfig.ld | 119 ++++++++++++ configs/spresense/src/.gitignore | 2 + configs/spresense/src/Makefile | 58 ++++++ configs/spresense/src/cxd56_appinit.c | 94 ++++++++++ configs/spresense/src/cxd56_boot.c | 96 ++++++++++ configs/spresense/src/cxd56_bringup.c | 98 ++++++++++ configs/spresense/src/cxd56_ioctl.c | 117 ++++++++++++ configs/spresense/src/cxd56_leds.c | 79 ++++++++ configs/spresense/src/cxd56_ostest.c | 114 ++++++++++++ configs/spresense/src/spresense.h | 80 ++++++++ 19 files changed, 1366 insertions(+), 1 deletion(-) create mode 100644 configs/spresense/Kconfig create mode 100644 configs/spresense/README.txt create mode 100644 configs/spresense/include/board.h create mode 100644 configs/spresense/nsh/.gdbinit create mode 100644 configs/spresense/nsh/defconfig create mode 100644 configs/spresense/scripts/Make.defs create mode 100644 configs/spresense/scripts/ramconfig.ld create mode 100644 configs/spresense/src/.gitignore create mode 100644 configs/spresense/src/Makefile create mode 100644 configs/spresense/src/cxd56_appinit.c create mode 100644 configs/spresense/src/cxd56_boot.c create mode 100644 configs/spresense/src/cxd56_bringup.c create mode 100644 configs/spresense/src/cxd56_ioctl.c create mode 100644 configs/spresense/src/cxd56_leds.c create mode 100644 configs/spresense/src/cxd56_ostest.c create mode 100644 configs/spresense/src/spresense.h diff --git a/Documentation/README.html b/Documentation/README.html index c27aaab74a..00be93a5a4 100644 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -8,7 +8,7 @@

NuttX README Files

-

Last Updated: March 13, 2019

+

Last Updated: April 22, 2019

@@ -286,6 +286,8 @@ nuttx/ | | `- README.txt | |- skp16c26/ | | `- README.txt + | |- spresense/ + | | `- README.txt | |- stm3210e-eval/ | | |- RIDE/README.txt | | `- README.txt diff --git a/README.txt b/README.txt index 57263368aa..26ee173b25 100644 --- a/README.txt +++ b/README.txt @@ -1959,6 +1959,8 @@ nuttx/ | | `- README.txt | |- skp16c26/ | | `- README.txt + | |- spresense/ + | | `- README.txt | |- stm3210e-eval/ | | |- RIDE/README.txt | | `- README.txt diff --git a/configs/Kconfig b/configs/Kconfig index 9addd75c55..3ee3b6df19 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -1713,6 +1713,16 @@ config ARCH_BOARD_ZKITARM Zilogic System's ARM development Kit, ZKIT-ARM-1769. This board is based on the NXP LPC1769. The Nuttx Buildroot toolchain is used by default. +config ARCH_BOARD_SPRESENSE + bool "Sony Spresense Board" + depends on ARCH_CHIP_CXD56XX + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + select ARCH_HAVE_POWEROFF + ---help--- + none + config ARCH_BOARD_SIM bool "User mode simulation" depends on ARCH_SIM @@ -1959,6 +1969,7 @@ config ARCH_BOARD default "zkit-arm-1769" if ARCH_BOARD_ZKITARM default "sim" if ARCH_BOARD_SIM default "moxa" if ARCH_BOARD_MOXA + default "spresense" if ARCH_BOARD_SPRESENSE comment "Common Board Options" @@ -2484,6 +2495,9 @@ endif if ARCH_BOARD_ZKITARM source "configs/zkit-arm-1769/Kconfig" endif +if ARCH_BOARD_SPRESENSE +source "configs/spresense/Kconfig" +endif if ARCH_BOARD_SIM source "configs/sim/Kconfig" endif diff --git a/configs/spresense/Kconfig b/configs/spresense/Kconfig new file mode 100644 index 0000000000..5244102f5c --- /dev/null +++ b/configs/spresense/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_SPRESENSE + +endif diff --git a/configs/spresense/README.txt b/configs/spresense/README.txt new file mode 100644 index 0000000000..ec9fcaee05 --- /dev/null +++ b/configs/spresense/README.txt @@ -0,0 +1,20 @@ +README +====== + +Spresense is a compact development board based on Sony’s power-efficient +multicore microcontroller CXD5602. It allows developers to create IoT +applications in a very short time and is supported by the Arduino IDE as well +as the more advanced NuttX based SDK. + +- Integrated GPS + The embedded GNSS with support for GPS, QZSS and GLONASS enables applications + where tracking is required. +- Hi-res audio output and multi mic inputs + Advanced 192kHz/24 bit audio codec and amplifier for audio output, and + support for up to 8 mic input channels. +- Multicore microcontroller + Spresense is powered by Sony's CXD5602 microcontroller (ARM® Cortex®-M4F × 6 + cores), with a clock speed of 156 MHz. + +Refer to https://developer.sony.com/develop/spresense/ for further information +about this board. diff --git a/configs/spresense/include/board.h b/configs/spresense/include/board.h new file mode 100644 index 0000000000..29ee204be2 --- /dev/null +++ b/configs/spresense/include/board.h @@ -0,0 +1,248 @@ +/**************************************************************************** + * configs/spresense/include/board.h + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef _CONFIGS_SPRESENSE_INCLUDE_BOARD_H +#define _CONFIGS_SPRESENSE_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking ****************************************************************/ + +#define BOARD_XTAL_FREQUENCY (26000000) /* XTAL oscillator frequency */ +#define BOARD_RTCCLK_FREQUENCY (32768) /* RTC oscillator frequency */ +#define BOARD_INTRCOSC_FREQUENCY (8192000) /* Internal RC oscillator frequency */ + +#ifdef CONFIG_CXD56_80MHz +# define BOARD_FCLKOUT_FREQUENCY (80000000) +#else +# define BOARD_FCLKOUT_FREQUENCY (97500000) +#endif + +#define CXD56_CCLK BOARD_FCLKOUT_FREQUENCY + +/* USB0 ********************************************************************/ + +#define BOARD_USB0_CLKSRC PLL0USB_CLKSEL_XTAL +#define BOARD_USB0_MDIV 0x06167ffa /* Table 149 datsheet, valid for 12Mhz Fclkin */ +#define BOARD_USB0_NP_DIV 0x00302062 /* Table 149 datsheet, valid for 12Mhz Fclkin */ + +/* SPIFI clocking **********************************************************/ + +/* The SPIFI will receive clocking from a divider per the settings provided + * in this file. The NuttX code will configure PLL1 as the input clock + * for the selected divider + */ + +#undef BOARD_SPIFI_PLL1 /* No division */ +#undef BOARD_SPIFI_DIVA /* Supports division by 1-4 */ +#undef BOARD_SPIFI_DIVB /* Supports division by 1-16 */ +#undef BOARD_SPIFI_DIVC /* Supports division by 1-16 */ +#undef BOARD_SPIFI_DIVD /* Supports division by 1-16 */ +#undef BOARD_SPIFI_DIVE /* Supports division by 1-256 */ + +#if BOARD_FCLKOUT_FREQUENCY < 20000000 +# define BOARD_SPIFI_PLL1 1 /* Use PLL1 directly */ +#else +# define BOARD_SPIFI_DIVB 1 /* Use IDIVB */ +#endif + +/* We need to configure the divider so that its output is as close to the + * desired SCLK value. The peak data transfer rate will be about half of + * this frequency in bytes per second. + */ + +#if BOARD_FCLKOUT_FREQUENCY < 20000000 +# define BOARD_SPIFI_FREQUENCY BOARD_FCLKOUT_FREQUENCY /* 72Mhz? */ +#else +# define BOARD_SPIFI_DIVIDER (14) /* 204MHz / 14 = 14.57MHz */ +# define BOARD_SPIFI_FREQUENCY (102000000) /* 204MHz / 14 = 14.57MHz */ +#endif + +/* UART clocking ***********************************************************/ + +/* Configure all UARTs to use the XTAL input frequency */ + +#define BOARD_UART0_BASEFREQ BOARD_XTAL_FREQUENCY +#define BOARD_UART1_BASEFREQ 48750000 +#define BOARD_UART2_BASEFREQ BOARD_XTAL_FREQUENCY + +/* LED definitions *********************************************************/ + +#define BOARD_LED1 (0) +#define BOARD_LED2 (1) +#define BOARD_NLEDS (2) + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) + +/* LED pattern for use with board_autoled_on() and board_autoled_off() + * ON OFF + * LED1 LED2 LED1 LED2 + * PTN0: OFF OFF - - + * PTN1: ON OFF - - + * PTN2: - ON - OFF + * + */ + +#define LED_AUTOLED_PTN0 (0) +#define LED_AUTOLED_PTN1 (1) +#define LED_AUTOLED_PTN2 (2) + +#define LED_STARTED (LED_AUTOLED_PTN0) +#define LED_HEAPALLOCATE (LED_AUTOLED_PTN1) +#define LED_IRQSENABLED (LED_AUTOLED_PTN1) +#define LED_STACKCREATED (LED_AUTOLED_PTN1) +#define LED_INIRQ (LED_AUTOLED_PTN2) +#define LED_SIGNAL (LED_AUTOLED_PTN2) +#define LED_ASSERTION (LED_AUTOLED_PTN2) +#define LED_PANIC (LED_AUTOLED_PTN2) + +/* Buttons definitions *****************************************************/ + +#define BOARD_NUM_BUTTONS (2) + +/* Power Control definitions ***********************************************/ + +/* Switch Device + * --------- ------------------------------- + * LSW2 AcaPulco Audio Digital VDD + * LSW3 SPI-Flash & TCXO + * LSW4 GNSS LNA + * GPO0 AcaPulco Audio Analog VDD + * GPO1 Sensor 1.8V + * GPO2 Sensor 3.3V + * GPO3 Bluetooth/Bluetooth Low Energy + * GPO4 Image Sensor 1.2V + * GPO5 Image Sensor 3.3V + * GPO6 eMMC 3.3V/1.8V + * GPO7 Image Sensor 1.8V + * + */ + +#define PMIC_NONE (0) +#define PMIC_TYPE_LSW (1u << 8) +#define PMIC_TYPE_GPO (1u << 9) +#define PMIC_TYPE_DDCLDO (1u << 10) +#define PMIC_GET_TYPE(v) ((v) & 0xff00) +#define PMIC_GET_CH(v) ((v) & 0x00ff) +#define PMIC_LSW(n) (PMIC_TYPE_LSW | (1u << (n))) +#define PMIC_GPO(n) (PMIC_TYPE_GPO | (1u << (n))) +#define PMIC_DDCLDO(n) (PMIC_TYPE_DDCLDO | (1u << (n))) + +enum board_power_device +{ + /* DDC/LDO */ + + POWER_DDC_IO = PMIC_DDCLDO(0), + POWER_LDO_EMMC = PMIC_DDCLDO(1), + POWER_DDC_ANA = PMIC_DDCLDO(2), + POWER_LDO_ANA = PMIC_DDCLDO(3), + POWER_DDC_CORE = PMIC_DDCLDO(4), + POWER_LDO_PERI = PMIC_DDCLDO(5), + + /* Load Switch */ + + POWER_AUDIO_DVDD = PMIC_LSW(2), + POWER_FLASH = PMIC_LSW(3), + POWER_TCXO = PMIC_LSW(3), + POWER_LNA = PMIC_LSW(4), + + /* GPO */ + + POWER_AUDIO_AVDD = PMIC_GPO(0), + POWER_SENSOR_18V = PMIC_GPO(1), + POWER_SENSOR_33V = PMIC_GPO(2), + POWER_BMI160 = POWER_SENSOR_18V, + POWER_SENSOR = POWER_SENSOR_18V | POWER_SENSOR_33V, + POWER_BTBLE = PMIC_GPO(3), + POWER_EINK = PMIC_NONE, + POWER_EMMC = PMIC_GPO(6), + POWER_LFOUR = PMIC_NONE, + POWER_LTE = PMIC_NONE, + POWER_IMAGE_SENSOR = PMIC_GPO(4) | PMIC_GPO(5) | PMIC_GPO(7), +}; + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: cxd56_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void cxd56_boardinitialize(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* _CONFIGS_SPRESENSE_INCLUDE_BOARD_H */ diff --git a/configs/spresense/nsh/.gdbinit b/configs/spresense/nsh/.gdbinit new file mode 100644 index 0000000000..c5fe8ea3b5 --- /dev/null +++ b/configs/spresense/nsh/.gdbinit @@ -0,0 +1,15 @@ +define hookpost-load + + if &g_readytorun != 0 + eval "monitor nuttx.pid_offset %d", &((struct tcb_s *)(0))->pid + eval "monitor nuttx.xcpreg_offset %d", &((struct tcb_s *)(0))->xcp.regs + eval "monitor nuttx.state_offset %d", &((struct tcb_s *)(0))->task_state + eval "monitor nuttx.name_offset %d", &((struct tcb_s *)(0))->name + eval "monitor nuttx.name_size %d", sizeof(((struct tcb_s *)(0))->name) + end + +end + +define connect + target remote | openocd -f interface/cmsis-dap.cfg -f cxd5602.cfg -c "gdb_port pipe; log_output openocd.log" +end diff --git a/configs/spresense/nsh/defconfig b/configs/spresense/nsh/defconfig new file mode 100644 index 0000000000..fd725797d2 --- /dev/null +++ b/configs/spresense/nsh/defconfig @@ -0,0 +1,49 @@ +# +# 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_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="spresense" +CONFIG_ARCH_BOARD_SPRESENSE=y +CONFIG_ARCH_CHIP_CXD56XX=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_USEBASEPRI=y +CONFIG_BOARD_LOOPSPERMSEC=5434 +CONFIG_BOOT_RUNFROMISRAM=y +CONFIG_BUILTIN=y +CONFIG_CLOCK_MONOTONIC=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POLL=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_I2C=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=16 +CONFIG_RAM_SIZE=1572864 +CONFIG_RAM_START=0x0d000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_SPI=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_CLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_CXXINITIALIZE=y +CONFIG_UART1_SERIAL_CONSOLE=y +CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/configs/spresense/scripts/Make.defs b/configs/spresense/scripts/Make.defs new file mode 100644 index 0000000000..35c8968761 --- /dev/null +++ b/configs/spresense/scripts/Make.defs @@ -0,0 +1,150 @@ +############################################################################ +# configs/cxd56evb/nsh/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +# Setup for the kind of memory that we are executing from + +LDSCRIPT = ramconfig.ld + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump +STRIP = $(CROSSDEV)strip + +MKNXFLAT = mknxflat +LDNXFLAT = ldnxflat + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin -mabi=aapcs +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti -std=c++98 +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +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 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +ifeq ($(WINTOOL),y) + LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/sched/module/gnu-elf.ld}" +else + LDMODULEFLAGS += -T $(TOPDIR)/sched/module/gnu-elf.ld +endif + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) +CXXELFFLAGS = $(CXXFLAGS) + +LDELFFLAGS = -r -e main +ifeq ($(WINTOOL),y) + LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}" +else + LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld +endif + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + CFLAGS += -gdwarf-3 + CXXFLAGS += -gdwarf-3 + LDFLAGS += -g +endif + +# Output map file with cross reference table + +ifeq ($(WINTOOL),y) + LDFLAGS += -Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" --cref +else + LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref +endif + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = diff --git a/configs/spresense/scripts/ramconfig.ld b/configs/spresense/scripts/ramconfig.ld new file mode 100644 index 0000000000..5f1ef754fe --- /dev/null +++ b/configs/spresense/scripts/ramconfig.ld @@ -0,0 +1,119 @@ +/**************************************************************************** + * configs/cxd56evb/scripts/ramconfig.ld + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +MEMORY +{ + ram (rwx) : ORIGIN = 0x0d000000, LENGTH = 1536K +} + +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 */ +EXTERN(__stack) /* Force the __stack 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.*) + Image$$MODLIST$$Base = .; + KEEP(*(.modulelist)) + Image$$MODLIST$$Limit = .; + _etext = ABSOLUTE(.); + } > ram + + .init_section : { + _sinit = ABSOLUTE(.); + KEEP(*(.init_array .init_array.*)) + _einit = ABSOLUTE(.); + } > ram + + .ARM.extab : { + *(.ARM.extab*) + } > ram + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > ram + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > ram + + .bss : { /* BSS */ + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > ram + + /* __stack symbol is referred from mkspk tool + * and means the end address of heap region */ + PROVIDE(__stack = ORIGIN(ram) + LENGTH(ram)); + + /* 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/configs/spresense/src/.gitignore b/configs/spresense/src/.gitignore new file mode 100644 index 0000000000..726d936e1e --- /dev/null +++ b/configs/spresense/src/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Make.dep diff --git a/configs/spresense/src/Makefile b/configs/spresense/src/Makefile new file mode 100644 index 0000000000..c7feedc0d1 --- /dev/null +++ b/configs/spresense/src/Makefile @@ -0,0 +1,58 @@ +############################################################################ +# configs/spresense/src/Makefile +# +# Copyright 2018 Sony Semiconductor Solutions Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +DEPPATH = --dep-path . + +ASRCS = +CSRCS = cxd56_boot.c cxd56_bringup.c + +ifeq ($(CONFIG_LIB_BOARDCTL),y) +CSRCS += cxd56_appinit.c +endif + +ifeq ($(CONFIG_BOARDCTL_IOCTL),y) +CSRCS += cxd56_ioctl.c +endif + +ifeq ($(CONFIG_ARCH_FPU),y) +CSRCS += cxd56_ostest.c +endif + +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += cxd56_leds.c +endif + +include $(TOPDIR)/configs/Board.mk diff --git a/configs/spresense/src/cxd56_appinit.c b/configs/spresense/src/cxd56_appinit.c new file mode 100644 index 0000000000..f699bb7ca5 --- /dev/null +++ b/configs/spresense/src/cxd56_appinit.c @@ -0,0 +1,94 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_appinit.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "spresense.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef OK +# define OK 0 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value cold 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 cxd56_bringup(); +#endif +} diff --git a/configs/spresense/src/cxd56_boot.c b/configs/spresense/src/cxd56_boot.c new file mode 100644 index 0000000000..289071a5ff --- /dev/null +++ b/configs/spresense/src/cxd56_boot.c @@ -0,0 +1,96 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_boot.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +#include "spresense.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: cxd56_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void cxd56_boardinitialize(void) +{ +} + + +/**************************************************************************** + * 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 */ + + (void)cxd56_bringup(); +} +#endif diff --git a/configs/spresense/src/cxd56_bringup.c b/configs/spresense/src/cxd56_bringup.c new file mode 100644 index 0000000000..0c229d9022 --- /dev/null +++ b/configs/spresense/src/cxd56_bringup.c @@ -0,0 +1,98 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_bringup.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include "spresense.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* procfs File System */ + +#ifdef CONFIG_FS_PROCFS +# ifdef CONFIG_NSH_PROC_MOUNTPOINT +# define CXD56_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT +# else +# define CXD56_PROCFS_MOUNTPOINT "/proc" +# endif +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: cxd56_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int cxd56_bringup(void) +{ + int ret; + + (void) ret; + +#ifdef CONFIG_FS_PROCFS + ret = mount(NULL, CXD56_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + if (ret < 0) + { + serr("ERROR: Failed to mount the procfs: %d\n", errno); + } +#endif + + return OK; +} diff --git a/configs/spresense/src/cxd56_ioctl.c b/configs/spresense/src/cxd56_ioctl.c new file mode 100644 index 0000000000..1f6a0e13c5 --- /dev/null +++ b/configs/spresense/src/cxd56_ioctl.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_ioctl.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "chip.h" +#include "cxd56_uart.h" + +#ifdef CONFIG_BOARDCTL_IOCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: boardctl + * + * Description: + * In a small embedded system, there will typically be a much greater + * interaction between application and low-level board features. The + * canonically correct to implement such interactions is by implementing a + * character driver and performing the interactions via low level ioctl + * calls. This, however, may not be practical in many cases and will lead + * to "correct" but awkward implementations. + * + * boardctl() is non-standard OS interface to alleviate the problem. It + * basically circumvents the normal device driver ioctl interlace and allows + * the application to perform direct IOCTL-like calls to the board-specific + * logic. It is especially useful for setting up board operational and + * test configurations. + * + * Input Parameters: + * cmd - Identifies the board command to be executed + * arg - The argument that accompanies the command. The nature of the + * argument is determined by the specific command. + * + * Returned Value: + * On success zero (OK) is returned; -1 (ERROR) is returned on failure + * with the errno variable to to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_ioctl(unsigned int cmd, uintptr_t arg) +{ + int ret = -ENOTTY; /* The correct return for the case of an unrecognized + * command. */ + + switch (cmd) + { +#ifdef CONFIG_USBDEV + /* CMD: BOARDIOC_USBDEV_SETNOTIFYSIG + * DESCRIPTION: Set signal id for notify USB device connection status + * and supply current value. + * ARG: None + * CONFIGURATION: CONFIG_LIB_BOARDCTL + * DEPENDENCIES: Board logic must provide board_app_initialization + */ + + case BOARDIOC_USBDEV_SETNOTIFYSIG: + { + ret = cxd56_usbdev_setsigno((int)arg); + } + break; +#endif + default: + break; + } + + /* Any failure errno value will be set in boardctl() */ + + return ret; +} +#endif diff --git a/configs/spresense/src/cxd56_leds.c b/configs/spresense/src/cxd56_leds.c new file mode 100644 index 0000000000..0c3bcf001d --- /dev/null +++ b/configs/spresense/src/cxd56_leds.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_leds.c + * + * Copyright 2018 Sony Semiconductor Solutions Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Sony Semiconductor Solutions Corporation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/configs/spresense/src/cxd56_ostest.c b/configs/spresense/src/cxd56_ostest.c new file mode 100644 index 0000000000..b36516ca60 --- /dev/null +++ b/configs/spresense/src/cxd56_ostest.c @@ -0,0 +1,114 @@ +/**************************************************************************** + * configs/spresense/src/cxd56_ostest.c + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#undef HAVE_FPU +#if defined(CONFIG_ARCH_FPU) && defined(CONFIG_EXAMPLES_OSTEST_FPUSIZE) && \ + defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_DISABLE_SIGNALS) && \ + !defined(CONFIG_ARMV7M_CMNVECTOR) +# define HAVE_FPU 1 +#endif + +#ifdef HAVE_FPU + +#if CONFIG_EXAMPLES_OSTEST_FPUSIZE != (4*SW_FPU_REGS) +# error "CONFIG_EXAMPLES_OSTEST_FPUSIZE has the wrong size" +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static uint32_t g_saveregs[XCPTCONTEXT_REGS]; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/* Given an array of size CONFIG_EXAMPLES_OSTEST_FPUSIZE, this function will + * return the current FPU registers. + */ + +void arch_getfpu(FAR uint32_t *fpusave) +{ + irqstate_t flags; + + /* Take a snapshot of the thread context right now */ + + flags = enter_critical_section(); + up_saveusercontext(g_saveregs); + + /* Return only the floating register values */ + + memcpy(fpusave, &g_saveregs[REG_S0], (4*SW_FPU_REGS)); + leave_critical_section(flags); +} + +/* Given two arrays of size CONFIG_EXAMPLES_OSTEST_FPUSIZE this function + * will compare them and return true if they are identical. + */ + +bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2) +{ + return memcmp(fpusave1, fpusave2, (4*SW_FPU_REGS)) == 0; +} + +#endif /* HAVE_FPU */ diff --git a/configs/spresense/src/spresense.h b/configs/spresense/src/spresense.h new file mode 100644 index 0000000000..e8b9b4f3e6 --- /dev/null +++ b/configs/spresense/src/spresense.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * configs/spresense/src/spresense.h + * + * Copyright (C) 2019 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __CONFIGS_SPRESENSE_SRC_SPRESENSE_H +#define __CONFIGS_SPRESENSE_SRC_SPRESENSE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: cxd56_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y : + * Called from the NSH library + * + ****************************************************************************/ + +int cxd56_bringup(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIGS_SPRESENSE_SRC_SPRESENSE_H */