This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 512dee830998ad6f502785910962905862f91f24 Author: raiden00pl <[email protected]> AuthorDate: Mon Oct 19 14:46:50 2026 +0200 boards/stm32g4: add nucleo-g491re board support Nucleo-64 board with the STM32G491RE, pin compatible with the Nucleo-G474RE. nsh configuration with the console on LPUART1, the ST-LINK virtual COM port. Signed-off-by: raiden00pl <[email protected]> Assisted-by: Claude Code --- .../arm/stm32g4/boards/nucleo-g491re/index.rst | 35 ++++ boards/Kconfig | 12 ++ boards/arm/stm32g4/nucleo-g491re/CMakeLists.txt | 23 +++ boards/arm/stm32g4/nucleo-g491re/Kconfig | 7 + .../stm32g4/nucleo-g491re/configs/nsh/defconfig | 36 ++++ boards/arm/stm32g4/nucleo-g491re/include/board.h | 182 +++++++++++++++++++++ boards/arm/stm32g4/nucleo-g491re/scripts/Make.defs | 47 ++++++ boards/arm/stm32g4/nucleo-g491re/scripts/ld.script | 138 ++++++++++++++++ .../arm/stm32g4/nucleo-g491re/src/CMakeLists.txt | 37 +++++ boards/arm/stm32g4/nucleo-g491re/src/Make.defs | 41 +++++ .../arm/stm32g4/nucleo-g491re/src/nucleo-g491re.h | 62 +++++++ .../arm/stm32g4/nucleo-g491re/src/stm32_autoleds.c | 58 +++++++ boards/arm/stm32g4/nucleo-g491re/src/stm32_boot.c | 49 ++++++ .../arm/stm32g4/nucleo-g491re/src/stm32_bringup.c | 66 ++++++++ .../arm/stm32g4/nucleo-g491re/src/stm32_buttons.c | 62 +++++++ .../arm/stm32g4/nucleo-g491re/src/stm32_userleds.c | 56 +++++++ 16 files changed, 911 insertions(+) diff --git a/Documentation/platforms/arm/stm32g4/boards/nucleo-g491re/index.rst b/Documentation/platforms/arm/stm32g4/boards/nucleo-g491re/index.rst new file mode 100644 index 00000000000..330b56824fa --- /dev/null +++ b/Documentation/platforms/arm/stm32g4/boards/nucleo-g491re/index.rst @@ -0,0 +1,35 @@ +================ +ST Nucleo G491RE +================ + +.. tags:: arch:arm, chip:stm32g4, part:stm32g491, vendor:st + +Nucleo-64 board with the STM32G491RE MCU: + + https://www.st.com/en/evaluation-tools/nucleo-g491re.html + +The STM32G491 is the category 4 member of the family: compared to the +STM32G474 it has no HRTIM, ADC4/5, DAC2/4, COMP5-7, OPAMP4/5, I2C4, SPI4, +FDCAN3, TIM5, FMC or QUADSPI, 112 KB of SRAM (80 + 16 KB plus 16 KB CCM) +and a single bank 512 KB flash with 2 KB pages. The board is otherwise +pin compatible with the Nucleo-G474RE. + +Clocking +======== + +SYSCLK is 170 MHz from the PLL fed by the 16 MHz HSI. HSE and LSE are not +installed. + +Serial Console +============== + +LPUART1 on PA2/PA3 is connected to the ST-LINK virtual COM port and is the +default console. USART3 on PC10/PC11 is available on CN7 pins 1 and 2. + +Configurations +============== + +nsh +--- + +NSH on the ST-LINK virtual COM port. diff --git a/boards/Kconfig b/boards/Kconfig index 04e9f317ec7..0f180dfb868 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -3535,6 +3535,17 @@ config ARCH_BOARD_NUCLEO_G474RE STMicro Nucleo-G474RE board based on the STMicro STM32G474RET6 MCU, a Cortex-M4 with FPU, 170 MHz, 128 KB SRAM, 512 KB code. +config ARCH_BOARD_NUCLEO_G491RE + bool "ST Micro Nucleo G491RE" + depends on ARCH_CHIP_STM32G491R + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS + select ARCH_BOARD_COMMON + ---help--- + STMicro Nucleo-G491RE board based on the STMicro STM32G491RET6 + MCU, a Cortex-M4 with FPU, 170 MHz, 112 KB SRAM, 512 KB code. + config ARCH_BOARD_B_L072Z_LRWAN1 bool "B-L072Z-LRWAN1" depends on ARCH_CHIP_STM32L072CZ @@ -4492,6 +4503,7 @@ config ARCH_BOARD default "nucleo-g431kb" if ARCH_BOARD_NUCLEO_G431KB default "nucleo-g431rb" if ARCH_BOARD_NUCLEO_G431RB default "nucleo-g474re" if ARCH_BOARD_NUCLEO_G474RE + default "nucleo-g491re" if ARCH_BOARD_NUCLEO_G491RE default "b-l072z-lrwan1" if ARCH_BOARD_B_L072Z_LRWAN1 default "b-l475e-iot01a" if ARCH_BOARD_B_L475E_IOT01A default "b-u585i-iot02a" if ARCH_BOARD_B_U585I_IOT02A diff --git a/boards/arm/stm32g4/nucleo-g491re/CMakeLists.txt b/boards/arm/stm32g4/nucleo-g491re/CMakeLists.txt new file mode 100644 index 00000000000..cdf8f8f799f --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/CMakeLists.txt @@ -0,0 +1,23 @@ +# ############################################################################## +# boards/arm/stm32g4/nucleo-g491re/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) diff --git a/boards/arm/stm32g4/nucleo-g491re/Kconfig b/boards/arm/stm32g4/nucleo-g491re/Kconfig new file mode 100644 index 00000000000..6018a478479 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/Kconfig @@ -0,0 +1,7 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_NUCLEO_G491RE +endif # ARCH_BOARD_NUCLEO_G491RE diff --git a/boards/arm/stm32g4/nucleo-g491re/configs/nsh/defconfig b/boards/arm/stm32g4/nucleo-g491re/configs/nsh/defconfig new file mode 100644 index 00000000000..12baf3bbfae --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/configs/nsh/defconfig @@ -0,0 +1,36 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nucleo-g491re" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_NUCLEO_G491RE=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="stm32g4" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32G491R=y +CONFIG_ARCH_CHIP_STM32G4=y +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_LPUART1_SERIAL_CONSOLE=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=98304 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_STM32_LPUART1=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=0 diff --git a/boards/arm/stm32g4/nucleo-g491re/include/board.h b/boards/arm/stm32g4/nucleo-g491re/include/board.h new file mode 100644 index 00000000000..27dc47a3d13 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/include/board.h @@ -0,0 +1,182 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/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_STM32G4_NUCLEO_G491RE_INCLUDE_BOARD_H +#define __BOARDS_ARM_STM32G4_NUCLEO_G491RE_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#undef STM32_BOARD_XTAL /* Not installed */ + +#define STM32_HSI_FREQUENCY 16000000ul /* 16MHz */ +#define STM32_LSI_FREQUENCY 32000 /* 32kHz */ +#undef STM32_HSE_FREQUENCY /* Not installed */ +#undef STM32_LSE_FREQUENCY /* Not installed */ + +/* Main PLL Configuration. + * + * PLL source is HSI = 16MHz + * PLLN = 85, PLLM = 4, PLLP = 10, PLLQ = 2, PLLR = 2 + * + * f(VCO Clock) = f(PLL Clock Input) x (PLLN / PLLM) + * f(PLL_P) = f(VCO Clock) / PLLP + * f(PLL_Q) = f(VCO Clock) / PLLQ + * f(PLL_R) = f(VCO Clock) / PLLR + * + * Where: + * 8 <= PLLN <= 127 + * 1 <= PLLM <= 16 + * PLLP = 2 through 31 + * PLLQ = 2, 4, 6, or 8 + * PLLR = 2, 4, 6, or 8 + * + * Do not exceed 170MHz on f(PLL_P), f(PLL_Q), or f(PLL_R). + * 64MHz <= f(VCO Clock) <= 344MHz. + * + * Given the above: + * + * f(VCO Clock) = HSI x PLLN / PLLM + * = 16MHz x 85 / 4 + * = 340MHz + * + * PLLPCLK = f(VCO Clock) / PLLP + * = 340MHz / 10 + * = 34MHz + * (May be used for ADC) + * + * PLLQCLK = f(VCO Clock) / PLLQ + * = 340MHz / 2 + * = 170MHz + * (May be used for QUADSPI, FDCAN, SAI1, I2S3. If set to + * 48MHz, may be used for USB, RNG.) + * + * PLLRCLK = f(VCO Clock) / PLLR + * = 340MHz / 2 + * = 170MHz + * (May be used for SYSCLK and most peripherals.) + */ + +#define STM32_PLLCFGR_PLLSRC RCC_PLLCFGR_PLLSRC_HSI +#define STM32_PLLCFGR_PLLCFG (RCC_PLLCFGR_PLLPEN | \ + RCC_PLLCFGR_PLLQEN | \ + RCC_PLLCFGR_PLLREN) + +#define STM32_PLLCFGR_PLLN RCC_PLLCFGR_PLLN(85) +#define STM32_PLLCFGR_PLLM RCC_PLLCFGR_PLLM(4) +#define STM32_PLLCFGR_PLLP RCC_PLLCFGR_PLLPDIV(10) +#define STM32_PLLCFGR_PLLQ RCC_PLLCFGR_PLLQ_2 +#define STM32_PLLCFGR_PLLR RCC_PLLCFGR_PLLR_2 + +#define STM32_VCO_FREQUENCY ((STM32_HSI_FREQUENCY / 4) * 85) +#define STM32_PLLP_FREQUENCY (STM32_VCO_FREQUENCY / 10) +#define STM32_PLLQ_FREQUENCY (STM32_VCO_FREQUENCY / 2) +#define STM32_PLLR_FREQUENCY (STM32_VCO_FREQUENCY / 2) + +/* Use the PLL and set the SYSCLK source to be PLLR (170MHz) */ + +#define STM32_SYSCLK_SW RCC_CFGR_SW_PLL +#define STM32_SYSCLK_SWS RCC_CFGR_SWS_PLL +#define STM32_SYSCLK_FREQUENCY STM32_PLLR_FREQUENCY + +/* AHB clock (HCLK) is SYSCLK (170MHz) */ + +#define STM32_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK +#define STM32_HCLK_FREQUENCY STM32_SYSCLK_FREQUENCY + +/* APB1 clock (PCLK1) is HCLK (170MHz) */ + +#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK +#define STM32_PCLK1_FREQUENCY STM32_HCLK_FREQUENCY + +/* APB2 clock (PCLK2) is HCLK (170MHz) */ + +#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK +#define STM32_PCLK2_FREQUENCY STM32_HCLK_FREQUENCY + +/* Timers driven from APB2 will be PCLK2 */ + +#define STM32_TIM1_CLKIN STM32_PCLK2_FREQUENCY +#define STM32_TIM8_CLKIN STM32_PCLK2_FREQUENCY +#define STM32_TIM15_CLKIN STM32_PCLK2_FREQUENCY +#define STM32_TIM16_CLKIN STM32_PCLK2_FREQUENCY +#define STM32_TIM17_CLKIN STM32_PCLK2_FREQUENCY +#define STM32_TIM20_CLKIN STM32_PCLK2_FREQUENCY + +/* Timers driven from APB1 will be PCLK1 */ + +#define STM32_TIM2_CLKIN STM32_PCLK1_FREQUENCY +#define STM32_TIM3_CLKIN STM32_PCLK1_FREQUENCY +#define STM32_TIM4_CLKIN STM32_PCLK1_FREQUENCY +#define STM32_TIM6_CLKIN STM32_PCLK1_FREQUENCY +#define STM32_TIM7_CLKIN STM32_PCLK1_FREQUENCY + +/* LPTIM1 kernel clock is PCLK1 (RCC_CCIPR LPTIM1SEL reset value) */ + +#define STM32_LPTIM1_CLKIN STM32_PCLK1_FREQUENCY + +/* LPUART1 is connected to the ST-LINK virtual COM port. */ + +#define GPIO_LPUART1_TX GPIO_LPUART1_TX_1 /* PA2 */ +#define GPIO_LPUART1_RX GPIO_LPUART1_RX_1 /* PA3 */ + +/* USART3 on CN7 pins 1 and 2. */ + +#define GPIO_USART3_TX GPIO_USART3_TX_3 /* PC10 */ +#define GPIO_USART3_RX GPIO_USART3_RX_3 /* PC11 */ + +/* User LEDs */ + +#define BOARD_LED1 0 /* User LD2 */ +#define BOARD_NLEDS 1 + +#define BOARD_LED1_BIT (1 << BOARD_LED1) + +/* NuttX LED state mapping. LD2 is active high. */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 1 +#define LED_INIRQ 2 +#define LED_SIGNAL 2 +#define LED_ASSERTION 2 +#define LED_PANIC 1 +#define LED_IDLE 0 + +/* User button B1 is active high. */ + +#define BUTTON_USER 0 +#define NUM_BUTTONS 1 + +#define BUTTON_USER_BIT (1 << BUTTON_USER) + +#endif /* __BOARDS_ARM_STM32G4_NUCLEO_G491RE_INCLUDE_BOARD_H */ diff --git a/boards/arm/stm32g4/nucleo-g491re/scripts/Make.defs b/boards/arm/stm32g4/nucleo-g491re/scripts/Make.defs new file mode 100644 index 00000000000..e57b3ec6cba --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/scripts/Make.defs @@ -0,0 +1,47 @@ +############################################################################ +# boards/arm/stm32g4/nucleo-g491re/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/armv7-m/Toolchain.defs + +ifeq ($(CONFIG_STM32_DFU),y) + LDSCRIPT = ld.script.dfu +else + LDSCRIPT = ld.script +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +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)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Embed absolute path to source file in debug information so that Eclipse +# source level debugging won't get confused. See: +# https://stackoverflow.com/questions/1275476/gcc-gdb-how-to-embed-absolute-path-to-source-file-in-debug-information +CFLAGS += -fdebug-prefix-map=..=$(readlink -f ..) diff --git a/boards/arm/stm32g4/nucleo-g491re/scripts/ld.script b/boards/arm/stm32g4/nucleo-g491re/scripts/ld.script new file mode 100644 index 00000000000..27eea7a0783 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/scripts/ld.script @@ -0,0 +1,138 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/scripts/ld.script + * + * 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 STM32G491RE has 512 KiB of FLASH beginning at address 0x0800:0000. + * + * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000 + * where the code expects to begin execution by jumping to the entry point in + * the 0x0800:0000 address range. + * + * The STM32G491RE has a total of 112 KiB of SRAM in three separate areas: + * + * 1) 80 KiB SRAM1 mapped at 0x2000:0000 thru 0x2001:3fff. + * 2) 16 KiB SRAM2 mapped at 0x2001:4000 thru 0x2001:7fff. + * + * CCM SRAM (Routine Booster): + * + * 3) 16 KiB CCM SRAM mapped at 0x1000:0000 thru 0x1000:3fff + * but also aliased at 0x2001:8000 thru 0x2001:bfff to be contiguous + * with the SRAM1 and SRAM2. + * + * Because SRAM1 and SRAM2 are contiguous, they are treated as one region + * by this logic. + * + * CCM SRAM is also contiguous to SRAM1 and SRAM2, however it is excluded + * from this linker script, to keep it reserved for special uses in code. + */ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08000000, LENGTH = 512K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +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 : ALIGN(4) { + _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(.); + } > flash + + .ARM.extab : ALIGN(4) { + *(.ARM.extab*) + } > flash + + .ARM.exidx : ALIGN(4) { + __exidx_start = ABSOLUTE(.); + *(.ARM.exidx*) + __exidx_end = ABSOLUTE(.); + } > flash + + .tdata : { + _stdata = ABSOLUTE(.); + *(.tdata .tdata.* .gnu.linkonce.td.*); + _etdata = ABSOLUTE(.); + } > flash + + .tbss : { + _stbss = ABSOLUTE(.); + *(.tbss .tbss.* .gnu.linkonce.tb.* .tcommon); + _etbss = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + .data : ALIGN(4) { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : ALIGN(4) { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(8); + _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) } +} diff --git a/boards/arm/stm32g4/nucleo-g491re/src/CMakeLists.txt b/boards/arm/stm32g4/nucleo-g491re/src/CMakeLists.txt new file mode 100644 index 00000000000..066acd9292c --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/CMakeLists.txt @@ -0,0 +1,37 @@ +# ############################################################################## +# boards/arm/stm32g4/nucleo-g491re/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() + +if(CONFIG_ARCH_BUTTONS) + list(APPEND SRCS stm32_buttons.c) +endif() + +target_sources(board PRIVATE ${SRCS}) + +set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script") diff --git a/boards/arm/stm32g4/nucleo-g491re/src/Make.defs b/boards/arm/stm32g4/nucleo-g491re/src/Make.defs new file mode 100644 index 00000000000..657ca96fc92 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# boards/arm/stm32g4/nucleo-g491re/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 + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += stm32_buttons.c +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board diff --git a/boards/arm/stm32g4/nucleo-g491re/src/nucleo-g491re.h b/boards/arm/stm32g4/nucleo-g491re/src/nucleo-g491re.h new file mode 100644 index 00000000000..fb4340f60a9 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/nucleo-g491re.h @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/src/nucleo-g491re.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_STM32G4_NUCLEO_G491RE_SRC_NUCLEO_G491RE_H +#define __BOARDS_ARM_STM32G4_NUCLEO_G491RE_SRC_NUCLEO_G491RE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <arch/board/board.h> + +#include "stm32.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* NUCLEO-G491RE GPIOs ******************************************************/ + +/* LD2 is connected to PA5 and is active high. */ + +#define GPIO_LD2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_5MHz | \ + GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN5) + +/* B1 USER is connected to PC13 and is active high. */ + +#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 Function Prototypes + ****************************************************************************/ + +int stm32_bringup(void); + +#endif /* __BOARDS_ARM_STM32G4_NUCLEO_G491RE_SRC_NUCLEO_G491RE_H */ diff --git a/boards/arm/stm32g4/nucleo-g491re/src/stm32_autoleds.c b/boards/arm/stm32g4/nucleo-g491re/src/stm32_autoleds.c new file mode 100644 index 00000000000..855541ec62c --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/stm32_autoleds.c @@ -0,0 +1,58 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/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 <stdbool.h> + +#include <nuttx/board.h> + +#include "nucleo-g491re.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + stm32_configgpio(GPIO_LD2); +} + +void board_autoled_on(int led) +{ + if (led == LED_STACKCREATED || led == LED_PANIC) + { + stm32_gpiowrite(GPIO_LD2, true); + } +} + +void board_autoled_off(int led) +{ + if (led == LED_PANIC) + { + stm32_gpiowrite(GPIO_LD2, false); + } +} diff --git a/boards/arm/stm32g4/nucleo-g491re/src/stm32_boot.c b/boards/arm/stm32g4/nucleo-g491re/src/stm32_boot.c new file mode 100644 index 00000000000..867d835ddda --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/stm32_boot.c @@ -0,0 +1,49 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/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 <nuttx/board.h> + +#include "nucleo-g491re.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void stm32_boardinitialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + board_autoled_initialize(); +#endif +} + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + stm32_bringup(); +} +#endif diff --git a/boards/arm/stm32g4/nucleo-g491re/src/stm32_bringup.c b/boards/arm/stm32g4/nucleo-g491re/src/stm32_bringup.c new file mode 100644 index 00000000000..ab1a94ae115 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/stm32_bringup.c @@ -0,0 +1,66 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/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 <syslog.h> + +#include <nuttx/board.h> +#include <nuttx/input/buttons.h> + +#include "board_common.h" +#include "nucleo-g491re.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int stm32_bringup(void) +{ + int ret; + + /* Initialize the board features common to all STM32 boards */ + + ret = stm32_common_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_common_initialize() failed: %d\n", + ret); + } + +#ifdef CONFIG_INPUT_BUTTONS + /* Register the BUTTON lower-half driver. */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} diff --git a/boards/arm/stm32g4/nucleo-g491re/src/stm32_buttons.c b/boards/arm/stm32g4/nucleo-g491re/src/stm32_buttons.c new file mode 100644 index 00000000000..9889385a281 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/stm32_buttons.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/src/stm32_buttons.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 <stdint.h> +#include <errno.h> + +#include <nuttx/board.h> + +#include "nucleo-g491re.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +uint32_t board_button_initialize(void) +{ + stm32_configgpio(GPIO_BTN_USER); + return NUM_BUTTONS; +} + +uint32_t board_buttons(void) +{ + return stm32_gpioread(GPIO_BTN_USER) ? BUTTON_USER_BIT : 0; +} + +#ifdef CONFIG_ARCH_IRQBUTTONS +int board_button_irq(int id, xcpt_t irqhandler, void *arg) +{ + if (id != BUTTON_USER) + { + return -EINVAL; + } + + return stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, + irqhandler, arg); +} +#endif diff --git a/boards/arm/stm32g4/nucleo-g491re/src/stm32_userleds.c b/boards/arm/stm32g4/nucleo-g491re/src/stm32_userleds.c new file mode 100644 index 00000000000..2129786f922 --- /dev/null +++ b/boards/arm/stm32g4/nucleo-g491re/src/stm32_userleds.c @@ -0,0 +1,56 @@ +/**************************************************************************** + * boards/arm/stm32g4/nucleo-g491re/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/board.h> + +#include "nucleo-g491re.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +uint32_t board_userled_initialize(void) +{ + stm32_configgpio(GPIO_LD2); + return BOARD_NLEDS; +} + +void board_userled(int led, bool ledon) +{ + if (led == BOARD_LED1) + { + stm32_gpiowrite(GPIO_LD2, ledon); + } +} + +void board_userled_all(uint32_t ledset) +{ + stm32_gpiowrite(GPIO_LD2, (ledset & BOARD_LED1_BIT) != 0); +}
