Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for CONFIG_FS_WRITABLE #602

Merged
merged 12 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions Documentation/NuttShell.html
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ <h1>Table of Contents</h1>
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
<p>Last Updated: November 3, 2019</p>
<p>Last Updated: March 21, 2020</p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -3736,7 +3736,7 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>df</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code></code></td>
<td><code>CONFIG_NSH_DISABLE_DF</code></td>
</tr>
<tr>
Expand Down Expand Up @@ -3785,7 +3785,7 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
<td><code>CONFIG_NSH_DISABLE_GET</code></td>
</tr>
<tr>
<td><b><code>help</code></b><sup>5</sup></td>
<td><b><code>help</code></b><sup>3</sup></td>
<td><br></td>
<td><code>CONFIG_NSH_DISABLE_HELP</code></td>
</tr>
Expand Down Expand Up @@ -3860,7 +3860,7 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>mkdir</code></b></td>
<td>(((!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code>) || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code>)</td>
<td>(!<code>CONFIG_DISABLE_MOUNTPOINT</code> || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code>)</td>
<td><code>CONFIG_NSH_DISABLE_MKDIR</code></td>
</tr>
<tr>
Expand All @@ -3875,17 +3875,17 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>mkrd</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code></code></td>
<td><code>CONFIG_NSH_DISABLE_MKRD</code></td>
</tr>
<tr>
<td><b><code>mount</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code></code></td>
<td><code>CONFIG_NSH_DISABLE_MOUNT</code></td>
</tr>
<tr>
<td><b><code>mv</code></b></td>
<td>(!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code>) || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code><sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code></td>
<td><code>CONFIG_NSH_DISABLE_MV</code></td>
</tr>
<tr>
Expand All @@ -3900,7 +3900,7 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>passwd</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code>sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code></td>
<td><code>CONFIG_NSH_DISABLE_PASSWD</code></td>
</tr>
<tr>
Expand Down Expand Up @@ -3941,12 +3941,12 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>rm</code></b></td>
<td>(!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code>) || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code><sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code></td>
<td><code>CONFIG_NSH_DISABLE_RM</code></td>
</tr>
<tr>
<td><b><code>rmdir</code></b></td>
<td>(!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code>) || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code><sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> || !<code>CONFIG_DISABLE_PSEUDOFS_OPERATIONS</code></td>
<td><code>CONFIG_NSH_DISABLE_RMDIR</code></td>
</tr>
<tr>
Expand Down Expand Up @@ -4006,7 +4006,7 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>umount</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code></code></td>
<td><code>CONFIG_NSH_DISABLE_UMOUNT</code></td>
</tr>
<tr>
Expand All @@ -4031,12 +4031,12 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
</tr>
<tr>
<td><b><code>useradd</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code>sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code></td>
<td><code>CONFIG_NSH_DISABLE_USERADD</code></td>
</tr>
<tr>
<td><b><code>userdel</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_FS_WRITABLE</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code>sup>4</sup></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NSH_LOGIN_PASSWD</code></td>
<td><code>CONFIG_NSH_DISABLE_USERDEL</code></td>
</tr>
<tr>
Expand All @@ -4062,13 +4062,6 @@ <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
Special TFTP server start-up options will probably be required to permit
creation of files for the correct operation of the <code>put</code> command.</small><br>
<sup>3</sup><small>
<code>CONFIG_FS_READABLE</code> is not a user configuration but is set automatically
if any readable file system is selected. At present, this is either <code>CONFIG_FS_FAT</code>
or <code>CONFIG_FS_ROMFS</code>.</small><br>
<sup>4</sup><small>
<code>CONFIG_FS_WRITABLE</code> is not a user configuration but is set automatically
if any writable file system is selected. At present, this is only <code>CONFIG_FS_FAT</code>.</small><br>
<sup>5</sup><small>
Verbose help output can be suppressed by defining <code>CONFIG_NSH_HELP_TERSE</code>.
In that case, the help command is still available but will be slightly smaller.
</small>
Expand Down
94 changes: 64 additions & 30 deletions arch/arm/src/cxd56xx/cxd56_emmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

#include <sys/types.h>
Expand All @@ -55,6 +59,10 @@
#include "hardware/cxd56_emmc.h"
#include "cxd56_pinconfig.h"

/****************************************************************************
* Pre-processoro Definitions
****************************************************************************/

#define SECTOR_SIZE (512)

#define EMMC_DATA_WRITE 0
Expand All @@ -67,7 +75,27 @@
#define EMMC_RESP_R2 3
#define EMMC_RESP_R3 4

struct emmc_dma_desc_s {
#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)

#define EMMC_RCA (2) /* greater than 1 */

#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */

#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif

/****************************************************************************
* Private Types
****************************************************************************/

struct emmc_dma_desc_s
{
uint32_t ctrl;
uint32_t size;
uint32_t addr;
Expand All @@ -81,14 +109,18 @@ struct cxd56_emmc_state_s
uint32_t total_sectors;
};

/****************************************************************************
* Private Function Prototypes
****************************************************************************/

/* Block driver interfaces **************************************************/

static int cxd56_emmc_open(FAR struct inode *inode);
static int cxd56_emmc_close(FAR struct inode *inode);
static ssize_t cxd56_emmc_read(FAR struct inode *inode,
unsigned char *buffer, size_t start_sector,
unsigned int nsectors);
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
#if !defined(CONFIG_MMCSD_READONLY)
static ssize_t cxd56_emmc_write(FAR struct inode *inode,
const unsigned char *buffer,
size_t start_sector,
Expand All @@ -98,37 +130,30 @@ static int cxd56_emmc_geometry(FAR struct inode *inode,
struct geometry *geometry);
static int emmc_interrupt(int irq, FAR void *context, FAR void *arg);

/****************************************************************************
* Private Data
****************************************************************************/

static const struct block_operations g_bops =
{
cxd56_emmc_open, /* open */
cxd56_emmc_close, /* close */
cxd56_emmc_read, /* read */
#if defined(CONFIG_FS_WRITABLE)
#if !defined(CONFIG_MMCSD_READONLY)
cxd56_emmc_write, /* write */
#else
NULL, /* write */
NULL, /* write */
#endif
cxd56_emmc_geometry, /* geometry */
NULL /* ioctl */
NULL /* ioctl */
};

static sem_t g_waitsem;
struct cxd56_emmc_state_s g_emmcdev;

#define EMMC_CLKDIV_UNDER_400KHZ (32u)
#define EMMC_CLKDIV_NON_DIV (0u)

#define EMMC_RCA (2) /* greater than 1 */

#define EMMC_DATA_TIMEOUT (0xFFFFFFu) /* max reg value */
#define EMMC_RESP_TIMEOUT (0xFFu) /* max reg value */

#define EMMC_MSIZE (6) /* Burst size is 512B */
#define EMMC_FIFO_DEPTH (0x100) /* FIFO size is 1KB */

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
* Private Functions
****************************************************************************/

static void emmc_takesem(FAR sem_t *sem)
{
Expand Down Expand Up @@ -164,7 +189,7 @@ static void emmc_reset(uint32_t reg, uint32_t bits)
while (val & bits);
}

#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
#if !defined(CONFIG_MMCSD_READONLY)
static void emmc_flushwritefifo(void)
{
/* eMMC host controller has a problem that invalid data is still remained
Expand Down Expand Up @@ -308,9 +333,9 @@ static struct emmc_dma_desc_s *emmc_setupdma(void *buf, unsigned int nbytes)

/* Adjust first and last descriptor members */

descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs-1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs-1].next = 0;
descs[0].ctrl |= EMMC_IDMAC_DES0_FD;
descs[ndescs - 1].ctrl |= EMMC_IDMAC_DES0_LD;
descs[ndescs - 1].next = 0;

#ifdef CONFIG_DEBUG_VERBOSE
for (i = 0, d = descs; i < ndescs; i++, d++)
Expand Down Expand Up @@ -341,6 +366,7 @@ static int emmc_checkresponse(void)
ferr("Response error %08x\n", resp);
return -EIO;
}

return OK;
}

Expand Down Expand Up @@ -454,6 +480,7 @@ static int emmc_is_powerup(void)
{
return 0;
}

up_mdelay(5);
}
while (--retry);
Expand Down Expand Up @@ -716,14 +743,14 @@ static int cxd56_emmc_readsectors(FAR struct cxd56_emmc_state_s *priv,
ret = -EIO;
}

finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);

return ret;
}

#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
#if !defined(CONFIG_MMCSD_READONLY)
static int cxd56_emmc_writesectors(FAR struct cxd56_emmc_state_s *priv,
const void *buf, size_t start_sector,
unsigned int nsectors)
Expand Down Expand Up @@ -787,7 +814,7 @@ static int cxd56_emmc_writesectors(FAR struct cxd56_emmc_state_s *priv,

emmc_flushwritefifo();

finish:
finish:
emmc_givesem(&priv->excsem);
kmm_free(descs);

Expand Down Expand Up @@ -826,8 +853,9 @@ static int cxd56_emmc_close(FAR struct inode *inode)
return OK;
}

static ssize_t cxd56_emmc_read(FAR struct inode *inode, unsigned char *buffer,
size_t start_sector, unsigned int nsectors)
static ssize_t cxd56_emmc_read(FAR struct inode *inode,
unsigned char *buffer, size_t start_sector,
unsigned int nsectors)
{
FAR struct cxd56_emmc_state_s *priv;
int ret;
Expand All @@ -848,7 +876,7 @@ static ssize_t cxd56_emmc_read(FAR struct inode *inode, unsigned char *buffer,
return nsectors;
}

#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
#if !defined(CONFIG_MMCSD_READONLY)
static ssize_t cxd56_emmc_write(FAR struct inode *inode,
const unsigned char *buffer,
size_t start_sector,
Expand Down Expand Up @@ -884,7 +912,7 @@ static int cxd56_emmc_geometry(FAR struct inode *inode,

geometry->geo_available = true;
geometry->geo_mediachanged = false;
#if defined(CONFIG_FS_WRITABLE)
#if !defined(CONFIG_MMCSD_READONLY)
geometry->geo_writeenabled = true;
#else
geometry->geo_writeenabled = false;
Expand Down Expand Up @@ -927,9 +955,11 @@ int cxd56_emmcinitialize(void)
kmm_free(buf);
return -EIO;
}

priv->total_sectors = *(FAR uint32_t *)&buf[EXTCSD_SEC_COUNT];
kmm_free(descs);
}

kmm_free(buf);
}

Expand All @@ -943,6 +973,10 @@ int cxd56_emmcinitialize(void)
return OK;
}

/****************************************************************************
* Public Functions
****************************************************************************/

int emmc_uninitialize(void)
{
/* Send power off command */
Expand Down
Loading