diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/Kconfig b/boards/arm/stm32f7/stm32f777zit6-meadow/Kconfig index 50dbb23628622..2390cffdfda35 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/Kconfig +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/Kconfig @@ -63,10 +63,21 @@ config MEADOW_PWR_MGMT_SUPPORT bool "Enables Meadow power management support" default n +choice + prompt "Select Main Board Model" + default BOARD_MEADOW_F7MICRO_DEFAULT + ---help--- + Select the mainboard model + +config BOARD_MEADOW_F7MICRO_DEFAULT + bool "Meadow F7 Micro Default" + select ARCH_BOARD_COMMON + ---help--- + The default Meadow F7 Micro board with STM32F777, + ESP32 for WiFi/Bluetooth, External Flash and RAM. config BOARD_MEADOW_PROJECTLAB bool "ProjectLab Mainboard" - default n select ARCH_BOARD_COMMON ---help--- ProjectLab is a main board with a Meadow F7Micro @@ -74,4 +85,13 @@ config BOARD_MEADOW_PROJECTLAB sensors, RS485, a 3.2" TFT Display, and Grove, Qwiic and mikroBUS connectors for expansion. +config BOARD_MEADOW_F7_CORE_COMPUTE + bool "F7 Core Compute Mainboard" + select ARCH_BOARD_COMMON + ---help--- + The F7 Core Compute is a modular mainboard with basic + features of F7-Micro, but with SDCard and Dual Ethernet. + +endchoice # "Main Board Model" + endif # ARCH_BOARD_MEADOW_F7MICRO diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/configs/f7corecomp/defconfig b/boards/arm/stm32f7/stm32f777zit6-meadow/configs/f7corecomp/defconfig new file mode 100644 index 0000000000000..6b4c8056dfa0f --- /dev/null +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/configs/f7corecomp/defconfig @@ -0,0 +1,79 @@ +# +# 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_MMCSD_SPI is not set +# CONFIG_STM32F7_USE_LEGACY_PINMAP is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="stm32f777zit6-meadow" +CONFIG_ARCH_BOARD_MEADOW_F7MICRO=y +CONFIG_ARCH_CHIP="stm32f7" +CONFIG_ARCH_CHIP_STM32F777ZI=y +CONFIG_ARCH_CHIP_STM32F7=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_DTCM=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_BOARDCTL_USBDEVCTRL=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=43103 +CONFIG_BOARD_MEADOW_F7_CORE_COMPUTE=y +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_CDCACM_PRODUCTID=0x0001 +CONFIG_CDCACM_PRODUCTSTR="Wilderness Labs" +CONFIG_CDCACM_VENDORID=0x2E6A +CONFIG_CDCACM_VENDORSTR="Meadow F7 Micro" +CONFIG_CRYPTO=y +CONFIG_CRYPTO_RANDOM_POOL=y +CONFIG_DEV_URANDOM=y +CONFIG_DEV_URANDOM_RANDOM_POOL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_LITTLEFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MMCSD=y +CONFIG_MMCSD_SDIO=y +CONFIG_MM_REGIONS=3 +CONFIG_MTD=y +CONFIG_MTD_BYTE_WRITE=y +CONFIG_MTD_PARTITION=y +CONFIG_MTD_SECT512=y +CONFIG_MTD_W25QXXXJV=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=245760 +CONFIG_RAM_START=0x20010000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SDMMC2_SDIO_MODE=y +CONFIG_SPI=y +CONFIG_START_DAY=14 +CONFIG_STM32F7_DMA1=y +CONFIG_STM32F7_DMA2=y +CONFIG_STM32F7_OTGFS=y +CONFIG_STM32F7_QSPI_POLLING=y +CONFIG_STM32F7_QUADSPI=y +CONFIG_STM32F7_SDMMC2=y +CONFIG_STM32F7_SDMMC_DMA=y +CONFIG_STM32F7_USART1=y +CONFIG_SYSTEM_FLASH_ERASEALL=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=64 +CONFIG_USBDEV=y +CONFIG_W25QXXXJV_QSPI_FREQUENCY=64000000 diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h b/boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h index d8e1e7b9fef4b..9c054cd020149 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h @@ -483,16 +483,16 @@ * * D0 - PG9 * D1 - PG10 - * D2 - PB3 - * D3 - PB4 + * D2 - PG11 + * D3 - PG12 */ #define GPIO_SDMMC2_CK (GPIO_SDMMC2_CK_0|GPIO_SPEED_50MHz) #define GPIO_SDMMC2_CMD (GPIO_SDMMC2_CMD_0|GPIO_SPEED_50MHz) #define GPIO_SDMMC2_D0 (GPIO_SDMMC2_D0_2|GPIO_SPEED_50MHz) #define GPIO_SDMMC2_D1 (GPIO_SDMMC2_D1_2|GPIO_SPEED_50MHz) -#define GPIO_SDMMC2_D2 (GPIO_SDMMC2_D2_1|GPIO_SPEED_50MHz) -#define GPIO_SDMMC2_D3 (GPIO_SDMMC2_D3_1|GPIO_SPEED_50MHz) +#define GPIO_SDMMC2_D2 (GPIO_SDMMC2_D2_2|GPIO_SPEED_50MHz) +#define GPIO_SDMMC2_D3 (GPIO_SDMMC2_D3_2|GPIO_SPEED_50MHz) /* OTGFS */ diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/Make.defs b/boards/arm/stm32f7/stm32f777zit6-meadow/src/Make.defs index 9aceb9528421a..cbe9bce0d3e87 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/src/Make.defs +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/Make.defs @@ -67,7 +67,7 @@ CSRCS += stm32_idle.c endif ifeq ($(CONFIG_STM32F7_SDMMC2),y) -CSRCS += meadow_sdmmc.c +CSRCS += stm32_sdmmc.c endif ifdef MEADOW_OS @@ -181,6 +181,10 @@ CSRCS += $(MEADOW_OS_DIR)/meadow_os/meadow_os_config.c endif endif # MEADOW_OS +ifeq ($(CONFIG_BOARD_MEADOW_F7_CORE_COMPUTE),y) +CSRCS += board_corecomp.c +endif + ifeq ($(CONFIG_BOARD_MEADOW_PROJECTLAB),y) CSRCS += board_projlab.c endif diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/board_corecomp.c b/boards/arm/stm32f7/stm32f777zit6-meadow/src/board_corecomp.c new file mode 100644 index 0000000000000..c5ba1136f7d90 --- /dev/null +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/board_corecomp.c @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/stm32f7/stm32f777zit6-meadow/src/board_corecomp.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include + +#include "stm32_bh1750.h" +#include "stm32_bmi270.h" +#include "stm32f777zit6-meadow.h" + +/**************************************************************************** + * Preprocessor definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: init_corecomp + * + * Description: + * Initialize the fixed devices from COre Compute board + * + ****************************************************************************/ + +int init_corecomp(void) +{ + int ret = OK; + + /* Initialize SD Card */ + +#ifdef HAVE_SDIO + ret = stm32_sdio_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: STM32 SDCard failed: %d\n", ret); + } +#endif + + /* Initialize Ethernet */ + + return ret; +} diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c index 1c0203aa0cbc9..7c0b50331efab 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c @@ -139,6 +139,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_BOARD_MEADOW_F7_CORE_COMPUTE + /* Initialize all devices in the F7 Core Compute */ + + ret = init_corecomp(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: F7 Core Compute init failed: %d\n", ret); + } +#endif + #ifdef CONFIG_BOARD_MEADOW_PROJECTLAB /* Initialize all devices in the ProjectLab */ diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_sdmmc.c b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_sdmmc.c new file mode 100644 index 0000000000000..d2de1b37efc51 --- /dev/null +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_sdmmc.c @@ -0,0 +1,156 @@ +/**************************************************************************** + * boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_sdmmc.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "stm32_gpio.h" +#include "stm32_sdmmc.h" +#include "stm32f777zit6-meadow.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* Card detections requires card support and a card detection GPIO */ + +#define HAVE_NCD 1 +#if !defined(HAVE_SDIO) || !defined(GPIO_SDIO_NCD) +# undef HAVE_NCD +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct sdio_dev_s *g_sdio_dev; +#ifdef HAVE_NCD +static bool g_sd_inserted; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_ncd_interrupt + * + * Description: + * Card detect interrupt handler. + * + ****************************************************************************/ + +#ifdef HAVE_NCD +static int stm32_ncd_interrupt(int irq, void *context, void *param) +{ + bool present; + + present = !stm32_gpioread(GPIO_SDIO_NCD); + if (present != g_sd_inserted) + { + sdio_mediachange(g_sdio_dev, present); + g_sd_inserted = present; + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +int stm32_sdio_initialize(void) +{ + int ret; + +#ifdef HAVE_NCD + /* Configure the card detect GPIO */ + + stm32_configgpio(GPIO_SDIO_NCD); + + /* Register an interrupt handler for the card detect pin */ + + stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, + stm32_ncd_interrupt, NULL); +#endif + + /* Mount the SDIO-based MMC/SD block driver */ + + /* First, get an instance of the SDIO interface */ + + finfo("Initializing SDIO slot %d\n", SDIO_SLOTNO); + + g_sdio_dev = sdio_initialize(SDIO_SLOTNO); + if (!g_sdio_dev) + { + ferr("ERROR: Failed to initialize SDIO slot %d\n", SDIO_SLOTNO); + return -ENODEV; + } + + /* Now bind the SDIO interface to the MMC/SD driver */ + + finfo("Bind SDIO to the MMC/SD driver, minor=%d\n", SDIO_MINOR); + + ret = mmcsd_slotinitialize(SDIO_MINOR, g_sdio_dev); + if (ret != OK) + { + ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + return ret; + } + + finfo("Successfully bound SDIO to the MMC/SD driver\n"); + +#ifdef HAVE_NCD + /* Use SD card detect pin to check if a card is g_sd_inserted */ + + g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD); + finfo("Card detect : %d\n", g_sd_inserted); + + sdio_mediachange(g_sdio_dev, g_sd_inserted); +#else + /* Assume that the SD card is inserted. What choice do we have? */ + + sdio_mediachange(g_sdio_dev, true); +#endif + + return OK; +} diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32f777zit6-meadow.h b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32f777zit6-meadow.h index 05b7ba3c16bfe..62c5ef6fcae28 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32f777zit6-meadow.h +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32f777zit6-meadow.h @@ -43,6 +43,16 @@ # endif #endif +/* SDCard validation */ + +#if defined(CONFIG_STM32F7_SDMMC1) || defined(CONFIG_STM32F7_SDMMC2) +# define HAVE_SDIO +#endif + +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_MMCSD_SDIO) +# undef HAVE_SDIO +#endif + #define GPIO_LD1 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN1) #define GPIO_LD2 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN0) #define GPIO_LD3 (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN2) @@ -58,6 +68,13 @@ #define GPIO_BTN_USER (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTA | GPIO_PIN0) +/* SD/TF Card'detected pin */ + +#define GPIO_SDIO_NCD (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN6) + +#define SDIO_SLOTNO 0 +#define SDIO_MINOR 0 + /* Sporadic scheduler instrumentation. * This configuration has been used for evaluating the NuttX sporadic * scheduler. @@ -154,6 +171,30 @@ void stm32_sdram_initialize(void); void stm32_disablefmc(void); #endif +/**************************************************************************** + * Name: stm32_sdio_initialize + * + * Description: + * Initialize SDIO-based MMC/SD card support + * + ****************************************************************************/ + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_STM32F7_SDMMC2) +int stm32_sdio_initialize(void); +#endif + +/**************************************************************************** + * Name: init_corecomp + * + * Description: + * Initialize the fixed devices from F7 Core Compute board + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_MEADOW_F7_CORE_COMPUTE +int init_corecomp(void); +#endif + /**************************************************************************** * Name: init_projectlab *