mirror of https://github.com/rusefi/ChibiOS.git
Added integration of LittleFS on top of our flash infrastructure.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15415 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
6b6813ec90
commit
5293cb6eba
|
@ -61,7 +61,6 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void lfsInit(void);
|
||||
int __lfs_read(const struct lfs_config *c, lfs_block_t block,
|
||||
lfs_off_t off, void *buffer, lfs_size_t size);
|
||||
int __lfs_prog(const struct lfs_config *c, lfs_block_t block,
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** Next ***
|
||||
- NEW: Added integration of LittleFS on top of our flash infrastructure.
|
||||
- NEW: Added a new MEM_IS_VALID_FUNCTION() macro to RT and NIL.
|
||||
- NEW: Improved HAL flash interface with mutual exclusion methods, improved
|
||||
EFL and SNOR drivers to use it.
|
||||
|
|
|
@ -76,6 +76,11 @@
|
|||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>littlefs</name>
|
||||
<type>2</type>
|
||||
<locationURI>CHIBIOS/ext/littlefs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>os</name>
|
||||
<type>2</type>
|
||||
|
|
|
@ -18,17 +18,54 @@
|
|||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "lfs.h"
|
||||
#include "lfs_hal.h"
|
||||
|
||||
#include "hal_serial_nor.h"
|
||||
|
||||
#include "portab.h"
|
||||
|
||||
const SNORConfig snorcfg1 = {
|
||||
static const SNORConfig snorcfg1 = {
|
||||
.busp = &PORTAB_WSPI1,
|
||||
.buscfg = &WSPIcfg1
|
||||
};
|
||||
|
||||
SNORDriver snor1;
|
||||
static SNORDriver snor1;
|
||||
|
||||
static uint8_t __lfs_read_buffer[16];
|
||||
static uint8_t __lfs_prog_buffer[16];
|
||||
static uint8_t __lfs_lookahead_buffer[16];
|
||||
|
||||
static const struct lfs_config lfscfg = {
|
||||
/* Link to the flash device driver.*/
|
||||
.context = &snor1,
|
||||
|
||||
/* Block device operations.*/
|
||||
.read = __lfs_read,
|
||||
.prog = __lfs_prog,
|
||||
.erase = __lfs_erase,
|
||||
.sync = __lfs_sync,
|
||||
.lock = __lfs_lock,
|
||||
.unlock = __lfs_unlock,
|
||||
|
||||
/* Block device configuration.*/
|
||||
.read_size = 16,
|
||||
.prog_size = 16,
|
||||
.block_size = 4096,
|
||||
.block_count = 128,
|
||||
.block_cycles = 500,
|
||||
.cache_size = 16,
|
||||
.lookahead_size = 16,
|
||||
.read_buffer = __lfs_read_buffer,
|
||||
.prog_buffer = __lfs_prog_buffer,
|
||||
.lookahead_buffer = __lfs_lookahead_buffer,
|
||||
.name_max = 0,
|
||||
.file_max = 0,
|
||||
.attr_max = 0,
|
||||
.metadata_max = 0
|
||||
};
|
||||
|
||||
static lfs_t lfs;
|
||||
|
||||
/*
|
||||
* LED blinker thread, times are in milliseconds.
|
||||
|
@ -50,6 +87,7 @@ static THD_FUNCTION(Thread1, arg) {
|
|||
* Application entry point.
|
||||
*/
|
||||
int main(void) {
|
||||
int err;
|
||||
|
||||
/*
|
||||
* System initializations.
|
||||
|
@ -70,19 +108,23 @@ int main(void) {
|
|||
/* Initializing and starting snor1 driver.*/
|
||||
snorObjectInit(&snor1);
|
||||
snorStart(&snor1, &snorcfg1);
|
||||
#if 1
|
||||
/* Testing memory mapped mode.*/
|
||||
{
|
||||
uint8_t *addr;
|
||||
|
||||
snorMemoryMap(&snor1, &addr);
|
||||
chThdSleepMilliseconds(50);
|
||||
snorMemoryUnmap(&snor1);
|
||||
}
|
||||
#endif
|
||||
/* Creates the blinker thread.*/
|
||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||
|
||||
/* Mounting the file system, if it fails then formatting.*/
|
||||
err = lfs_mount(&lfs, &lfscfg);
|
||||
if (err < 0) {
|
||||
err = lfs_format(&lfs, &lfscfg);
|
||||
if (err < 0) {
|
||||
chSysHalt("LFS format failed");
|
||||
}
|
||||
err = lfs_mount(&lfs, &lfscfg);
|
||||
if (err < 0) {
|
||||
chSysHalt("LFS mount failed");
|
||||
}
|
||||
}
|
||||
|
||||
/* Normal main() thread activity, in this demo it does nothing.*/
|
||||
while (true) {
|
||||
if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
|
||||
|
|
|
@ -55,7 +55,7 @@ endif
|
|||
# Stack size to be allocated to the Cortex-M process stack. This stack is
|
||||
# the stack used by the main() thread.
|
||||
ifeq ($(USE_PROCESS_STACKSIZE),)
|
||||
USE_PROCESS_STACKSIZE = 0x400
|
||||
USE_PROCESS_STACKSIZE = 0x800
|
||||
endif
|
||||
|
||||
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
||||
|
|
Loading…
Reference in New Issue