Freedom-K64F: Add hooks for automounter; Change NSH configuration to use Windows

This commit is contained in:
Gregory Nutt
2016-07-13 09:23:57 -06:00
parent 590af73bd2
commit 2f12de6f28
9 changed files with 368 additions and 157 deletions
+133 -11
View File
@@ -11,6 +11,7 @@ Contents
o Serial Console
o LEDs and Buttons
o Networking Support
o SD Card Support
o Development Environment
o GNU Toolchain Options
o Freedom K64F Configuration Options
@@ -409,6 +410,134 @@ f Application Configuration -> Network Utilities
CONFIG_NSH_NETINIT_RETRYMSEC=2000 : Configure the network monitor as you like
CONFIG_NSH_NETINIT_SIGNO=18
SD Card Support
===============
Card Slot
---------
A micro Secure Digital (SD) card slot is available on the FRDM-K64F connected to
the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro
format SD memory cards. The SD card detect pin (PTE6) is an open switch that
shorts with VDD when card is inserted.
------------ ------------- --------
SD Card Slot Board Signal K64F Pin
------------ ------------- --------
DAT0 SDHC0_D0 PTE0
DAT1 SDHC0_D1 PTE1
DAT2 SDHC0_D2 PTE5
CD/DAT3 SDHC0_D3 PTE4
CMD SDHC0_CMD PTE3
CLK SDHC0_DCLK PTE2
SWITCH D_CARD_DETECT PTE6
------------ ------------- --------
There is no Write Protect pin available to the K64F.
Configuration Settings
----------------------
Enabling SDHC support. The Freedom K64F provides one microSD memory card
slot. Support for the SD slots can be enabled with the following
settings:
System Type->Kinetic Peripheral Selection
CONFIG_KINETIS_SDHC=y : To enable SDHC0 support
System Type
CONFIG_GPIO_IRQ=y : GPIO interrupts needed
CONFIG_KINETIS_PORTEINTS=y : Card detect pin is on PTE6
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
CONFIG_SCHED_HPWORK=y
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : NSH board-initialization, and
CONFIG_LIB_BOARDCTL=y : Or
CONFIG_BOARD_INITIALIZE=y
Using the SD card
-----------------
1. After booting, the SDHC 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. Insert 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 SDHC 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_FRDMK64F_SDHC_AUTOMOUNT=y
CONFIG_FRDMK64F_SDHC_AUTOMOUNT_FSTYPE="vfat"
CONFIG_FRDMK64F_SDHC_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
CONFIG_FRDMK64F_SDHC_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
CONFIG_FRDMK64F_SDHC_AUTOMOUNT_DDELAY=1000
CONFIG_FRDMK64F_SDHC_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.
Development Environment
=======================
@@ -639,13 +768,6 @@ Where <subdir> is one of the following:
1. Most of the notes associated with the nsh configuration apply here
as well (see below).
2. Default platform/toolchain:
CONFIG_HOST_WINDOWS=y : Cygwin under Windows
CONFIG_WINDOWS_CYGWIN=y
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc)
CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary
3. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU
is requests status of the Ethernet link connection. Internal pullup is
required when port configuration for MDIO signal is enabled:
@@ -682,9 +804,9 @@ Where <subdir> is one of the following:
2. Default platform/toolchain:
CONFIG_HOST_LINUX=y : Linux (Cygwin under Windows okay too).
CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y : Buildroot (arm-nuttx-elf-gcc)
CONFIG_ARMV7M_OABI_TOOLCHAIN=y : The older OABI version
CONFIG_HOST_WINDOWS=y : Cygwin under Windows
CONFIG_WINDOWS_CYGWIN=y
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc)
CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary
3. The Serial Console is provided on UART3 with the correct pin
@@ -723,7 +845,7 @@ Status
2016-07-12: Added support for the KSZ8081 PHY and added the netnsh
configuration. The network is basically functional, but a lot more
testing is needed to confirm that.
In testing, I notice a strange thing. If I run at full optimization the
code runs (albeit with bugs-to-be-solved). But with no optimization or
even at -O1, the system fails to boot. This seems to be related to the