boards/xtensa/esp32: Initial support for the ESP32 Ethernet Kit.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
parent
a8f7959a21
commit
e097890f22
47
boards/xtensa/esp32/esp32-ethernet-kit/Kconfig
Normal file
47
boards/xtensa/esp32/esp32-ethernet-kit/Kconfig
Normal file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_BOARD_ESP32_ETHERNETKIT
|
||||
|
||||
choice
|
||||
prompt "On-board Crystal Frequency"
|
||||
default ESP32_ETHERNETKIT_XTAL_40MZ
|
||||
|
||||
config ESP32_ETHERNETKIT_XTAL_40MZ
|
||||
bool "40MHz"
|
||||
|
||||
config ESP32_ETHERNETKIT_XTAL_26MHz
|
||||
bool "26MHz"
|
||||
|
||||
endchoice # On-board Crystal Frequency
|
||||
|
||||
config ESP32_ETHERNETKIT_RUN_IRAM
|
||||
bool "Run from IRAM"
|
||||
default n
|
||||
---help---
|
||||
The default configuration is set up run from IRAM. However, the
|
||||
current (2016-11-14) OpenOCD for ESP32 does not support writing to
|
||||
FLASH. This option sets up the linker scripts to support execution
|
||||
from IRAM. In this case, OpenOCD can be used to load directly into
|
||||
IRAM.
|
||||
|
||||
At this stage the nuttx image is small enough to be entirely memory-
|
||||
resident. Once board support is more mature you can add flash cache
|
||||
mapping code to run from SPI flash after initial boot. There are at
|
||||
least two possible approaches you could take: You can add the flash
|
||||
cache mapping code into nuttx directly, so it is self-contained -
|
||||
early nuttx initialization runs from IRAM and enables flash cache,
|
||||
and then off you go. Or you can use the esp-idf software bootloader
|
||||
and partition table scheme and have nuttx be an esp-idf "app" which
|
||||
allows interoperability with the esp-idf system but makes you
|
||||
reliant on the esp-idf design for these parts. Both are possible.
|
||||
|
||||
config ESP32_ETHERNETKIT_FLASH_IMAGE
|
||||
bool "esp32 flash image"
|
||||
default n
|
||||
---help---
|
||||
Create flash_image.bin mainly used for QEMU.
|
||||
|
||||
endif # ARCH_BOARD_ESP32_ETHERNETKIT
|
69
boards/xtensa/esp32/esp32-ethernet-kit/README.txt
Normal file
69
boards/xtensa/esp32/esp32-ethernet-kit/README.txt
Normal file
@ -0,0 +1,69 @@
|
||||
README for the Espressif ESP32 Ethernet Kit
|
||||
==============================================
|
||||
|
||||
The ESP32 is a dual-core system from Espressif with two Harvard
|
||||
architecture Xtensa LX6 CPUs. All embedded memory, external memory and
|
||||
peripherals are located on the data bus and/or the instruction bus of
|
||||
these CPUs. With some minor exceptions, the address mapping of two CPUs
|
||||
is symmetric, meaning they use the same addresses to access the same
|
||||
memory. Multiple peripherals in the system can access embedded memory via
|
||||
DMA.
|
||||
|
||||
The ESP32-Ethernet-Kit is an Ethernet-to-Wi-Fi development board that enables
|
||||
Ethernet devices to be interconnected over Wi-Fi. At the same time, to provide
|
||||
more flexible power supply options, the ESP32-Ethernet-Kit also supports power
|
||||
over Ethernet (PoE).
|
||||
|
||||
Buttons and LEDs
|
||||
================
|
||||
|
||||
Buttons
|
||||
-------
|
||||
There are two buttons labeled Boot and EN. The EN button is not available
|
||||
to software. It pulls the chip enable line that doubles as a reset line.
|
||||
|
||||
The BOOT button is connected to IO0. On reset it is used as a strapping
|
||||
pin to determine whether the chip boots normally or into the serial
|
||||
bootloader. After reset, however, the BOOT button can be used for software
|
||||
input.
|
||||
|
||||
LEDs
|
||||
----
|
||||
There are several on-board LEDs for that indicate the presence of power
|
||||
and USB activity. None of these are available for use by software.
|
||||
|
||||
Ethernet
|
||||
========
|
||||
|
||||
ESP32 has a 802.11 hardware MAC, so just connects to external PHY chip.
|
||||
Due to the limited number of GPIOs in ESP32, it's recommended to use RMII to
|
||||
connect to an external PHY chip. Current driver also only supports RMII option.
|
||||
|
||||
The RMII GPIO pins are fixed, but the SMI and functional GPIO pins are optional.
|
||||
|
||||
RMII GPIO pins are as following:
|
||||
|
||||
ESP32 GPIO PHY Chip GPIO
|
||||
IO25 <--> RXD[0]
|
||||
IO26 <--> RXD[1]
|
||||
IO27 <--> CRS_DV
|
||||
IO0 <--> REF_CLK
|
||||
IO19 <--> TXD[0]
|
||||
IO21 <--> TX_EN
|
||||
IO22 <--> TXD[1]
|
||||
|
||||
SMI GPIO pins (default option) are as following:
|
||||
|
||||
ESP32 GPIO PHY Chip GPIO
|
||||
IO18 <--> MDIO
|
||||
IO23 <--> MDC
|
||||
|
||||
Functional GPIO pins(default option) are as following:
|
||||
|
||||
ESP32 GPIO PHY Chip GPIO
|
||||
IO5 <--> Reset_N
|
||||
|
||||
Espressif has an offcial Ethernet development board:
|
||||
|
||||
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit.html
|
||||
|
@ -0,0 +1,72 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32-ethernet-kit"
|
||||
CONFIG_ARCH_BOARD_ESP32CORE=y
|
||||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32_EMAC=y
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x08080808
|
||||
CONFIG_NETDB_HOSTFILE=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETINIT_DRIPADDR=0xc0a80f01
|
||||
CONFIG_NETINIT_IPADDR=0xc0a80f64
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NETUTILS_TFTPC=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NET_ARP_SEND=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCPBACKLOG=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SUPPRESS_CLOCK_CONFIG=y
|
||||
CONFIG_SUPPRESS_UART_CONFIG=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
48
boards/xtensa/esp32/esp32-ethernet-kit/configs/nsh/defconfig
Normal file
48
boards/xtensa/esp32/esp32-ethernet-kit/configs/nsh/defconfig
Normal file
@ -0,0 +1,48 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32-ethernet-kit"
|
||||
CONFIG_ARCH_BOARD_ESP32CORE=y
|
||||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
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_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
82
boards/xtensa/esp32/esp32-ethernet-kit/include/board.h
Normal file
82
boards/xtensa/esp32/esp32-ethernet-kit/include/board.h
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/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_XTENSA_ESP32_ESP32_ETHERNET_KIT_INCLUDE_BOARD_H
|
||||
#define __BOARDS_XTENSA_ESP32_ESP32_ETHERNET_KIT_INCLUDE_BOARD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Clocking *****************************************************************/
|
||||
|
||||
/* The ESP32 Ethernet kit board V2 is fitted with either a 26 or a 40MHz
|
||||
* crystal
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ESP32_ETHERNETKIT_XTAL_26MHz
|
||||
# define BOARD_XTAL_FREQUENCY 26000000
|
||||
#else
|
||||
# define BOARD_XTAL_FREQUENCY 40000000
|
||||
#endif
|
||||
|
||||
/* Clock reconfiguration is currently disabled, so the CPU will be running
|
||||
* at the XTAL frequency or at two times the XTAL frequency, depending upon
|
||||
* how we load the code:
|
||||
*
|
||||
* - If we load the code into FLASH at address 0x1000 where it is started by
|
||||
* the second level bootloader, then the frequency is the crystal
|
||||
* frequency.
|
||||
* - If we load the code into IRAM after the second level bootloader has run
|
||||
* this frequency will be twice the crystal frequency.
|
||||
*
|
||||
* Don't ask me for an explanation.
|
||||
*/
|
||||
|
||||
/* Note: The bootloader (esp-idf bootloader.bin) configures:
|
||||
*
|
||||
* - CPU frequency to 80MHz
|
||||
* - The XTAL frequency according to the SDK config CONFIG_ESP32_XTAL_FREQ,
|
||||
* which is 40MHz by default.
|
||||
*
|
||||
* Reference:
|
||||
* https://github.com/espressif/esp-idf/blob
|
||||
* /6fd855ab8d00d23bad4660216bc2122c2285d5be/components
|
||||
* /bootloader_support/src/bootloader_clock.c#L38-L62
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ESP32_ETHERNETKIT_RUN_IRAM
|
||||
# define BOARD_CLOCK_FREQUENCY (2 * BOARD_XTAL_FREQUENCY)
|
||||
#else
|
||||
#ifdef CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ
|
||||
# define BOARD_CLOCK_FREQUENCY (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000)
|
||||
#else
|
||||
# define BOARD_CLOCK_FREQUENCY 80000000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
||||
/* Define how many LEDs this board has (needed by userleds) */
|
||||
|
||||
#define BOARD_NLEDS 1
|
||||
#define GPIO_LED1 2
|
||||
|
||||
#endif /* __BOARDS_XTENSA_ESP32_ESP32_ETHERNET_KIT_INCLUDE_BOARD_H */
|
1
boards/xtensa/esp32/esp32-ethernet-kit/scripts/.gitignore
vendored
Normal file
1
boards/xtensa/esp32/esp32-ethernet-kit/scripts/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/esp32_out.ld
|
62
boards/xtensa/esp32/esp32-ethernet-kit/scripts/Config.mk
Normal file
62
boards/xtensa/esp32/esp32-ethernet-kit/scripts/Config.mk
Normal file
@ -0,0 +1,62 @@
|
||||
############################################################################
|
||||
# boards/xtensa/esp32/esp32-ethernet-kit/scripts/Config.mk
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# These are the macros that will be used in the NuttX make system to compile
|
||||
# and assemble source files and to insert the resulting object files into an
|
||||
# archive. These replace the default definitions at tools/Config.mk
|
||||
|
||||
# POSTBUILD -- Perform post build operations
|
||||
|
||||
ifdef BLOBDIR
|
||||
BOOTLOADER=${BLOBDIR}/esp32core/bootloader.bin
|
||||
PARTITION_TABLE=${BLOBDIR}/esp32core/partition-table.bin
|
||||
else
|
||||
BOOTLOADER=$(IDF_PATH)/hello_world/build/bootloader/bootloader.bin
|
||||
PARTITION_TABLE=$(IDF_PATH)/hello_world/build/partition_table/partition-table.bin
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32_ETHERNETKIT_FLASH_IMAGE),y)
|
||||
define POSTBUILD
|
||||
@echo "MKIMAGE: ESP32 binary"
|
||||
$(Q) if ! esptool.py version ; then \
|
||||
echo ""; \
|
||||
echo "Please install ESP-IDF tools"; \
|
||||
echo ""; \
|
||||
echo "Check https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/index.html#installation-step-by-step or run the following command"; \
|
||||
echo ""; \
|
||||
echo "cd tools/esp32 && make && cd ../.."; \
|
||||
echo ""; \
|
||||
echo "run make again to create the nuttx.bin image."; \
|
||||
else \
|
||||
echo "Generating: $(NUTTXNAME).bin (ESP32 compatible)"; \
|
||||
esptool.py --chip esp32 elf2image --flash_mode dio --flash_size 4MB -o $(NUTTXNAME).bin nuttx; \
|
||||
echo "Generated: $(NUTTXNAME).bin (ESP32 compatible)"; \
|
||||
echo "Generating: flash_image.bin"; \
|
||||
echo " Bootloader: $(BOOTLOADER)"; \
|
||||
echo " Parition Table: $(PARTITION_TABLE)"; \
|
||||
dd if=/dev/zero bs=1024 count=4096 of=flash_image.bin && \
|
||||
dd if=$(BOOTLOADER) bs=1 seek=$(shell printf "%d" 0x1000) of=flash_image.bin conv=notrunc && \
|
||||
dd if=$(PARTITION_TABLE) bs=1 seek=$(shell printf "%d" 0x8000) of=flash_image.bin conv=notrunc && \
|
||||
dd if=$(NUTTXNAME).bin bs=1 seek=$(shell printf "%d" 0x10000) of=flash_image.bin conv=notrunc && \
|
||||
echo "Generated: flash_image.bin (it can be run with 'qemu-system-xtensa -nographic -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw')"; \
|
||||
echo "flash_image.bin" >> $(NUTTXNAME).manifest; \
|
||||
fi
|
||||
endef
|
||||
endif
|
109
boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs
Normal file
109
boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs
Normal file
@ -0,0 +1,109 @@
|
||||
############################################################################
|
||||
# boards/xtensa/esp32/esp32-ethernet-kit/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)/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Config.mk
|
||||
include $(TOPDIR)/arch/xtensa/src/lx6/Toolchain.defs
|
||||
|
||||
LDSCRIPT1 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_out.ld
|
||||
LDSCRIPT3 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_rom.ld
|
||||
LDSCRIPT4 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_peripherals.ld
|
||||
|
||||
ifeq ($(CONFIG_ESP32_ETHERNETKIT_RUN_IRAM),y)
|
||||
LDSCRIPT2 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_iram.ld
|
||||
else
|
||||
LDSCRIPT2 = $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32_flash.ld
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(LDSCRIPT1)}"
|
||||
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT2)}"
|
||||
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT3)}"
|
||||
ARCHSCRIPT += -T "${shell cygpath -w $(LDSCRIPT4)}"
|
||||
else
|
||||
ARCHSCRIPT = -T$(LDSCRIPT1) -T$(LDSCRIPT2) -T$(LDSCRIPT3) -T$(LDSCRIPT4)
|
||||
endif
|
||||
|
||||
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 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls
|
||||
ARCHCXXFLAGS = $(ARCHCFLAGS) -fno-exceptions -fcheck-new -fno-rtti
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHPICFLAGS = -fpic
|
||||
|
||||
# if SPIRAM/PSRAM is used then we need to include a workaround
|
||||
|
||||
ifeq ($(CONFIG_ESP32_SPIRAM),y)
|
||||
ARCHCFLAGS += -mfix-esp32-psram-cache-issue
|
||||
endif
|
||||
|
||||
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(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
|
||||
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
|
||||
else
|
||||
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
|
||||
endif
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
CELFFLAGS = $(CFLAGS) -mtext-section-literals
|
||||
CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
LDELFFLAGS += -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld}"
|
||||
else
|
||||
LDELFFLAGS += -T $(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld
|
||||
endif
|
||||
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
|
||||
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
|
||||
LDFLAGS += -Map="${shell cygpath -w $(TOPDIR)/nuttx.map}" --cref
|
||||
else
|
||||
LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32.template.ld
|
||||
* ESP32 Linker Script Memory Layout
|
||||
*
|
||||
* This file describes the memory layout (memory blocks) as virtual
|
||||
* memory addresses.
|
||||
*
|
||||
* esp32.common.ld contains output sections to link compiler output
|
||||
* into these memory blocks.
|
||||
*
|
||||
* NOTE: That this is not the actual linker script but rather a "template"
|
||||
* for the elf32_out.ld script. This template script is passed through
|
||||
* the C preprocessor to include selected configuration options.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* All these values assume the flash cache is on, and have the blocks this
|
||||
* uses subtracted from the length of the various regions. The 'data access
|
||||
* port' dram/drom regions map to the same iram/irom regions but are
|
||||
* connected to the data port of the CPU and eg allow bytewise access.
|
||||
*/
|
||||
|
||||
/* IRAM for PRO cpu. Not sure if happy with this, this is MMU area... */
|
||||
|
||||
iram0_0_seg (RX) : org = 0x40080000, len = 0x20000
|
||||
|
||||
/* Even though the segment name is iram, it is actually mapped to flash.
|
||||
*
|
||||
* NOTE: (0x20 offset above is a convenience for the app binary image
|
||||
* generation.
|
||||
* Flash cache has 64KB pages. The .bin file which is flashed to the chip
|
||||
* has a 0x18 byte file header, and each segment has a 0x08 byte segment
|
||||
* header. Setting this offset makes it simple to meet the flash cache MMU's
|
||||
* constraint that (paddr % 64KB == vaddr % 64KB).)
|
||||
*/
|
||||
|
||||
iram0_2_seg (RX) : org = 0x400d0020, len = 0x330000 - 0x20
|
||||
|
||||
/* Shared data RAM, excluding memory reserved for ROM bss/data/stack.
|
||||
* Enabling Bluetooth & Trace Memory features in menuconfig will decrease
|
||||
* the amount of RAM available.
|
||||
*
|
||||
* Note: The length of this section should be 0x50000, and this extra
|
||||
* DRAM is available in heap at runtime. However due to static ROM memory
|
||||
* usage at this 176KB mark, the additional static memory temporarily cannot
|
||||
* be used.
|
||||
*/
|
||||
|
||||
dram0_0_seg (RW) : org = 0x3ffb0000 + CONFIG_ESP32_BT_RESERVE_DRAM,
|
||||
len = 0x2c200 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM - CONFIG_ESP32_BT_RESERVE_DRAM
|
||||
|
||||
/* Flash mapped constant data */
|
||||
|
||||
drom0_0_seg (R) : org = 0x3f400020, len = 0x400000 - 0x20
|
||||
|
||||
/* RTC fast memory (executable). Persists over deep sleep. */
|
||||
|
||||
rtc_iram_seg(RWX) : org = 0x400c0000, len = 0x2000
|
||||
|
||||
/* RTC slow memory (data accessible). Persists over deep sleep.
|
||||
* Start of RTC slow memory is reserved for ULP co-processor code + data,
|
||||
* if enabled.
|
||||
*/
|
||||
|
||||
rtc_slow_seg(RW) : org = 0x50000000 + CONFIG_ESP32_ULP_COPROC_RESERVE_MEM,
|
||||
len = 0x1000 - CONFIG_ESP32_ULP_COPROC_RESERVE_MEM
|
||||
}
|
||||
|
||||
/* Heap ends at top of dram0_0_seg */
|
||||
|
||||
_eheap = 0x40000000 - CONFIG_ESP32_TRACEMEM_RESERVE_DRAM;
|
||||
|
||||
/* Module text area ends at top of dram0_0_seg */
|
||||
|
||||
_emodtext = 0x400a0000;
|
202
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
Normal file
202
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
Normal file
@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_flash.ld
|
||||
****************************************************************************/
|
||||
|
||||
/* Default entry point: */
|
||||
|
||||
ENTRY(__start);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Send .iram0 code to iram */
|
||||
|
||||
.iram0.vectors :
|
||||
{
|
||||
/* Vectors go to IRAM */
|
||||
|
||||
_init_start = ABSOLUTE(.);
|
||||
|
||||
/* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */
|
||||
|
||||
. = 0x0;
|
||||
KEEP (*(.window_vectors.text));
|
||||
. = 0x180;
|
||||
KEEP (*(.xtensa_level2_vector.text));
|
||||
. = 0x1c0;
|
||||
KEEP (*(.xtensa_level3_vector.text));
|
||||
. = 0x200;
|
||||
KEEP (*(.xtensa_level4_vector.text));
|
||||
. = 0x240;
|
||||
KEEP (*(.xtensa_level5_vector.text));
|
||||
. = 0x280;
|
||||
KEEP (*(.debug_exception_vector.text));
|
||||
. = 0x2c0;
|
||||
KEEP (*(.nmi_vector.text));
|
||||
. = 0x300;
|
||||
KEEP (*(.kernel_exception_vector.text));
|
||||
. = 0x340;
|
||||
KEEP (*(.user_exception_vector.text));
|
||||
. = 0x3c0;
|
||||
KEEP (*(.double_exception_vector.text));
|
||||
. = 0x400;
|
||||
*(.*_vector.literal)
|
||||
|
||||
. = ALIGN (16);
|
||||
*(.entry.text)
|
||||
*(.init.literal)
|
||||
*(.init)
|
||||
_init_end = ABSOLUTE(.);
|
||||
} > iram0_0_seg
|
||||
|
||||
.iram0.text :
|
||||
{
|
||||
/* Code marked as running out of IRAM */
|
||||
|
||||
_iram_text_start = ABSOLUTE(.);
|
||||
*(.iram1 .iram1.*)
|
||||
*libphy.a:(.literal .text .literal.* .text.*)
|
||||
*librtc.a:(.literal .text .literal.* .text.*)
|
||||
*libpp.a:(.literal .text .literal.* .text.*)
|
||||
*libhal.a:(.literal .text .literal.* .text.*)
|
||||
*libarch.a:esp32_spiflash.*(.literal .text .literal.* .text.*)
|
||||
*(.wifirxiram .wifirxiram.*)
|
||||
*(.wifirxiram .wifi0iram.*)
|
||||
_iram_text_end = ABSOLUTE(.);
|
||||
|
||||
/* Module text area starts at the end of iram0_0_seg */
|
||||
|
||||
_smodtext = ABSOLUTE(.);
|
||||
} > iram0_0_seg
|
||||
|
||||
/* Shared RAM */
|
||||
|
||||
.dram0.bss (NOLOAD) :
|
||||
{
|
||||
/* .bss initialized on power-up */
|
||||
|
||||
. = ALIGN (8);
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.dynsbss)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
*(.sbss2)
|
||||
*(.sbss2.*)
|
||||
*(.gnu.linkonce.sb2.*)
|
||||
*(.dynbss)
|
||||
KEEP (*(.bss))
|
||||
*(.bss.*)
|
||||
*(.share.mem)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
*libarch.a:esp32_spiflash.*(.bss .bss.* COMMON)
|
||||
. = ALIGN(8);
|
||||
_ebss = ABSOLUTE(.);
|
||||
|
||||
/* Uninitialized .bss */
|
||||
|
||||
*(.noinit)
|
||||
} >dram0_0_seg
|
||||
|
||||
.dram0.data :
|
||||
{
|
||||
/* .data initialized on power-up in ROMed configurations. */
|
||||
|
||||
_sdata = ABSOLUTE(.);
|
||||
KEEP (*(.data))
|
||||
KEEP (*(.data.*))
|
||||
KEEP (*(.gnu.linkonce.d.*))
|
||||
KEEP (*(.data1))
|
||||
KEEP (*(.sdata))
|
||||
KEEP (*(.sdata.*))
|
||||
KEEP (*(.gnu.linkonce.s.*))
|
||||
KEEP (*(.sdata2))
|
||||
KEEP (*(.sdata2.*))
|
||||
KEEP (*(.gnu.linkonce.s2.*))
|
||||
KEEP (*(.jcr))
|
||||
*(.dram1 .dram1.*)
|
||||
*libarch.a:esp32_spiflash.*(.rodata .rodata.*)
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
|
||||
/* Heap starts at the end of .data */
|
||||
|
||||
_sheap = ABSOLUTE(.);
|
||||
} >dram0_0_seg
|
||||
|
||||
.flash.rodata :
|
||||
{
|
||||
_srodata = ABSOLUTE(.);
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
__XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
|
||||
*(.xt_except_table)
|
||||
*(.gcc_except_table)
|
||||
*(.gcc_except_table.*)
|
||||
*(.gnu.linkonce.e.*)
|
||||
*(.gnu.version_r)
|
||||
*(.eh_frame)
|
||||
|
||||
. = (. + 3) & ~ 3;
|
||||
|
||||
/* C++ constructor and destructor tables, properly ordered: */
|
||||
|
||||
_sinit = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
_einit = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
|
||||
/* C++ exception handlers table: */
|
||||
|
||||
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
|
||||
*(.xt_except_desc)
|
||||
*(.gnu.linkonce.h.*)
|
||||
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
||||
*(.xt_except_desc_end)
|
||||
*(.dynamic)
|
||||
*(.gnu.version_d)
|
||||
_erodata = ABSOLUTE(.);
|
||||
/* Literals are also RO data. */
|
||||
_lit4_start = ABSOLUTE(.);
|
||||
*(*.lit4)
|
||||
*(.lit4.*)
|
||||
*(.gnu.linkonce.lit4.*)
|
||||
_lit4_end = ABSOLUTE(.);
|
||||
. = ALIGN(4);
|
||||
} >drom0_0_seg
|
||||
|
||||
.flash.text :
|
||||
{
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
} >iram0_2_seg
|
||||
|
||||
.rtc.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rtc.literal .rtc.text)
|
||||
} >rtc_iram_seg
|
||||
|
||||
.rtc.data :
|
||||
{
|
||||
*(.rtc.data)
|
||||
*(.rtc.rodata)
|
||||
} > rtc_slow_seg
|
||||
}
|
190
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_iram.ld
Normal file
190
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_iram.ld
Normal file
@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_iram.ld
|
||||
****************************************************************************/
|
||||
|
||||
/* Default entry point: */
|
||||
|
||||
ENTRY(__start);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Send .iram0 code to iram */
|
||||
|
||||
.iram0.vectors :
|
||||
{
|
||||
/* Vectors go to IRAM */
|
||||
|
||||
_init_start = ABSOLUTE(.);
|
||||
|
||||
/* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */
|
||||
|
||||
. = 0x0;
|
||||
KEEP (*(.window_vectors.text));
|
||||
. = 0x180;
|
||||
KEEP (*(.xtensa_level2_vector.text));
|
||||
. = 0x1c0;
|
||||
KEEP (*(.xtensa_level3_vector.text));
|
||||
. = 0x200;
|
||||
KEEP (*(.xtensa_level4_vector.text));
|
||||
. = 0x240;
|
||||
KEEP (*(.xtensa_level5_vector.text));
|
||||
. = 0x280;
|
||||
KEEP (*(.debug_exception_vector.text));
|
||||
. = 0x2c0;
|
||||
KEEP (*(.nmi_vector.text));
|
||||
. = 0x300;
|
||||
KEEP (*(.kernel_exception_vector.text));
|
||||
. = 0x340;
|
||||
KEEP (*(.user_exception_vector.text));
|
||||
. = 0x3c0;
|
||||
KEEP (*(.double_exception_vector.text));
|
||||
. = 0x400;
|
||||
*(.*_vector.literal)
|
||||
|
||||
. = ALIGN (16);
|
||||
*(.entry.text)
|
||||
*(.init.literal)
|
||||
*(.init)
|
||||
_init_end = ABSOLUTE(.);
|
||||
} > iram0_0_seg
|
||||
|
||||
.iram0.text :
|
||||
{
|
||||
/* Code marked as running out of IRAM */
|
||||
|
||||
_iram_text_start = ABSOLUTE(.);
|
||||
*(.iram1 .iram1.*)
|
||||
*libphy.a:(.literal .text .literal.* .text.*)
|
||||
*librtc.a:(.literal .text .literal.* .text.*)
|
||||
*libpp.a:(.literal .text .literal.* .text.*)
|
||||
*libhal.a:(.literal .text .literal.* .text.*)
|
||||
_iram_text_end = ABSOLUTE(.);
|
||||
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
|
||||
/* Module text area starts at the end of iram0_0_seg */
|
||||
|
||||
_smodtext = ABSOLUTE(.);
|
||||
} > iram0_0_seg
|
||||
|
||||
/* Shared RAM */
|
||||
|
||||
.dram0.bss (NOLOAD) :
|
||||
{
|
||||
/* .bss initialized on power-up */
|
||||
|
||||
. = ALIGN (8);
|
||||
_sbss = ABSOLUTE(.);
|
||||
*(.dynsbss)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
*(.sbss2)
|
||||
*(.sbss2.*)
|
||||
*(.gnu.linkonce.sb2.*)
|
||||
*(.dynbss)
|
||||
KEEP (*(.bss))
|
||||
*(.bss.*)
|
||||
*(.share.mem)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(8);
|
||||
_ebss = ABSOLUTE(.);
|
||||
|
||||
/* Uninitialized .bss */
|
||||
|
||||
*(.noinit)
|
||||
} >dram0_0_seg
|
||||
|
||||
.dram0.data :
|
||||
{
|
||||
/* .data initialized on power-up in ROMed configurations. */
|
||||
|
||||
_sdata = ABSOLUTE(.);
|
||||
KEEP (*(.data))
|
||||
KEEP (*(.data.*))
|
||||
KEEP (*(.gnu.linkonce.d.*))
|
||||
KEEP (*(.data1))
|
||||
KEEP (*(.sdata))
|
||||
KEEP (*(.sdata.*))
|
||||
KEEP (*(.gnu.linkonce.s.*))
|
||||
KEEP (*(.sdata2))
|
||||
KEEP (*(.sdata2.*))
|
||||
KEEP (*(.gnu.linkonce.s2.*))
|
||||
KEEP (*(.jcr))
|
||||
*(.dram1 .dram1.*)
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
|
||||
_srodata = ABSOLUTE(.);
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
__XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
|
||||
*(.xt_except_table)
|
||||
*(.gcc_except_table)
|
||||
*(.gnu.linkonce.e.*)
|
||||
*(.gnu.version_r)
|
||||
*(.eh_frame)
|
||||
|
||||
. = (. + 3) & ~ 3;
|
||||
|
||||
/* C++ constructor and destructor tables, properly ordered: */
|
||||
|
||||
_sinit = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
_einit = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
|
||||
/* C++ exception handlers table: */
|
||||
|
||||
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
|
||||
*(.xt_except_desc)
|
||||
*(.gnu.linkonce.h.*)
|
||||
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
|
||||
*(.xt_except_desc_end)
|
||||
*(.dynamic)
|
||||
*(.gnu.version_d)
|
||||
_erodata = ABSOLUTE(.);
|
||||
/* Literals are also RO data. */
|
||||
_lit4_start = ABSOLUTE(.);
|
||||
*(*.lit4)
|
||||
*(.lit4.*)
|
||||
*(.gnu.linkonce.lit4.*)
|
||||
_lit4_end = ABSOLUTE(.);
|
||||
. = ALIGN(4);
|
||||
|
||||
/* Heap starts at the end of .data */
|
||||
|
||||
_sheap = ABSOLUTE(.);
|
||||
} >dram0_0_seg
|
||||
|
||||
.rtc.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rtc.literal .rtc.text)
|
||||
} >rtc_iram_seg
|
||||
|
||||
.rtc.data :
|
||||
{
|
||||
*(.rtc.data)
|
||||
*(.rtc.rodata)
|
||||
} > rtc_slow_seg
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_peripherals.ld
|
||||
****************************************************************************/
|
||||
|
||||
PROVIDE ( UART0 = 0x3ff40000 );
|
||||
PROVIDE ( SPI1 = 0x3ff42000 );
|
||||
PROVIDE ( SPI0 = 0x3ff43000 );
|
||||
PROVIDE ( GPIO = 0x3ff44000 );
|
||||
PROVIDE ( SIGMADELTA = 0x3ff44f00 );
|
||||
PROVIDE ( UHCI1 = 0x3ff4C000 );
|
||||
PROVIDE ( I2S0 = 0x3ff4F000 );
|
||||
PROVIDE ( UART1 = 0x3ff50000 );
|
||||
PROVIDE ( I2C0 = 0x3ff53000 );
|
||||
PROVIDE ( UHCI0 = 0x3ff54000 );
|
||||
PROVIDE ( RMT = 0x3ff56000 );
|
||||
PROVIDE ( PCNT = 0x3ff57000 );
|
||||
PROVIDE ( LEDC = 0x3ff59000 );
|
||||
PROVIDE ( TIMERG0 = 0x3ff5F000 );
|
||||
PROVIDE ( TIMERG1 = 0x3ff60000 );
|
||||
PROVIDE ( SPI2 = 0x3ff64000 );
|
||||
PROVIDE ( SPI3 = 0x3ff65000 );
|
||||
PROVIDE ( I2C1 = 0x3ff67000 );
|
||||
PROVIDE ( I2S1 = 0x3ff6D000 );
|
||||
PROVIDE ( UART2 = 0x3ff6E000 );
|
1859
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_rom.ld
Normal file
1859
boards/xtensa/esp32/esp32-ethernet-kit/scripts/esp32_rom.ld
Normal file
File diff suppressed because it is too large
Load Diff
115
boards/xtensa/esp32/esp32-ethernet-kit/scripts/gnu-elf.ld
Normal file
115
boards/xtensa/esp32/esp32-ethernet-kit/scripts/gnu-elf.ld
Normal file
@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/scripts/gnu-elf.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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x00000000 :
|
||||
{
|
||||
_stext = . ;
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.gnu.warning)
|
||||
*(.stub)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.jcr)
|
||||
|
||||
/* C++ support: The .init and .fini sections contain specific logic
|
||||
* to manage static constructors and destructors.
|
||||
*/
|
||||
|
||||
*(.gnu.linkonce.t.*)
|
||||
*(.init) /* Old ABI */
|
||||
*(.fini) /* Old ABI */
|
||||
_etext = . ;
|
||||
}
|
||||
|
||||
.rodata :
|
||||
{
|
||||
_srodata = . ;
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
*(.rodata.*)
|
||||
*(.gnu.linkonce.r*)
|
||||
_erodata = . ;
|
||||
}
|
||||
|
||||
.data :
|
||||
{
|
||||
_sdata = . ;
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.data.*)
|
||||
*(.gnu.linkonce.d*)
|
||||
. = ALIGN(4);
|
||||
_edata = . ;
|
||||
}
|
||||
|
||||
/* C++ support. For each global and static local C++ object,
|
||||
* GCC creates a small subroutine to construct the object. Pointers
|
||||
* to these routines (not the routines themselves) are stored as
|
||||
* simple, linear arrays in the .ctors section of the object file.
|
||||
* Similarly, pointers to global/static destructor routines are
|
||||
* stored in .dtors.
|
||||
*/
|
||||
|
||||
.ctors :
|
||||
{
|
||||
_sctors = . ;
|
||||
*(.ctors) /* Old ABI: Unallocated */
|
||||
*(.init_array) /* New ABI: Allocated */
|
||||
_ectors = . ;
|
||||
}
|
||||
|
||||
.dtors :
|
||||
{
|
||||
_sdtors = . ;
|
||||
*(.dtors) /* Old ABI: Unallocated */
|
||||
*(.fini_array) /* New ABI: Allocated */
|
||||
_edtors = . ;
|
||||
}
|
||||
|
||||
.bss :
|
||||
{
|
||||
_sbss = . ;
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.gnu.linkonce.b*)
|
||||
*(COMMON)
|
||||
_ebss = . ;
|
||||
}
|
||||
|
||||
/* 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) }
|
||||
}
|
68
boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs
Normal file
68
boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs
Normal file
@ -0,0 +1,68 @@
|
||||
#############################################################################
|
||||
# boards/xtensa/esp32/esp32-ethernet-kit/src/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)/Make.defs
|
||||
|
||||
SCRIPTDIR = $(BOARD_DIR)$(DELIM)scripts
|
||||
|
||||
CONFIGFILE = $(TOPDIR)$(DELIM)include$(DELIM)nuttx$(DELIM)config.h
|
||||
|
||||
CSRCS = esp32_boot.c esp32_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += esp32_appinit.c
|
||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||
CSRCS += esp32_reset.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32_SPI),y)
|
||||
CSRCS += esp32_spi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MMCSD),y)
|
||||
CSRCS += esp32_mmcsd.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32_SPIFLASH),y)
|
||||
CSRCS += esp32_spiflash.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USERLED),y)
|
||||
CSRCS += esp32_userleds.c
|
||||
endif
|
||||
|
||||
SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32.template.ld
|
||||
SCRIPTOUT = $(SCRIPTDIR)$(DELIM)esp32_out.ld
|
||||
|
||||
.PHONY = context distclean
|
||||
|
||||
$(SCRIPTOUT): $(SCRIPTIN) $(CONFIGFILE)
|
||||
$(Q) $(CC) -isystem $(TOPDIR)/include -C -P -x c -E $(SCRIPTIN) -o $@
|
||||
|
||||
context:: $(SCRIPTOUT)
|
||||
|
||||
distclean::
|
||||
$(call DELFILE, $(SCRIPTOUT))
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||
|
103
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h
Normal file
103
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.h
Normal file
@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32-ethernet-kit.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_XTENSA_ESP32_ESP32_ETHERNETKIT_SRC_ESP32_ETHERNETKIT_H
|
||||
#define __BOARDS_XTENSA_ESP32_ESP32_ETHERNETKIT_SRC_ESP32_ETHERNETKIT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_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 via board_app_initialize()
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_mmcsd_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SPI-based SD card and card detect thread.
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_mmcsd_initialize(int minor);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_spiflash_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPIFLASH and register the MTD device.
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_spiflash_init(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_spiflash_encrypt_test
|
||||
*
|
||||
* Description:
|
||||
* Test ESP32 SPI Flash driver read/write with encryption.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST
|
||||
void esp32_spiflash_encrypt_test(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_XTENSA_ESP32_ESP32_ETHERNETKIT_SRC_ESP32_ETHERNETKIT_H */
|
80
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_appinit.c
Normal file
80
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_appinit.c
Normal file
@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
#ifdef CONFIG_LIB_BOARDCTL
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_app_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform application specific initialization. This function is never
|
||||
* called directly from application code, but only indirectly via the
|
||||
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
|
||||
*
|
||||
* Input Parameters:
|
||||
* arg - The boardctl() argument is passed to the board_app_initialize()
|
||||
* implementation without modification. The argument has no
|
||||
* meaning to NuttX; the meaning of the argument is a contract
|
||||
* between the board-specific initialization logic and the
|
||||
* matching application logic. The value could be such things as a
|
||||
* mode enumeration value, a set of DIP switch 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 esp32_bringup();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_LIB_BOARDCTL */
|
82
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c
Normal file
82
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_boot.c
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_board_initialize
|
||||
*
|
||||
* Description:
|
||||
* All ESP32 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 esp32_board_initialize(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 */
|
||||
|
||||
esp32_bringup();
|
||||
}
|
||||
#endif
|
251
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
Normal file
251
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c
Normal file
@ -0,0 +1,251 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_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 <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <syslog.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <syslog.h>
|
||||
#include <sys/errno.h>
|
||||
#include <nuttx/himem/himem.h>
|
||||
|
||||
#include "esp32_procfs_imm.h"
|
||||
|
||||
#include "esp32_wlan.h"
|
||||
#include "esp32_spiflash.h"
|
||||
#include "esp32_partition.h"
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
# include <nuttx/leds/userled.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_TIMER
|
||||
# include "esp32_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_WDT
|
||||
# include "esp32_wdt.h"
|
||||
#endif
|
||||
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_WIFI_SAVE_PARAM
|
||||
static int esp32_init_wifi_storage(void)
|
||||
{
|
||||
int ret;
|
||||
const char *path = "/dev/mtdblock1";
|
||||
FAR struct mtd_dev_s *mtd_part;
|
||||
|
||||
mtd_part = esp32_spiflash_alloc_mtdpart();
|
||||
if (!mtd_part)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to alloc MTD partition of SPI Flash\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = register_mtddriver(path, mtd_part, 0777, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to regitser MTD: %d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = mount(path, CONFIG_ESP32_WIFI_FS_MOUNTPT, "spiffs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to mount the FS volume: %d\n", errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int esp32_bringup(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_XTENSA_IMEM_PROCFS
|
||||
/* Register the internal memory procfs entry.
|
||||
* This must be done before the procfs is mounted.
|
||||
*/
|
||||
|
||||
ret = imm_procfs_register();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to register internal memory to PROCFS: %d\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ESP32_SPIRAM) && \
|
||||
defined(CONFIG_ESP32_SPIRAM_BANKSWITCH_ENABLE)
|
||||
ret = esp_himem_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to init HIMEM: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
/* Mount the procfs file system */
|
||||
|
||||
ret = mount(NULL, "/proc", "procfs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD
|
||||
ret = esp32_mmcsd_initialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize SD slot: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIFLASH
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST
|
||||
esp32_spiflash_encrypt_test();
|
||||
#endif
|
||||
|
||||
ret = esp32_spiflash_init();
|
||||
if (ret)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SPI Flash\n");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_PARTITION
|
||||
ret = esp32_partition_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize partition error=%d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_WIRELESS
|
||||
|
||||
#ifdef CONFIG_ESP32_WIFI_SAVE_PARAM
|
||||
ret = esp32_init_wifi_storage();
|
||||
if (ret)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize WiFi storage\n");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
ret = esp32_wlan_initialize();
|
||||
if (ret)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize WiFi\n");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
/* Configure timer driver */
|
||||
|
||||
ret = board_timer_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize timer drivers: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
/* Register the LED driver */
|
||||
|
||||
ret = userled_lower_initialize("/dev/userleds");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
/* Configure watchdog timer */
|
||||
|
||||
ret = board_wdt_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize watchdog drivers: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we got here then perhaps not all initialization was successful, but
|
||||
* at least enough succeeded to bring-up NSH with perhaps reduced
|
||||
* capabilities.
|
||||
*/
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
84
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_mmcsd.c
Normal file
84
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_mmcsd.c
Normal file
@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_mmcsd.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 <debug.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "esp32_spi.h"
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_mmcsd_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SPI-based SD card and card detect thread.
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_mmcsd_initialize(int minor)
|
||||
{
|
||||
struct spi_dev_s *spi;
|
||||
int rv;
|
||||
|
||||
mcinfo("INFO: Initializing mmcsd card\n");
|
||||
|
||||
spi = esp32_spibus_initialize(2);
|
||||
if (spi == NULL)
|
||||
{
|
||||
mcerr("ERROR: Failed to initialize SPI port %d\n", 2);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rv = mmcsd_spislotinitialize(minor, 0, spi);
|
||||
if (rv < 0)
|
||||
{
|
||||
mcerr("ERROR: Failed to bind SPI port %d to SD slot %d\n",
|
||||
2, 0);
|
||||
return rv;
|
||||
}
|
||||
|
||||
spiinfo("INFO: mmcsd card has been initialized successfully\n");
|
||||
return OK;
|
||||
}
|
63
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_reset.c
Normal file
63
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_reset.c
Normal file
@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_reset.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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_RESET
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset board. Support for this function is required by board-level
|
||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
||||
*
|
||||
* Input Parameters:
|
||||
* status - Status information provided with the reset event. This
|
||||
* meaning of this status information is board-specific. If not
|
||||
* used by a board, the value zero may be provided in calls to
|
||||
* board_reset().
|
||||
*
|
||||
* Returned Value:
|
||||
* If this function returns, then it was not possible to power-off the
|
||||
* board due to some constraints. The return value in this case is a
|
||||
* board-specific reason for the failure to shutdown.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_reset(int status)
|
||||
{
|
||||
up_systemreset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_RESET */
|
56
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spi.c
Normal file
56
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spi.c
Normal file
@ -0,0 +1,56 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spi.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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_spi2_status
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t esp32_spi2_status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
#ifdef CONFIG_MMCSD_SPI
|
||||
if (devid == SPIDEV_MMCSD(0))
|
||||
{
|
||||
status |= SPI_STATUS_PRESENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
262
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c
Normal file
262
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.c
Normal file
@ -0,0 +1,262 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_spiflash.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 <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/fs/nxffs.h>
|
||||
|
||||
#include "esp32_spiflash.h"
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_spiflash_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SPIFLASH and register the MTD device.
|
||||
****************************************************************************/
|
||||
|
||||
int esp32_spiflash_init(void)
|
||||
{
|
||||
FAR struct mtd_dev_s *mtd;
|
||||
int ret = ERROR;
|
||||
|
||||
mtd = esp32_spiflash_alloc_mtdpart();
|
||||
|
||||
#if defined (CONFIG_ESP32_SPIFLASH_SMARTFS)
|
||||
ret = smart_initialize(0, mtd, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
finfo("smart_initialize failed, Trying to erase first...\n");
|
||||
ret = mtd->ioctl(mtd, MTDIOC_BULKERASE, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: ioctl(BULKERASE) failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
finfo("Erase successed, initializaing again\n");
|
||||
ret = smart_initialize(0, mtd, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: smart_initialize failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined (CONFIG_ESP32_SPIFLASH_NXFFS)
|
||||
ret = nxffs_initialize(mtd);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: NXFFS init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
ret = register_mtddriver("/dev/esp32flash", mtd, 0755, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: Register mtd failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32_spiflash_encrypt_test
|
||||
*
|
||||
* Description:
|
||||
* Test ESP32 SPI Flash driver read/write with encryption.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST
|
||||
|
||||
void esp32_spiflash_encrypt_test(void)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
uint8_t *wbuf;
|
||||
uint8_t *rbuf;
|
||||
struct mtd_geometry_s geo;
|
||||
uint32_t erase_block;
|
||||
uint32_t erase_nblocks;
|
||||
uint32_t rw_block;
|
||||
uint32_t rw_nblocks;
|
||||
struct mtd_dev_s *mtd = esp32_spiflash_get_mtd();
|
||||
struct mtd_dev_s *enc_mtd = esp32_spiflash_encrypt_get_mtd();
|
||||
const uint32_t address = CONFIG_ESP32_SPIFLASH_TEST_ADDRESS;
|
||||
const uint32_t size = 4096;
|
||||
|
||||
ret = MTD_IOCTL(enc_mtd, MTDIOC_GEOMETRY,
|
||||
(unsigned long)(uintptr_t)&geo);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: Failed to get GEO errno =%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
wbuf = kmm_malloc(size);
|
||||
if (!wbuf)
|
||||
{
|
||||
ferr("ERROR: Failed to alloc %d heap\n", size);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
rbuf = kmm_malloc(size);
|
||||
if (!rbuf)
|
||||
{
|
||||
ferr("ERROR: Failed to alloc %d heap\n", size);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
wbuf[i] = (uint8_t)random();
|
||||
}
|
||||
|
||||
erase_block = address / geo.erasesize;
|
||||
erase_nblocks = size / geo.erasesize;
|
||||
|
||||
rw_block = address / geo.blocksize;
|
||||
rw_nblocks = size / geo.blocksize;
|
||||
|
||||
ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
|
||||
if (ret != erase_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to erase block errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
ret = MTD_BWRITE(enc_mtd, rw_block, rw_nblocks, wbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to encrypt write errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
memset(rbuf, 0, size);
|
||||
ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
if (memcmp(wbuf, rbuf, size))
|
||||
{
|
||||
ferr("ASSERT: Encrypted and decrypted data is not same\n");
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
memset(rbuf, 0, size);
|
||||
ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to read errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
if (!memcmp(wbuf, rbuf, size))
|
||||
{
|
||||
ferr("ASSERT: Encrypted and normal data is same\n");
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
wbuf[i] = (uint8_t)random();
|
||||
}
|
||||
|
||||
ret = MTD_ERASE(enc_mtd, erase_block, erase_nblocks);
|
||||
if (ret != erase_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to erase errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
ret = MTD_BWRITE(mtd, rw_block, rw_nblocks, wbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to write errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
memset(rbuf, 0, size);
|
||||
ret = MTD_BREAD(enc_mtd, rw_block, rw_nblocks, rbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to decrypt read errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
if (!memcmp(wbuf, rbuf, size))
|
||||
{
|
||||
ferr("ASSERT: Normal and decrypted data is same\n");
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
memset(rbuf, 0, size);
|
||||
ret = MTD_BREAD(mtd, rw_block, rw_nblocks, rbuf);
|
||||
if (ret != rw_nblocks)
|
||||
{
|
||||
ferr("ERROR: Failed to read errno=%d\n", ret);
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
if (memcmp(wbuf, rbuf, size))
|
||||
{
|
||||
ferr("ASSERT: Normal and normal data is not same\n");
|
||||
DEBUGASSERT(0);
|
||||
}
|
||||
|
||||
kmm_free(wbuf);
|
||||
kmm_free(rbuf);
|
||||
|
||||
finfo("INFO: ESP32 SPI Flash encryption test successfully\n");
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ESP32_SPIFLASH_ENCRYPTION_TEST */
|
93
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_userleds.c
Normal file
93
boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_userleds.c
Normal file
@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
#include <arch/board/board.h>
|
||||
#include "esp32_gpio.h"
|
||||
|
||||
#include "esp32-ethernet-kit.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* This array maps an LED number to GPIO pin configuration */
|
||||
|
||||
static const uint32_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
GPIO_LED1,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_initialize
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t board_userled_initialize(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < BOARD_NLEDS; i++)
|
||||
{
|
||||
esp32_configgpio(g_ledcfg[i], OUTPUT);
|
||||
}
|
||||
|
||||
return BOARD_NLEDS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
if ((unsigned)led < BOARD_NLEDS)
|
||||
{
|
||||
esp32_gpiowrite(g_ledcfg[led], ledon);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_userled_all
|
||||
****************************************************************************/
|
||||
|
||||
void board_userled_all(uint32_t ledset)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
/* Configure LED1-8 GPIOs for output */
|
||||
|
||||
for (i = 0; i < BOARD_NLEDS; i++)
|
||||
{
|
||||
esp32_gpiowrite(g_ledcfg[i], (ledset & (1 << i)) != 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user