```
void spi_flash_littlefs_init(void) {
// mount the filesystem
int err = lfs_mount(&g_lfs, &cfg);
// reformat if we can't mount the filesystem
// this should only happen on the first boot
if(err) {
spi_flash_erase_chip();
err = lfs_format(&g_lfs, &cfg);
err = lfs_mount(&g_lfs, &cfg);
}
NRF_LOG_INFO("spi flash littlefs done");
}
```
* **测试**
```
void spi_flash_littlefs_test(void) {
// read current count
int i;
uint32_t buf_len = 0;
uint8_t test_buf[1024] = {'\0'};