mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Olimex STM32 P407: Add support for on-board microSD slot. Does not work... Currently all commands to the SD card timeout.
This commit is contained in:
@@ -7,8 +7,8 @@ to share the same board design. Other code comes from the STM3240G board
|
|||||||
support (which has the same crystal and clocking) and from the STM32 F4
|
support (which has the same crystal and clocking) and from the STM32 F4
|
||||||
Discovery (which has the same STM32 part)
|
Discovery (which has the same STM32 part)
|
||||||
|
|
||||||
Peripherals
|
Board Support
|
||||||
===========
|
=============
|
||||||
|
|
||||||
The following peripherals are available in this configuration.
|
The following peripherals are available in this configuration.
|
||||||
|
|
||||||
@@ -31,6 +31,82 @@ The following peripherals are available in this configuration.
|
|||||||
|
|
||||||
- Ethernet: Ping to other station on the network works.
|
- Ethernet: Ping to other station on the network works.
|
||||||
|
|
||||||
|
microSD Card Interface
|
||||||
|
======================
|
||||||
|
|
||||||
|
microSD Connector
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
----------------- ----------------- ------------------------
|
||||||
|
SD/MMC CONNECTOR BOARD GPIO CONFIGURATION(s
|
||||||
|
PIN SIGNAL SIGNAL (no remapping)
|
||||||
|
--- ------------- ----------------- -------------------------
|
||||||
|
1 DAT2/RES SD_D2/USART3_TX/ PC10 GPIO_SDIO_D2
|
||||||
|
SPI3_SCK
|
||||||
|
2 CD/DAT3/CS SD_D3/USART3_RX/ PC11 GPIO_SDIO_D3
|
||||||
|
SPI3_MISO
|
||||||
|
3 CMD/DI SD_CMD PD2 GPIO_SDIO_CMD
|
||||||
|
4 VDD N/A N/A
|
||||||
|
5 CLK/SCLK SD_CLK/SPI3_MOSI PC12 GPIO_SDIO_CK
|
||||||
|
6 VSS N/A N/A
|
||||||
|
7 DAT0/D0 SD_D0/DCMI_D2 PC8 GPIO_SDIO_D0
|
||||||
|
8 DAT1/RES SD_D1/DCMI_D3 PC9 GPIO_SDIO_D1
|
||||||
|
--- ------------- ----------------- -------------------------
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
1. DAT4, DAT4, DAT6, and DAT7 not connected.
|
||||||
|
2. There are no alternative pin selections.
|
||||||
|
3. There is no card detect (CD) GPIO input so we will not
|
||||||
|
sense if there is a card in the SD slot or not. This will
|
||||||
|
make usage very awkward.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Enabling SDIO-based MMC/SD support:
|
||||||
|
|
||||||
|
System Type->STM32 Peripheral Support
|
||||||
|
CONFIG_STM32_SDIO=y : Enable SDIO support
|
||||||
|
CONFIG_STM32_DMA2=y : DMA2 is needed by the driver
|
||||||
|
|
||||||
|
Device Drivers -> MMC/SD Driver Support
|
||||||
|
CONFIG_MMCSD=y : Enable MMC/SD support
|
||||||
|
CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance
|
||||||
|
# CONFIG_MMCSD_HAVECARDDETECT is not set : No card-detect GPIO
|
||||||
|
# CONFIG_MMCSD_MMCSUPPORT is not set : Interferes with some SD cards
|
||||||
|
# CONFIG_MMCSD_SPI is not set : No SPI-based MMC/SD support
|
||||||
|
CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support
|
||||||
|
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y : Disable to keep things simple
|
||||||
|
CONFIG_SDIO_DMA=y : Use SDIO DMA
|
||||||
|
# CONFIG_SDIO_BLOCKSETUP is not set : (not implemented)
|
||||||
|
|
||||||
|
Library Routines
|
||||||
|
CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support
|
||||||
|
|
||||||
|
Application Configuration -> NSH Library
|
||||||
|
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
|
||||||
|
|
||||||
|
Using the SD card
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
1. Since there is no CD GPIO pin, the firmware sill not know if there is
|
||||||
|
a card in the SD slot or not. It will assume that there is and attempt
|
||||||
|
to mount the SD card on power-up. If there is no SD card in the card
|
||||||
|
slot, there will be a long delay during initialization as the firmware
|
||||||
|
attempts to query the non-existent card, timeout, and retry.
|
||||||
|
|
||||||
|
2. After booting, an SDIO device will appear as /dev/mmcsd0
|
||||||
|
|
||||||
|
3. If you try mounting an SD card with nothing in the slot, the
|
||||||
|
mount will fail:
|
||||||
|
|
||||||
|
nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
|
||||||
|
nsh: mount: mount failed: 19
|
||||||
|
|
||||||
|
STATUS:
|
||||||
|
-------
|
||||||
|
2017-01-28: There is no card communication. All commands to the SD card timeout.
|
||||||
|
|
||||||
Configurations
|
Configurations
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/olimex-stm32-p407/include/board.h
|
* configs/olimex-stm32-p407/include/board.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2012, 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -240,6 +240,32 @@
|
|||||||
#define GPIO_CAN1_RX GPIO_CAN1_RX_2 /* PB8 */
|
#define GPIO_CAN1_RX GPIO_CAN1_RX_2 /* PB8 */
|
||||||
#define GPIO_CAN1_TX GPIO_CAN1_TX_2 /* PB9 */
|
#define GPIO_CAN1_TX GPIO_CAN1_TX_2 /* PB9 */
|
||||||
|
|
||||||
|
/* microSD Connector:
|
||||||
|
*
|
||||||
|
* ----------------- ----------------- ------------------------
|
||||||
|
* SD/MMC CONNECTOR BOARD GPIO CONFIGURATION(s
|
||||||
|
* PIN SIGNAL SIGNAL (no remapping)
|
||||||
|
* --- ------------- ----------------- -------------------------
|
||||||
|
* 1 DAT2/RES SD_D2/USART3_TX/ PC10 GPIO_SDIO_D2
|
||||||
|
* SPI3_SCK
|
||||||
|
* 2 CD/DAT3/CS SD_D3/USART3_RX/ PC11 GPIO_SDIO_D3
|
||||||
|
* SPI3_MISO
|
||||||
|
* 3 CMD/DI SD_CMD PD2 GPIO_SDIO_CMD
|
||||||
|
* 4 VDD N/A N/A
|
||||||
|
* 5 CLK/SCLK SD_CLK/SPI3_MOSI PC12 GPIO_SDIO_CK
|
||||||
|
* 6 VSS N/A N/A
|
||||||
|
* 7 DAT0/D0 SD_D0/DCMI_D2 PC8 GPIO_SDIO_D0
|
||||||
|
* 8 DAT1/RES SD_D1/DCMI_D3 PC9 GPIO_SDIO_D1
|
||||||
|
* --- ------------- ----------------- -------------------------
|
||||||
|
*
|
||||||
|
* NOTES:
|
||||||
|
* 1. DAT4, DAT4, DAT6, and DAT7 not connected.
|
||||||
|
* 2. There are no alternative pin selections.
|
||||||
|
* 3. There is no card detect (CD) GPIO input so we will not
|
||||||
|
* sense if there is a card in the SD slot or not. This will
|
||||||
|
* make usage very awkward.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Ethernet:
|
/* Ethernet:
|
||||||
*
|
*
|
||||||
* - PA2 is ETH_MDIO
|
* - PA2 is ETH_MDIO
|
||||||
@@ -276,6 +302,17 @@
|
|||||||
#define GPIO_ETH_RMII_TXD0 GPIO_ETH_RMII_TXD0_2
|
#define GPIO_ETH_RMII_TXD0 GPIO_ETH_RMII_TXD0_2
|
||||||
#define GPIO_ETH_RMII_TXD1 GPIO_ETH_RMII_TXD1_2
|
#define GPIO_ETH_RMII_TXD1 GPIO_ETH_RMII_TXD1_2
|
||||||
|
|
||||||
|
/* DMA Channel/Stream Selections ****************************************************/
|
||||||
|
/* Stream selections are arbitrary for now but might become important in the future
|
||||||
|
* if we set aside more DMA channels/streams.
|
||||||
|
*
|
||||||
|
* SDIO DMA
|
||||||
|
* DMAMAP_SDIO_1 = Channel 4, Stream 3
|
||||||
|
* DMAMAP_SDIO_2 = Channel 4, Stream 6
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DMAMAP_SDIO DMAMAP_SDIO_1
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/olimex-stm32-p107/src/olimex-stm32-p407.h
|
* configs/olimex-stm32-p107/src/olimex-stm32-p407.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Derives from a file of a similar name for the Olimex STM32 P207:
|
* Derives from a file of a similar name for the Olimex STM32 P207:
|
||||||
@@ -55,10 +55,48 @@
|
|||||||
|
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
|
/* Assume that we support everything until convinced otherwise */
|
||||||
|
|
||||||
|
#define HAVE_MMCSD 1
|
||||||
#define HAVE_USBDEV 1
|
#define HAVE_USBDEV 1
|
||||||
#define HAVE_USBHOST 1
|
#define HAVE_USBHOST 1
|
||||||
#define HAVE_USBMONITOR 1
|
#define HAVE_USBMONITOR 1
|
||||||
|
|
||||||
|
/* Can't support MMC/SD features if mountpoints are disabled or if SDIO support
|
||||||
|
* is not enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_SDIO) || \
|
||||||
|
!defined(CONFIG_MMCSD_SDIO)
|
||||||
|
# undef HAVE_MMCSD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Default MMC/SD minor number */
|
||||||
|
|
||||||
|
#ifdef HAVE_MMCSD
|
||||||
|
|
||||||
|
/* Default MMC/SD SLOT number */
|
||||||
|
|
||||||
|
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||||
|
# error Only one MMC/SD slot
|
||||||
|
# undef CONFIG_NSH_MMCSDSLOTNO
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef CONFIG_NSH_MMCSDSLOTNO
|
||||||
|
# define MMCSD_SLOTNO CONFIG_NSH_MMCSDSLOTNO
|
||||||
|
# else
|
||||||
|
# define MMCSD_SLOTNO 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Default minor device number */
|
||||||
|
|
||||||
|
# ifdef CONFIG_NSH_MMCSDMINOR
|
||||||
|
# define MMCSD_MINOR CONFIG_NSH_MMCSDMINOR
|
||||||
|
# else
|
||||||
|
# define MMCSD_MINOR 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Can't support USB host or device features if USB OTG FS is not enabled */
|
/* Can't support USB host or device features if USB OTG FS is not enabled */
|
||||||
|
|
||||||
#ifndef CONFIG_STM32_OTGFS
|
#ifndef CONFIG_STM32_OTGFS
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* config/olimex-stm32-p407/src/stm32_bringup.c
|
* config/olimex-stm32-p407/src/stm32_bringup.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
|
#include <nuttx/mmcsd.h>
|
||||||
|
|
||||||
#ifdef CONFIG_USBMONITOR
|
#ifdef CONFIG_USBMONITOR
|
||||||
# include <nuttx/usb/usbmonitor.h>
|
# include <nuttx/usb/usbmonitor.h>
|
||||||
@@ -78,6 +79,9 @@
|
|||||||
|
|
||||||
int stm32_bringup(void)
|
int stm32_bringup(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MMCSD
|
||||||
|
FAR struct sdio_dev_s *sdio;
|
||||||
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_FS_PROCFS
|
#ifdef CONFIG_FS_PROCFS
|
||||||
@@ -90,6 +94,38 @@ int stm32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MMCSD
|
||||||
|
/* Mount the SDIO-based MMC/SD block driver */
|
||||||
|
/* First, get an instance of the SDIO interface */
|
||||||
|
|
||||||
|
sdio = sdio_initialize(MMCSD_SLOTNO);
|
||||||
|
if (!sdio)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR,
|
||||||
|
"ERROR: Failed to initialize SDIO slot %d\n",
|
||||||
|
MMCSD_SLOTNO);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now bind the SDIO interface to the MMC/SD driver */
|
||||||
|
|
||||||
|
ret = mmcsd_slotinitialize(MMCSD_MINOR, sdio);
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR,
|
||||||
|
"ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n",
|
||||||
|
ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then let's guess and say that there is a card in the slot. The Olimex
|
||||||
|
* STM32 P407 does not support a GPIO to detect if there is a card in
|
||||||
|
* the slot so we are reduced to guessing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sdio_mediachange(sdio, true);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CAN
|
#ifdef CONFIG_CAN
|
||||||
/* Initialize CAN and register the CAN driver. */
|
/* Initialize CAN and register the CAN driver. */
|
||||||
|
|
||||||
|
|||||||
@@ -297,9 +297,8 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
#warning "Now what are we going to do with this SPI FLASH driver?"
|
#warning "Now what are we going to do with this SPI FLASH driver?"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Mount the SDIO-based MMC/SD block driver */
|
|
||||||
|
|
||||||
#ifdef HAVE_MMCSD
|
#ifdef HAVE_MMCSD
|
||||||
|
/* Mount the SDIO-based MMC/SD block driver */
|
||||||
/* First, get an instance of the SDIO interface */
|
/* First, get an instance of the SDIO interface */
|
||||||
|
|
||||||
sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
|
sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
|
||||||
|
|||||||
Reference in New Issue
Block a user