SmartSnippers Ver3.9擦除DA14580带16M(字节)Flash失败!但我可以擦除扇区

⚠️
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年6个月前
Joined:2014-11-05 09:10
SmartSnippers Ver3.9擦除DA14580带16M(字节)Flash失败!但我可以擦除扇区

Hi,dialog:
I use a flash(16M bytes)with da14580 in my project.In order to make it work:
1> SPI_FLAH.h,我添加了代码,如下所示:
// 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>使用UART运行SmartSnippets3.9并连接DA14580
[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]成功与COM5端口断开连接。
[信息@ 17-09-29 19:09:16]与COM5端口的连接已成功打开。
[info @ 17-09-29 19:09:16]成功与COM5端口断开连接。
[info @ 17-09-29 19:09:16]成功下载了固件文件到电路板。
[info @ 17-09-29 19:09:16]成功配置了SPI闪存端口和引脚。

6>填充SmartSnippets3.9中的偏移0x0,然后单击按钮(擦除扇区),现在将0到0x07FFF的所有数据到0xFF
[信息@ 17-09-29 19:11:52]与COM5端口的连接已成功打开。
[info @ 17-09-29 19:11:52]成功与COM5端口断开连接。
[INFO @17-09-29 19:11:52] SPI Memory erasing completed successfully.
[信息@ 17-09-29 19:11:52]阅读内存以验证其内容擦除后...
[信息@ 17-09-29 19:11:52]与COM5端口的连接已成功打开。
[INFO @17-09-29 19:11:53] Successfully disconnected from port COM5.
[info @ 17-09-29 19:11:53]验证成功。
[info @ 17-09-29 19:11:53]阅读内存刷新表内容....
[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...
[信息@ 17-09-29 19:15:20]与COM5端口的连接已成功打开。
[INFO @17-09-29 19:15:21] Successfully disconnected from port COM5.
[info @ 17-09-29 19:15:21]验证成功了。
[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>将偏移量更改为0x0,然后单击“按钮擦除”,“红色错误”来自:(发生超时)
[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.
[错误@ 17-09-29 19:17:36] SPI内存擦除失败。

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>我尝试将W25q128jv_total_flash_size的值重新定义为其他0x20000,400,80000等,我得到了相同的结果。

Questions:
如何用一个单击擦除按钮擦除闪存,至少从0x0〜0x20000擦除?因为我有多映像(引导加载程序,app,font_resource)需要刻录到闪存。

谢谢!

设备:
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年6个月前
Joined:2014-11-05 09:10
谢谢!

谢谢!
我通过在函数spi_flash_chip_erase中添加一些代码来解决问题,如下所示:

INT8_T SPI_FLASH_CHIP_ERASE(void)
{
uint8_t status;

if(spi_flash_set_write_enable()!= err_ok)//发送[写入启用]指令
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;
//虽然(address0x40000
while(address<0x40000)
{
spi_flash_block_erase(地址,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.

最好的问候mt_dialog.