Emulated SPI FLASH driver for the sim target from Ken Pettit

This commit is contained in:
Gregory Nutt
2014-09-19 10:27:18 -06:00
parent 2eef637ca2
commit 400d469956
5 changed files with 970 additions and 1 deletions
+75
View File
@@ -114,4 +114,79 @@ config SIM_TCNWAITERS
The maximum number of threads that can be waiting on poll() for a touchscreen event.
Default: 4
config SIM_SPIFLASH
bool "Simulated SPI FLASH with SMARTFS"
default n
select FS_SMARTFS
select MTD_SMART
---help---
Adds a simulated SPI FLASH that responds to standard M25 style
commands on the SPI bus.
choice
prompt "Simulated SPI FLASH Size"
default SIM_SPIFLASH_1M
depends on SIM_SPIFLASH
config SIM_SPIFLASH_1M
bool "1 MBit (128K Byte)"
config SIM_SPIFLASH_8M
bool "8 MBit (1M Byte)"
config SIM_SPIFLASH_32M
bool "32 MBit (4M Byte)"
config SIM_SPIFLASH_64M
bool "64 MBit (8M Byte)"
config SIM_SPIFLASH_128M
bool "128 MBit (16M Byte)"
endchoice
config SIM_SPIFLASH_MANUFACTURER
hex "Hex ID of the FLASH manufacturer code"
default 0x20
depends on SIM_SPIFLASH
---help---
Allows the simulated FLASH Manufacturer ID to be set.
config SIM_SPIFLASH_MEMORY_TYPE
hex "Hex ID of the FLASH Memory Type code"
default 0x20
depends on SIM_SPIFLASH
---help---
Allows the simulated FLASH Memory Type code to be set.
config SIM_SPIFLASH_SECTORSIZE
int "FLASH Sector Erase Size"
default 65536
depends on SIM_SPIFLASH
---help---
Sets the large sector erase size that the part simulates.
This driver simulates SPI devices that have both a large
sector erase as well as a "sub-sector" (per the datasheet)
erase size (typically 4K bytes).
config SIM_SPIFLASH_SUBSECTORSIZE
int "FLASH Sub-Sector Erase Size"
default 4096
depends on SIM_SPIFLASH
---help---
Sets the smaller sub-sector erase size supported by the
FLASH emulation
config SIM_SPIFLASH_PAGESIZE
int "FLASH Write / Program Page Size
default 256
depends on SIM_SPIFLASH
---help---
Sets the size of a page program operation. The page size
represents the maximum number of bytes that can be sent
for a program operation. If more bytes than this are
sent on a single Page Program, then the address will
"wrap" causing the initial data sent to be overwritten.
This is consistent with standard SPI FLASH operation.
endif
+1 -1
View File
@@ -43,7 +43,7 @@ AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c
CSRCS += up_createstack.c up_usestack.c up_releasestack.c up_stackframe.c
CSRCS += up_unblocktask.c up_blocktask.c up_releasepending.c
CSRCS += up_reprioritizertr.c up_exit.c up_schedulesigaction.c
CSRCS += up_reprioritizertr.c up_exit.c up_schedulesigaction.c up_spiflash.c
CSRCS += up_allocateheap.c up_devconsole.c
HOSTSRCS = up_stdio.c up_hostusleep.c
+32
View File
@@ -43,6 +43,8 @@
#include <nuttx/arch.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
#include <nuttx/mtd/mtd.h>
#include <nuttx/syslog/ramlog.h>
#include "up_internal.h"
@@ -59,6 +61,32 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: up_init_smartfs
*
* Description:
* Initialize a simulated SPI FLASH block device m25p MTD driver and bind
* it to a SMART Flash block device.
*
****************************************************************************/
#if defined(CONFIG_FS_SMARTFS) && defined(CONFIG_SIM_SPIFLASH)
static void up_init_smartfs(void)
{
FAR struct mtd_dev_s *mtd;
FAR struct spi_dev_s *spi;
/* Initialize a simulated SPI FLASH block device m25p MTD driver */
spi = up_spiflashinitialize();
mtd = m25p_initialize(spi);
/* Now initialize a SMART Flash block device and bind it to the MTD device */
smart_initialize(0, mtd, NULL);
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -130,4 +158,8 @@ void up_initialize(void)
#ifdef CONFIG_NET
netdriver_init(); /* Our "real" network driver */
#endif
#if defined(CONFIG_FS_SMARTFS) && defined(CONFIG_SIM_SPIFLASH)
up_init_smartfs();
#endif
}
+4
View File
@@ -236,5 +236,9 @@ int netdriver_setmacaddr(unsigned char *macaddr);
void netdriver_loop(void);
#endif
#ifdef CONFIG_SIM_SPIFLASH
struct spi_dev_s *up_spiflashinitialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_UP_INTERNAL_H */
File diff suppressed because it is too large Load Diff