Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
LittleFsStorageManager.cpp File Reference
#include "storage/LittleFsStorageManager.h"
#include "storage/LittleFsFileReader.h"
#include <hardware/flash.h>
#include <hardware/sync.h>
#include <pico/multicore.h>
#include <hardware/regs/addressmap.h>
#include <cstring>
#include <iostream>
#include <FreeRTOS.h>
#include <semphr.h>
#include <pico/flash.h>
#include "utility/utility.h"
#include "framework_config.h"
#include "DebugTrace.h"
+ Include dependency graph for LittleFsStorageManager.cpp:

Go to the source code of this file.

Classes

struct  FlashProgParams
 
struct  FlashEraseParams
 

Functions

static void __not_in_flash_func() flash_prog_callback (void *p)
 
static int __not_in_flash_func() lfs_prog_multicore (const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size)
 
static void __not_in_flash_func() flash_erase_callback (void *p)
 
static int lfs_erase_cb_flashsafe (const struct lfs_config *c, lfs_block_t block)
 

Variables

uint8_t __flash_lfs_start
 
uint8_t __flash_lfs_end
 

Function Documentation

◆ flash_erase_callback()

static void __not_in_flash_func() flash_erase_callback ( void *  p)
static

Definition at line 136 of file LittleFsStorageManager.cpp.

137{
138 auto *params = static_cast<FlashEraseParams *>(p);
139 flash_range_erase(params->addr, params->size);
140}

Referenced by lfs_erase_cb_flashsafe().

+ Here is the caller graph for this function:

◆ flash_prog_callback()

static void __not_in_flash_func() flash_prog_callback ( void *  p)
static

Definition at line 80 of file LittleFsStorageManager.cpp.

81{
82 auto *params = static_cast<FlashProgParams *>(p);
83 flash_range_program(params->addr, params->data, params->size);
84}

Referenced by lfs_prog_multicore().

+ Here is the caller graph for this function:

◆ lfs_erase_cb_flashsafe()

static int lfs_erase_cb_flashsafe ( const struct lfs_config *  c,
lfs_block_t  block 
)
static

Definition at line 142 of file LittleFsStorageManager.cpp.

143{
144 auto *self = static_cast<LittleFsStorageManager *>(c->context);
145 uintptr_t addr = self->getFlashBase() + block * c->block_size;
146
147 FlashEraseParams eraseParams = {
148 .addr = addr - XIP_BASE,
149 .size = c->block_size};
150 int result = flash_safe_execute(flash_erase_callback, &eraseParams, 1000);
151 return (result == PICO_OK) ? 0 : -1;
152}
static void __not_in_flash_func() flash_erase_callback(void *p)
A LittleFS-based implementation of StorageManager, storing files in flash memory.
uintptr_t getFlashBase() const
get Flash base address

References FlashEraseParams::addr, flash_erase_callback(), and LittleFsStorageManager::getFlashBase().

Referenced by LittleFsStorageManager::lfs_erase_cb_multicore().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lfs_prog_multicore()

static int __not_in_flash_func() lfs_prog_multicore ( const struct lfs_config *  c,
lfs_block_t  block,
lfs_off_t  off,
const void *  buffer,
lfs_size_t  size 
)
static

Definition at line 86 of file LittleFsStorageManager.cpp.

91{
92 auto *self = static_cast<LittleFsStorageManager *>(c->context);
93 uintptr_t addr = self->getFlashBase() + block * c->block_size + off;
94
95 FlashProgParams params = {
96 .addr = addr - XIP_BASE,
97 .data = static_cast<const uint8_t *>(buffer),
98 .size = size};
99 int result = flash_safe_execute(flash_prog_callback, &params, 1000);
100 return (result == PICO_OK) ? 0 : -1;
101}
static void __not_in_flash_func() flash_prog_callback(void *p)

References FlashProgParams::addr, flash_prog_callback(), and LittleFsStorageManager::getFlashBase().

Referenced by LittleFsStorageManager::lfs_prog_cb_multicore().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ __flash_lfs_end

uint8_t __flash_lfs_end
extern

Definition at line 166 of file LittleFsStorageManager.cpp.

Referenced by LittleFsStorageManager::configure().

◆ __flash_lfs_start

uint8_t __flash_lfs_start
extern

Definition at line 165 of file LittleFsStorageManager.cpp.

Referenced by LittleFsStorageManager::configure().