diff --git a/boards/arm/stm32l4r9i_disco/Kconfig.board b/boards/arm/stm32l4r9i_disco/Kconfig.board new file mode 100644 index 00000000000..57da0f65fdf --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/Kconfig.board @@ -0,0 +1,8 @@ +# STM32L4R9I Discovery board configuration + +# Copyright (c) 2023 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_STM32L4R9I_DISCO + bool "STM32L4R9I Discovery Development Board" + depends on SOC_STM32L4R9XX diff --git a/boards/arm/stm32l4r9i_disco/Kconfig.defconfig b/boards/arm/stm32l4r9i_disco/Kconfig.defconfig new file mode 100644 index 00000000000..82eafa62744 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/Kconfig.defconfig @@ -0,0 +1,11 @@ +# STM32L4R9I Discovery board configuration + +# Copyright (c) 2023 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_STM32L4R9I_DISCO + +config BOARD + default "stm32l4r9i_disco" + +endif # BOARD_STM32L4R9I_DISCO diff --git a/boards/arm/stm32l4r9i_disco/arduino_r3_connector.dtsi b/boards/arm/stm32l4r9i_disco/arduino_r3_connector.dtsi new file mode 100644 index 00000000000..29b56539b70 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/arduino_r3_connector.dtsi @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + arduino_header: connector { + compatible = "arduino-header-r3"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpioa 7 0>, /* A0 */ + <1 0 &gpioc 4 0>, /* A1 */ + <2 0 &gpioc 3 0>, /* A2 */ + <3 0 &gpiob 0 0>, /* A3 */ + <4 0 &gpioa 0 0>, /* A4 */ + <5 0 &gpioa 5 0>, /* A5 */ + <6 0 &gpioc 0 0>, /* D0 */ + <7 0 &gpioc 1 0>, /* D1 */ + <8 0 &gpiog 11 0>, /* D2 */ + <9 0 &gpiof 10 0>, /* D3 */ + <10 0 &gpiog 6 0>, /* D4 */ + <11 0 &gpioa 1 0>, /* D5 */ + <12 0 &gpiob 4 0>, /* D6 */ + <13 0 &gpioa 4 0>, /* D7 */ + <14 0 &gpioh 15 0>, /* D8 */ + <15 0 &gpioh 13 0>, /* D9 */ + <16 0 &gpioi 0 0>, /* D10 */ + <17 0 &gpiob 15 0>, /* D11 */ + <18 0 &gpiob 14 0>, /* D12 */ + <19 0 &gpiob 13 0>, /* D13 */ + <20 0 &gpiog 8 0>, /* D14 */ + <21 0 &gpiog 7 0>; /* D15 */ + }; +}; + +arduino_i2c: &i2c3 {}; +arduino_spi: &spi2 {}; diff --git a/boards/arm/stm32l4r9i_disco/board.cmake b/boards/arm/stm32l4r9i_disco/board.cmake new file mode 100644 index 00000000000..c88ae7d0783 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32L4R9AI" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/stm32l4r9i_disco/doc/img/stm32l4r9i_disco.jpg b/boards/arm/stm32l4r9i_disco/doc/img/stm32l4r9i_disco.jpg new file mode 100644 index 00000000000..06914737b5b Binary files /dev/null and b/boards/arm/stm32l4r9i_disco/doc/img/stm32l4r9i_disco.jpg differ diff --git a/boards/arm/stm32l4r9i_disco/doc/index.rst b/boards/arm/stm32l4r9i_disco/doc/index.rst new file mode 100644 index 00000000000..a8f7798f840 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/doc/index.rst @@ -0,0 +1,150 @@ +.. _stm32l4r9i_disco_board: + +ST STM32L4R9I Discovery +####################### + +Overview +******** + +The 32L4R9IDISCOVERY Discovery kit is a complete demonstration and development platform +for STMicroelectronics Arm® Cortex®-M4 core-based STM32L4R9AI microcontroller. + +Leveraging the innovative ultra-low-power oriented features, 640 Kbytes of embedded RAM, +graphics performance (Chrom-ART Accelerator), and DSI controller offered by the STM32L4R9AI, +the 32L4R9IDISCOVERY Discovery kit enables users to easily prototype applications with +state-of-the-art energy efficiency, as well as stunning audio and graphics rendering with direct +support for AMOLED DSI round LCD display. + +For even more user-friendliness, the on-board ST-LINK/V2-1 debugger provides out-of-the-box +programming and debugging capabilities. + +.. image:: img/stm32l4r9i_disco.jpg + :align: center + :alt: STM32L4R9I-DISCO + +More information about the board can be found at the `STM32L4R9I-DISCOVERY website`_. +More information about STM32L4R9 can be found here: + +- `STM32L4R9/S9 on www.st.com`_ +- `STM32L4+ Series reference manual`_ +- `STM32L4R5xx/R7xx/R9xx datasheet`_ + +Supported Features +================== + +The current Zephyr stm32l4r9i_disco board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial port-polling | ++-----------+------------+-------------------------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| FLASH | on-chip | on-chip flash memory; | +| | | external OctoSPI memory | ++-----------+------------+-------------------------------------+ +| ADC | on-chip | ADC Controller | ++-----------+------------+-------------------------------------+ +| RTC | on-chip | Real Time Clock | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | spi | ++-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ +| SDMMC | on-chip | sd/mmc | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported on Zephyr porting. + +The default configuration can be found in the defconfig file: + + ``boards/arm/stm32l4r9i_disco/stm32l4r9i_disco_defconfig`` + + +Pin Mapping +=========== + +For mode details, please refer to `STM32L4R9I-DISCOVERY website`_. + +System Clock +============ + +The STM32L4R9AI System Clock can be driven by an internal or external oscillator, +as well as by the main PLL clock. By default, the System clock is driven by +the PLL clock at 120MHz. PLL clock is driven by a 4MHz medium speed internal clock. + +Serial Port +=========== + +The STM32L4R9I Discovery board has up to 6 U(S)ARTs. +The Zephyr console output is assigned to UART2, which is connected to the onboard +ST-LINK Virtual COM port interface. Default communication settings are 115200 8N1. + + +Programming and Debugging +************************* + +Flashing +======== + +The STM32L4R9I Discovery board includes an ST-LINK/V2-1 debug tool. + +Applications for the ``stm32l4r9i_disco`` board configuration can be +built and flashed in the usual way (see :ref:`build_an_application` +and :ref:`application_run` for more details). + + +Flashing an application to STM32L4R9I Discovery +----------------------------------------------- + +Connect the STM32L4R9I Discovery to your host computer using the ST-LINK +USB port, then run a serial host program to connect with the board. For example: + +.. code-block:: console + + $ minicom -b 115200 -D /dev/ttyACM0 + +You can then build and flash applications in the usual way. +Here is an example for the :ref:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: stm32l4r9i_disco + :goals: build flash + +You should see the following message in the serial host program: + +.. code-block:: console + + $ Hello World! stm32l4r9i_disco + + +Debugging +========= + +You can debug an application in the usual way. Here is an example for the +:ref:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: stm32l4r9i_disco + :goals: debug + +.. _STM32L4R9I-DISCOVERY website: + https://www.st.com/en/evaluation-tools/32l4r9idiscovery.html + +.. _STM32L4R9/S9 on www.st.com: + https://www.st.com/en/microcontrollers-microprocessors/stm32l4r9-s9.html + +.. _STM32L4+ Series reference manual: + https://www.st.com/resource/en/reference_manual/rm0432-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32L4R5xx/R7xx/R9xx datasheet: + https://www.st.com/resource/en/datasheet/stm32l4r5vi.pdf diff --git a/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.dts b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.dts new file mode 100644 index 00000000000..8a4833e8c97 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.dts @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2023 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +/dts-v1/; +#include +#include +#include +#include "arduino_r3_connector.dtsi" + +/ { + model = "STMicroelectronics STM32L4R9I-DISCO board"; + compatible = "st,stm32l4r9i-disco"; + + chosen { + zephyr,console = &usart2; + zephyr,shell-uart = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + /* N.B. LD1 (orange) is not wired to MCU */ + green_led: led_2 { + gpios = <&gpioh 4 GPIO_ACTIVE_LOW>; + label = "User LD2"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + joy_sel: joystick_selection { + label = "joystick selection"; + gpios = <&gpioc 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>; + zephyr,code = ; + }; + }; + + aliases { + led0 = &green_led; + sw0 = &joy_sel; + die-temp0 = &die_temp; + volt-sensor0 = &vref; + volt-sensor1 = &vbat; + spi-flash0 = &mx25lm51245; + }; +}; + +&clk_lse { + status = "okay"; +}; + +&clk_lsi { + status = "okay"; +}; + +&clk_hsi48 { + status = "okay"; +}; + +&clk_hsi { + status = "okay"; +}; + +&clk_msi { + status = "okay"; + msi-range = <6>; + msi-pll-mode; +}; + +&pll { + status = "okay"; + div-m = <1>; + mul-n = <60>; + /* + * WORKAROUND: stm32l4-pll-clock does not allow arbitrary PLLP dividers. + * Disable PLLP completely since it only feeds SAI, which is not active either. + */ + /* div-p = <5>; */ + div-q = <2>; + div-r = <2>; + clocks = <&clk_msi>; +}; + +&rcc { + clocks = <&pll>; + ahb-prescaler = <1>; + clock-frequency = ; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +&usart2 { + status = "okay"; + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; + current-speed = <115200>; +}; + +&lpuart1 { + status = "okay"; + pinctrl-0 = <&lpuart1_tx_pc1 &lpuart1_rx_pc0>; + pinctrl-names = "default"; + current-speed = <115200>; +}; + +&timers3 { + status = "okay"; + + pwm3: pwm { + status = "okay"; + /* + * N.B.: Datasheet indicates that ARD_D11 (wired to PB15) is connected to TIM3_CH2. + * However, this is incorrect as PB15 cannot be muxed to TIM3 (see DS12023). + * Moved ARD_D11 to TIM15_CH2 instead. + */ + pinctrl-0 = <&tim3_ch1_pb4>; + pinctrl-names = "default"; + }; +}; + +&timers5 { + status = "okay"; + + pwm5: pwm { + status = "okay"; + pinctrl-0 = <&tim5_ch2_pa1 &tim5_ch4_pi0>; + pinctrl-names = "default"; + }; +}; + +&timers8 { + status = "okay"; + + pwm8: pwm { + status = "okay"; + pinctrl-0 = <&tim8_ch1n_ph13>; + pinctrl-names = "default"; + }; +}; + +&timers15 { + status = "okay"; + + pwm15: pwm { + status = "okay"; + pinctrl-0 = <&tim15_ch2_pf10 &tim15_ch2_pb15>; + pinctrl-names = "default"; + }; +}; + +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pg13>; + pinctrl-names = "default"; + clock-frequency = ; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_scl_pg7 &i2c3_sda_pg8>; + pinctrl-names = "default"; + clock-frequency = ; +}; + +&spi2 { + status = "okay"; + pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>; + pinctrl-names = "default"; + cs-gpios = <&gpioi 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; +}; + +&rtc { + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>, + <&rcc STM32_SRC_LSE RTC_SEL(1)>; + status = "okay"; +}; + +&sdmmc1 { + status = "okay"; + pinctrl-0 = <&sdmmc1_d0_pc8 &sdmmc1_d1_pc9 + &sdmmc1_d2_pc10 &sdmmc1_d3_pc11 + &sdmmc1_ck_pc12 &sdmmc1_cmd_pd2>; + pinctrl-names = "default"; +}; + +&adc1 { + status = "okay"; + pinctrl-0 = <&adc1_in5_pa0 &adc1_in12_pa7 &adc1_in15_pb0 + &adc1_in4_pc3 &adc1_in13_pc4>; + pinctrl-names = "default"; + st,adc-clock-source = ; + st,adc-prescaler = <1>; +}; + +zephyr_udc0: &usbotg_fs { + status = "okay"; + pinctrl-0 = <&usb_otg_fs_dm_pa11 &usb_otg_fs_dp_pa12 + &usb_otg_fs_id_pa10>; + pinctrl-names = "default"; +}; + +&die_temp { + status = "okay"; +}; + +&vref { + status = "okay"; +}; + +&vbat { + status = "okay"; +}; + +&octospi2 { + status = "okay"; + pinctrl-0 = <&octospim_p2_clk_pi6 &octospim_p2_ncs_pg12 + &octospim_p2_io0_pi11 &octospim_p2_io1_pi10 + &octospim_p2_io2_pi9 &octospim_p2_io3_ph8 + &octospim_p2_io4_ph9 &octospim_p2_io5_ph10 + &octospim_p2_io6_pg9 &octospim_p2_io7_pg10 + &octospim_p2_dqs_pg15>; + pinctrl-names = "default"; + + mx25lm51245: ospi-nor-flash@0 { + status = "okay"; + compatible = "st,stm32-ospi-nor"; + reg = <0>; + ospi-max-frequency = ; + size = ; /* 512 Mbits = 64 MBytes */ + spi-bus-width = ; + data-rate = ; + four-byte-opcodes; + sfdp-bfp = [ + 53 46 44 50 06 01 02 ff + 00 06 01 10 30 00 00 ff + c2 00 01 04 10 01 00 ff + 84 00 01 02 c0 00 00 ff + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + e5 20 fb ff ff ff ff 1f + 44 eb 08 6b 08 3b 04 bb + fe ff ff ff ff ff 00 ff + ff ff 44 eb 0c 20 0f 52 + 10 d8 00 ff d6 49 c5 00 + 81 df 04 e3 44 03 67 38 + 30 b0 30 b0 f7 bd d5 5c + 4a 9e 29 ff f0 50 f9 85 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 + 7f ef ff ff 21 5c dc ff + ]; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x00000000 DT_SIZE_M(64)>; + }; + }; + }; +}; diff --git a/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.yaml b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.yaml new file mode 100644 index 00000000000..89ab98c92b1 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco.yaml @@ -0,0 +1,25 @@ +identifier: stm32l4r9i_disco +name: ST STM32L4R9I Discovery +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 640 +flash: 2048 +vendor: st +supported: + - adc + - arduino_gpio + - arduino_i2c + - arduino_spi + - gpio + - i2c + - pwm + - rtc + - sdhc + - spi + - uart + - usb + - usb_device diff --git a/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco_defconfig b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco_defconfig new file mode 100644 index 00000000000..546bd3379a8 --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/stm32l4r9i_disco_defconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_STM32L4X=y +CONFIG_SOC_STM32L4R9XX=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable HW stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable UART +CONFIG_SERIAL=y + +# Enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# Enable GPIO +CONFIG_GPIO=y + +# Enable clocks +CONFIG_CLOCK_CONTROL=y + +# Enable pin controller +CONFIG_PINCTRL=y diff --git a/boards/arm/stm32l4r9i_disco/support/openocd.cfg b/boards/arm/stm32l4r9i_disco/support/openocd.cfg new file mode 100644 index 00000000000..295299f2fbe --- /dev/null +++ b/boards/arm/stm32l4r9i_disco/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/stm32l4discovery.cfg] + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +}