summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-29 15:34:31 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-29 15:34:31 -0600
commit0ac2ac1d8196c25465a7b63e3f339fc723f7c4cd (patch)
tree27ddc5f0722822b822accc0cebee19505d9ef16a
parent42f5d29534eb3199f5d257b8a1c03c3bf26a6996 (diff)
downloadpx4-nuttx-0ac2ac1d8196c25465a7b63e3f339fc723f7c4cd.tar.gz
px4-nuttx-0ac2ac1d8196c25465a7b63e3f339fc723f7c4cd.tar.bz2
px4-nuttx-0ac2ac1d8196c25465a7b63e3f339fc723f7c4cd.zip
SAMA5D4: Add auto-mounter support for HSMCI0
-rw-r--r--nuttx/configs/sam4e-ek/Kconfig4
-rw-r--r--nuttx/configs/sam4e-ek/README.txt2
-rw-r--r--nuttx/configs/sam4e-ek/nsh/defconfig2
-rw-r--r--nuttx/configs/sam4e-ek/src/sam4e-ek.h2
-rw-r--r--nuttx/configs/sam4e-ek/usbnsh/defconfig2
-rw-r--r--nuttx/configs/sama5d3-xplained/Kconfig4
-rw-r--r--nuttx/configs/sama5d3-xplained/README.txt10
-rw-r--r--nuttx/configs/sama5d3-xplained/src/sama5d3-xplained.h2
-rw-r--r--nuttx/configs/sama5d3x-ek/Kconfig12
-rw-r--r--nuttx/configs/sama5d3x-ek/README.txt14
-rw-r--r--nuttx/configs/sama5d3x-ek/demo/defconfig2
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h6
-rw-r--r--nuttx/configs/sama5d4-ek/Kconfig69
-rw-r--r--nuttx/configs/sama5d4-ek/README.txt14
-rw-r--r--nuttx/configs/sama5d4-ek/at25boot/defconfig2
-rw-r--r--nuttx/configs/sama5d4-ek/src/Makefile4
-rw-r--r--nuttx/configs/sama5d4-ek/src/at25_main.c4
-rw-r--r--nuttx/configs/sama5d4-ek/src/sam_automount.c390
-rw-r--r--nuttx/configs/sama5d4-ek/src/sam_hsmci.c32
-rw-r--r--nuttx/configs/sama5d4-ek/src/sam_nsh.c6
-rw-r--r--nuttx/configs/sama5d4-ek/src/sama5d4-ek.h144
-rw-r--r--nuttx/fs/fs_automount.c21
-rw-r--r--nuttx/include/nuttx/fs/automount.h2
23 files changed, 686 insertions, 64 deletions
diff --git a/nuttx/configs/sam4e-ek/Kconfig b/nuttx/configs/sam4e-ek/Kconfig
index 34a7e1897..90052291a 100644
--- a/nuttx/configs/sam4e-ek/Kconfig
+++ b/nuttx/configs/sam4e-ek/Kconfig
@@ -17,7 +17,7 @@ config SAM4EEK_120MHZ
endchoice # CPU Frequency
-config SAM4EEK_AT25_AUTOMOUNT
+config SAM4EEK_AT25_BLOCKMOUNT
bool "AT25 serial FLASH auto-mount"
default n
depends on SAM34_SPI0 && MTD_AT25
@@ -27,7 +27,7 @@ config SAM4EEK_AT25_AUTOMOUNT
choice
prompt "AT25 serial FLASH configuration"
default SAM4EEK_AT25_FTL
- depends on SAM4EEK_AT25_AUTOMOUNT
+ depends on SAM4EEK_AT25_BLOCKMOUNT
config SAM4EEK_AT25_FTL
bool "Create AT25 Serial FLASH block driver"
diff --git a/nuttx/configs/sam4e-ek/README.txt b/nuttx/configs/sam4e-ek/README.txt
index 14680c0df..6704039de 100644
--- a/nuttx/configs/sam4e-ek/README.txt
+++ b/nuttx/configs/sam4e-ek/README.txt
@@ -572,7 +572,7 @@ AT25 Serial FLASH
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
Board Selection
- CONFIG_SAM4EEK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH
+ CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH
CONFIG_SAM4EEK_AT25_FTL=y : Create block driver for FAT
You can then format the AT25 FLASH for a FAT file system and mount the
diff --git a/nuttx/configs/sam4e-ek/nsh/defconfig b/nuttx/configs/sam4e-ek/nsh/defconfig
index 31c916433..69c54dac5 100644
--- a/nuttx/configs/sam4e-ek/nsh/defconfig
+++ b/nuttx/configs/sam4e-ek/nsh/defconfig
@@ -331,7 +331,7 @@ CONFIG_NSH_MMCSDMINOR=0
#
# CONFIG_SAM4EEK_96MHZ is not set
CONFIG_SAM4EEK_120MHZ=y
-CONFIG_SAM4EEK_AT25_AUTOMOUNT=y
+CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y
CONFIG_SAM4EEK_AT25_FTL=y
#
diff --git a/nuttx/configs/sam4e-ek/src/sam4e-ek.h b/nuttx/configs/sam4e-ek/src/sam4e-ek.h
index fb52b3921..c485632b0 100644
--- a/nuttx/configs/sam4e-ek/src/sam4e-ek.h
+++ b/nuttx/configs/sam4e-ek/src/sam4e-ek.h
@@ -92,7 +92,7 @@
* asked to mount the AT25 part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAM4EEK_AT25_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAM4EEK_AT25_BLOCKMOUNT)
# undef HAVE_AT25
#endif
diff --git a/nuttx/configs/sam4e-ek/usbnsh/defconfig b/nuttx/configs/sam4e-ek/usbnsh/defconfig
index aac602b65..935dacfae 100644
--- a/nuttx/configs/sam4e-ek/usbnsh/defconfig
+++ b/nuttx/configs/sam4e-ek/usbnsh/defconfig
@@ -336,7 +336,7 @@ CONFIG_NSH_MMCSDMINOR=0
#
# CONFIG_SAM4EEK_96MHZ is not set
CONFIG_SAM4EEK_120MHZ=y
-CONFIG_SAM4EEK_AT25_AUTOMOUNT=y
+CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y
CONFIG_SAM4EEK_AT25_FTL=y
#
diff --git a/nuttx/configs/sama5d3-xplained/Kconfig b/nuttx/configs/sama5d3-xplained/Kconfig
index 242eb0c8a..27139b53e 100644
--- a/nuttx/configs/sama5d3-xplained/Kconfig
+++ b/nuttx/configs/sama5d3-xplained/Kconfig
@@ -37,7 +37,7 @@ config SAMA5D3XPLAINED_MT47H64M16HR
endchoice # SAMA5D3-Xplained DRAM Type
-config SAMA5D3XPLAINED_NAND_AUTOMOUNT
+config SAMA5D3XPLAINED_NAND_BLOCKMOUNT
bool "NAND FLASH auto-mount"
default n
depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND
@@ -47,7 +47,7 @@ config SAMA5D3XPLAINED_NAND_AUTOMOUNT
choice
prompt "NAND FLASH configuration"
default SAMA5D3XPLAINED_NAND_NXFFS
- depends on SAMA5D3XPLAINED_NAND_AUTOMOUNT
+ depends on SAMA5D3XPLAINED_NAND_BLOCKMOUNT
config SAMA5D3XPLAINED_NAND_FTL
bool "Create NAND FLASH block driver"
diff --git a/nuttx/configs/sama5d3-xplained/README.txt b/nuttx/configs/sama5d3-xplained/README.txt
index 47d1f7961..3209a3040 100644
--- a/nuttx/configs/sama5d3-xplained/README.txt
+++ b/nuttx/configs/sama5d3-xplained/README.txt
@@ -1636,8 +1636,8 @@ NAND Support
to enable SDRAM as described above.
Board Selection
- CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y : Use the NXFFS file system
+ CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y : Use the NXFFS file system
Other file systems are not recommended because only NXFFS can handle
bad blocks and only NXFFS performs wear-levelling.
@@ -1660,8 +1660,8 @@ NAND Support
Defaults for all other NXFFS settings should be okay.
Board Selection
- CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D3XPLAINED_NAND_FTL=y : Use an flash translation layer
+ CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D3XPLAINED_NAND_FTL=y : Use an flash translation layer
NOTE: FTL will require some significant buffering because of
the large size of the NAND flash blocks. You will also need
@@ -1678,7 +1678,7 @@ NAND Support
Using NAND with NXFFS
---------------------
- With the options CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y and
+ With the options CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y and
CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH
start-up logic before the NSH prompt appears. There is no feedback as
to whether or not the mount was successful. You can, however, see the
diff --git a/nuttx/configs/sama5d3-xplained/src/sama5d3-xplained.h b/nuttx/configs/sama5d3-xplained/src/sama5d3-xplained.h
index bc32ec8d8..94a63dfff 100644
--- a/nuttx/configs/sama5d3-xplained/src/sama5d3-xplained.h
+++ b/nuttx/configs/sama5d3-xplained/src/sama5d3-xplained.h
@@ -95,7 +95,7 @@
* asked to mount the NAND part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT)
# undef HAVE_NAND
#endif
diff --git a/nuttx/configs/sama5d3x-ek/Kconfig b/nuttx/configs/sama5d3x-ek/Kconfig
index 2a16ef9fb..321d84d49 100644
--- a/nuttx/configs/sama5d3x-ek/Kconfig
+++ b/nuttx/configs/sama5d3x-ek/Kconfig
@@ -68,7 +68,7 @@ config SAMA5D3xEK_NOR_START
option: If SAMA5D3xEK_NOR_START is defined, then it will not wait but
will, instead, immediately start the program in NOR FLASH.
-config SAMA5_NAND_AUTOMOUNT
+config SAMA5D3XEK_NAND_BLOCKMOUNT
bool "NAND FLASH auto-mount"
default n
depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND
@@ -78,7 +78,7 @@ config SAMA5_NAND_AUTOMOUNT
choice
prompt "NAND FLASH configuration"
default SAMA5D3xEK_NAND_NXFFS
- depends on SAMA5_NAND_AUTOMOUNT
+ depends on SAMA5D3XEK_NAND_BLOCKMOUNT
config SAMA5D3xEK_NAND_FTL
bool "Create NAND FLASH block driver"
@@ -107,7 +107,7 @@ config SAMA5D3xEK_NAND_NXFFS
endchoice # NAND FLASH configuration
-config SAMA5D3xEK_AT25_AUTOMOUNT
+config SAMA5D3xEK_AT25_BLOCKMOUNT
bool "AT25 serial FLASH auto-mount"
default n
depends on NSH_ARCHINIT && SAMA5_SPI0 && MTD_AT25
@@ -117,7 +117,7 @@ config SAMA5D3xEK_AT25_AUTOMOUNT
choice
prompt "AT25 serial FLASH configuration"
default SAMA5D3xEK_AT25_FTL
- depends on SAMA5D3xEK_AT25_AUTOMOUNT
+ depends on SAMA5D3xEK_AT25_BLOCKMOUNT
config SAMA5D3xEK_AT25_FTL
bool "Create AT25 Serial FLASH block driver"
@@ -137,7 +137,7 @@ config SAMA5D3xEK_AT25_NXFFS
endchoice # AT25 serial FLASH configuration
-config SAMA5D3xEK_AT24_AUTOMOUNT
+config SAMA5D3xEK_AT24_BLOCKMOUNT
bool "AT24 Serial EEPROM auto-mount"
default n
depends on NSH_ARCHINIT && SAMA5_TWI0 && MTD_AT24XX
@@ -158,7 +158,7 @@ config SAMA5D3xEK_AT24_AUTOMOUNT
choice
prompt "AT24 serial EPPROM configuration"
default SAMA5D3xEK_AT24_FTL
- depends on SAMA5D3xEK_AT24_AUTOMOUNT
+ depends on SAMA5D3xEK_AT24_BLOCKMOUNT
config SAMA5D3xEK_AT24_FTL
bool "Create AT24 block driver"
diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt
index 21c3b9480..e24a3e057 100644
--- a/nuttx/configs/sama5d3x-ek/README.txt
+++ b/nuttx/configs/sama5d3x-ek/README.txt
@@ -1115,7 +1115,7 @@ AT25 Serial FLASH
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
Board Selection
- CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH
+ CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH
CONFIG_SAMA5D3xEK_AT25_FTL=y : Create block driver for FAT
NOTE that you must close JP1 on the Embest/Ronetix board in order to
@@ -1832,8 +1832,8 @@ NAND Support
to enable SDRAM as described above.
Board Selection
- CONFIG_SAMA5_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D3xEK_NAND_NXFFS=y : Use the NXFFS file system
+ CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D3xEK_NAND_NXFFS=y : Use the NXFFS file system
Other file systems are not recommended because only NXFFS can handle
bad blocks and only NXFFS performs wear-levelling.
@@ -1856,8 +1856,8 @@ NAND Support
Defaults for all other NXFFS settings should be okay.
Board Selection
- CONFIG_SAMA5_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D3xEK_NAND_FTL=y : Use an flash translation layer
+ CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D3xEK_NAND_FTL=y : Use an flash translation layer
NOTE: FTL will require some significant buffering because of
the large size of the NAND flash blocks. You will also need
@@ -1874,7 +1874,7 @@ NAND Support
Using NAND with NXFFS
---------------------
- With the options CONFIG_SAMA5_NAND_AUTOMOUNT=y and
+ With the options CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y and
CONFIG_SAMA5D3xEK_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH
start-up logic before the NSH prompt appears. There is no feedback as
to whether or not the mount was successful. You can, however, see the
@@ -2097,7 +2097,7 @@ AT24 Serial EEPROM
: Other defaults are probably OK
Board Selection
- CONFIG_SAMA5D3xEK_AT24_AUTOMOUNT=y : Mounts AT24 for NSH
+ CONFIG_SAMA5D3xEK_AT24_BLOCKMOUNT=y : Mounts AT24 for NSH
CONFIG_SAMA5D3xEK_AT24_NXFFS=y : Mount the AT24 using NXFFS
You can then format the AT24 EEPROM for a FAT file system and mount the
diff --git a/nuttx/configs/sama5d3x-ek/demo/defconfig b/nuttx/configs/sama5d3x-ek/demo/defconfig
index 7c8e36561..a0ca86aef 100644
--- a/nuttx/configs/sama5d3x-ek/demo/defconfig
+++ b/nuttx/configs/sama5d3x-ek/demo/defconfig
@@ -360,7 +360,7 @@ CONFIG_SAMA5D3xEK_396MHZ=y
CONFIG_SAMA5D3xEK_MT47H128M16RT=y
# CONFIG_SAMA5D3xEK_MT47H64M16HR is not set
# CONFIG_SAMA5D3xEK_NOREDLED is not set
-CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT=y
+CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT=y
CONFIG_SAMA5D3xEK_AT25_FTL=y
#
diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
index 3bbc1cbc9..feebec328 100644
--- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
+++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
@@ -97,7 +97,7 @@
* asked to mount the NAND part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_NAND_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT)
# undef HAVE_NAND
#endif
@@ -142,7 +142,7 @@
* asked to mount the AT25 part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT)
# undef HAVE_AT25
#endif
@@ -192,7 +192,7 @@
* asked to mount the AT25 part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT24_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT24_BLOCKMOUNT)
# undef HAVE_AT24
#endif
diff --git a/nuttx/configs/sama5d4-ek/Kconfig b/nuttx/configs/sama5d4-ek/Kconfig
index 500b8f825..ad8ac7936 100644
--- a/nuttx/configs/sama5d4-ek/Kconfig
+++ b/nuttx/configs/sama5d4-ek/Kconfig
@@ -106,7 +106,7 @@ config SAMA5D4EK_DRAM_BOOT
will simply origin your program at 0x2000:0000 as required by the
sdram_main bootloader (vs. 0x2000:8000 as required by U-Boot).
-config SAMA5D4EK_NAND_AUTOMOUNT
+config SAMA5D4EK_NAND_BLOCKMOUNT
bool "NAND FLASH auto-mount"
default n
depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND
@@ -116,7 +116,7 @@ config SAMA5D4EK_NAND_AUTOMOUNT
choice
prompt "NAND FLASH configuration"
default SAMA5D4EK_NAND_NXFFS
- depends on SAMA5D4EK_NAND_AUTOMOUNT
+ depends on SAMA5D4EK_NAND_BLOCKMOUNT
config SAMA5D4EK_NAND_FTL
bool "Create NAND FLASH block driver"
@@ -145,7 +145,7 @@ config SAMA5D4EK_NAND_NXFFS
endchoice # NAND FLASH configuration
-config SAMA5D4EK_AT25_AUTOMOUNT
+config SAMA5D4EK_AT25_BLOCKMOUNT
bool "AT25 serial FLASH auto-mount"
default n
depends on (NSH_ARCHINIT || SAMA5D4EK_AT25_MAIN) && SAMA5_SPI0 && MTD_AT25
@@ -155,7 +155,7 @@ config SAMA5D4EK_AT25_AUTOMOUNT
choice
prompt "AT25 serial FLASH configuration"
default SAMA5D4EK_AT25_FTL
- depends on SAMA5D4EK_AT25_AUTOMOUNT
+ depends on SAMA5D4EK_AT25_BLOCKMOUNT
config SAMA5D4EK_AT25_FTL
bool "Create AT25 Serial FLASH block driver"
@@ -183,6 +183,67 @@ config SAMA5D4EK_AT25_NXFFS
endchoice # AT25 serial FLASH configuration
+if FS_AUTOMOUNTER
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT
+ bool "HSMCI0 automounter"
+ default n
+ depends on SAMA5_HSMCI0
+
+if SAMA5D4EK_HSMCI0_AUTOMOUNT
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE
+ string "HSMCI0 file system type"
+ default "vfat"
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV
+ string "HSMCI0 block device"
+ default "/dev/mmcds0"
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT
+ string "HSMCI0 mount point"
+ default "/mnt/sdcard0"
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY
+ int "HSMCI0 debounce delay (milliseconds)"
+ default 1000
+
+config SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY
+ int "HSMCI0 unmount retry delay (milliseconds)"
+ default 2000
+
+endif # SAMA5D4EK_HSMCI0_AUTOMOUNT
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT
+ bool "HSMCI1 automounter"
+ default n
+ depends on SAMA5_HSMCI1
+
+if SAMA5D4EK_HSMCI1_AUTOMOUNT
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE
+ string "HSMCI1 file system type"
+ default "vfat"
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV
+ string "HSMCI1 block device"
+ default "/dev/mmcds0"
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT
+ string "HSMCI1 mount point"
+ default "/mnt/sdcard0"
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY
+ int "HSMCI1 debounce delay (milliseconds)"
+ default 1000
+
+config SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY
+ int "HSMCI1 unmount retry delay (milliseconds)"
+ default 2000
+
+endif # SAMA5D4EK_HSMCI1_AUTOMOUNT
+endif # FS_AUTOMOUNTER
+
if INPUT_MXT
config SAMA5D4EK_MXT_I2CFREQUENCY
diff --git a/nuttx/configs/sama5d4-ek/README.txt b/nuttx/configs/sama5d4-ek/README.txt
index 4b7a9b968..3271a703e 100644
--- a/nuttx/configs/sama5d4-ek/README.txt
+++ b/nuttx/configs/sama5d4-ek/README.txt
@@ -1434,8 +1434,8 @@ AT25 Serial FLASH
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
Board Selection
- CONFIG_SAMA5D4EK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH
- CONFIG_SAMA5D4EK_AT25_FTL=y : Create block driver for FAT
+ CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH
+ CONFIG_SAMA5D4EK_AT25_FTL=y : Create block driver for FAT
NOTE: that you must close JP6 in order to enable the AT25 FLASH chip select.
@@ -2119,8 +2119,8 @@ NAND Support
to enable SDRAM as described above.
Board Selection
- CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D4EK_NAND_NXFFS=y : Use the NXFFS file system
+ CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D4EK_NAND_NXFFS=y : Use the NXFFS file system
Other file systems are not recommended because only NXFFS can handle
bad blocks and only NXFFS performs wear-levelling.
@@ -2143,8 +2143,8 @@ NAND Support
Defaults for all other NXFFS settings should be okay.
Board Selection
- CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y : Enable FS support on NAND
- CONFIG_SAMA5D4EK_NAND_FTL=y : Use an flash translation layer
+ CONFIG_SAMA5D4EK_NAND_BLOCKOMOUNT=y : Enable FS support on NAND
+ CONFIG_SAMA5D4EK_NAND_FTL=y : Use an flash translation layer
NOTE: FTL will require some significant buffering because of
the large size of the NAND flash blocks. You will also need
@@ -2161,7 +2161,7 @@ NAND Support
Using NAND with NXFFS
---------------------
- With the options CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y and
+ With the options CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT=y and
CONFIG_SAMA5D4EK_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH
start-up logic before the NSH prompt appears. There is no feedback as
to whether or not the mount was successful. You can, however, see the
diff --git a/nuttx/configs/sama5d4-ek/at25boot/defconfig b/nuttx/configs/sama5d4-ek/at25boot/defconfig
index 27ed38383..4f923e7f4 100644
--- a/nuttx/configs/sama5d4-ek/at25boot/defconfig
+++ b/nuttx/configs/sama5d4-ek/at25boot/defconfig
@@ -322,7 +322,7 @@ CONFIG_SAMA5D4EK_MT47H128M16RT=y
# CONFIG_SAMA5D4EK_DRAM_MAIN is not set
CONFIG_SAMA5D4EK_AT25_MAIN=y
CONFIG_SAMA5D4EK_AT25_PROGSIZE=131072
-CONFIG_SAMA5D4EK_AT25_AUTOMOUNT=y
+CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT=y
# CONFIG_SAMA5D4EK_AT25_FTL is not set
CONFIG_SAMA5D4EK_AT25_CHARDEV=y
diff --git a/nuttx/configs/sama5d4-ek/src/Makefile b/nuttx/configs/sama5d4-ek/src/Makefile
index 46e296961..4ede75871 100644
--- a/nuttx/configs/sama5d4-ek/src/Makefile
+++ b/nuttx/configs/sama5d4-ek/src/Makefile
@@ -76,6 +76,10 @@ CSRCS += sam_at25.c
endif
endif
+ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
+CSRCS += sam_automount.c
+endif
+
ifeq ($(CONFIG_AUDIO_WM8904),y)
ifeq ($(CONFIG_SAMA5_TWI0),y)
ifeq ($(CONFIG_SAMA5_SSC0),y)
diff --git a/nuttx/configs/sama5d4-ek/src/at25_main.c b/nuttx/configs/sama5d4-ek/src/at25_main.c
index 25e694e06..2a9259ab1 100644
--- a/nuttx/configs/sama5d4-ek/src/at25_main.c
+++ b/nuttx/configs/sama5d4-ek/src/at25_main.c
@@ -63,8 +63,8 @@
# error The AT25 Serial FLASH is not available
#endif
-#ifndef CONFIG_SAMA5D4EK_AT25_AUTOMOUNT
-# error CONFIG_SAMA5D4EK_AT25_AUTOMOUNT must be selected
+#ifndef CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT
+# error CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT must be selected
#endif
#ifndef CONFIG_SAMA5D4EK_AT25_CHARDEV
diff --git a/nuttx/configs/sama5d4-ek/src/sam_automount.c b/nuttx/configs/sama5d4-ek/src/sam_automount.c
new file mode 100644
index 000000000..8da4d6f86
--- /dev/null
+++ b/nuttx/configs/sama5d4-ek/src/sam_automount.c
@@ -0,0 +1,390 @@
+/************************************************************************************
+ * configs/sama5d4-ek/src/sam_automount.c
+ *
+ * Copyright (C) 2014 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>
+
+#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS)
+# define CONFIG_DEBUG_FS 1
+#endif
+
+#include <debug.h>
+
+#include <arch/irq.h>
+#include <nuttx/clock.h>
+#include <nuttx/fs/automount.h>
+
+#include "sama5d4-ek.h"
+
+#ifdef HAVE_AUTOMOUNTER
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+#ifndef NULL
+# define NULL (FAR void *)0
+#endif
+
+#ifndef OK
+# define OK 0
+#endif
+
+/************************************************************************************
+ * Private Types
+ ************************************************************************************/
+/* This structure represents the changeable state of the automounter */
+
+struct sam_automount_state_s
+{
+ volatile automount_handler_t handler; /* Upper half handler */
+ FAR void *arg; /* Handler argument */
+ bool enable; /* Fake interrupt enable */
+ bool pending; /* Set if there an event while disabled */
+};
+
+/* This structure represents the static configuration of an automounter */
+
+struct sam_automount_config_s
+{
+ /* This must be first thing in structure so that we can simply cast from struct
+ * automount_lower_s to struct sam_automount_config_s
+ */
+
+ struct automount_lower_s lower; /* Publicly visible part */
+ uint8_t hsmci; /* HSMCI0_SLOTNO or HSMCI1_SLOTNO */
+ FAR struct sam_automount_state_s *state; /* Changeable state */
+};
+
+/************************************************************************************
+ * Private Function Prototypes
+ ************************************************************************************/
+
+static int sam_attach(FAR const struct automount_lower_s *lower,
+ automount_handler_t isr, FAR void *arg);
+static void sam_enable(FAR const struct automount_lower_s *lower, bool enable);
+static bool sam_inserted(FAR const struct automount_lower_s *lower);
+
+/************************************************************************************
+ * Private Data
+ ************************************************************************************/
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+static struct sam_automount_state_s g_hsmci0state;
+static const struct sam_automount_config_s g_hsmci0config =
+{
+ .lower =
+ {
+ .fstype = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE,
+ .blockdev = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV,
+ .mountpoint = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT,
+ .ddelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY),
+ .udelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY),
+ .attach = sam_attach,
+ .enable = sam_enable,
+ .inserted = sam_inserted
+ },
+ .hsmci = HSMCI0_SLOTNO,
+ .state = &g_hsmci0state
+};
+#endif
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+static struct sam_automount_state_s g_hsmci1state;
+static const struct sam_automount_config_s g_hsmci1config =
+{
+ .lower =
+ {
+ .fstype = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE,
+ .blockdev = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV,
+ .mountpoint = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT,
+ .ddelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY),
+ .udelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY),
+ .attach = sam_attach,
+ .enable = sam_enable,
+ .inserted = sam_inserted
+ },
+ .hsmci = HSMCI1_SLOTNO,
+ .state = &g_hsmci1state
+};
+#endif
+
+/************************************************************************************
+ * Private Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: sam_automount_initialize
+ *
+ * Description:
+ * Configure auto-mounters for each enable and so configured HSMCI
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static int sam_attach(FAR const struct automount_lower_s *lower,
+ automount_handler_t isr, FAR void *arg)
+{
+ FAR const struct sam_automount_config_s *config;
+ FAR struct sam_automount_state_s *state;
+
+ /* Recover references to our structure */
+
+ config = (FAR struct sam_automount_config_s *)lower;
+ DEBUGASSERT(config && config->state);
+
+ state = config->state;
+
+ /* Save the new handler info (clearing the handler first to eliminate race
+ * conditions.
+ */
+
+ state->handler = NULL;
+ state->pending = false;
+ state->arg = arg;
+ state->handler = isr;
+ return OK;
+}
+
+/************************************************************************************
+ * Name: sam_automount_initialize
+ *
+ * Description:
+ * Configure auto-mounters for each enable and so configured HSMCI
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static void sam_enable(FAR const struct automount_lower_s *lower, bool enable)
+{
+ FAR const struct sam_automount_config_s *config;
+ FAR struct sam_automount_state_s *state;
+ irqstate_t flags;
+
+ /* Recover references to our structure */
+
+ config = (FAR struct sam_automount_config_s *)lower;
+ DEBUGASSERT(config && config->state);
+
+ state = config->state;
+
+ /* Save the fake enable setting */
+
+ flags = irqsave();
+ state->enable = enable;
+
+ /* Did an interrupt occur while interrupts were disabled? */
+
+ if (enable && state->pending)
+ {
+ /* Yes.. perform the fake interrupt if the interrutp is attached */
+
+ if (state->handler)
+ {
+ bool inserted = sam_cardinserted(config->hsmci);
+ (void)state->handler(&config->lower, state->arg, inserted);
+ }
+
+ state->pending = false;
+ }
+
+ irqrestore(flags);
+}
+
+/************************************************************************************
+ * Name: sam_automount_initialize
+ *
+ * Description:
+ * Configure auto-mounters for each enable and so configured HSMCI
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+static bool sam_inserted(FAR const struct automount_lower_s *lower)
+{
+ FAR const struct sam_automount_config_s *config;
+
+ config = (FAR struct sam_automount_config_s *)lower;
+ DEBUGASSERT(config && config->state);
+
+ return sam_cardinserted(config->hsmci);
+}
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/************************************************************************************
+ * Name: sam_automount_initialize
+ *
+ * Description:
+ * Configure auto-mounters for each enable and so configured HSMCI
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+void sam_automount_initialize(void)
+{
+ FAR void *handle;
+
+ fvdbg("Initializing automounter(s)\n");
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+ /* Initialize the HSMCI0 auto-mounter */
+
+ handle = automount_initialize(&g_hsmci0config.lower);
+ if (!handle)
+ {
+ fdbg("ERROR: Failed to initialize auto-mounter for HSMCI0\n");
+ }
+#endif
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+ /* Initialize the HSMCI1 auto-mounter */
+
+ handle = automount_initialize(&g_hsmci1config.lower);
+ if (!handle)
+ {
+ fdbg("ERROR: Failed to initialize auto-mounter for HSMCI1\n");
+ }
+#endif
+}
+
+/************************************************************************************
+ * Name: sam_automount_event
+ *
+ * Description:
+ * The HSMCI card detection logic has detected an insertion or removal event. It
+ * has already scheduled the MMC/SD block driver operations. Now we need to
+ * schedule the auto-mount event which will occur with a substantial delay to make
+ * sure that everything has settle down.
+ *
+ * Input Parameters:
+ * slotno - Identifies the HSMCI0 slot: HSMCI0_SLOTNO or HSMCI1_SLOTNO. There is a
+ * terminology problem here: Each HSMCI supports two slots, slot A and slot B.
+ * Only slot A is used. So this is not a really a slot, but an HSCMI peripheral
+ * number.
+ * inserted - True if the card is inserted in the slot. False otherwise.
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Interrupts are disabled.
+ *
+ ************************************************************************************/
+
+void sam_automount_event(int slotno, bool inserted)
+{
+ FAR const struct sam_automount_config_s *config;
+ FAR struct sam_automount_state_s *state;
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+ /* Is this a change in the HSMCI0 insertion state? */
+
+ if (slotno == HSMCI0_SLOTNO)
+ {
+ /* Yes.. Select the HSMCI0 automounter */
+
+ config = &g_hsmci0config;
+ state = &g_hsmci0state;
+ }
+ else
+#endif
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+ /* Is this a change in the HSMCI1 insertion state? */
+
+ if (slotno == HSMCI1_SLOTNO)
+ {
+ /* Yes.. Select the HSMCI1 automounter */
+
+ config = &g_hsmci1config;
+ state = &g_hsmci1state;
+ }
+ else
+#endif
+ {
+ fdbg("ERROR: Unsupported HSCMI%d\n", slotno);
+ return;
+ }
+
+ /* Is the auto-mounter interrupt attached? */
+
+ if (state->handler)
+ {
+ /* Yes.. Have we been asked to hold off interrupts? */
+
+ if (!state->enable)
+ {
+ /* Yes.. just remember the there is a pending interrupt. We will
+ * deliver the interrupt when interrupts are "re-enabled."
+ */
+
+ state->pending = true;
+ }
+ else
+ {
+ /* No.. forward the event to the handler */
+
+ (void)state->handler(&config->lower, state->arg, inserted);
+ }
+ }
+}
+
+#endif /* HAVE_AUTOMOUNTER */
diff --git a/nuttx/configs/sama5d4-ek/src/sam_hsmci.c b/nuttx/configs/sama5d4-ek/src/sam_hsmci.c
index b36d97692..a6ab1439c 100644
--- a/nuttx/configs/sama5d4-ek/src/sam_hsmci.c
+++ b/nuttx/configs/sama5d4-ek/src/sam_hsmci.c
@@ -204,14 +204,42 @@ static int sam_hsmci_cardetect(struct sam_hsmci_state_s *state)
#ifdef CONFIG_SAMA5_HSMCI0
static int sam_hsmci0_cardetect(int irq, void *regs)
{
- return sam_hsmci_cardetect(&g_hsmci0);
+ int ret;
+
+ /* Handle the card detect interrupt. The interrupt level logic will
+ * kick of the driver-level operations to initialize the MMC/SD block
+ * device.
+ */
+
+ ret = sam_hsmci_cardetect(&g_hsmci0);
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+ /* Let the automounter know about the insertion event */
+
+ sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
+#endif
+
+ return ret;
}
#endif
#ifdef CONFIG_SAMA5_HSMCI1
static int sam_hsmci1_cardetect(int irq, void *regs)
{
- return sam_hsmci_cardetect(&g_hsmci1);
+ int ret;
+
+ /* Handle the card detect interrupt. The interrupt level logic will
+ * kick of the driver-level operations to initialize the MMC/SD block
+ * device.
+ */
+
+ ret = sam_hsmci_cardetect(&g_hsmci1);
+
+#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+ /* Let the automounter know about the insertion event */
+
+ sam_automount_event(HSMCI1_SLOTNO, sam_cardinserted(HSMCI1_SLOTNO));
+#endif
}
#endif
diff --git a/nuttx/configs/sama5d4-ek/src/sam_nsh.c b/nuttx/configs/sama5d4-ek/src/sam_nsh.c
index 1c44d273c..45fda54ca 100644
--- a/nuttx/configs/sama5d4-ek/src/sam_nsh.c
+++ b/nuttx/configs/sama5d4-ek/src/sam_nsh.c
@@ -135,6 +135,12 @@ int nsh_archinitialize(void)
#endif
#endif
+#ifdef HAVE_AUTOMOUNTER
+ /* Initialize the automounter */
+
+ sam_automount_initialize();
+#endif
+
#ifdef HAVE_USBHOST
/* Initialize USB host operation. sam_usbhost_initialize() starts a thread
* will monitor for USB connection and disconnection events.
diff --git a/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h b/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h
index f974a393f..91fd6fddc 100644
--- a/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h
+++ b/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h
@@ -55,18 +55,19 @@
************************************************************************************/
/* Configuration ************************************************************/
-#define HAVE_HSMCI 1
-#define HAVE_AT25 1
-#define HAVE_NAND 1
-#define HAVE_USBHOST 1
-#define HAVE_USBDEV 1
-#define HAVE_USBOVCUR 1
-#define HAVE_USBMONITOR 1
-#define HAVE_NETWORK 1
-#define HAVE_MAXTOUCH 1
-#define HAVE_WM8904 1
-#define HAVE_AUDIO_NULL 1
-#define HAVE_PMIC 1
+#define HAVE_HSMCI 1
+#define HAVE_AT25 1
+#define HAVE_NAND 1
+#define HAVE_AUTOMOUNTER 1
+#define HAVE_USBHOST 1
+#define HAVE_USBDEV 1
+#define HAVE_USBOVCUR 1
+#define HAVE_USBMONITOR 1
+#define HAVE_NETWORK 1
+#define HAVE_MAXTOUCH 1
+#define HAVE_WM8904 1
+#define HAVE_AUDIO_NULL 1
+#define HAVE_PMIC 1
/* HSMCI */
/* Can't support MMC/SD if the card interface(s) are not enable */
@@ -100,7 +101,7 @@
* asked to mount the NAND part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_NAND_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT)
# undef HAVE_NAND
#endif
@@ -145,7 +146,7 @@
* asked to mount the AT25 part
*/
-#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_AT25_AUTOMOUNT)
+#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT)
# undef HAVE_AT25
#endif
@@ -220,6 +221,75 @@
#else
#endif
+/* Automounter. Currently only works with HSMCI. */
+
+#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
+# undef HAVE_AUTOMOUNTER
+#endif
+
+#ifndef CONFIG_SAMA5_HSMCI0
+# undef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+#endif
+
+#ifndef CONFIG_SAMA5_HSMCI1
+# undef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+#endif
+
+#if !defined(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT) && \
+ !defined(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT)
+# undef HAVE_AUTOMOUNTER
+#endif
+
+#ifdef HAVE_AUTOMOUNTER
+# ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT
+ /* HSMCI0 Automounter defaults */
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE
+# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV
+# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT
+# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY
+# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY 1000
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY
+# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY 2000
+# endif
+# endif
+
+# ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT
+ /* HSMCI1 Automounter defaults */
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE
+# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE "vfat"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV
+# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV "/dev/mmcds0"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT
+# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY
+# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY 1000
+# endif
+
+# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY
+# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY 2000
+# endif
+# endif
+#endif
+
/* USB Host / USB Device */
/* Either CONFIG_SAMA5_UHPHS or CONFIG_SAMA5_UDPHS must be defined, or there is
* no USB of any kind.
@@ -859,6 +929,52 @@ bool sam_cardinserted(int slotno);
#endif
/************************************************************************************
+ * Name: sam_automount_initialize
+ *
+ * Description:
+ * Configure auto-mounters for each enable and so configured HSMCI
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ************************************************************************************/
+
+#ifdef HAVE_AUTOMOUNTER
+void sam_automount_initialize(void);
+#endif
+
+/************************************************************************************
+ * Name: sam_automount_event
+ *
+ * Description:
+ * The HSMCI card detection logic has detected an insertion or removal event. It
+ * has already scheduled the MMC/SD block driver operations. Now we need to
+ * schedule the auto-mount event which will occur with a substantial delay to make
+ * sure that everything has settle down.
+ *
+ * Input Parameters:
+ * slotno - Identifies the HSMCI0 slot: HSMCI0 or HSMCI1_SLOTNO. There is a
+ * terminology problem here: Each HSMCI supports two slots, slot A and slot B.
+ * Only slot A is used. So this is not a really a slot, but an HSCMI peripheral
+ * number.
+ * inserted - True if the card is inserted in the slot. False otherwise.
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Interrupts are disabled.
+ *
+ ************************************************************************************/
+
+#ifdef HAVE_AUTOMOUNTER
+void sam_automount_event(int slotno, bool inserted);
+#endif
+
+/************************************************************************************
* Name: sam_writeprotected
*
* Description:
diff --git a/nuttx/fs/fs_automount.c b/nuttx/fs/fs_automount.c
index 8a1c44c4e..14b2420fc 100644
--- a/nuttx/fs/fs_automount.c
+++ b/nuttx/fs/fs_automount.c
@@ -199,6 +199,8 @@ static void automount_mount(FAR struct automounter_state_s *priv)
FAR const struct automount_lower_s *lower = priv->lower;
int ret;
+ fvdbg("Mounting %s\n", lower->mountpoint);
+
/* Check if the something is already mounted at the mountpoint. */
ret = automount_findinode(lower->mountpoint);
@@ -274,6 +276,8 @@ static int automount_unmount(FAR struct automounter_state_s *priv)
FAR const struct automount_lower_s *lower = priv->lower;
int ret;
+ fvdbg("Unmounting %s\n", lower->mountpoint);
+
/* Check if the something is already mounted at the mountpoint. */
ret = automount_findinode(lower->mountpoint);
@@ -366,6 +370,7 @@ static void automount_timeout(int argc, uint32_t arg1, ...)
(FAR struct automounter_state_s *)((uintptr_t)arg1);
int ret;
+ fllvdbg("Timeout!\n");
DEBUGASSERT(argc == 1 && priv);
/* Check the state of things. This timeout at the interrupt level and
@@ -379,7 +384,7 @@ static void automount_timeout(int argc, uint32_t arg1, ...)
/* Queue work to occur immediately. */
- ret = work_queue(LPWORK, &priv->work, automount_worker, priv, 0);
+ ret = work_queue(LPWORK, &priv->work, automount_worker, priv, 0);
if (ret < 0)
{
/* NOTE: Currently, work_cancel only returns success */
@@ -565,7 +570,19 @@ FAR void *automount_initialize(FAR const struct automount_lower_s *lower)
/* Handle the initial state of the mount on the caller's thread */
priv->inserted = AUTOMOUNT_INSERTED(lower);
- automount_worker(priv);
+
+ /* Set up the first action at a delay from the initialization time (to
+ * allow time for any extended block driver initialization to complete.
+ */
+
+ ret = work_queue(LPWORK, &priv->work, automount_worker, priv,
+ priv->lower->ddelay);
+ if (ret < 0)
+ {
+ /* NOTE: Currently, work_cancel only returns success */
+
+ fdbg("ERROR: Failed to schedule work: %d\n", ret);
+ }
/* Attach and enable automounter interrupts */
diff --git a/nuttx/include/nuttx/fs/automount.h b/nuttx/include/nuttx/fs/automount.h
index 12f6f1430..cfc9eb2d6 100644
--- a/nuttx/include/nuttx/fs/automount.h
+++ b/nuttx/include/nuttx/fs/automount.h
@@ -107,7 +107,7 @@ struct automount_lower_s
uint32_t ddelay;
- /* Unmount delay time in sysem clock ticks. If a volume has open
+ /* Unmount delay time in system clock ticks. If a volume has open
* references at the time that the media is removed, then we will be
* unable to unmount it. In that case, hopefully, the clients of the
* mount will eventually fail with file access errors and eventually close