Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port for WeAct Studio H723VG-LCD dev board #9550

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ CFLAGS += -DSTM32_HAL_H="<stm32$(MCU_SERIES_LOWER)xx_hal.h>"
CFLAGS += -DSTM32_SERIES_LOWER='"stm32$(MCU_SERIES_LOWER)"'

# Floating point settings
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx))
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32H723xx))
CFLAGS += -mfpu=fpv5-d16 -mfloat-abi=hard
else
CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
Expand Down Expand Up @@ -134,6 +134,8 @@ SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
hal_gpio.c \
hal_i2c.c \
hal_i2c_ex.c \
hal_pcd.c \
hal_pcd_ex.c \
hal_pwr.c \
hal_pwr_ex.c \
hal_qspi.c \
Expand All @@ -156,6 +158,7 @@ SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
ll_rcc.c \
ll_sdmmc.c \
ll_usart.c \
ll_usb.c \
ll_utils.c \
)

Expand All @@ -165,10 +168,14 @@ endif

# Need this to avoid UART linker problems. TODO: rewrite to use registered callbacks.
# Does not exist for F4 and lower
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32L4R5xx))
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32H723xx STM32L4R5xx))
SRC_STM32 += $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_hal_uart_ex.c
endif

ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32H723xx))
SRC_STM32 += $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_hal_ospi.c
endif

SRC_STM32 += boards/system_stm32$(MCU_SERIES_LOWER)xx.c

SRC_C += \
Expand Down Expand Up @@ -238,7 +245,7 @@ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(S
SRC_QSTR_PREPROCESSOR +=

# Bin section settings specific to the STM32H7
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32H743xx))
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32H743xx STM32H723xx))
MCU_SECTIONS = -j .isr_vector -j .text -j .data -j .itcm -j .dtcm_data $^ $@
else
MCU_SECTIONS = $^ $@
Expand Down
38 changes: 38 additions & 0 deletions ports/stm/boards/STM32H723_fs.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
GNU linker script for STM32H723 with filesystem, tcm
*/

/* Entry Point */
ENTRY(Reset_Handler)

_ld_default_stack_size = 24K;

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* sector 0, 128K */
FLASH_FS (r) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 1-3, 128K */
FLASH_FIRMWARE (rx) : ORIGIN = 0x08080000, LENGTH = 512K /* sectors 4*128 + 8*128 */
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 320K /* AXI SRAM */
SRAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K /* AHB1 SRAM */
SRAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K /* AHB2 SRAM */
ITCM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 24K; /*TODO: this can probably be bigger, but how big?*/
_minimum_heap_size = 16K;

/* brainless copy paste for stack code. Results in ambiguous hard crash */
/* _ld_default_stack_size = 20K; */

/* Define tho top end of the stack. The stack is full descending so begins just
above last byte of RAM. Note that EABI requires the stack to be 8-byte
aligned for a call. */
_estack = ORIGIN(DTCM) + LENGTH(DTCM);

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
37 changes: 37 additions & 0 deletions ports/stm/boards/STM32H723_nofs.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
GNU linker script for STM32H723 with no filesystem, tcm
*/

/* Entry Point */
ENTRY(Reset_Handler)

_ld_default_stack_size = 24K;

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* sector 0, 128K */
FLASH_FIRMWARE (rx) : ORIGIN = 0x08020000, LENGTH = 896K /* sectors 1-15, 15*128 */
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 320K /* AXI SRAM */
SRAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K /* AHB1 SRAM */
SRAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K /* AHB2 SRAM */
ITCM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}

/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 24K; /*TODO: this can probably be bigger, but how big?*/
_minimum_heap_size = 16K;

/* brainless copy paste for stack code. Results in ambiguous hard crash */
/* _ld_default_stack_size = 20K; */

/* Define tho top end of the stack. The stack is full descending so begins just
above last byte of RAM. Note that EABI requires the stack to be 8-byte
aligned for a call. */
_estack = ORIGIN(DTCM) + LENGTH(DTCM);

/* RAM extents for the garbage collector */
_ram_start = ORIGIN(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2 changes: 1 addition & 1 deletion ports/stm/boards/common_tcm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SECTIONS
_ld_d1_ram_bss_start = ADDR(.bss);
_ld_d1_ram_bss_size = SIZEOF(.bss);
_ld_heap_start = _ld_d1_ram_bss_start + _ld_d1_ram_bss_size;
_ld_heap_end = ORIGIN(RAM) + LENGTH(RAM);
_ld_heap_end = ORIGIN(RAM) + LENGTH(RAM) - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the last byte used for?


/* this is to define the start of the heap, and make sure we have a minimum size */
.heap :
Expand Down
61 changes: 61 additions & 0 deletions ports/stm/boards/weact-h723vg-lcd/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include "supervisor/board.h"
#include "stm32h7xx_hal.h"

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

void board_init(void) {

}

void external_flash_setup(void) {

/**OCTOSPI1 GPIO Configuration
PE2 ------> OCTOSPIM_P1_IO2
PB2 ------> OCTOSPIM_P1_CLK
PD11 ------> OCTOSPIM_P1_IO0
PD12 ------> OCTOSPIM_P1_IO1
PD13 ------> OCTOSPIM_P1_IO3
PB6 ------> OCTOSPIM_P1_NCS
*/

GPIO_InitTypeDef GPIO_InitStruct = {0};

GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* OCTOSPI1 interrupt Init */
HAL_NVIC_SetPriority(OCTOSPI1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(OCTOSPI1_IRQn);

}
62 changes: 62 additions & 0 deletions ports/stm/boards/weact-h723vg-lcd/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2020 Lucian Copeland for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#pragma once

// Micropython setup

#define MICROPY_HW_BOARD_NAME "WeAct H723VG LCD"
#define MICROPY_HW_MCU_NAME "STM32H723"

#define FLASH_PAGE_SIZE (0x4000)

// H7 and F7 MPU definitions
#define CPY_FLASH_REGION_SIZE ARM_MPU_REGION_SIZE_1MB
#define CPY_ITCM_REGION_SIZE ARM_MPU_REGION_SIZE_64KB
#define CPY_DTCM_REGION_SIZE ARM_MPU_REGION_SIZE_128KB
#define CPY_SRAM_REGION_SIZE ARM_MPU_REGION_SIZE_320KB
#define CPY_SRAM_SUBMASK 0x00
#define CPY_SRAM_START_ADDR 0x24000000
#define CFG_TUSB_OS OPT_OS_NONE

#define HSE_VALUE ((uint32_t)25000000)
#define LSE_VALUE ((uint32_t)32768)

#define BOARD_HSE_SOURCE (RCC_HSE_ON)
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
#define BOARD_NO_VBUS_SENSE 1
#define BOARD_NO_USB_OTG_ID_SENSE 1

#define MICROPY_HW_LED_STATUS (&pin_PE03)

// on-board SPI flash
#define SPI_FLASH_MOSI_PIN (&pin_PD07)
#define SPI_FLASH_MISO_PIN (&pin_PB04)
#define SPI_FLASH_SCK_PIN (&pin_PB03)
#define SPI_FLASH_CS_PIN (&pin_PD06)

#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 (&pin_PD11)
#define MICROPY_QSPI_DATA1 (&pin_PD12)
#define MICROPY_QSPI_DATA2 (&pin_PE02)
#define MICROPY_QSPI_DATA3 (&pin_PD13)
#define MICROPY_QSPI_SCK (&pin_PB02)
#define MICROPY_QSPI_CS (&pin_PB06)
#endif

// usb?
#define IGNORE_PIN_PA11 1
#define IGNORE_PIN_PA12 1

#define DEFAULT_I2C_BUS_SCL (&pin_PB08)
#define DEFAULT_I2C_BUS_SDA (&pin_PB09)

#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
#define DEFAULT_SPI_BUS_MOSI (&pin_PB15)
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)

#define DEFAULT_UART_BUS_RX (&pin_PA10)
#define DEFAULT_UART_BUS_TX (&pin_PA09)
64 changes: 64 additions & 0 deletions ports/stm/boards/weact-h723vg-lcd/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
USB_VID = 0x0483
USB_PID = 0x5740
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generic STM VID/PID. If you don't work for WeAct you can request a USB PID from: https://pid.codes/ If you do work for WeAct, then you should sublicense a unique PID from STM or acquire your own VID from the USB folks.

USB_PRODUCT = "H723VG LCD"
USB_MANUFACTURER = "WeAct Studio"

INTERNAL_FLASH_FILESYSTEM = 0
QSPI_FLASH_FILESYSTEM = 1
# SPI_FLASH_FILESYSTEM = 1

MCU_SERIES = H7
MCU_VARIANT = STM32H723xx
MCU_PACKAGE = LQFP100_x7

EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ"

LD_COMMON = boards/common_tcm.ld
LD_FILE = boards/STM32H723_nofs.ld

CIRCUITPY_BLEIO_HCI = 0

# Typically the first module to create
CIRCUITPY_MICROCONTROLLER = 1
# Typically the second module to create
CIRCUITPY_DIGITALIO = 1
# Other modules:
CIRCUITPY_ANALOGIO = 0
CIRCUITPY_PWMIO = 1
CIRCUITPY_BUSIO = 1
CIRCUITPY_COUNTIO = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_PULSEIO = 1
CIRCUITPY_OS = 1
CIRCUITPY_NVM = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 1
CIRCUITPY_SDCARDIO = 1
CIRCUITPY_SDIOIO = 1
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CTARGET = 0
# Requires SPI, PulseIO (stub ok):
CIRCUITPY_DISPLAYIO = 1

# These modules are implemented in shared-module/ - they can be included in
# any port once their prerequisites in common-hal are complete.
# Requires DigitalIO:
CIRCUITPY_BITBANGIO = 0
# Requires neopixel_write or SPI (dotstar)
CIRCUITPY_PIXELBUF = 0
# Requires OS
CIRCUITPY_RANDOM = 1
# Requires OS, filesystem
CIRCUITPY_STORAGE = 1
# Requires Microcontroller
CIRCUITPY_TOUCHIO = 0
# Requires USB
CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0
# Does nothing without I2C
CIRCUITPY_REQUIRE_I2C_PULLUPS = 0
# No requirements, but takes extra flash
CIRCUITPY_ULAB = 0
Loading