Open e135193 opened 6 years ago
Hi, I have done it on STM32f103. the code shows below:
int fs_flash_read(const struct lfs_config *cfg, lfs_block_t block,
lfs_off_t off, void *buffer, lfs_size_t size)
{
assert(off % cfg->read_size == 0);
assert(size % cfg->read_size == 0);
assert(block < cfg->block_count);
uint32_t addr = SPI_FLASH_FS_BASE_ADDR + block*4096 + off;
int ret = lsspi_flash_read(buffer, addr, size);
if (ret == -1)
{
return -1;
}
else
{
return 0;
}
}
int fs_flash_prog(const struct lfs_config *cfg, lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size)
{
assert(off % cfg->prog_size == 0);
assert(size % cfg->prog_size == 0);
assert(block < cfg->block_count);
uint32_t addr = SPI_FLASH_FS_BASE_ADDR + block*4096 + off;
int ret = lsspi_flash_write((u8*)buffer, addr, size);
if (ret == -1)
{
return -1;
}
else
{
return 0;
}
}
int fs_flash_erase(const struct lfs_config *cfg, lfs_block_t block)
{
assert(block < cfg->block_count);
int block_addr = SPI_FLASH_FS_BLOCK_OFF + block;
int ret = lsspi_flash_erase_sector(block_addr);
if (ret == -1)
{
return -1;
}
else
{
return 0;
}
}
int fs_flash_sync(const struct lfs_config *c)
{
return 0;
}
Hello, I can not see functions to read via SPI hardware.
HAL_SPI_Transmit(); HAL_SPI_Receive();
Could you please share the full source code to my email address; enkavak@hotmail.com
stm32 has supported the hal driver.
Hi @e135193, you'll need to provide the driver to communicate to the W25Q16JV over the STM32 SPI bus. This code is different for each SPI driver.
It looks like this may be provided by the "lsspi" functions in @fzhenyu's example, but I'm unfamiliar with the STM libaries.
In Mbed OS this is provided by the SPIFBlockdevice class. It's in C++ but may help as a starting point: https://github.com/ARMmbed/spif-driver/blob/master/SPIFBlockDevice.cpp
Could you please send the source code for block device driver based HAL-CUBE STM32 + W25 manymix@yahoo.com.
@fzhenyu . You have mentioned 4096 (block*4096). Is that your Block size. By seeing this It seems you are writing to and reading from absolute addresses , is that right?. can you provide your config structure for LFS.
I would like to use littlefs on my STM32 MCU with W25N01 flash.
Could someone provide me or send me a code already made that serves as a reference?
Hi @joserp93 I'm in the same situation as you, have you succesfully use littlefs with w25n01?
Hello,
Best Regards