SAMV71-XULT: Bring HSMCI and auto-mounter support from SAMA5D4-EK

This commit is contained in:
Gregory Nutt
2015-03-13 09:27:16 -06:00
parent a45d7ca909
commit 361d4a3fac
9 changed files with 947 additions and 30 deletions
+30
View File
@@ -4,4 +4,34 @@
#
if ARCH_BOARD_SAMV71_XULT
config SAMV7XULT_HSMCI0_AUTOMOUNT
bool "HSMCI0 automounter"
default n
depends on FS_AUTOMOUNTER && SAMA5_HSMCI0
if SAMV7XULT_HSMCI0_AUTOMOUNT
config SAMV7XULT_HSMCI0_AUTOMOUNT_FSTYPE
string "HSMCI0 file system type"
default "vfat"
config SAMV7XULT_HSMCI0_AUTOMOUNT_BLKDEV
string "HSMCI0 block device"
default "/dev/mmcsd0"
config SAMV7XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT
string "HSMCI0 mount point"
default "/mnt/sdcard0"
config SAMV7XULT_HSMCI0_AUTOMOUNT_DDELAY
int "HSMCI0 debounce delay (milliseconds)"
default 1000
config SAMV7XULT_HSMCI0_AUTOMOUNT_UDELAY
int "HSMCI0 unmount retry delay (milliseconds)"
default 2000
endif # SAMV7XULT_HSMCI0_AUTOMOUNT
endif # ARCH_BOARD_SAMV71_XULT
+127
View File
@@ -10,6 +10,8 @@ Contents
- Board Features
- Serial Console
- SD card
- Automounter
- LEDs and Buttons
- AT24MAC402 Serial EEPROM
- Debugging
@@ -103,6 +105,131 @@ Any of these options can be selected as the serial console by:
2. Configuring the peripheral in the "Drivers -> Serial Configuration"
menu.
SD Card
=======
Card Slot
---------
The SAM V71 Xplained Ultra has one standard SD card connector which is
connected to the High Speed Multimedia Card Interface (HSMCI) of the SAM
V71. SD card connector:
------ ----------------- ---------------------
SAMV71 SAMV71 Shared functionality
Pin Function
------ ----------------- ---------------------
PA30 MCDA0 (DAT0)
PA31 MCDA1 (DAT1)
PA26 MCDA2 (DAT2)
PA27 MCDA3 (DAT3) Camera
PA25 MCCK (CLK) Shield
PA28 MCCDA (CMD)
PD18 Card Detect (C/D) Shield
------ ----------------- ---------------------
Configuration Settings
----------------------
Enabling HSMCI support. The SAMV7-XULT provides a one, full-size SD memory card slots. The full size SD card slot connects via HSMCI0. Support for the SD slots can be enabled with the following settings:
System Type->SAMV7 Peripheral Selection
CONFIG_SAMV7_HSMCI0=y : To enable HSMCI0 support
CONFIG_SAMV7_XDMAC=y : XDMAC is needed by HSMCI0/1
System Type
CONFIG_SAMV7_PIO_IRQ=y : PIO interrupts needed
CONFIG_SAMV7_PIOD_IRQ=y : Card detect pin is on PD18
Device Drivers -> MMC/SD Driver Support
CONFIG_MMCSD=y : Enable MMC/SD support
CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y : (REVISIT)
CONFIG_MMCSD_HAVECARDDETECT=y : Supports card-detect PIOs
CONFIG_MMCSD_MMCSUPPORT=n : Interferes with some SD cards
CONFIG_MMCSD_SPI=n : No SPI-based MMC/SD support
CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support
CONFIG_SDIO_DMA=y : Use SDIO DMA
CONFIG_SDIO_BLOCKSETUP=y : Needs to know block sizes
RTOS Features -> Work Queue Support
CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : NSH board-initialization, OR
CONFIG_BOARD_INITIALIZE=y
Using the SD card
-----------------
1) After booting, the HSCMI device will appear as /dev/mmcsd0.
2) If you try mounting an SD card with nothing in the slot, the mount will
fail:
nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0
nsh: mount: mount failed: 19
NSH can be configured to provide errors as strings instead of
numbers. But in this case, only the error number is reported. The
error numbers can be found in nuttx/include/errno.h:
#define ENODEV 19
#define ENODEV_STR "No such device"
So the mount command is saying that there is no device or, more
correctly, that there is no card in the SD card slot.
3) Inserted the SD card. Then the mount should succeed.
nsh> mount -t vfat /dev/mmcsd0 /mnt/sd0
nsh> ls /mnt/sd1
/mnt/sd1:
atest.txt
nsh> cat /mnt/sd1/atest.txt
This is a test
NOTE: See the next section entitled "Auto-Mounter" for another way
to mount your SD card.
4) Before removing the card, you must umount the file system. This is
equivalent to "ejecting" or "safely removing" the card on Windows: It
flushes any cached data to an SD card and makes the SD card unavailable
to the applications.
nsh> umount -t /mnt/sd0
It is now safe to remove the card. NuttX provides into callbacks
that can be used by an application to automatically unmount the
volume when it is removed. But those callbacks are not used in
these configurations.
Auto-Mounter
============
NuttX implements an auto-mounter than can make working with SD cards
easier. With the auto-mounter, the file system will be automatically
mounted when the SD card is inserted into the HSMCI slot and automatically
unmounted when the SD card is removed.
Here is a sample configuration for the auto-mounter:
File System Configuration
CONFIG_FS_AUTOMOUNTER=y
Board-Specific Options
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT=y
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT_DDELAY=1000
CONFIG_SAMV7XULT_HSMCI0_AUTOMOUNT_UDELAY=2000
WARNING: SD cards should never be removed without first unmounting
them. This is to avoid data and possible corruption of the file
system. Certainly this is the case if you are writing to the SD card
at the time of the removal. If you use the SD card for read-only access,
however, then I cannot think of any reason why removing the card without
mounting would be harmful.
LEDs and Buttons
================
+5 -3
View File
@@ -156,13 +156,15 @@ CONFIG_ARCH_CHIP_SAMV71Q=y
CONFIG_SAMV7_HAVE_CAN1=y
CONFIG_SAMV7_HAVE_DAC1=y
CONFIG_SAMV7_HAVE_EBI=y
CONFIG_SAMV7_HAVE_HSMCI=y
# CONFIG_SAMV7_HSMCI is not set
CONFIG_SAMV7_HAVE_HSMCI0=y
# CONFIG_SAMV7_HAVE_ISI8 is not set
CONFIG_SAMV7_HAVE_SDRAMC=y
# CONFIG_SAMV7_HAVE_SPI is not set
CONFIG_SAMV7_HAVE_SPI0=y
CONFIG_SAMV7_HAVE_SPI1=y
# CONFIG_SAMV7_QSPI_IS_SPI is not set
# CONFIG_SAMV7_SSC is not set
CONFIG_SAMV7_HAVE_TWIHS2=y
# CONFIG_SAMV7_HAVE_USBFS is not set
CONFIG_SAMV7_HAVE_USBHS=y
@@ -184,7 +186,7 @@ CONFIG_SAMV7_HAVE_USART2=y
# CONFIG_SAMV7_EBI is not set
# CONFIG_SAMV7_EMAC is not set
# CONFIG_SAMV7_XDMAC is not set
# CONFIG_SAMV7_HSMCI is not set
# CONFIG_SAMV7_HSMCI0 is not set
# CONFIG_SAMV7_ISI is not set
# CONFIG_SAMV7_MLB is not set
# CONFIG_SAMV7_PWM0 is not set
@@ -196,7 +198,7 @@ CONFIG_SAMV7_HAVE_USART2=y
# CONFIG_SAMV7_SMC is not set
# CONFIG_SAMV7_SPI0 is not set
# CONFIG_SAMV7_SPI1 is not set
# CONFIG_SAMV7_SSC is not set
# CONFIG_SAMV7_SSC0 is not set
# CONFIG_SAMV7_TC0 is not set
# CONFIG_SAMV7_TC1 is not set
# CONFIG_SAMV7_TC2 is not set
+9 -7
View File
@@ -42,6 +42,12 @@ AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = sam_boot.c
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c sam_bringup.c
else ifeq ($(CONFIG_BOARD_INITIALIZE),y)
CSRCS += sam_bringup.c
endif
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
CSRCS += sam_cxxinitialize.c
endif
@@ -56,19 +62,15 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += sam_buttons.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c
endif
ifeq ($(CONFIG_SAM34_HSMCI),y)
ifeq ($(CONFIG_SAMV7_HSMCI0),y)
CSRCS += sam_hsmci.c
endif
ifeq ($(CONFIG_SAM34_EMAC),y)
ifeq ($(CONFIG_SAMV7_EMAC),y)
CSRCS += sam_ethernet.c
endif
ifeq ($(CONFIG_SAM34_SPI0),y)
ifeq ($(CONFIG_SAMV7_SPI0),y)
CSRCS += sam_spi.c
endif
+2 -7
View File
@@ -117,13 +117,8 @@ void sam_boardinitialize(void)
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
/* Perform NSH initialization here instead of from the NSH. This
* alternative NSH initialization is necessary when NSH is ran in user-space
* but the initialization function must run in kernel space.
*/
/* Perform board initialization */
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
(void)nsh_archinitialize();
#endif
(void)sam_bringup();
}
#endif /* CONFIG_BOARD_INITIALIZE */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+73
View File
@@ -0,0 +1,73 @@
/****************************************************************************
* config/samv71-xult/src/sam_nsh.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "samv71-xult.h"
#if defined(CONFIG_NSH_ARCHINIT) && !defined(CONFIG_BUILD_KERNEL)
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
#ifndef CONFIG_BOARD_INITIALIZE
/* Perform board initialization */
return sam_bringup();
#else
return OK;
#endif
}
#endif /* CONFIG_NSH_ARCHINIT && !CONFIG_BUILD_KERNEL */
File diff suppressed because it is too large Load Diff