mirror of https://github.com/rusefi/ChibiOS.git
SNOR rework because cache-related issue, not finished.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15552 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
7fbd1ae369
commit
141c1f6639
|
@ -135,7 +135,6 @@ static bool mx25_find_id(const uint8_t *set, size_t size, uint8_t element) {
|
|||
}
|
||||
|
||||
static flash_error_t mx25_poll_status(SNORDriver *devp) {
|
||||
uint8_t sts[2], sec[2];
|
||||
|
||||
do {
|
||||
#if MX25_NICE_WAITING == TRUE
|
||||
|
@ -143,21 +142,24 @@ static flash_error_t mx25_poll_status(SNORDriver *devp) {
|
|||
#endif
|
||||
/* Read status command.*/
|
||||
#if MX25_BUS_MODE == MX25_BUS_MODE_SPI
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSR, 1U, sts);
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSR, 1U, devp->nocache->buf1);
|
||||
#else
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSR,
|
||||
0U, 4U, 2U, sts); /*Note: always 4 dummies.*/
|
||||
0U, 4U, 2U,
|
||||
devp->nocache->buf); /* Note: always 4 dummies.*/
|
||||
#endif
|
||||
} while ((sts[0] & 1U) != 0U);
|
||||
} while ((devp->nocache->buf[0] & 1U) != 0U);
|
||||
|
||||
/* Reading security register and checking for errors.*/
|
||||
#if MX25_BUS_MODE == MX25_BUS_MODE_SPI
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSCUR, 1U, sec);
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDSCUR,
|
||||
1U, devp->nocache->buf1);
|
||||
#else
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDSCUR,
|
||||
0U, 4U, 2U, sec); /*Note: always 4 dummies.*/
|
||||
0U, 4U, 2U,
|
||||
devp->nocache->buf); /* Note: always 4 dummies.*/
|
||||
#endif
|
||||
if ((sec[0] & MX25_FLAGS_ALL_ERRORS) != 0U) {
|
||||
if ((devp->nocache->buf[0] & MX25_FLAGS_ALL_ERRORS) != 0U) {
|
||||
|
||||
return FLASH_ERROR_PROGRAM;
|
||||
}
|
||||
|
@ -338,17 +340,18 @@ void snor_device_init(SNORDriver *devp) {
|
|||
#endif
|
||||
|
||||
/* Reading device ID and unique ID.*/
|
||||
wspiReceive(devp->config->busp, &mx25_cmd_read_id, 3U, devp->device_id);
|
||||
wspiReceive(devp->config->busp, &mx25_cmd_read_id, 3U,
|
||||
&devp->nocache->buf[0]);
|
||||
#endif /* SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI */
|
||||
|
||||
/* Checking if the device is white listed.*/
|
||||
osalDbgAssert(mx25_find_id(mx25_manufacturer_ids,
|
||||
sizeof mx25_manufacturer_ids,
|
||||
devp->device_id[0]),
|
||||
devp->nocache->buf[0]),
|
||||
"invalid manufacturer id");
|
||||
osalDbgAssert(mx25_find_id(mx25_memory_type_ids,
|
||||
sizeof mx25_memory_type_ids,
|
||||
devp->device_id[1]),
|
||||
devp->nocache->buf[1]),
|
||||
"invalid memory type id");
|
||||
|
||||
#if SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI
|
||||
|
@ -361,7 +364,6 @@ void snor_device_init(SNORDriver *devp) {
|
|||
|
||||
#if (SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI) && (MX25_SWITCH_WIDTH == TRUE)
|
||||
{
|
||||
uint8_t id[8];
|
||||
#if MX25_BUS_MODE == MX25_BUS_MODE_SPI
|
||||
static const uint8_t v[1] = {0x00};
|
||||
#elif MX25_BUS_MODE == MX25_BUS_MODE_OPI_STR
|
||||
|
@ -376,25 +378,29 @@ void snor_device_init(SNORDriver *devp) {
|
|||
/* Reading ID again for confirmation, in DTR mode bytes are read twice,
|
||||
it needs adjusting.*/
|
||||
#if MX25_BUS_MODE == MX25_BUS_MODE_SPI
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDID, 3U, id);
|
||||
bus_cmd_receive(devp->config->busp, MX25_CMD_SPI_RDID, 3U,
|
||||
&devp->nocache->buf[16]);
|
||||
#elif MX25_BUS_MODE == MX25_BUS_MODE_OPI_STR
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDID,
|
||||
0U, 4U, 3U, id); /*Note: always 4 dummies. */
|
||||
0U, 4U, 3U,
|
||||
&devp->nocache->buf[16]); /*Note: always 4 dummies.*/
|
||||
#elif MX25_BUS_MODE == MX25_BUS_MODE_OPI_DTR
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_RDID,
|
||||
0U, 4U, 6U, id); /*Note: always 4 dummies. */
|
||||
id[1] = id[2];
|
||||
id[2] = id[4];
|
||||
0U, 4U, 6U,
|
||||
&devp->nocache->buf[16]); /*Note: always 4 dummies.*/
|
||||
devp->nocache->buf[16 + 1] = devp->nocache->buf[16 + 2];
|
||||
devp->nocache->buf[16 + 2] = devp->nocache->buf[16 + 4];
|
||||
#endif
|
||||
|
||||
/* Checking if the device is white listed.*/
|
||||
osalDbgAssert(memcmp(id, devp->device_id, 3) == 0,
|
||||
osalDbgAssert(memcmp(&devp->nocache->buf[0],
|
||||
&devp->nocache->buf[16], 3) == 0,
|
||||
"id confirmation failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Setting up the device size.*/
|
||||
snor_descriptor.sectors_count = (1U << ((size_t)devp->device_id[2] & 0x1FU)) /
|
||||
snor_descriptor.sectors_count = (1U << ((size_t)devp->nocache->buf[2] & 0x1FU)) /
|
||||
SECTOR_SIZE;
|
||||
snor_descriptor.size = (size_t)snor_descriptor.sectors_count * SECTOR_SIZE;
|
||||
}
|
||||
|
@ -556,7 +562,6 @@ flash_error_t snor_device_start_erase_sector(SNORDriver *devp,
|
|||
*/
|
||||
flash_error_t snor_device_verify_erase(SNORDriver *devp,
|
||||
flash_sector_t sector) {
|
||||
uint8_t cmpbuf[MX25_COMPARE_BUFFER_SIZE];
|
||||
flash_offset_t offset;
|
||||
size_t n;
|
||||
|
||||
|
@ -569,16 +574,16 @@ flash_error_t snor_device_verify_erase(SNORDriver *devp,
|
|||
#if SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI
|
||||
#if MX25_BUS_MODE == MX25_BUS_MODE_SPI
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_SPI_FAST_READ4B,
|
||||
offset, 8, /* Note, always 8 dummy cycles. */
|
||||
sizeof cmpbuf, cmpbuf);
|
||||
offset, 8, /* Note, always 8 dummy cycles.*/
|
||||
SNOR_BUFFER_SIZE, devp->nocache->buf);
|
||||
#elif MX25_BUS_MODE == MX25_BUS_MODE_OPI_STR
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_8READ,
|
||||
offset, MX25_READ_DUMMY_CYCLES,
|
||||
sizeof cmpbuf, cmpbuf);
|
||||
SNOR_BUFFER_SIZE, devp->nocache->buf);
|
||||
#elif MX25_BUS_MODE == MX25_BUS_MODE_OPI_DTR
|
||||
bus_cmd_addr_dummy_receive(devp->config->busp, MX25_CMD_OPI_8DTRD,
|
||||
offset, MX25_READ_DUMMY_CYCLES,
|
||||
sizeof cmpbuf, cmpbuf);
|
||||
SNOR_BUFFER_SIZE, devp->nocache->buf);
|
||||
#endif
|
||||
#else
|
||||
/* Normal read command in SPI mode.*/
|
||||
|
@ -587,7 +592,7 @@ flash_error_t snor_device_verify_erase(SNORDriver *devp,
|
|||
#endif
|
||||
|
||||
/* Checking for erased state of current buffer.*/
|
||||
for (p = cmpbuf; p < &cmpbuf[MX25_COMPARE_BUFFER_SIZE]; p++) {
|
||||
for (p = devp->nocache->buf; p < &devp->nocache->buf[SNOR_BUFFER_SIZE]; p++) {
|
||||
if (*p != 0xFFU) {
|
||||
/* Ready state again.*/
|
||||
devp->state = FLASH_READY;
|
||||
|
@ -596,8 +601,8 @@ flash_error_t snor_device_verify_erase(SNORDriver *devp,
|
|||
}
|
||||
}
|
||||
|
||||
offset += sizeof cmpbuf;
|
||||
n -= sizeof cmpbuf;
|
||||
offset += SNOR_BUFFER_SIZE;
|
||||
n -= SNOR_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
return FLASH_NO_ERROR;
|
||||
|
|
|
@ -315,17 +315,6 @@
|
|||
#define MX25_USE_SUB_SECTORS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Size of the compare buffer.
|
||||
* @details This buffer is allocated in the stack frame of the function
|
||||
* @p flashVerifyErase() and its size must be a power of two.
|
||||
* Larger buffers lead to better verify performance but increase
|
||||
* stack usage for that function.
|
||||
*/
|
||||
#if !defined(MX25_COMPARE_BUFFER_SIZE) || defined(__DOXYGEN__)
|
||||
#define MX25_COMPARE_BUFFER_SIZE 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of dummy cycles for fast read (1..15).
|
||||
* @details This is the number of dummy cycles to be used for fast read
|
||||
|
@ -339,10 +328,6 @@
|
|||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if (MX25_COMPARE_BUFFER_SIZE & (MX25_COMPARE_BUFFER_SIZE - 1)) != 0
|
||||
#error "invalid MX25_COMPARE_BUFFER_SIZE value"
|
||||
#endif
|
||||
|
||||
#if (MX25_READ_DUMMY_CYCLES < 6) || (MX25_READ_DUMMY_CYCLES > 20) || \
|
||||
((MX25_READ_DUMMY_CYCLES & 1) != 0)
|
||||
#error "invalid MX25_READ_DUMMY_CYCLES value (6, 8, 10, 12, 14, 16, 18, 20)"
|
||||
|
|
|
@ -662,16 +662,18 @@ void bus_cmd_addr_dummy_receive(BUSDriver *busp,
|
|||
* @brief Initializes an instance.
|
||||
*
|
||||
* @param[out] devp pointer to the @p SNORDriver object
|
||||
* @param[in] nocache pointer to the non-cacheable buffers
|
||||
*
|
||||
* @init
|
||||
*/
|
||||
void snorObjectInit(SNORDriver *devp) {
|
||||
void snorObjectInit(SNORDriver *devp, snor_nocache_buffer_t *nocache) {
|
||||
|
||||
osalDbgCheck(devp != NULL);
|
||||
|
||||
devp->vmt = &snor_vmt;
|
||||
devp->state = FLASH_STOP;
|
||||
devp->config = NULL;
|
||||
devp->nocache = nocache;
|
||||
#if SNOR_USE_MUTUAL_EXCLUSION == TRUE
|
||||
osalMutexObjectInit(&devp->mutex);
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
#define SNOR_BUS_DRIVER_WSPI 1U
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Size of the buffer for internal operations.
|
||||
*/
|
||||
#define SNOR_BUFFER_SIZE 32
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
@ -127,6 +132,13 @@ struct SNORDriverVMT {
|
|||
_snor_flash_methods
|
||||
};
|
||||
|
||||
typedef struct snor_nocache_buffer {
|
||||
/**
|
||||
* @brief Temporary buffer.
|
||||
*/
|
||||
uint8_t buf[SNOR_BUFFER_SIZE];
|
||||
} snor_nocache_buffer_t;
|
||||
|
||||
/**
|
||||
* @extends BaseFlash
|
||||
*
|
||||
|
@ -143,9 +155,9 @@ typedef struct {
|
|||
*/
|
||||
const SNORConfig *config;
|
||||
/**
|
||||
* @brief Device ID and unique ID.
|
||||
* @brief Non-cacheable buffer associated to this instance.
|
||||
*/
|
||||
uint8_t device_id[20];
|
||||
snor_nocache_buffer_t *nocache;
|
||||
#if (SNOR_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Mutex protecting SNOR.
|
||||
|
@ -204,7 +216,7 @@ extern "C" {
|
|||
size_t n,
|
||||
uint8_t *p);
|
||||
#endif
|
||||
void snorObjectInit(SNORDriver *devp);
|
||||
void snorObjectInit(SNORDriver *devp, snor_nocache_buffer_t *nocache);
|
||||
void snorStart(SNORDriver *devp, const SNORConfig *config);
|
||||
void snorStop(SNORDriver *devp);
|
||||
#if (SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI) || defined(__DOXYGEN__)
|
||||
|
|
|
@ -419,6 +419,9 @@ void wspi_lld_unmap_flash(WSPIDriver *wspip) {
|
|||
*/
|
||||
void wspi_lld_serve_interrupt(WSPIDriver *wspip) {
|
||||
|
||||
wspip->ospi->FCR = OCTOSPI_FCR_CTEF | OCTOSPI_FCR_CTCF |
|
||||
OCTOSPI_FCR_CSMF | OCTOSPI_FCR_CTOF;
|
||||
|
||||
/* Portable WSPI ISR code defined in the high level driver, note, it is
|
||||
a macro.*/
|
||||
_wspi_isr_code(wspip);
|
||||
|
|
|
@ -74,8 +74,9 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** Next ***
|
||||
- NEW: FatFS now functional on STM32H7xx, added a target to the VFS demo.
|
||||
- NEW: Improved cache settings in STM32H7xx mcuconf.h.
|
||||
- NEW: Modified SDMMCv2 to allow for uncached buffers.
|
||||
- NEW: Modified SDMMCv2 to allow for uncached buffers, tested on STM32H7xx.
|
||||
- NEW: Added OCTOSPIv2 driver using MDMA for STM32H7xx.
|
||||
- NEW: Added demos for STM32H723ZG Nucleo144 and STM32H735ZI Discovery boards.
|
||||
- NEW: Added support for STM32H723/25/33/35.
|
||||
|
|
|
@ -103,6 +103,40 @@
|
|||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="0.1093754934.1746620542.146052967.1694773297">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1093754934.1746620542.146052967.1694773297" moduleId="org.eclipse.cdt.core.settings" name="Build for STM32H735IG-Discovery">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1093754934.1746620542.146052967.1694773297" name="Build for STM32H735IG-Discovery" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="0.1093754934.1746620542.146052967.1694773297." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.297050713" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.297050713.33554878" name=""/>
|
||||
<builder arguments="-f ./make/stm32h735ig_discovery.make" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.177006326" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1162759966" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.428968794" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.936734990" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1869431849" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1143156004" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1308823506" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1156066943" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="STM32-WSPI-MFS.null.932840044" name="STM32-WSPI-MFS"/>
|
||||
|
@ -129,10 +163,10 @@
|
|||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32-WSPI-MFS"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Build for STM32F746-Discovery">
|
||||
<configuration configurationName="Build for STM32L4R9I-Discovery">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32-WSPI-MFS"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Build for STM32L4R9I-Discovery">
|
||||
<configuration configurationName="Build for STM32F746-Discovery">
|
||||
<resource resourceType="PROJECT" workspacePath="/STM32-WSPI-MFS"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Build for STM32L476-Discovery">
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
#
|
||||
|
||||
all:
|
||||
@echo
|
||||
@echo === Building for STM32H735IG-Discovery =============================
|
||||
+@make --no-print-directory -f ./make/stm32h735ig_discovery.make all
|
||||
@echo ====================================================================
|
||||
@echo
|
||||
@echo === Building for STM32L4R9-Discovery ===============================
|
||||
+@make --no-print-directory -f ./make/stm32l4r9_discovery.make all
|
||||
@echo ====================================================================
|
||||
@echo
|
||||
@echo === Building for STM32L476-Discovery ===============================
|
||||
+@make --no-print-directory -f ./make/stm32l476_discovery.make all
|
||||
|
@ -13,6 +18,8 @@ all:
|
|||
@echo
|
||||
|
||||
clean:
|
||||
@echo
|
||||
+@make --no-print-directory -f ./make/stm32h735ig_discovery.make clean
|
||||
@echo
|
||||
+@make --no-print-directory -f ./make/stm32l4r9_discovery.make clean
|
||||
@echo
|
||||
|
|
|
@ -32,6 +32,7 @@ const SNORConfig snorcfg1 = {
|
|||
};
|
||||
|
||||
SNORDriver snor1;
|
||||
snor_nocache_buffer_t __nocache_snor1buf;
|
||||
|
||||
const MFSConfig mfscfg1 = {
|
||||
.flashp = (BaseFlash *)&snor1,
|
||||
|
@ -54,8 +55,6 @@ static THD_FUNCTION(Thread1, arg) {
|
|||
while (true) {
|
||||
palToggleLine(PORTAB_LINE_LED1);
|
||||
chThdSleepMilliseconds(500);
|
||||
palToggleLine(PORTAB_LINE_LED1);
|
||||
chThdSleepMilliseconds(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +80,7 @@ int main(void) {
|
|||
sdStart(&PORTAB_SD1, NULL);
|
||||
|
||||
/* Initializing and starting snor1 driver.*/
|
||||
snorObjectInit(&snor1);
|
||||
snorObjectInit(&snor1, &__nocache_snor1buf);
|
||||
snorStart(&snor1, &snorcfg1);
|
||||
#if 1
|
||||
/* Testing memory mapped mode.*/
|
||||
|
|
Loading…
Reference in New Issue