Flashing driver over QSPI working but not complete, it needs more work.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9524 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
249d014e0b
commit
96f3718cc7
|
@ -699,7 +699,9 @@ static flash_error_t start_erase_sector(void *instance, flash_sector_t sector) {
|
||||||
|
|
||||||
static flash_error_t verify_erase(void *instance, flash_sector_t sector) {
|
static flash_error_t verify_erase(void *instance, flash_sector_t sector) {
|
||||||
M25QDriver *devp = (M25QDriver *)instance;
|
M25QDriver *devp = (M25QDriver *)instance;
|
||||||
unsigned i;
|
uint8_t cmpbuf[M25Q_COMPARE_BUFFER_SIZE];
|
||||||
|
flash_address_t addr;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
osalDbgCheck(instance != NULL);
|
osalDbgCheck(instance != NULL);
|
||||||
osalDbgCheck(sector < descriptor.sectors_count);
|
osalDbgCheck(sector < descriptor.sectors_count);
|
||||||
|
@ -717,6 +719,35 @@ static flash_error_t verify_erase(void *instance, flash_sector_t sector) {
|
||||||
devp->state = FLASH_READ;
|
devp->state = FLASH_READ;
|
||||||
|
|
||||||
/* Read command.*/
|
/* Read command.*/
|
||||||
|
addr = (flash_address_t)(sector * SECTOR_SIZE);
|
||||||
|
n = SECTOR_SIZE;
|
||||||
|
while (n > 0U) {
|
||||||
|
uint8_t *p;
|
||||||
|
|
||||||
|
#if M25Q_BUS_MODE != M25Q_BUS_MODE_SPI
|
||||||
|
flash_cmd_addr_dummy_receive(devp, M25Q_CMD_FAST_READ,
|
||||||
|
addr, M25Q_READ_DUMMY_CYCLES,
|
||||||
|
sizeof cmpbuf, cmpbuf);
|
||||||
|
#else
|
||||||
|
/* Normal read command in SPI mode.*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Checking for erased state of current buffer.*/
|
||||||
|
for (p = cmpbuf; p < &cmpbuf[M25Q_COMPARE_BUFFER_SIZE]; p++) {
|
||||||
|
if (*p != 0xFFU) {
|
||||||
|
/* Ready state again.*/
|
||||||
|
devp->state = FLASH_READY;
|
||||||
|
|
||||||
|
/* Bus released.*/
|
||||||
|
flash_bus_release(devp);
|
||||||
|
|
||||||
|
return FLASH_ERROR_VERIFY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addr += sizeof cmpbuf;
|
||||||
|
n -= sizeof cmpbuf;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ready state again.*/
|
/* Ready state again.*/
|
||||||
devp->state = FLASH_READY;
|
devp->state = FLASH_READY;
|
||||||
|
|
|
@ -175,6 +175,16 @@
|
||||||
#define M25Q_SUPPORTED_MEMORY_TYPE_IDS {0xBA, 0xBB}
|
#define M25Q_SUPPORTED_MEMORY_TYPE_IDS {0xBA, 0xBB}
|
||||||
#endif
|
#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(M25Q_COMPARE_BUFFER_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define M25Q_COMPARE_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -206,6 +216,10 @@
|
||||||
#error "invalid M25Q_READ_DUMMY_CYCLES value (1..15)"
|
#error "invalid M25Q_READ_DUMMY_CYCLES value (1..15)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (M25Q_COMPARE_BUFFER_SIZE & (M25Q_COMPARE_BUFFER_SIZE - 1)) != 0
|
||||||
|
#error "invalid M25Q_COMPARE_BUFFER_SIZE value"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="cmd-flash_cmd_receive-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="cfg-cmdp-qspiSend-(format)" val="4"/><content id="CR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="cfg-cmdp-qspiReceive-(format)" val="4"/><content id="r2-(format)" val="4"/><content id="config-initgpio-(format)" val="4"/><content id="moder-config-initgpio-(format)" val="4"/><content id="afrh-config-initgpio-(format)" val="4"/><content id="MODER-gpiop-initgpio-(format)" val="4"/><content id="OSPEEDR-gpiop-initgpio-(format)" val="4"/><content id="PUPDR-gpiop-initgpio-(format)" val="4"/><content id="IDR-gpiop-initgpio-(format)" val="4"/><content id="ODR-gpiop-initgpio-(format)" val="4"/><content id="AFRH-gpiop-initgpio-(format)" val="4"/><content id="AFRL-gpiop-initgpio-(format)" val="4"/><content id="id[0]-id-m25qStart-(format)" val="4"/><content id="id[1]-id-m25qStart-(format)" val="4"/><content id="id[2]-id-m25qStart-(format)" val="4"/><content id="cfg-cmdp-qspi_lld_receive-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_receive-(format)" val="4"/></contentList>"/>
|
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="CCR-qspi-qspip-qspi_lld_receive-(format)" val="4"/><content id="cfg-cmdp-qspi_lld_receive-(format)" val="4"/><content id="id[2]-id-m25qStart-(format)" val="4"/><content id="id[1]-id-m25qStart-(format)" val="4"/><content id="id[0]-id-m25qStart-(format)" val="4"/><content id="AFRL-gpiop-initgpio-(format)" val="4"/><content id="AFRH-gpiop-initgpio-(format)" val="4"/><content id="ODR-gpiop-initgpio-(format)" val="4"/><content id="IDR-gpiop-initgpio-(format)" val="4"/><content id="PUPDR-gpiop-initgpio-(format)" val="4"/><content id="OSPEEDR-gpiop-initgpio-(format)" val="4"/><content id="MODER-gpiop-initgpio-(format)" val="4"/><content id="afrh-config-initgpio-(format)" val="4"/><content id="moder-config-initgpio-(format)" val="4"/><content id="config-initgpio-(format)" val="4"/><content id="r2-(format)" val="4"/><content id="cfg-cmdp-qspiReceive-(format)" val="4"/><content id="CCR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="CR-qspi-qspip-qspi_lld_send-(format)" val="4"/><content id="cfg-cmdp-qspiSend-(format)" val="4"/><content id="CR2-adc-adcp-adc_lld_start_conversion-(format)" val="4"/><content id="CR2-adc-null-port_wait_for_interrupt-(format)" val="4"/><content id="cr2-adc_lld_start_conversion-(format)" val="4"/><content id="cmd-flash_cmd_receive-(format)" val="4"/></contentList>"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||||
|
|
|
@ -112,16 +112,32 @@ int main(void) {
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("erase error");
|
chSysHalt("erase error");
|
||||||
|
|
||||||
|
/* Verifying the erase operation.*/
|
||||||
|
err = flashVerifyErase(&m25q, 0);
|
||||||
|
if (err != FLASH_NO_ERROR)
|
||||||
|
chSysHalt("verify erase error");
|
||||||
|
|
||||||
/* Programming a pattern.*/
|
/* Programming a pattern.*/
|
||||||
err = flashProgram(&m25q, 0, pattern, 128);
|
err = flashProgram(&m25q, 0, pattern, 128);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("program error");
|
chSysHalt("program error");
|
||||||
|
|
||||||
|
/* Verifying the erase operation.*/
|
||||||
|
err = flashVerifyErase(&m25q, 0);
|
||||||
|
if (err != FLASH_ERROR_VERIFY)
|
||||||
|
chSysHalt("verify non-erase error");
|
||||||
|
|
||||||
/* Reading it back.*/
|
/* Reading it back.*/
|
||||||
err = flashRead(&m25q, 0, buffer, 128);
|
err = flashRead(&m25q, 0, buffer, 128);
|
||||||
if (err != FLASH_NO_ERROR)
|
if (err != FLASH_NO_ERROR)
|
||||||
chSysHalt("read error");
|
chSysHalt("read error");
|
||||||
|
|
||||||
|
/* Erasing again.*/
|
||||||
|
(void) flashStartEraseSector(&m25q, 0);
|
||||||
|
err = flashWaitErase((BaseFlash *)&m25q);
|
||||||
|
if (err != FLASH_NO_ERROR)
|
||||||
|
chSysHalt("erase error");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing.
|
* Normal main() thread activity, in this demo it does nothing.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue