mirror of
https://github.com/apache/nuttx.git
synced 2026-10-07 22:35:22 +00:00
boards/arm/stm32n6: add initial STM32N6570-DK support
add initial STM32N6570-DK support Assisted-by: Codex:GPT-6 Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
97a8da4fd9
commit
38d6c3b8bb
19 changed files with 1225 additions and 4 deletions
|
|
@ -0,0 +1,108 @@
|
|||
================
|
||||
ST STM32N6570-DK
|
||||
================
|
||||
|
||||
.. tags:: chip:stm32, chip:stm32n6, chip:stm32n657
|
||||
|
||||
.. figure:: stm32n6570-dk-front.jpg
|
||||
:align: center
|
||||
:alt: STM32N6570-DK Front
|
||||
|
||||
STM32N6570-DK Front
|
||||
|
||||
.. figure:: stm32n6570-dk-back.jpg
|
||||
:align: center
|
||||
:alt: STM32N6570-DK Back
|
||||
|
||||
STM32N6570-DK Back
|
||||
|
||||
The STM32N6570-DK Discovery kit is based on the STM32N657X0H3Q
|
||||
Arm Cortex-M55 microcontroller.
|
||||
|
||||
Loading and running
|
||||
===================
|
||||
|
||||
Use SRAM loading for routine debugging and external flash for persistent
|
||||
boot, reset testing and standalone operation. The console is the ST-LINK
|
||||
Virtual COM Port at 115200 8N1.
|
||||
|
||||
Persistent flash
|
||||
----------------
|
||||
|
||||
OpenOCD adds the STM32N6 ROM header to ``nuttx.bin`` and programs the
|
||||
on-board NOR flash with its ``stmqspi`` driver. Use an OpenOCD version
|
||||
that provides ``target/stm32n6x.cfg``.
|
||||
|
||||
Build and program the persistent boot image with:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ make flash
|
||||
|
||||
This erases the affected flash sectors, programs and verifies the image,
|
||||
and resets the board. ``OPENOCD`` and ``OPENOCD_TARGET`` can override the
|
||||
OpenOCD executable and target script. The board's ``scripts/flash.cfg``
|
||||
configures the NOR pins, clocks and geometry for the native flash driver.
|
||||
|
||||
For a CMake build configured in ``build``:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ cmake --build build --target flash
|
||||
|
||||
Both targets build ``nuttx.bin`` before flashing. With CMake, ``OPENOCD``
|
||||
and ``OPENOCD_TARGET`` are cache variables set with ``-D`` at configuration.
|
||||
|
||||
The boot ROM loads NuttX from flash and starts it without a debugger or
|
||||
separate FSBL.
|
||||
The header and padding occupy the first 1 KiB at ``0x34180000``; NuttX is
|
||||
linked at ``0x34180400``. The ROM download buffer limits the binary to
|
||||
511 KiB. The generated image is unauthenticated and requires a device
|
||||
that permits unauthenticated boot.
|
||||
|
||||
SRAM debugging
|
||||
--------------
|
||||
|
||||
Build with ``make`` or ``cmake --build build``. Start OpenOCD using its
|
||||
standard ST-LINK and STM32N6 scripts:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ openocd -f interface/stlink.cfg -c 'transport select swd' \
|
||||
-f target/stm32n6x.cfg -c 'reset_config srst_only srst_nogate'
|
||||
|
||||
In another terminal, open the ELF with GDB. Use ``build/nuttx`` instead of
|
||||
``nuttx`` for CMake:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ arm-none-eabi-gdb nuttx
|
||||
(gdb) target extended-remote :3333
|
||||
(gdb) monitor reset halt
|
||||
(gdb) load
|
||||
(gdb) set $msp = *(unsigned int *)0x34180400
|
||||
(gdb) set $pc = *(unsigned int *)0x34180404
|
||||
(gdb) hbreak nx_start
|
||||
(gdb) continue
|
||||
|
||||
``load`` writes the ELF sections into SRAM without programming external
|
||||
flash. The next two commands initialize the stack pointer and entry point
|
||||
from the vector table. Continue again after reaching ``nx_start`` to run
|
||||
NSH. Reset before each reload; resetting after ``load`` boots the image
|
||||
stored in flash instead. The SRAM image is lost on power-off.
|
||||
|
||||
To inspect an already running image, attach with its matching ELF and omit
|
||||
the reset, load and register-setting commands.
|
||||
|
||||
NSH enables ``CONFIG_STM32N6_DEBUG`` to reopen debug access after ROM boot
|
||||
and includes debug symbols. These debugging steps require an installed
|
||||
image that enables debug access. Stop GDB and OpenOCD before running either
|
||||
flash target.
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
nsh
|
||||
---
|
||||
|
||||
Minimal NuttShell configuration.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
|
|
@ -5,10 +5,6 @@ ST STM32N6
|
|||
This is a port of NuttX to the STM32N6 family.
|
||||
The STM32N6 is a chip based on the Arm Cortex-M55.
|
||||
|
||||
Development is performed on the Nucleo-N657X0-Q. At this time only the
|
||||
STM32N657X0 is supported. Kconfig will need updates to support other
|
||||
MCUs in the family.
|
||||
|
||||
Supported MCUs
|
||||
==============
|
||||
|
||||
|
|
|
|||
|
|
@ -3498,6 +3498,14 @@ config ARCH_BOARD_NUCLEO_N657X0_Q
|
|||
code directly into SRAM via the on-board ST-Link V3EC, with
|
||||
the NSH console on USART1 (ST-Link Virtual COM Port).
|
||||
|
||||
config ARCH_BOARD_STM32N6570_DK
|
||||
bool "STM32N6570-DK"
|
||||
depends on ARCH_CHIP_STM32N657X0
|
||||
select ARCH_HAVE_LEDS
|
||||
---help---
|
||||
STMicro STM32N6570-DK Discovery kit based on the STM32N657X0
|
||||
MCU (Cortex-M55).
|
||||
|
||||
config ARCH_BOARD_STM32L562E_DK
|
||||
bool "STM32L562E-DK"
|
||||
depends on ARCH_CHIP_STM32L562QE
|
||||
|
|
@ -4302,6 +4310,7 @@ config ARCH_BOARD
|
|||
default "nucleo-h533re" if ARCH_BOARD_NUCLEO_H533RE
|
||||
default "nucleo-h563zi" if ARCH_BOARD_NUCLEO_H563ZI
|
||||
default "nucleo-n657x0-q" if ARCH_BOARD_NUCLEO_N657X0_Q
|
||||
default "stm32n6570-dk" if ARCH_BOARD_STM32N6570_DK
|
||||
default "nucleo-u5a5zj-q" if ARCH_BOARD_NUCLEO_U5A5ZJ_Q
|
||||
default "nucleo-u3c5zi-q" if ARCH_BOARD_NUCLEO_U3C5ZI_Q
|
||||
default "nucleo-c562re" if ARCH_BOARD_NUCLEO_C562RE
|
||||
|
|
@ -5029,6 +5038,9 @@ endif
|
|||
if ARCH_BOARD_NUCLEO_N657X0_Q
|
||||
source "boards/arm/stm32n6/nucleo-n657x0-q/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_STM32N6570_DK
|
||||
source "boards/arm/stm32n6/stm32n6570-dk/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_STM32L562E_DK
|
||||
source "boards/arm/stm32l5/stm32l562e-dk/Kconfig"
|
||||
endif
|
||||
|
|
|
|||
42
boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
Normal file
42
boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# ##############################################################################
|
||||
# boards/arm/stm32n6/stm32n6570-dk/CMakeLists.txt
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||
# license agreements. See the NOTICE file distributed with this work for
|
||||
# additional information regarding copyright ownership. The ASF licenses this
|
||||
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||
# use this file except in compliance with the License. You may obtain a copy of
|
||||
# the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
#
|
||||
# ##############################################################################
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(CONFIG_RAW_BINARY)
|
||||
set(OPENOCD
|
||||
openocd
|
||||
CACHE STRING "OpenOCD executable")
|
||||
set(OPENOCD_TARGET
|
||||
target/stm32n6x.cfg
|
||||
CACHE STRING "OpenOCD target script")
|
||||
|
||||
add_custom_target(
|
||||
flash
|
||||
COMMAND
|
||||
${OPENOCD} -f interface/stlink.cfg -c "transport select swd" -f
|
||||
${OPENOCD_TARGET} -f ${CMAKE_CURRENT_LIST_DIR}/scripts/flash.cfg -c
|
||||
"stm32n6_program nuttx.bin"
|
||||
WORKING_DIRECTORY ${NUTTX_BINARY_DIR}
|
||||
USES_TERMINAL VERBATIM)
|
||||
add_dependencies(flash nuttx-bin)
|
||||
endif()
|
||||
8
boards/arm/stm32n6/stm32n6570-dk/Kconfig
Normal file
8
boards/arm/stm32n6/stm32n6570-dk/Kconfig
Normal 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_STM32N6570_DK
|
||||
|
||||
endif
|
||||
37
boards/arm/stm32n6/stm32n6570-dk/configs/nsh/defconfig
Normal file
37
boards/arm/stm32n6/stm32n6570-dk/configs/nsh/defconfig
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# 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="arm"
|
||||
CONFIG_ARCH_BOARD="stm32n6570-dk"
|
||||
CONFIG_ARCH_BOARD_STM32N6570_DK=y
|
||||
CONFIG_ARCH_CHIP="stm32n6"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32N657X0=y
|
||||
CONFIG_ARCH_CHIP_STM32N6=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=4096
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=21000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_RAM_SIZE=2620416
|
||||
CONFIG_RAM_START=0x34180400
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_STM32N6_DEBUG=y
|
||||
CONFIG_STM32_USART1=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
165
boards/arm/stm32n6/stm32n6570-dk/include/board.h
Normal file
165
boards/arm/stm32n6/stm32n6570-dk/include/board.h
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/include/board.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H
|
||||
#define __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Clocking *****************************************************************/
|
||||
|
||||
/* Clock tree (single PLL1 fed from the internal HSI):
|
||||
*
|
||||
* HSI 64 MHz / M=4 * N=50 = 800 MHz VCO
|
||||
* IC1 /4 = 200 MHz -> CPU clock (CPUSW)
|
||||
* IC2 /8 = 100 MHz \
|
||||
* IC6 /12 = 66.7 MHz > SYSCLK components (SYSSW IC2_IC6_IC11)
|
||||
* IC11 /8 = 100 MHz /
|
||||
* HPRE /2 = 50 MHz -> HCLK
|
||||
* PPRE1 /1 = 50 MHz -> PCLK1
|
||||
* PPRE2 /1 = 50 MHz -> PCLK2
|
||||
*
|
||||
* Works with the default VOS SCALE1, no SMPS overdrive required. Higher
|
||||
* CPU frequencies (600/800 MHz) are deferred to a follow-up.
|
||||
*/
|
||||
|
||||
#define STM32_HSI_FREQUENCY 64000000ul
|
||||
|
||||
#define STM32_PLL1_M 4
|
||||
#define STM32_PLL1_N 50
|
||||
#define STM32_PLL1_IC1_DIV 4
|
||||
|
||||
#define STM32_CPUCLK_FREQUENCY 200000000ul
|
||||
#define STM32_SYSCLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 2)
|
||||
#define STM32_HCLK_FREQUENCY (STM32_CPUCLK_FREQUENCY / 4)
|
||||
#define STM32_PCLK1_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
#define STM32_PCLK2_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
|
||||
/* Timer input clock = SYSCLK (TIMPRE=0 default) */
|
||||
|
||||
#define STM32_APB1_TIM_FREQUENCY STM32_SYSCLK_FREQUENCY
|
||||
#define STM32_APB2_TIM_FREQUENCY STM32_SYSCLK_FREQUENCY
|
||||
|
||||
/* I/O voltage domains ******************************************************/
|
||||
|
||||
/* VDDIO2 and VDDIO3 are supplied at 1.8 V on the Discovery kit.
|
||||
* Mark both supplies valid and select their 1.8 V range before the
|
||||
* common STM32N6 startup configures I/O compensation.
|
||||
*/
|
||||
|
||||
#define BOARD_PWR_VDDIO (PWR_SVMCR3_VDDIO2SV | PWR_SVMCR3_VDDIO3SV | \
|
||||
PWR_SVMCR3_VDDIO2VRSEL | PWR_SVMCR3_VDDIO3VRSEL)
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
||||
/* LD1 (green, PO1) is active high; LD2 (red, PG10) is active low. */
|
||||
|
||||
/* 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)
|
||||
|
||||
/* OS event indications when CONFIG_ARCH_LEDS is enabled:
|
||||
*
|
||||
* SYMBOL Meaning Green Red
|
||||
* --------------------- ----------------------- ----- -----
|
||||
*/
|
||||
|
||||
#define LED_STARTED 0 /* NuttX has started OFF OFF */
|
||||
#define LED_HEAPALLOCATE 0 /* Heap allocated OFF OFF */
|
||||
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF */
|
||||
#define LED_STACKCREATED 1 /* Idle stack created ON OFF */
|
||||
#define LED_INIRQ 2 /* In an interrupt N/C N/C */
|
||||
#define LED_SIGNAL 2 /* In a signal handler N/C N/C */
|
||||
#define LED_ASSERTION 2 /* An assertion failed N/C N/C */
|
||||
#define LED_PANIC 3 /* The system crashed OFF Blink */
|
||||
|
||||
/* Alternate function pin selections ****************************************/
|
||||
|
||||
/* USART1 GPIOs *************************************************************/
|
||||
|
||||
/* USART1 (ST-LINK Virtual COM Port): PE5=TX (AF7), PE6=RX (AF7)
|
||||
* Connected to the on-board ST-Link to provide a Virtual COM Port.
|
||||
*/
|
||||
|
||||
#define GPIO_USART1_TX GPIO_USART1_TX_1
|
||||
#define GPIO_USART1_RX GPIO_USART1_RX_1
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_board_initialize
|
||||
*
|
||||
* Description:
|
||||
* All STM32N6 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 stm32_board_initialize(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_STM32N6_STM32N6570_DK_INCLUDE_BOARD_H */
|
||||
47
boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
Normal file
47
boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
##############################################################################
|
||||
# boards/arm/stm32n6/stm32n6570-dk/scripts/Make.defs
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv8-m/Toolchain.defs
|
||||
|
||||
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)flash.ld
|
||||
|
||||
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
OPENOCD ?= openocd
|
||||
OPENOCD_TARGET ?= target/stm32n6x.cfg
|
||||
|
||||
ifeq ($(CONFIG_RAW_BINARY),y)
|
||||
define FLASH
|
||||
$(Q) $(OPENOCD) -f interface/stlink.cfg -c 'transport select swd' \
|
||||
-f $(OPENOCD_TARGET) -f $(BOARD_DIR)/scripts/flash.cfg \
|
||||
-c 'stm32n6_program nuttx.bin'
|
||||
endef
|
||||
endif
|
||||
148
boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
Normal file
148
boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
##############################################################################
|
||||
# boards/arm/stm32n6/stm32n6570-dk/scripts/flash.cfg
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Load interface/stlink.cfg and target/stm32n6x.cfg before this file.
|
||||
|
||||
reset_config srst_only srst_nogate
|
||||
flash bank stm32n6570_dk.nor stmqspi 0x70000000 0 0 0 $_TARGETNAME 0x5802a000
|
||||
proc stm32n6570_dk_flash_init {} {
|
||||
# Stop inherited interrupts and instruction caching while OpenOCD runs
|
||||
# SRAM algorithms. The boot ROM also leaves stack limits set.
|
||||
|
||||
mww 0xe000e010 0
|
||||
mww 0xe000ed04 0x0a000000
|
||||
mmw 0xe000ed14 0 0x20000
|
||||
mww 0xe000ef50 0
|
||||
reg msplim_s 0
|
||||
reg psplim_s 0
|
||||
reg primask_s 1
|
||||
|
||||
# PWR, GPION and all XSPIM clocks. Reset both XSPI controllers before
|
||||
# restoring the direct XSPI2-to-port-2 mapping left changed by ROM.
|
||||
|
||||
mww 0x56028a5c 0x42000
|
||||
mww 0x56028a60 0x3020
|
||||
mww 0x56028a20 0x3020
|
||||
mww 0x56029220 0x3020
|
||||
|
||||
# HCLK kernel source and conservative /8 prescaler.
|
||||
|
||||
mmw 0x56028158 0 0x30
|
||||
|
||||
# The DK NOR uses the 1.8 V VDDIO3 domain.
|
||||
|
||||
mmw 0x5602483c 0x04000200 0
|
||||
|
||||
# PN1 NCS, PN2 MOSI, PN3 MISO, PN6 CLK, AF9.
|
||||
|
||||
mmw 0x56023400 0x20a8 0x30fc
|
||||
mmw 0x56023408 0x30fc 0
|
||||
mmw 0x5602340c 0x504 0x3ffc
|
||||
mmw 0x56023420 0x09009990 0x0f00fff0
|
||||
|
||||
# Map XSPI2 to port 2 and configure single-lane, 32-bit-address reads.
|
||||
|
||||
mww 0x5802b400 0
|
||||
mww 0x5802a008 0x001a0700
|
||||
mww 0x5802a00c 7
|
||||
mww 0x5802a108 0
|
||||
mww 0x5802a100 0x01003101
|
||||
mww 0x5802a110 0x13
|
||||
mww 0x5802a000 0x30000001
|
||||
|
||||
# MX66UW1G45G geometry and standard 4-byte read/program/erase commands.
|
||||
# This part is absent from some OpenOCD JEDEC ID tables.
|
||||
|
||||
stmqspi set stm32n6570_dk.nor MX66UW1G45G 0x8000000 256 \
|
||||
0x13 0 0x12 0x60 0x10000 0xdc
|
||||
}
|
||||
|
||||
# Add the unauthenticated ROM header v2.3 (UM3234) as part of programming.
|
||||
# The vector table follows the header and padding at offset 0x400.
|
||||
|
||||
proc stm32n6_program {image} {
|
||||
set input [open $image rb]
|
||||
set data [read $input]
|
||||
close $input
|
||||
|
||||
# Jim Tcl strings can contain UTF-8; use the binary byte count.
|
||||
|
||||
set size [string bytelength $data]
|
||||
if {$size < 8 || $size > 0x7fc00} {
|
||||
error "NuttX binary must contain vectors and fit in 511 KiB"
|
||||
}
|
||||
|
||||
binary scan $data ii stack entry
|
||||
if {$stack < 0x34180400 || $stack > 0x34400000 || ($stack & 3)} {
|
||||
error "Initial SP must be word-aligned and inside AXISRAM"
|
||||
}
|
||||
if {!($entry & 1) || ($entry & ~1) < 0x34180400 ||
|
||||
($entry & ~1) >= 0x34180400 + $size} {
|
||||
error "Reset vector must point into the payload at 0x34180400"
|
||||
}
|
||||
|
||||
set checksum 0
|
||||
binary scan $data c* bytes
|
||||
foreach byte $bytes {
|
||||
set checksum [expr {($checksum + ($byte & 0xff)) & 0xffffffff}]
|
||||
}
|
||||
set padding [expr {(-$size) & 31}]
|
||||
set length [expr {0x1c0 + $size + $padding}]
|
||||
set header [lrepeat 256 0]
|
||||
foreach {offset value} [list \
|
||||
0x00 0x324d5453 \
|
||||
0x64 $checksum \
|
||||
0x68 0x00020300 \
|
||||
0x6c $length \
|
||||
0x70 $entry \
|
||||
0x78 0xffffffff \
|
||||
0x84 0x80000000 \
|
||||
0x88 0x1a0 \
|
||||
0x8c 0x10 \
|
||||
0xa0 0xffff5453 \
|
||||
0xa4 0x1a0] {
|
||||
lset header [expr {$offset / 4}] $value
|
||||
}
|
||||
|
||||
set boot [file rootname $image]-boot.bin
|
||||
set output [open $boot wb]
|
||||
puts -nonewline $output [binary format i* $header]
|
||||
puts -nonewline $output $data
|
||||
puts -nonewline $output [binary format x$padding]
|
||||
close $output
|
||||
|
||||
# Reject a truncated or incorrectly encoded image before touching flash.
|
||||
|
||||
if {[file size $boot] != 0x400 + $size + $padding} {
|
||||
error "Boot image size does not match the ROM header"
|
||||
}
|
||||
|
||||
# Keep the current debug access until the replacement image is verified.
|
||||
|
||||
init
|
||||
halt
|
||||
stm32n6570_dk_flash_init
|
||||
echo [flash write_image erase $boot 0x70000000 bin]
|
||||
echo [verify_image $boot 0x70000000 bin]
|
||||
reset run
|
||||
shutdown
|
||||
}
|
||||
109
boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
Normal file
109
boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/scripts/flash.ld
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* The STM32N657X0 boot ROM copies the image from external flash into
|
||||
* AXISRAM2. The STM32 image header occupies 0x34180000-0x341803ff;
|
||||
* the vector table and payload start at 0x34180400. The ROM download
|
||||
* buffer ends at 0x34200000, limiting the payload to 511 KiB.
|
||||
* After boot, the remaining contiguous AXISRAM is available for data
|
||||
* and the heap through 0x34400000.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
sram (rwx) : ORIGIN = 0x34180400, LENGTH = 2620416
|
||||
}
|
||||
|
||||
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(.);
|
||||
} > sram
|
||||
|
||||
.init_section : {
|
||||
_sinit = ABSOLUTE(.);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors))
|
||||
_einit = ABSOLUTE(.);
|
||||
} > sram
|
||||
|
||||
.ARM.extab : {
|
||||
*(.ARM.extab*)
|
||||
} > sram
|
||||
|
||||
__exidx_start = ABSOLUTE(.);
|
||||
.ARM.exidx : {
|
||||
*(.ARM.exidx*)
|
||||
} > sram
|
||||
__exidx_end = ABSOLUTE(.);
|
||||
|
||||
.data : {
|
||||
_eronly = ABSOLUTE(.);
|
||||
_sdata = ABSOLUTE(.);
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
CONSTRUCTORS
|
||||
. = ALIGN(4);
|
||||
_edata = ABSOLUTE(.);
|
||||
} > sram
|
||||
|
||||
ASSERT(_edata <= 0x34200000,
|
||||
"STM32N6 boot ROM payload exceeds 511 KiB")
|
||||
|
||||
.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) }
|
||||
}
|
||||
33
boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
Normal file
33
boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# ##############################################################################
|
||||
# boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||
# license agreements. See the NOTICE file distributed with this work for
|
||||
# additional information regarding copyright ownership. The ASF licenses this
|
||||
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||
# use this file except in compliance with the License. You may obtain a copy of
|
||||
# the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
#
|
||||
# ##############################################################################
|
||||
|
||||
set(SRCS stm32_boot.c stm32_bringup.c)
|
||||
|
||||
if(CONFIG_ARCH_LEDS)
|
||||
list(APPEND SRCS stm32_autoleds.c)
|
||||
else()
|
||||
list(APPEND SRCS stm32_userleds.c)
|
||||
endif()
|
||||
|
||||
target_sources(board PRIVATE ${SRCS})
|
||||
|
||||
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
|
||||
36
boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
Normal file
36
boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
##############################################################################
|
||||
# boards/arm/stm32n6/stm32n6570-dk/src/Make.defs
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ASRCS =
|
||||
CSRCS = stm32_boot.c stm32_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += stm32_autoleds.c
|
||||
else
|
||||
CSRCS += stm32_userleds.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
|
||||
103
boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
Normal file
103
boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/src/stm32_autoleds.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32n6570-dk.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_autoled_initialize
|
||||
*
|
||||
* Description:
|
||||
* Configure both user LEDs as outputs, initially off.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_autoled_initialize(void)
|
||||
{
|
||||
stm32_configgpio(GPIO_LD1);
|
||||
stm32_configgpio(GPIO_LD2);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_autoled_on
|
||||
*
|
||||
* Description:
|
||||
* Indicate successful startup with the green LED and panic with red.
|
||||
* Interrupt and signal events leave the LEDs unchanged.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_autoled_on(int led)
|
||||
{
|
||||
switch (led)
|
||||
{
|
||||
case LED_STARTED:
|
||||
stm32_gpiowrite(GPIO_LD1, false);
|
||||
stm32_gpiowrite(GPIO_LD2, true);
|
||||
break;
|
||||
|
||||
case LED_STACKCREATED:
|
||||
stm32_gpiowrite(GPIO_LD1, true);
|
||||
break;
|
||||
|
||||
case LED_PANIC:
|
||||
stm32_gpiowrite(GPIO_LD1, false);
|
||||
stm32_gpiowrite(GPIO_LD2, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_autoled_off
|
||||
*
|
||||
* Description:
|
||||
* Turn off the red LED between panic indications.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_autoled_off(int led)
|
||||
{
|
||||
if (led == LED_PANIC)
|
||||
{
|
||||
stm32_gpiowrite(GPIO_LD2, true);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
83
boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
Normal file
83
boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/src/stm32_boot.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "arm_internal.h"
|
||||
#include "stm32n6570-dk.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_board_initialize
|
||||
*
|
||||
* Description:
|
||||
* All STM32 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 stm32_board_initialize(void)
|
||||
{
|
||||
#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 */
|
||||
|
||||
stm32_bringup();
|
||||
}
|
||||
#endif
|
||||
87
boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
Normal file
87
boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/leds/userled.h>
|
||||
|
||||
#include "stm32n6570-dk.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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_BOARDCTL=y :
|
||||
* Called from the NSH library
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void)
|
||||
{
|
||||
#if defined(CONFIG_FS_PROCFS) || \
|
||||
(!defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER))
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FS_PROCFS
|
||||
/* Mount the procfs file system. */
|
||||
|
||||
ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
return OK;
|
||||
}
|
||||
127
boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
Normal file
127
boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/src/stm32_userleds.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <nuttx/debug.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32n6570-dk.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* 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_LD1,
|
||||
GPIO_LD2,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* 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 LD1 and LD2 GPIOs for output */
|
||||
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
stm32_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 < nitems(g_ledcfg))
|
||||
{
|
||||
/* LD1 is active high; LD2 is active low. */
|
||||
|
||||
stm32_gpiowrite(g_ledcfg[led], led == BOARD_LED_RED ? !ledon : 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;
|
||||
|
||||
/* Apply the polarity of each LED. */
|
||||
|
||||
for (i = 0; i < nitems(g_ledcfg); i++)
|
||||
{
|
||||
board_userled(i, (ledset & (1 << i)) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
||||
80
boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
Normal file
80
boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/****************************************************************************
|
||||
* boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H
|
||||
#define __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "stm32_gpio.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* LED definitions **********************************************************/
|
||||
|
||||
/* LD1 is active high; LD2 is active low. Start with both LEDs off. */
|
||||
|
||||
#define GPIO_LD1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTO | GPIO_PIN1)
|
||||
#define GPIO_LD2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHZ | \
|
||||
GPIO_OUTPUT_SET | GPIO_PORTG | GPIO_PIN10)
|
||||
|
||||
/****************************************************************************
|
||||
* 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_BOARDCTL=y :
|
||||
* Called from the NSH library
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_STM32N6_STM32N6570_DK_SRC_STM32N6570_DK_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue