stm32l562e-dk: Board Support

Support for the STMicroelectronics STM32L562E-DK development board. This
is a proof-of-concept port that demonstrates running NuttX as the
Non-Secure TrustZone domain companion to TrustedFirmware-M.

Signed-off-by: Michael Jung <mijung@gmx.net>
This commit is contained in:
Michael Jung 2021-03-03 18:30:02 +01:00 committed by Xiang Xiao
parent 70c9d38437
commit 9b679a7860
17 changed files with 1604 additions and 0 deletions

View File

@ -1862,6 +1862,15 @@ config ARCH_BOARD_STM32L476_MDK
The STM32L476ME is a Cortex-M4 optimised for low-power operation
at up to 80MHz operation with 1024Kb Flash memory and 96+32Kb SRAM.
config ARCH_BOARD_STM32L562E_DK
bool "STM32L562E-DK"
depends on ARCH_CHIP_STM32L562QE
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
STMicro STM32L562E-DK board based on the STMicro STM32L562QEI6 MCU.
config ARCH_BOARD_STM32L_DISCOVERY
bool "STMicro STM32L-Discovery board"
depends on ARCH_CHIP_STM32L152RB || ARCH_CHIP_STM32L152RC
@ -2395,6 +2404,7 @@ config ARCH_BOARD
default "stm32l476vg-disco" if ARCH_BOARD_STM32L476VG_DISCO
default "stm32l476-mdk" if ARCH_BOARD_STM32L476_MDK
default "stm32l4r9ai-disco" if ARCH_BOARD_STM32L4R9AI_DISCO
default "stm32l562e-dk" if ARCH_BOARD_STM32L562E_DK
default "stm32ldiscovery" if ARCH_BOARD_STM32L_DISCOVERY
default "stm32vldiscovery" if ARCH_BOARD_STM32VL_DISCOVERY
default "mikroe-stm32f4" if ARCH_BOARD_MIKROE_STM32F4
@ -2796,6 +2806,9 @@ endif
if ARCH_BOARD_STM32L4R9AI_DISCO
source "boards/arm/stm32l4/stm32l4r9ai-disco/Kconfig"
endif
if ARCH_BOARD_STM32L562E_DK
source "boards/arm/stm32l5/stm32l562e-dk/Kconfig"
endif
if ARCH_BOARD_AXOLOTI
source "boards/arm/stm32/axoloti/Kconfig"
endif

View File

@ -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_STM32L562E_DK
endif

View File

@ -0,0 +1,248 @@
STM32L562E-DK README
====================
This README file discusses the port of NuttX to the STMicro STM32L562E-DK
board. That board features the STM32L562QEI6QU MCU with 512KiB of FLASH
and 256KiB of SRAM.
This port is a proof-of-concept to demonstrate running NuttX in the Non-
Secure TrustZone domain as a companion to TrustedFirmware-M (TFM). Running
NuttX on the STM32L562E-DK without TFM is currently not supported.
Contents
========
- Status
- LEDs
- Buttons
- Serial Console
- TrustedFirmware-M
- Configurations
Status
======
2021-03-03: The board now boots and the basic NSH configuration works
without problem.
LEDs
====
The Board provides a 2 user LEDs, LD9 and LD10
LED9 (Red) PD_3
LED10 (Green) PG_12
- When the I/O is LOW value, the LEDs are on.
- When the I/O is HIGH value, the LEDs are off.
These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
defined. In that case, the usage by the board port is defined in
include/board.h and src/stm32_autoleds.c. The LEDs are used to encode OS
related events as follows when the LEDs are available:
SYMBOL Meaning RED GREEN
------------------- ----------------------- --- -----
LED_STARTED NuttX has been started OFF OFF
LED_HEAPALLOCATE Heap has been allocated ON OFF
LED_IRQSENABLED Interrupts enabled ON ON
LED_STACKCREATED Idle stack created OFF ON
LED_INIRQ In an interrupt GLOW NC (momentary)
LED_SIGNAL In a signal handler GLOW NC (momentary)
LED_ASSERTION An assertion failed GLOW NC (momentary)
LED_PANIC The system has crashed ON OFF (flashing 2Hz)
LED_IDLE MCU is is sleep mode NC ON
OFF - means that the OS is still initializing. Initialization is very fast
so if you see this at all, it probably means that the system is
hanging up somewhere in the initialization phases.
GREEN - This means that the OS completed initialization.
Flashing RED - In the event of a fatal crash, all other LEDs will be
extinguished and RED LED will FLASH at a 2Hz rate.
Thus if the GREEN LED is lit, NuttX has successfully booted and is,
apparently, idleing normally. If the RED LED is flashing at
approximately 2Hz, then a fatal error has been detected and the system has
halted.
Buttons
=======
B1 USER: the user button is connected to the I/O PC13 (pin 2) of the STM32
microcontroller.
Serial Consoles
===============
USART1 - Virtual COM Port
-------------------------
Default board is configured to use USART1 as console, which is wired to
the STLINK Virtual COM Port.
FUNC GPIO
---- ----
TXD: PA9
RXD: PA10
---- ----
Use make menuconfig to configure USART1 as the console:
CONFIG_STM32L5_USART1=y
CONFIG_USART1_SERIALDRIVER=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USART1_RXBUFSIZE=256
CONFIG_USART1_TXBUFSIZE=256
CONFIG_USART1_BAUD=115200
CONFIG_USART1_BITS=8
CONFIG_USART1_PARITY=0
CONFIG_USART1_2STOP=0
Default
-------
As shipped, the virtual COM port is enabled.
TrustedFirmware-M
=================
You should study [UM2671] STMicroelectronics. UM2671: Getting started with
STM32CubeL5 TFM application, 2nd edition, July 2020.
I was using STM32CubeL5 v1.3.1
(https://github.com/STMicroelectronics/STM32CubeL5/tree/v1.3.1).
Changes required to STM32CubeL5's TFM
-------------------------------------
The following two changes to TFM have to be applied to be able to run NuttX.
The first one is required since NuttX issues SVC instructions while interrupts
are disabled, which causes HardFaults. NuttX then detects this situation in
the HardFault handler. Per default HardFaults are taken to the secure domain,
though. Thus, this change:
--- a/Projects/STM32L562E-DK/Applications/TFM/TFM_SBSFU_Boot/Src/boot_hal.c
+++ b/Projects/STM32L562E-DK/Applications/TFM/TFM_SBSFU_Boot/Src/boot_hal.c
@@ -306,6 +306,9 @@ void jumper(struct arm_vector_table *vector)
/* set the secure vector */
SCB->VTOR = (uint32_t)vector;
+ /* Stay in Non-Secure mode for BusFault, HardFault, and NMI exceptions */
+ SCB->AIRCR = (SCB->AIRCR & 0x0000FFFF) | 0x05FA0000 | SCB_AIRCR_BFHFNMINS_Msk;
+
vt = (struct arm_vector_table *)vector;
The second change is required to ensure all interrupts are taken to the
non-secure domain:
--- a/Projects/STM32L562E-DK/Applications/TFM/TFM_Appli/Secure/Src/spm_hal.c
+++ b/Projects/STM32L562E-DK/Applications/TFM/TFM_Appli/Secure/Src/spm_hal.c
@@ -535,6 +535,7 @@ enum tfm_plat_err_t tfm_spm_hal_system_reset_cfg(void)
enum tfm_plat_err_t tfm_spm_hal_nvic_interrupt_target_state_cfg(void)
{
/* return nvic_interrupt_target_state_cfg();*/
+ nvic_interrupt_target_state_cfg();
return TFM_PLAT_ERR_SUCCESS;
}
Encrypting and Signing the NuttX Binary
---------------------------------------
According to Figure 24 of [UM2671] and since we use the 'external flash
configuration', we must create the 'tfm_ns_enc_sign.bin' image from
'nuttx.bin'. This is done with mcuboot's imgtool.py.
imgtool.py sign \
-k root-rsa-2048_1.pem \ Key used for signing
-E enc-rsa2048-pub.pem \ Encrypt image using the provided public key
-o 0x90000400 \ OTFDEC
-e little \ Little Endian
-S 0x100000 \ Size of Flash Slot
-H 0x400 \ Header Size
--pad-header \ Pad header with zeroes
-v $version \ Version (TEXT)
-s auto \ Security Counter - auto: Create from Version
--align 8 \ 8 byte alignment
nuttx.bin \ input file
tfm_ns_enc_sign.bin output file
On my system the full command is as follows:
$ python3 ~/compile/STM32CubeL5/Middlewares/Third_Party/mcuboot/scripts/imgtool.py sign -k ~/compile/STM32CubeL5/Middlewares/Third_Party/trustedfirmware/bl2/ext/mcuboot/root-rsa-2048_1.pem -E ~/compile/STM32CubeL5/Middlewares/Third_Party/trustedfirmware/bl2/ext/mcuboot/enc-rsa2048-pub.pem -o 0x90000400 -e little -S 0x100000 -H 0x400 --pad-header -v 1 -s auto --align 8 nuttx.bin tfm_ns_enc_sign.bin
Configurations
==============
Information Common to All Configurations
----------------------------------------
Each configuration is maintained in a sub-directory and can be
selected as follow:
tools/configure.sh nucleo-l552ze:<subdir>
Before building, make sure the PATH environment variable includes the
correct path to the directory than holds your toolchain binaries.
And then build NuttX by simply typing the following. At the conclusion of
the make, the nuttx binary will reside in an ELF file called, simply, nuttx.
make oldconfig
make
The <subdir> that is provided above as an argument to the tools/configure.sh
must be is one of the following.
NOTES:
1. These configurations use the mconf-based configuration tool. To
change any of these configurations using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. Unless stated otherwise, all configurations generate console
output on USART1, as described above under "Serial Console". The
elevant configuration settings are listed below:
CONFIG_STM32L5_USART1=y
CONFIG_STM32L5_USART1_SERIALDRIVER=y
CONFIG_STM32L5_USART=y
CONFIG_USART1_SERIALDRIVER=y
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USART1_RXBUFSIZE=256
CONFIG_USART1_TXBUFSIZE=256
CONFIG_USART1_BAUD=115200
CONFIG_USART1_BITS=8
CONFIG_USART1_PARITY=0
CONFIG_USART1_2STOP=0
3. All of these configurations are set up to build under Linux using the
"GNU Tools for ARM Embedded Processors" that is maintained by ARM
(unless stated otherwise in the description of the configuration).
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
That toolchain selection can easily be reconfigured using
'make menuconfig'. Here are the relevant current settings:
Build Setup:
CONFIG_HOST_LINUX=y : Linux environment
System Type -> Toolchain:
CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL=y : GNU ARM EABI toolchain
Configuration sub-directories
-----------------------------
nsh:
Configures the NuttShell (nsh) located at examples/nsh. This
configuration is focused on low level, command-line driver testing.

View File

@ -0,0 +1,59 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_ARGCAT is not set
# CONFIG_NSH_CMDPARMS is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32l562e-dk"
CONFIG_ARCH_BOARD_STM32L562E_DK=y
CONFIG_ARCH_BOARD_STM32L5_CUSTOM_CLOCKCONFIG=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="stm32l5"
CONFIG_ARCH_CHIP_STM32L562QE=y
CONFIG_ARCH_CHIP_STM32L5=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV8M_STACKCHECK=y
CONFIG_BOARD_LOOPSPERMSEC=8499
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEBUG_WARN=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MAX_TASKS=16
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_IFUPDOWN=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=131072
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_STACK_COLORATION=y
CONFIG_STM32L5_USART1=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_STACKMONITOR=y
CONFIG_SYSTEM_TEE=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"

View File

@ -0,0 +1,205 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_STM32L5_STM32L562E_DK_INCLUDE_BOARD_H
#define __BOARDS_ARM_STM32L5_STM32L562E_DK_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
/* Currently the STM32L562E-DK board support is restricted to running NuttX
* in the Non-Secure domain together with TrustedFirmware-M (TFM). In this
* setup the clock configuration is done by TFM, not by NuttX. The
* respective code is in STM32CubeL5/Projects/STM32L562E-DK/Applications/TFM/
* TFM_SBSFU_Boot/Src/boot_hal.c and configures the clocks as follows:
*
* System Clock source : PLL (MSI)
* SYSCLK(Hz) : 110000000
* HCLK(Hz) : 110000000
* AHB Prescaler : 1
* APB1 Prescaler : 1
* APB2 Prescaler : 1
* MSI Frequency(Hz) : 4000000
* PLLM : 1
* PLLN : 55
* PLLP : 2
* PLLQ : 2
* PLLR : 2
* Flash Latency(WS) : 5
* Voltage range : 0
*/
/* HSI - 16 MHz RC factory-trimmed
* LSI - 32 KHz RC
* MSI - 4 MHz, autotrimmed via LSE
* HSE - not installed
* LSE - 32.768 kHz installed
*/
#define STM32L5_HSI_FREQUENCY 16000000ul
#define STM32L5_LSI_FREQUENCY 32000
#define STM32L5_MSI_FREQUENCY 4000000ul
#define STM32L5_LSE_FREQUENCY 32768
#define STM32L5_SYSCLK_FREQUENCY 110000000ul
#define STM32L5_HCLK_FREQUENCY STM32L5_SYSCLK_FREQUENCY
#define STM32L5_BOARD_HCLK STM32L5_HCLK_FREQUENCY
#define STM32L5_PCLK1_FREQUENCY STM32L5_HCLK_FREQUENCY
#define STM32L5_PCLK2_FREQUENCY (STM32L5_HCLK_FREQUENCY / 1)
/* The timer clock frequencies are automatically defined by hardware. If the
* APB prescaler equals 1, the timer clock frequencies are set to the same
* frequency as that of the APB domain. Otherwise they are set to twice.
* Note: TIM1,15,16 are on APB2, others on APB1
*/
#define BOARD_TIM1_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM2_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM3_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM4_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM5_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM6_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM7_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM15_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_TIM16_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_LPTIM1_FREQUENCY STM32L5_HCLK_FREQUENCY
#define BOARD_LPTIM2_FREQUENCY STM32L5_HCLK_FREQUENCY
/* DMA Channel/Stream Selections ********************************************/
/* Alternate function pin selections ****************************************/
/* USART3: Connected to Arduino connector D0/D1 (or to STLink VCP if solder
* bridges SB123 to SB130 are re-worked accordingly).
*/
#define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */
#define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */
/* LED definitions **********************************************************/
/* The STM32L562E-DK board has numerous LEDs but only two, LD9 a Red LED,
* and LD10 a Green LED, that can be controlled by software.
*
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs
* in any way.
* The following definitions are used to access individual LEDs.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED1 0
#define BOARD_LED2 1
#define BOARD_NLEDS 2
#define BOARD_LED_GREEN BOARD_LED1
#define BOARD_LED_RED BOARD_LED2
/* LED bits for use with board_userled_all() */
#define BOARD_LED1_BIT (1 << BOARD_LED1)
#define BOARD_LED2_BIT (1 << BOARD_LED2)
/* If CONFIG_ARCH_LEDS is defined, the usage by the board port is defined in
* include/board.h and src/stm32_autoleds.c. The LEDs are used to encode OS-
* related events as follows:
*
*
* SYMBOL Meaning LED state
* Red Green
* ---------------------- -------------------------- ------ -----
*/
#define LED_STARTED 0 /* NuttX has been started OFF OFF */
#define LED_HEAPALLOCATE 1 /* Heap has been allocated ON OFF */
#define LED_IRQSENABLED 2 /* Interrupts enabled ON ON */
#define LED_STACKCREATED 3 /* Idle stack created OFF ON */
#define LED_INIRQ 4 /* In an interrupt GLOW N/C */
#define LED_SIGNAL 5 /* In a signal handler GLOW N/C */
#define LED_ASSERTION 6 /* An assertion failed GLOW N/C */
#define LED_PANIC 7 /* The system has crashed Blink OFF */
#define LED_IDLE 8 /* MCU is is sleep mode N/C ON */
/* Thus if the Green LED is statically on, NuttX has successfully booted and
* is, apparently, idleing. If the Red LED is flashing at approximately 2Hz,
* then a fatal error has been detected and the system has halted.
*/
/* Button definitions *******************************************************/
/* The Nucleo-L552ZE supports one button: Pushbutton B1, labeled "User", is
* connected to GPIO PC13.
* A high value will be sensed when the button is pressed.
*/
#define BUTTON_USER 0
#define NUM_BUTTONS 1
#define BUTTON_USER_BIT (1 << BUTTON_USER)
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: stm32l5_board_initialize
*
* Description:
* All STM32L5 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 stm32l5_board_initialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_STM32L5_STM32L562E_DK_INCLUDE_BOARD_H */

View File

@ -0,0 +1,69 @@
##############################################################################
# boards/arm/stm32l5/stm32l562e-dk-ns/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
##############################################################################
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs
ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
ARCHSCRIPT = -T "${shell cygpath -w $(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld}"
else
ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)tfm-ns.ld
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
# enable precise stack overflow tracking
ifeq ($(CONFIG_ARMV8M_STACKCHECK),y)
INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) $(INSTRUMENTATIONDEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
ifneq ($(CROSSDEV),arm-nuttx-elf-)
ifneq ($(CROSSDEV),arm-nuttx-eabi-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif

View File

@ -0,0 +1,114 @@
/*****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/scripts/tfm-ns.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.
*
****************************************************************************/
/* This linker script supports running NuttX in the 'Non-Secure' (ns) domain
* in conjunction with TrustedFirmware-M (tfm).
*
* NuttX will run as the 'Non secure application' in the 'Non-Secure Image
* primary primary slot Area 1' in external flash. Compare [UM2671],
* Figure 8. Furthermore, see Figure 15 for the SRAM area used for 'Non-
* Secure application volatile data'
*
* While the 'Non-Secure Image primary slot Area 1' is actually one MiB large
* in the referenced setup, the image will be enriched with a header of 0x400
* bytes and a trailer of 0x2000 bytes. Thus the 'flash' statement in the
* MEMORY definition below.
*
* References
* [UM2671] STMicroelectronics. UM2671: Getting started with STM32CubeL5 TFM
* application, 2nd edition, July 2020
*/
MEMORY
{
flash (rx) : ORIGIN = 0x90000400, LENGTH = 0xFDC00
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 192K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
SECTIONS
{
.text : {
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section : {
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab : {
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx : {
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = ABSOLUTE(.);
} > sram
/* 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) }
}

View File

@ -0,0 +1,2 @@
/.depend
/Make.dep

View File

@ -0,0 +1,40 @@
##############################################################################
# boards/arm/stm32l5/stm32l562e-dk/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
##############################################################################
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = stm32_boot.c stm32_bringup.c stm32_clockconfig.c
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += stm32_autoleds.c
else
CSRCS += stm32_userleds.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += stm32_buttons.c
endif
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += stm32_appinit.c
endif
include $(TOPDIR)/boards/Board.mk

View File

@ -0,0 +1,71 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_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 <stdint.h>
#include "stm32l562e-dk.h"
#include <nuttx/board.h>
/****************************************************************************
* 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)
{
/* Did we already initialize via board_late_initialize()? */
#ifndef CONFIG_BOARD_LATE_INITIALIZE
return stm32_bringup();
#else
return OK;
#endif
}

View File

@ -0,0 +1,175 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_autoleds.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include "chip.h"
#include "arm_arch.h"
#include "arm_internal.h"
#include "stm32l5_gpio.h"
#include "stm32l562e-dk.h"
#include <arch/board/board.h>
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
/****************************************************************************
* Private Data
****************************************************************************/
/* Indexed by BOARD_LED_<color> */
static const uint32_t g_ledmap[BOARD_NLEDS] =
{
GPIO_LD10,
GPIO_LD9,
};
/****************************************************************************
* Private Functions
****************************************************************************/
static void phy_set_led(int led, bool state)
{
/* Active Low */
stm32l5_gpiowrite(g_ledmap[led], !state);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/
void board_autoled_initialize(void)
{
int i;
/* Configure the LD9 and LD10 GPIOs for output. Initial state is OFF */
for (i = 0; i < ARRAYSIZE(g_ledmap); i++)
{
stm32l5_configgpio(g_ledmap[i]);
}
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
switch (led)
{
default:
break;
case LED_HEAPALLOCATE:
phy_set_led(BOARD_LED_RED, true);
phy_set_led(BOARD_LED_GREEN, false);
break;
case LED_IRQSENABLED:
phy_set_led(BOARD_LED_RED, true);
phy_set_led(BOARD_LED_GREEN, true);
break;
case LED_STACKCREATED:
phy_set_led(BOARD_LED_RED, false);
phy_set_led(BOARD_LED_GREEN, true);
break;
case LED_INIRQ:
phy_set_led(BOARD_LED_RED, true);
break;
case LED_SIGNAL:
phy_set_led(BOARD_LED_RED, true);
break;
case LED_ASSERTION:
phy_set_led(BOARD_LED_RED, true);
break;
case LED_PANIC:
phy_set_led(BOARD_LED_RED, true);
phy_set_led(BOARD_LED_GREEN, false);
break;
case LED_IDLE:
phy_set_led(BOARD_LED_GREEN, true);
break;
}
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
switch (led)
{
default:
break;
case LED_SIGNAL:
phy_set_led(BOARD_LED_RED, false);
break;
case LED_INIRQ:
phy_set_led(BOARD_LED_RED, false);
break;
case LED_ASSERTION:
phy_set_led(BOARD_LED_RED, false);
break;
case LED_PANIC:
phy_set_led(BOARD_LED_RED, false);
phy_set_led(BOARD_LED_GREEN, false);
break;
case LED_IDLE:
phy_set_led(BOARD_LED_GREEN, false);
break;
}
}
#endif /* CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,90 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_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 "arm_arch.h"
#include "stm32l562e-dk.h"
#include "stm32l5_pwr.h"
#include <arch/board/board.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32l5_board_initialize
*
* Description:
* All STM32 architectures must provide the following entry point. This
* entry point is called early in the intitialization -- after all memory
* has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void stm32l5_board_initialize(void)
{
/* On the STM32L562E-DK Vddio2 is supplied by Vdd_mcu. Thus, when the MCU
* is running Vddio2 is guaranteed to be valid. LED LD10 is driven by
* PG12, whose power is supplied by Vddio2. Thus, its important to report
* Vddio2 to be valid here.
*/
stm32l5_pwr_vddio2_valid(true);
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */
board_autoled_initialize();
#endif
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will
* be called immediately after up_initialize() is called and just before
* the initial application is started. This additional initialization
* phase may be used, for example, to initialize board-specific device
* drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform board-specific initialization here if so configured */
(void)stm32_bringup();
}
#endif

View File

@ -0,0 +1,105 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_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 <sys/mount.h>
#include <sys/types.h>
#include <debug.h>
#include <nuttx/input/buttons.h>
#include <nuttx/leds/userled.h>
#include <nuttx/board.h>
#include "stm32l562e-dk.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_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 stm32_bringup(void)
{
int ret;
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
ferr("ERROR: Failed to mount procfs at /proc: %d\n", ret);
}
#endif
#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
/* 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_BUTTONS
#ifdef CONFIG_BUTTONS_LOWER
iinfo("Initializing button driver\n");
/* Register the BUTTON driver */
ret = btn_lower_initialize("/dev/buttons");
if (ret < 0)
{
ierr("ERROR: btn_lower_initialize() failed: %d\n", ret);
}
#else
/* Enable BUTTON support for some other purpose */
board_button_initialize();
#endif
#endif /* CONFIG_BUTTONS */
UNUSED(ret);
return OK;
}

View File

@ -0,0 +1,113 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_buttons.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 <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include "stm32l5_gpio.h"
#include "stm32l562e-dk.h"
#include <arch/board/board.h>
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
uint32_t board_button_initialize(void)
{
/* Configure the single button as an input. NOTE that EXTI interrupts are
* also configured for the pin.
*/
stm32l5_configgpio(GPIO_BTN_USER);
return NUM_BUTTONS;
}
/****************************************************************************
* Name: board_buttons
****************************************************************************/
uint32_t board_buttons(void)
{
/* Check the state of the USER button. */
return stm32l5_gpioread(GPIO_BTN_USER) ? BUTTON_USER_BIT : 0;
}
/****************************************************************************
* Button support.
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
* After board_button_initialize() has been called, board_buttons() may be
* called to collect the state of all buttons. board_buttons() returns a
* 32-bit bit set with each bit associated with a button. See the
* BUTTON_*_BIT definitions in board.h for the meaning of each bit.
*
* board_button_irq() may be called to register an interrupt handler that
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
int ret = -EINVAL;
if (id == BUTTON_USER)
{
ret = stm32l5_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler,
arg);
}
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -0,0 +1,48 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_clockconfig.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>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_board_clockconfig
*
* Description:
* Currently the STM32L562E-DK board support is restricted to running NuttX
* in the Non-Secure domain together with TrustedFirmware-M (TFM). In this
* setup the clock configuration is done by TFM, not by NuttX. Thus, the
* board's configuration sets CONFIG_ARCH_BOARD_STM32L5_CUSTOM_CLOCKCONFIG
* to avoid the standard clock config logic to run and instead do just
* nothing in this function.
*
****************************************************************************/
#if defined(CONFIG_ARCH_BOARD_STM32L5_CUSTOM_CLOCKCONFIG)
void stm32l5_board_clockconfig(void)
{
}
#endif

View File

@ -0,0 +1,127 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32_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 <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "stm32l5_gpio.h"
#include "stm32l562e-dk.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
/****************************************************************************
* Private Data
****************************************************************************/
/* This array maps an LED number to GPIO pin configuration and is indexed by
* BOARD_LED_<color>
*/
static const uint32_t g_ledcfg[BOARD_NLEDS] =
{
GPIO_LD10,
GPIO_LD9,
};
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the
* board_userled_initialize() is available to initialize the LEDs from user
* application logic.
*
****************************************************************************/
uint32_t board_userled_initialize(void)
{
int i;
/* Configure LED1-2 GPIOs for output */
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
{
stm32l5_configgpio(g_ledcfg[i]);
}
return BOARD_NLEDS;
}
/****************************************************************************
* Name: board_userled
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the board_userled() is
* available to control the LEDs from user application logic.
*
****************************************************************************/
void board_userled(int led, bool ledon)
{
if ((unsigned)led < ARRAYSIZE(g_ledcfg))
{
stm32l5_gpiowrite(g_ledcfg[led], !ledon);
}
}
/****************************************************************************
* Name: board_userled_all
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board
* LEDs. If CONFIG_ARCH_LEDS is not defined, then the board_userled_all()
* is available to control the LED from user application logic.
*
****************************************************************************/
void board_userled_all(uint32_t ledset)
{
int i;
/* Configure LED1-2 GPIOs for output */
for (i = 0; i < ARRAYSIZE(g_ledcfg); i++)
{
stm32l5_gpiowrite(g_ledcfg[i], !(ledset & (1 << i)));
}
}
#endif /* !CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,117 @@
/****************************************************************************
* boards/arm/stm32l5/stm32l562e-dk/src/stm32l562e-dk.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_ARM_STM32L5_STM32L562E_DK_SRC_STM32L562E_DK_H
#define __BOARDS_ARM_STM32L5_STM32L562E_DK_SRC_STM32L562E_DK_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include "stm32l5_gpio.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#define HAVE_PROC 1
#define HAVE_RTC_DRIVER 1
#if !defined(CONFIG_FS_PROCFS)
# undef HAVE_PROC
#endif
#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT)
# warning Mountpoints disabled. No procfs support
# undef HAVE_PROC
#endif
/* Check if we can support the RTC driver */
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
# undef HAVE_RTC_DRIVER
#endif
/* STM32L562E-DK GPIOs ******************************************************/
/* LED I/O Color
* LD9 PD3 Red
* LD10 PG12 Green
*
* - When the I/O is LOW, the LED is on.
* - When the I/O is HIGH value, the LED is off
*/
#define GPIO_LD9 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
GPIO_OUTPUT_SET | GPIO_PORTD | GPIO_PIN3)
#define GPIO_LD10 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
GPIO_OUTPUT_SET | GPIO_PORTG | GPIO_PIN12)
/* Button definitions *******************************************************/
/* B1 USER: the user button is connected to the I/O PC13 (pin 2) of the STM32
* microcontroller.
*/
#define MIN_IRQBUTTON BUTTON_USER
#define MAX_IRQBUTTON BUTTON_USER
#define NUM_IRQBUTTONS 1
#define GPIO_BTN_USER (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | \
GPIO_PORTC | GPIO_PIN13)
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: stm32_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 stm32_bringup(void);
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_STM32L5_STM32L562E_DK_SRC_STM32L562E_DK_H */