SAMA5D4-EK: Add logic to mount an SD card as a boot device

This commit is contained in:
Gregory Nutt 2014-09-03 08:34:28 -06:00
parent a488b10ac4
commit ee96ed963c
5 changed files with 193 additions and 38 deletions

View File

@ -244,6 +244,48 @@ config SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY
endif # SAMA5D4EK_HSMCI1_AUTOMOUNT
endif # FS_AUTOMOUNTER
config SAMA5D4EK_HSMCI0_MOUNT
bool "HSMCI0 boot mount"
default n
depends on SAMA5_HSMCI0 && !SAMA5D4EK_HSMCI0_AUTOMOUNT
if SAMA5D4EK_HSMCI0_MOUNT
config SAMA5D4EK_HSMCI0_MOUNT_FSTYPE
string "HSMCI0 file system type"
default "vfat"
config SAMA5D4EK_HSMCI0_MOUNT_BLKDEV
string "HSMCI0 block device"
default "/dev/mmcsd0"
config SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT
string "HSMCI0 mount point"
default "/bin"
endif # SAMA5D4EK_HSMCI0_MOUNT
config SAMA5D4EK_HSMCI1_MOUNT
bool "HSMCI1 boot mount"
default n
depends on SAMA5_HSMCI1 && !SAMA5D4EK_HSMCI1_AUTOMOUNT
if SAMA5D4EK_HSMCI1_MOUNT
config SAMA5D4EK_HSMCI1_MOUNT_FSTYPE
string "HSMCI1 file system type"
default "vfat"
config SAMA5D4EK_HSMCI1_MOUNT_BLKDEV
string "HSMCI1 block device"
default "/dev/mmcsd1"
config SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT
string "HSMCI1 mount point"
default "/bin"
endif # SAMA5D4EK_HSMCI1_MOUNT
if INPUT_MXT
config SAMA5D4EK_MXT_I2CFREQUENCY

View File

@ -1611,7 +1611,8 @@ HSMCI Card Slots
CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
CONFIG_NSH_ARCHINIT=y : NSH board-initialization, OR
CONFIG_BOARD_INITIALIZE=y
Using the SD card
-----------------
@ -3726,25 +3727,63 @@ Configurations
2014-8-29: System call interface verified.
kernel:
A configuration used to test the SAMA5D kenel build configuration. This configuration is based on the elf configuration. Primary differences in
the two configurations are noted below:
Build Setup -> Build Configuration -> Memory Organization
CONFIG_BUILD_KERNEL=y : Kernel build enabled
RTOS Features -> Tasks and Scheduling
CONFIG_INIT_FILEPATH=y : Start-up is via an ELF file
CONFIG_USER_INITPATH="/bin/init" : The location of the startup
RTOS Features -> System call support
CONFIG_SYS_RESERVED=5 : More reserved SYSCALLs
Memory Management
CONFIG_MM_KERNEL_HEAP=y : Enable a kernel heap
CONFIG_MM_KERNEL_HEAPSIZE=8192 : (temporary.. will change)
A configuration used to test the SAMA5D kenel build configuration.
More to come... this is still a work in progress as of this writing.
Since this configuration is based on the ELF configuration, all of the notes for that configuration apply.
NOTES:
Since this configuration is based on the ELF configuration, all of
the notes for that configuration also apply.
1. This configuration is based on the elf configuration. Primary
differences between the two configurations are noted below:
Build Setup -> Build Configuration -> Memory Organization
CONFIG_BUILD_KERNEL=y : Kernel build enabled
RTOS Features -> Tasks and Scheduling
CONFIG_INIT_FILEPATH=y : Start-up is via an ELF file
CONFIG_USER_INITPATH="/bin/init" : The location of the startup
RTOS Features -> System call support
CONFIG_SYS_RESERVED=5 : More reserved SYSCALLs
Memory Management
CONFIG_MM_KERNEL_HEAP=y : Enable a kernel heap
CONFIG_MM_KERNEL_HEAPSIZE=8192 : (temporary.. will change)
2. Board initialization is performed performed before the application
is started:
RTOS Features -> RTOS Hooks
CONFIG_BOARD_INITITIALIZE=y
The board initialization will mount the FAT filesystem on an SD card
inserted int the HSMCI0 slot (full size). The SAMA4D4-EK provides
two SD memory card slots: (1) a full size SD card slot (J10), and
(2) a microSD memory card slot (J11). The full size SD card slot
connects via HSMCI0; the microSD connects vi HSMCI1. See the relevant
configuration settings above in the paragraph entitled "HSMCI Card
Slots" above.
The SD card is mounted at /bin by this board initialization logic.
NuttX will boot from the SD card so there are some special operational
requirements to use this configuration:
a. The SD card must contain a NuttX executable called 'init'
b. The SD card must be in the HSCMCI slot when NuttX boots and must
not be removed while NuttX is running.
The NuttX automounter is *not* enabled. It cannot be used it would
mount the boot file system with a delay. In this configuration. The
file system must be mounted immediately at boot up. To accomplish
this, the board logic supports these special configurations:
Board Selection ->
CONFIG_SAMA5D4EK_HSMCI0_AMOUNT=y
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV="/dev/mmcsd0"
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE="vfat"
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT="/bin"
nsh:

View File

@ -125,6 +125,8 @@ CONFIG_ARMV7A_TOOLCHAIN_CODESOURCERYW=y
# CONFIG_ARMV7A_TOOLCHAIN_GNU_EABIW is not set
# CONFIG_ARMV7A_TOOLCHAIN_GNU_OABI is not set
# CONFIG_ARMV7A_DECODEFIQ is not set
CONFIG_SDIO_DMA=y
# CONFIG_SDIO_WIDTH_D1_ONLY is not set
#
# SAMA5 Configuration Options
@ -192,7 +194,7 @@ CONFIG_SAMA5_USART4=y
# CONFIG_SAMA5_TWI1 is not set
# CONFIG_SAMA5_TWI2 is not set
# CONFIG_SAMA5_TWI3 is not set
# CONFIG_SAMA5_HSMCI0 is not set
CONFIG_SAMA5_HSMCI0=y
# CONFIG_SAMA5_HSMCI1 is not set
# CONFIG_SAMA5_SBM is not set
# CONFIG_SAMA5_SFC is not set
@ -204,7 +206,7 @@ CONFIG_SAMA5_USART4=y
# CONFIG_SAMA5_TC2 is not set
# CONFIG_SAMA5_PWM is not set
# CONFIG_SAMA5_ADC is not set
# CONFIG_SAMA5_XDMAC0 is not set
CONFIG_SAMA5_XDMAC0=y
# CONFIG_SAMA5_XDMAC1 is not set
# CONFIG_SAMA5_UHPHS is not set
# CONFIG_SAMA5_UDPHS is not set
@ -213,6 +215,8 @@ CONFIG_SAMA5_USART4=y
# CONFIG_SAMA5_EMAC1 is not set
# CONFIG_SAMA5_LCDC is not set
# CONFIG_SAMA5_ISI is not set
# CONFIG_SAMA5_SSC0 is not set
# CONFIG_SAMA5_SSC1 is not set
# CONFIG_SAMA5_SHA is not set
CONFIG_SAMA5_TRNG=y
# CONFIG_SAMA5_ARM is not set
@ -220,7 +224,19 @@ CONFIG_SAMA5_TRNG=y
# CONFIG_SAMA5_MPDDRC is not set
# CONFIG_SAMA5_VDEC is not set
# CONFIG_SAMA5_SECURE is not set
# CONFIG_SAMA5_PIO_IRQ is not set
CONFIG_SAMA5_PIO_IRQ=y
# CONFIG_SAMA5_PIOA_IRQ is not set
# CONFIG_SAMA5_PIOB_IRQ is not set
# CONFIG_SAMA5_PIOC_IRQ is not set
# CONFIG_SAMA5_PIOD_IRQ is not set
CONFIG_SAMA5_PIOE_IRQ=y
#
# HSMCI device driver options
#
CONFIG_SAMA5_HSMCI0_XDMAC0=y
# CONFIG_SAMA5_HSMCI_RDPROOF is not set
# CONFIG_SAMA5_HSMCI_WRPROOF is not set
#
# External Memory Configuration
@ -249,7 +265,7 @@ CONFIG_SAMA5_DDRCS_PGHEAP_SIZE=134217728
#
# CONFIG_ARCH_NOINTC is not set
# CONFIG_ARCH_VECNOTIRQ is not set
# CONFIG_ARCH_DMA is not set
CONFIG_ARCH_DMA=y
CONFIG_ARCH_HAVE_IRQPRIO=y
# CONFIG_ARCH_L2CACHE is not set
CONFIG_ARCH_HAVE_COHERENT_DCACHE=y
@ -333,6 +349,10 @@ CONFIG_SAMA5D4_MB_REVC=y
# CONFIG_SAMA5D4EK_396MHZ is not set
CONFIG_SAMA5D4EK_528MHZ=y
CONFIG_SAMA5D4EK_DRAM_BOOT=y
CONFIG_SAMA5D4EK_HSMCI0_MOUNT=y
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE="vfat"
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV="/dev/mmcsd0"
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT="/bin"
# CONFIG_SAMA5D4EK_SLOWCLOCK is not set
#
@ -469,7 +489,17 @@ CONFIG_AUDIO_DEVICES=y
# CONFIG_BCH is not set
# CONFIG_INPUT is not set
# CONFIG_LCD is not set
# CONFIG_MMCSD is not set
CONFIG_MMCSD=y
CONFIG_MMCSD_NSLOTS=1
# CONFIG_MMCSD_READONLY is not set
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
# CONFIG_MMCSD_MMCSUPPORT is not set
CONFIG_MMCSD_HAVECARDDETECT=y
CONFIG_ARCH_HAVE_SDIO=y
CONFIG_MMCSD_SDIO=y
# CONFIG_SDIO_PREFLIGHT is not set
# CONFIG_SDIO_MUXBUS is not set
CONFIG_SDIO_BLOCKSETUP=y
# CONFIG_MTD is not set
# CONFIG_PIPES is not set
# CONFIG_PM is not set
@ -574,9 +604,14 @@ CONFIG_USART4_2STOP=0
# CONFIG_FS_AUTOMOUNTER is not set
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
CONFIG_FS_READABLE=y
# CONFIG_FS_WRITABLE is not set
CONFIG_FS_WRITABLE=y
# CONFIG_FS_RAMMAP is not set
# CONFIG_FS_FAT is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FAT_MAXFNAME=32
# CONFIG_FS_FATTIME is not set
# CONFIG_FAT_DMAMEMORY is not set
# CONFIG_FS_NXFFS is not set
CONFIG_FS_ROMFS=y
# CONFIG_FS_SMARTFS is not set

View File

@ -149,16 +149,18 @@ static const struct sam_automount_config_s g_hsmci1config =
************************************************************************************/
/************************************************************************************
* Name: sam_automount_initialize
* Name: sam_attach
*
* Description:
* Configure auto-mounters for each enable and so configured HSMCI
* Attach a new HSMCI event handler
*
* Input Parameters:
* None
* lower - An instance of the auto-mounter lower half state structure
* isr - The new event handler to be attach
* arg - Client data to be provided when the event handler is invoked.
*
* Returned Value:
* None
* Always returns OK
*
************************************************************************************/
@ -176,7 +178,7 @@ static int sam_attach(FAR const struct automount_lower_s *lower,
state = config->state;
/* Save the new handler info (clearing the handler first to eliminate race
* conditions.
* conditions).
*/
state->handler = NULL;
@ -187,13 +189,14 @@ static int sam_attach(FAR const struct automount_lower_s *lower,
}
/************************************************************************************
* Name: sam_automount_initialize
* Name: sam_enable
*
* Description:
* Configure auto-mounters for each enable and so configured HSMCI
* Enable card insertion/removal event detection
*
* Input Parameters:
* None
* lower - An instance of the auto-mounter lower half state structure
* enable - True: enable event detection; False: disable
*
* Returned Value:
* None
@ -237,16 +240,16 @@ static void sam_enable(FAR const struct automount_lower_s *lower, bool enable)
}
/************************************************************************************
* Name: sam_automount_initialize
* Name: sam_inserted
*
* Description:
* Configure auto-mounters for each enable and so configured HSMCI
* Check if a card is inserted into the slot.
*
* Input Parameters:
* None
* lower - An instance of the auto-mounter lower half state structure
*
* Returned Value:
* None
* True if the card is inserted; False otherwise
*
************************************************************************************/

View File

@ -114,6 +114,24 @@ int sam_bringup(void)
message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",
HSMCI0_SLOTNO, HSMCI0_MINOR, ret);
}
#ifdef CONFIG_SAMA5D4EK_HSMCI0_MOUNT
else
{
/* Mount the volume on HSMCI0 */
ret = mount(CONFIG_SAMA5D4EK_HSMCI0_MOUNT_BLKDEV,
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT,
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_FSTYPE,
0, NULL);
if (ret < 0)
{
message("ERROR: Failed to mount %s: %d\n",
CONFIG_SAMA5D4EK_HSMCI0_MOUNT_MOUNTPOINT, errno);
}
}
#endif
#endif
#ifdef CONFIG_SAMA5_HSMCI1
@ -125,6 +143,24 @@ int sam_bringup(void)
message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n",
HSMCI1_SLOTNO, HSMCI1_MINOR, ret);
}
#ifdef CONFIG_SAMA5D4EK_HSMCI1_MOUNT
else
{
/* Mount the volume on HSMCI1 */
ret = mount(CONFIG_SAMA5D4EK_HSMCI1_MOUNT_BLKDEV,
CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT,
CONFIG_SAMA5D4EK_HSMCI1_MOUNT_FSTYPE,
0, NULL);
if (ret < 0)
{
message("ERROR: Failed to mount %s: %d\n",
CONFIG_SAMA5D4EK_HSMCI1_MOUNT_MOUNTPOINT, errno);
}
}
#endif
#endif
#endif