smartsnippers ver3.9擦掉DA14580 16米(字节)flash failed! but I can erase sector

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
kurbylee
Offline
Last seen:3 years 6 months ago
Joined:2014-11-05 09:10
smartsnippers ver3.9擦掉DA14580 16米(字节)flash failed! but I can erase sector

Hi,dialog:
I use a flash(16M bytes)with da14580 in my project.In order to make it work:
1>spi_flah.h,I add code as below:
// 5. W25Q128JV(128Mb/16MB)
#define SPI_FLASH_DEVICE_INDEX_W25Q128JV 4
#define W25Q128JV_MAN_DEV_ID 0xEF17
#define W25Q128JV_JEDEC_ID 0xEF4018
#define W25Q128JV_JEDEC_ID_MATCHING_BITMASK 0xFFFFFF
#define W25Q128JV_TOTAL_FLASH_SIZE 0x20000 //0x40000 //0xFFFFFF //0x1000000 //16M=0x1000000
#define W25Q128JV_PAGE_SIZE 0x100
#define W25Q128JV_MEM_PROT_BITMASK (0x1C)
#define W25Q128JV_MEM_PROT_NONE 0
#define W25Q128JV_MEM_PROT_UPPER_QUARTER 4
#define W25Q128JV_MEM_PROT_UPPER_HALF 8
#define W25Q128JV_MEM_PROT_LOWER_QUARTER 36
#define W25Q128JV_MEM_PROT_LOWER_HALF 40
#define W25Q128JV_MEM_PROT_ALL 12

2>add code in spi_flash.c
const SPI_FLASH_DEVICE_PARAMETERS_BY_JEDEC_ID_t SPI_FLASH_KNOWN_DEVICES_PARAMETERS_LIST[] =
{
{W25X10_JEDEC_ID, W25X10_JEDEC_ID_MATCHING_BITMASK, W25X10_TOTAL_FLASH_SIZE, W25X10_PAGE_SIZE, W25x_MEM_PROT_BITMASK, W25x10_MEM_PROT_NONE},
{W25X20_JEDEC_ID, W25X20_JEDEC_ID_MATCHING_BITMASK, W25X20_TOTAL_FLASH_SIZE, W25X20_PAGE_SIZE, W25x_MEM_PROT_BITMASK, W25x20_MEM_PROT_NONE},
{AT25Dx011_JEDEC_ID, AT25Dx011_JEDEC_ID_MATCHING_BITMASK, AT25Dx011_TOTAL_FLASH_SIZE, AT25Dx011_PAGE_SIZE, AT25Dx011_MEM_PROT_BITMASK, AT25Dx011_MEM_PROT_NONE},
{MX25V1006E_JEDEC_ID, MX25V1006E_JEDEC_ID_MATCHING_BITMASK, MX25V1006E_TOTAL_FLASH_SIZE, MX25V1006E_PAGE_SIZE, MX25V1006E_MEM_PROT_BITMASK, MX25V1006E_MEM_PROT_NONE},
{W25Q128JV_JEDEC_ID, W25Q128JV_JEDEC_ID_MATCHING_BITMASK, W25Q128JV_TOTAL_FLASH_SIZE, W25Q128JV_PAGE_SIZE, W25Q128JV_MEM_PROT_BITMASK, W25Q128JV_MEM_PROT_NONE},
};

3>compile the programmer project and get flash_programmer.bin
4>copy the bin file to D:\APP\SmartSnippets3.9\workspace\resources;
5>run SmartSnippets3.9 and connect da14580 with uart
[ACTION @17-09-29 19:09:10] Please press the hardware reset button on the board to start the download process.
[INFO @17-09-29 19:09:14] Reset detected
[INFO @17-09-29 19:09:16] Successfully disconnected from port COM5.
[INFO @17-09-29 19:09:16] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:09:16] Successfully disconnected from port COM5.
[INFO @17-09-29 19:09:16] Successfully downloaded firmware file to the board.
[INFO @17-09-29 19:09:16] Successfully configured SPI Flash ports and pins.

6>fill the offset 0x0 in SmartSnippets3.9 and click button(erase sector) Now all data from 0 to 0x07FFF chang to 0xff
[INFO @17-09-29 19:11:52] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:11:52] Successfully disconnected from port COM5.
[INFO @17-09-29 19:11:52] SPI Memory erasing completed successfully.
[INFO @17-09-29 19:11:52] Reading memory to verify its contents after erase...
[INFO @17-09-29 19:11:52] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:11:53] Successfully disconnected from port COM5.
[INFO @17-09-29 19:11:53] Verification succeeded.
[INFO @17-09-29 19:11:53] Reading memory to refresh table contents....
[INFO @17-09-29 19:11:54] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:12:00] Successfully disconnected from port COM5.
[INFO @17-09-29 19:12:00] Reading has finished. Read 32768 bytes.

7>change offset to 0x20000,and click button (erase sector),It seems that all work well.
[INFO @17-09-29 19:15:19] Connection to COM5 port has successfully opened.
(信息@17-09-29 19:15:20]成功disconnected from port COM5.
[INFO @17-09-29 19:15:20] SPI Memory erasing completed successfully.
[INFO @17-09-29 19:15:20] Reading memory to verify its contents after erase...
[INFO @17-09-29 19:15:20] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:15:21] Successfully disconnected from port COM5.
[INFO @17-09-29 19:15:21] Verification succeeded.
[INFO @17-09-29 19:15:21] Reading memory to refresh table contents....
[INFO @17-09-29 19:15:21] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:15:27] Successfully disconnected from port COM5.
[INFO @17-09-29 19:15:27] Reading has finished. Read 32768 bytes.

8>change offset to 0x0,and click button erase.and RED ERROR come:(timeout happened)
[INFO @17-09-29 19:15:21] Connection to COM5 port has successfully opened.
[INFO @17-09-29 19:15:27] Successfully disconnected from port COM5.
[INFO @17-09-29 19:15:27] Reading has finished. Read 32768 bytes.
[INFO @17-09-29 19:17:26] Connection to COM5 port has successfully opened.
[ERROR @17-09-29 19:17:36] Timeout while waiting to receive the most significant byte of packet length (10000 msecs)
[INFO @17-09-29 19:17:36] Successfully disconnected from port COM5.
[ERROR @17-09-29 19:17:36] SPI Memory erasing failed.

9>I try change MAX_READY_WAIT_COUNT as below, but nothing is different.
#define MAX_READY_WAIT_COUNT (0xFFFFFFFF) // 2000000*10

10>I erase the first sector and download a app_image to flash ,then the app run normal.

11>I try redefine the value of W25Q128JV_TOTAL_FLASH_SIZE to other, 0x20000,40000,80000 and so on,I got same result.

Questions:
how can i erase flash with one click Erase button,at least erase from 0x0~0x20000?Because i have multi image(bootloader,app,font_resource) need to burn into flash.

Thanks!

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi kurbylee,

Hi kurbylee,

Perhaps you could try with the new Smart Snippets Toolbox and give it a try, i dont see any thing suspicious in the additions that you had in the code. Also what happens when you dont push the erase sector and you hit the Erase command on your Smart Snippets version ? Also regardless what the Smart Snippets reports can you check if the flash is erased ?

Thanks MT_dialog

kurbylee
Offline
Last seen:3 years 6 months ago
Joined:2014-11-05 09:10
Thanks!

Thanks!
I have solved the problem through add some code in function spi_flash_chip_erase as below:

int8_t spi_flash_chip_erase(void)
{
uint8_t status;

if (spi_flash_set_write_enable() != ERR_OK) // send [Write Enable] instruction
return ERR_TIMEOUT;

if(spi_flash_size<0x40000)
{
spi_set_bitmode(SPI_MODE_8BIT);
spi_transaction(CHIP_ERASE); // Command for Chip Erase
status = spi_flash_wait_till_ready();
}
else
{
uint32_t address=0;
//while(address0x40000
while(address<0x40000)
{
spi_flash_block_erase(address,BLOCK_ERASE_64);
status = spi_flash_wait_till_ready();
if(status!=ERR_OK)break;
address+=64*1024;
}

}

return status;
}

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi kurbylee,

Hi kurbylee,

Thanks for indicating this, hopefully it will help quite a few users.

Best Regards MT_dialog