1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

Flashfs: Separate out the sector sizes and magic values into a runtime

configurable structure.  This makes it easier to deal with different chip
layouts.
This commit is contained in:
James Cotton 2012-01-24 23:56:36 -06:00
parent 1971ba30dc
commit a02cad6f52
5 changed files with 36 additions and 12 deletions

View File

@ -147,6 +147,13 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = {
};
#endif /* PIOS_INCLUDE_L3GD20 */
struct flashfs_cfg flashfs_w25x_cfg = {
.table_magic = 0x85FB3C35,
.obj_magic = 0x3015AE71,
.obj_table_start = 0x00000010,
.obj_table_end = 0x00001000,
.sector_size = 0x00001000,
};
#include <pios_board_info.h>
/**
@ -196,7 +203,7 @@ void PIOS_Board_Init(void) {
#endif
PIOS_Flash_W25X_Init(pios_spi_flash_accel_id, 1);
PIOS_FLASHFS_Init();
PIOS_FLASHFS_Init(&flashfs_w25x_cfg);
/* Initialize UAVObject libraries */
EventDispatcherInitialize();

View File

@ -56,20 +56,22 @@ struct fileHeader {
} __attribute__((packed));
#define OBJECT_TABLE_MAGIC 0x85FB3C35
#define OBJ_MAGIC 0x3015AE71
#define OBJECT_TABLE_START 0x00000010
#define OBJECT_TABLE_END 0x00001000
#define SECTOR_SIZE 0x00001000
#define OBJECT_TABLE_MAGIC cfg->table_magic
#define OBJ_MAGIC cfg->obj_magic
#define OBJECT_TABLE_START cfg->obj_table_start
#define OBJECT_TABLE_END cfg->obj_table_end
#define SECTOR_SIZE cfg->sector_size
#define MAX_BADMAGIC 1000
static const struct flashfs_cfg * cfg;
/**
* @brief Initialize the flash object setting FS
* @return 0 if success, -1 if failure
*/
int32_t PIOS_FLASHFS_Init()
int32_t PIOS_FLASHFS_Init(const struct flashfs_cfg * new_cfg)
{
cfg = new_cfg;
// Check for valid object table or create one
uint32_t object_table_magic;
uint32_t magic_fail_count = 0;

View File

@ -31,7 +31,15 @@
#include "openpilot.h"
#include "uavobjectmanager.h"
int32_t PIOS_FLASHFS_Init();
struct flashfs_cfg {
uint32_t table_magic;
uint32_t obj_magic;
uint32_t obj_table_start;
uint32_t obj_table_end;
uint32_t sector_size;
};
int32_t PIOS_FLASHFS_Init(const struct flashfs_cfg * cfg);
int32_t PIOS_FLASHFS_Format();
int32_t PIOS_FLASHFS_ObjSave(UAVObjHandle obj, uint16_t instId, uint8_t * data);
int32_t PIOS_FLASHFS_ObjLoad(UAVObjHandle obj, uint16_t instId, uint8_t * data);

View File

@ -126,7 +126,6 @@
65904E56146128A500FD9482 /* pios_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_config.h; sourceTree = "<group>"; };
65904E58146128A500FD9482 /* pios_board.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_board.c; sourceTree = "<group>"; };
65904E59146128A500FD9482 /* revolution.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = revolution.c; sourceTree = "<group>"; };
65904E5B146128A500FD9482 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = test.c; sourceTree = "<group>"; };
65904E5C146128A500FD9482 /* UAVObjects.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; path = UAVObjects.inc; sourceTree = "<group>"; };
65904E5F14613B6100FD9482 /* pios_i2c_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_i2c_config.h; sourceTree = "<group>"; };
65904E6014613B6100FD9482 /* pios_usart_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usart_config.h; sourceTree = "<group>"; };
@ -3876,7 +3875,6 @@
children = (
65904E4B146128A500FD9482 /* Makefile */,
65904E4C146128A500FD9482 /* System */,
65904E5B146128A500FD9482 /* test.c */,
65904E5C146128A500FD9482 /* UAVObjects.inc */,
);
name = Revolution;

View File

@ -1581,6 +1581,15 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = {
};
#endif /* PIOS_INCLUDE_L3GD20 */
struct flashfs_cfg flashfs_m25p_cfg = {
.table_magic = 0x85FB3C35,
.obj_magic = 0x3015AE71,
.obj_table_start = 0x00000010,
.obj_table_end = 0x00010000,
.sector_size = 0x00010000,
};
/**
* PIOS_Board_Init()
* initializes all the core subsystems on this specific hardware
@ -1614,7 +1623,7 @@ void PIOS_Board_Init(void) {
#else
PIOS_Flash_W25X_Init(pios_spi_accel_id, 1);
#endif
PIOS_FLASHFS_Init();
PIOS_FLASHFS_Init(&flashfs_m25p_cfg);
/* Initialize UAVObject libraries */
EventDispatcherInitialize();