diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 18e426e178..667a618d49 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sim/src/up_initialize.c * - * Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -79,6 +79,7 @@ static void up_init_smartfs(void) FAR struct mtd_dev_s *mtd; FAR struct spi_dev_s *spi; +#ifdef CONFIG_MTD_M25P /* Initialize a simulated SPI FLASH block device m25p MTD driver */ spi = up_spiflashinitialize(); @@ -87,6 +88,18 @@ static void up_init_smartfs(void) /* Now initialize a SMART Flash block device and bind it to the MTD device */ smart_initialize(0, mtd, NULL); +#endif + +#ifdef CONFIG_MTD_W25 + /* Initialize a simulated SPI FLASH block device m25p MTD driver */ + + spi = up_spiflashinitialize(); + mtd = w25_initialize(spi); + + /* Now initialize a SMART Flash block device and bind it to the MTD device */ + + smart_initialize(0, mtd, NULL); +#endif } #endif diff --git a/arch/sim/src/up_spiflash.c b/arch/sim/src/up_spiflash.c index b1e8366018..4e378b5457 100644 --- a/arch/sim/src/up_spiflash.c +++ b/arch/sim/src/up_spiflash.c @@ -84,6 +84,11 @@ #ifdef CONFIG_SIM_SPIFLASH_1M # define CONFIG_SPIFLASH_SIZE (128 * 1024) # define CONFIG_SPIFLASH_CAPACITY 0x11 + +#ifndef CONFIG_SIM_SPIFLASH_SECTORSIZE +# define CONFIG_SIM_SPIFLASH_SECTORSIZE 2048 +#endif + #endif #ifdef CONFIG_SIM_SPIFLASH_8M @@ -157,6 +162,7 @@ #define SPIFLASH_STATE_READ2 14 #define SPIFLASH_STATE_READ3 15 #define SPIFLASH_STATE_READ4 16 +#define SPIFLASH_STATE_FREAD_WAIT 17 /* Instructions */ /* Command Value N Description Addr Dummy Data */ @@ -666,6 +672,7 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data break; case SPIFLASH_READ: + case SPIFLASH_FAST_READ: priv->state = SPIFLASH_STATE_READ1; break; @@ -780,6 +787,18 @@ static void spiflash_writeword(FAR struct sim_spiflashdev_s *priv, uint16_t data case SPIFLASH_STATE_READ3: priv->address |= data; + if (priv->last_cmd == SPIFLASH_FAST_READ) + { + priv->state = SPIFLASH_STATE_FREAD_WAIT; + } + else + { + priv->state = SPIFLASH_STATE_READ4; + } + break; + + case SPIFLASH_STATE_FREAD_WAIT: + priv->read_data = 0xff; priv->state = SPIFLASH_STATE_READ4; break; @@ -850,6 +869,7 @@ FAR struct spi_dev_s *up_spiflashinitialize() priv->state = SPIFLASH_STATE_IDLE; priv->read_data = 0xFF; priv->last_cmd = 0xFF; + memset(&priv->data[0], 0xFF, sizeof(priv->data)); irqrestore(flags); return (FAR struct spi_dev_s *)priv;