Skip to content

Commit

Permalink
update:little flash延长等待时间
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed May 16, 2024
1 parent 3ded376 commit 5dd7ee8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/little_flash/inc/little_flash_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ struct little_flash{
#define LF_SFDP_MAJOR_REV (0x01)
#define LF_SFDP_MINOR_REV (0x0A)

#define LF_RETRY_TIMES (500000)
#define LF_RETRY_TIMES (5000000)

#define LF_NORFLASH_PAGE_ZISE (256) /**< NOR flash page size (bytes) */
#define LF_NORFLASH_SECTOR_ZISE (4096) /**< NOR flash sector size (bytes) */
Expand Down
6 changes: 3 additions & 3 deletions components/little_flash/luat_little_flash_lfs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ static int lf_block_device_read(const struct lfs_config *cfg, lfs_block_t block,
little_flash_t* flash = (little_flash_t*)cfg->context;
int ret = little_flash_read(flash, lf_offset + block * flash->chip_info.erase_size + off, buffer, size);
// LLOGD("lf_block_device_read ret %d", ret);
return ret;
return LFS_ERR_OK;
}

static int lf_block_device_prog(const struct lfs_config *cfg, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) {
little_flash_t* flash = (little_flash_t*)cfg->context;
int ret = little_flash_write(flash, lf_offset + block * flash->chip_info.erase_size + off, buffer, size);
// LLOGD("lf_block_device_prog ret %d", ret);
return ret;
return LFS_ERR_OK;
}

static int lf_block_device_erase(const struct lfs_config *cfg, lfs_block_t block) {
little_flash_t* flash = (little_flash_t*)cfg->context;
int ret = little_flash_erase(flash, lf_offset + block * flash->chip_info.erase_size, flash->chip_info.erase_size);
// LLOGD("lf_block_device_erase ret %d", ret);
return ret;
return LFS_ERR_OK;
}

static int lf_block_device_sync(const struct lfs_config *cfg) {
Expand Down
20 changes: 11 additions & 9 deletions components/little_flash/src/little_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static lf_err_t little_flash_reset(little_flash_t *lf){
result |= little_flash_write_status(lf,LF_NANDFLASH_STATUS_REGISTER2,(1 << 4) | (1 << 3));
}
if(lf->chip_info.retry_times==0) lf->chip_info.retry_times = LF_RETRY_TIMES;
lf->wait_10us(5);
return result;
}

Expand Down Expand Up @@ -410,8 +410,7 @@ lf_err_t little_flash_erase(const little_flash_t *lf, uint32_t addr, uint32_t le
cmd_data[1] = page_addr >> 16;
cmd_data[2] = page_addr >> 8;
cmd_data[3] = page_addr;
result |= lf->spi.transfer(lf,cmd_data, 4,LF_NULL,0);
if(result) goto error;
lf->spi.transfer(lf,cmd_data, 4,LF_NULL,0);
lf->wait_10us(200);
result |= little_flash_cheak_erase(lf);
if(result) goto error;
Expand Down Expand Up @@ -454,11 +453,13 @@ lf_err_t little_flash_write(const little_flash_t *lf, uint32_t addr, const uint8
lf->lock(lf);
}

result = little_flash_write_enabled(lf, LF_ENABLE);
if(result) goto error;
if(little_flash_write_enabled(lf, LF_ENABLE)){
goto error;
}
while (len){
result |= little_flash_wait_busy(lf);
if(result) goto error;
if (little_flash_wait_busy(lf)){
goto error;
}

if (lf->chip_info.type==LF_DRIVER_NOR_FLASH){
cmd_data[0] = LF_CMD_PROG_DATA;
Expand Down Expand Up @@ -533,7 +534,6 @@ lf_err_t little_flash_write(const little_flash_t *lf, uint32_t addr, const uint8
addr += lf->chip_info.prog_size;
}
}

little_flash_wait_busy(lf);
cmd_data[0] = LF_NANDFLASH_PAGE_PROG_EXEC;
cmd_data[1] = page_addr >> 16;
Expand Down Expand Up @@ -579,7 +579,9 @@ lf_err_t little_flash_read(const little_flash_t *lf, uint32_t addr, uint8_t *dat
}
}else{
while (len){
little_flash_wait_busy(lf);
if (little_flash_wait_busy(lf)){
goto error;
}
uint32_t page_addr = addr/lf->chip_info.prog_size;
uint16_t column_addr = addr%lf->chip_info.prog_size;

Expand Down

0 comments on commit 5dd7ee8

Please sign in to comment.