Skip to content

Commit

Permalink
board/stm32f777zit6-meadow: Add support to F7 Core Compute
Browse files Browse the repository at this point in the history
This patch add basic support to Meadow F7 Core Compute board.
The board profile "f7corecomp" include support to USB Console
and SD Card.
  • Loading branch information
acassis committed Sep 14, 2023
1 parent 0beba02 commit eb6a705
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 6 deletions.
15 changes: 14 additions & 1 deletion boards/arm/stm32f7/stm32f777zit6-meadow/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,28 @@ config MEADOW_PWR_MGMT_SUPPORT
bool "Enables Meadow power management support"
default n

choice
prompt "Select Main Board Model"
default BOARD_MEADOW_PROJECTLAB
---help---
Select the mainboard model

config BOARD_MEADOW_PROJECTLAB
bool "ProjectLab Mainboard"
default n
select ARCH_BOARD_COMMON
---help---
ProjectLab is a main board with a Meadow F7Micro
module soldered on it. The projectLab has a lot of
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
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions boards/arm/stm32f7/stm32f777zit6-meadow/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
6 changes: 5 additions & 1 deletion boards/arm/stm32f7/stm32f777zit6-meadow/src/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
72 changes: 72 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/src/board_corecomp.c
Original file line number Diff line number Diff line change
@@ -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 <nuttx/config.h>

#include <sys/types.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>

#include <nuttx/fs/fs.h>

#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;
}
10 changes: 10 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
156 changes: 156 additions & 0 deletions boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_sdmmc.c
Original file line number Diff line number Diff line change
@@ -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 <nuttx/config.h>

#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>

#include <nuttx/sdio.h>
#include <nuttx/mmcsd.h>

#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;
}
Loading

0 comments on commit eb6a705

Please sign in to comment.