mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Moved OSD settings from SDCard to mcu internal flash memory
This commit is contained in:
parent
e43e5c5028
commit
8698bcfb84
@ -103,9 +103,11 @@
|
|||||||
/* #define PIOS_INCLUDE_OVERO */
|
/* #define PIOS_INCLUDE_OVERO */
|
||||||
/* #define PIOS_OVERO_SPI */
|
/* #define PIOS_OVERO_SPI */
|
||||||
#define PIOS_INCLUDE_SDCARD
|
#define PIOS_INCLUDE_SDCARD
|
||||||
|
/* #define PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
#define LOG_FILENAME "startup.log"
|
#define LOG_FILENAME "startup.log"
|
||||||
/* #define PIOS_INCLUDE_FLASH */
|
#define PIOS_INCLUDE_FLASH
|
||||||
/* #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS */
|
#define PIOS_INCLUDE_FLASH_INTERNAL
|
||||||
|
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||||
/* #define FLASH_FREERTOS */
|
/* #define FLASH_FREERTOS */
|
||||||
/* #define PIOS_INCLUDE_FLASH_EEPROM */
|
/* #define PIOS_INCLUDE_FLASH_EEPROM */
|
||||||
|
|
||||||
|
@ -161,6 +161,16 @@ void PIOS_Board_Init(void) {
|
|||||||
#endif
|
#endif
|
||||||
#endif /* PIOS_INCLUDE_SPI */
|
#endif /* PIOS_INCLUDE_SPI */
|
||||||
|
|
||||||
|
#ifdef PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||||
|
uintptr_t flash_id;
|
||||||
|
uintptr_t fs_id;
|
||||||
|
PIOS_Flash_Internal_Init(&flash_id, &flash_internal_cfg);
|
||||||
|
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_internal_cfg, &pios_internal_flash_driver, flash_id);
|
||||||
|
#elif !defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
|
#error No setting storage specified. (define PIOS_USE_SETTINGS_ON_SDCARD or INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Initialize UAVObject libraries */
|
/* Initialize UAVObject libraries */
|
||||||
EventDispatcherInitialize();
|
EventDispatcherInitialize();
|
||||||
UAVObjInitialize();
|
UAVObjInitialize();
|
||||||
|
@ -158,7 +158,11 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
|||||||
static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
||||||
UAVObjEventCallback cb);
|
UAVObjEventCallback cb);
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD) && defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||||
|
#error Both PIOS_USE_SETTINGS_ON_SDCARD and PIOS_INCLUDE_FLASH_SECTOR_SETTINGS. Only one settings storage allowed.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
static void objectFilename(UAVObjHandle obj_handle, uint8_t * filename);
|
static void objectFilename(UAVObjHandle obj_handle, uint8_t * filename);
|
||||||
static void customSPrintf(uint8_t * buffer, uint8_t * format, ...);
|
static void customSPrintf(uint8_t * buffer, uint8_t * format, ...);
|
||||||
#endif
|
#endif
|
||||||
@ -668,7 +672,7 @@ unlock_exit:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
/**
|
/**
|
||||||
* Save the data of the specified object instance to the file system (SD card).
|
* Save the data of the specified object instance to the file system (SD card).
|
||||||
* The object will be appended and the file will not be closed.
|
* The object will be appended and the file will not be closed.
|
||||||
@ -743,7 +747,7 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj_handle, uint16_t instId,
|
|||||||
xSemaphoreGiveRecursive(mutex);
|
xSemaphoreGiveRecursive(mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the data of the specified object to the file system (SD card).
|
* Save the data of the specified object to the file system (SD card).
|
||||||
@ -779,7 +783,7 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
FILEINFO file;
|
FILEINFO file;
|
||||||
uint8_t filename[14];
|
uint8_t filename[14];
|
||||||
|
|
||||||
@ -807,11 +811,11 @@ int32_t UAVObjSave(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
// Done, close file and unlock
|
// Done, close file and unlock
|
||||||
PIOS_FCLOSE(file);
|
PIOS_FCLOSE(file);
|
||||||
xSemaphoreGiveRecursive(mutex);
|
xSemaphoreGiveRecursive(mutex);
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
/**
|
/**
|
||||||
* Load an object from the file system (SD card).
|
* Load an object from the file system (SD card).
|
||||||
* @param[in] file File to read from
|
* @param[in] file File to read from
|
||||||
@ -899,7 +903,7 @@ UAVObjHandle UAVObjLoadFromFile(FILEINFO * file)
|
|||||||
xSemaphoreGiveRecursive(mutex);
|
xSemaphoreGiveRecursive(mutex);
|
||||||
return obj_handle;
|
return obj_handle;
|
||||||
}
|
}
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load an object from the file system (SD card).
|
* Load an object from the file system (SD card).
|
||||||
@ -939,7 +943,7 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
FILEINFO file;
|
FILEINFO file;
|
||||||
UAVObjHandle loadedObj;
|
UAVObjHandle loadedObj;
|
||||||
uint8_t filename[14];
|
uint8_t filename[14];
|
||||||
@ -975,7 +979,7 @@ int32_t UAVObjLoad(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
// Done, close file and unlock
|
// Done, close file and unlock
|
||||||
PIOS_FCLOSE(file);
|
PIOS_FCLOSE(file);
|
||||||
xSemaphoreGiveRecursive(mutex);
|
xSemaphoreGiveRecursive(mutex);
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,7 +995,7 @@ int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
|
||||||
PIOS_FLASHFS_ObjDelete(0, UAVObjGetID(obj_handle), instId);
|
PIOS_FLASHFS_ObjDelete(0, UAVObjGetID(obj_handle), instId);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
uint8_t filename[14];
|
uint8_t filename[14];
|
||||||
|
|
||||||
// Check for file system availability
|
// Check for file system availability
|
||||||
@ -1009,7 +1013,7 @@ int32_t UAVObjDelete(UAVObjHandle obj_handle, uint16_t instId)
|
|||||||
|
|
||||||
// Done
|
// Done
|
||||||
xSemaphoreGiveRecursive(mutex);
|
xSemaphoreGiveRecursive(mutex);
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1995,7 +1999,7 @@ static int32_t disconnectObj(UAVObjHandle obj_handle, xQueueHandle queue,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SDCARD)
|
#if defined(PIOS_USE_SETTINGS_ON_SDCARD)
|
||||||
/**
|
/**
|
||||||
* Wrapper for the sprintf function
|
* Wrapper for the sprintf function
|
||||||
*/
|
*/
|
||||||
@ -2013,4 +2017,4 @@ static void objectFilename(UAVObjHandle obj_handle, uint8_t * filename)
|
|||||||
{
|
{
|
||||||
customSPrintf(filename, (uint8_t *) "%X.obj", UAVObjGetID(obj_handle));
|
customSPrintf(filename, (uint8_t *) "%X.obj", UAVObjGetID(obj_handle));
|
||||||
}
|
}
|
||||||
#endif /* PIOS_INCLUDE_SDCARD */
|
#endif /* PIOS_USE_SETTINGS_ON_SDCARD */
|
||||||
|
@ -71,6 +71,30 @@ const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revisio
|
|||||||
|
|
||||||
#endif /* PIOS_INCLUDE_LED */
|
#endif /* PIOS_INCLUDE_LED */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(PIOS_INCLUDE_FLASH)
|
||||||
|
#include "pios_flashfs_logfs_priv.h"
|
||||||
|
#include "pios_flash_internal_priv.h"
|
||||||
|
|
||||||
|
static const struct pios_flash_internal_cfg flash_internal_cfg = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct flashfs_logfs_cfg flashfs_internal_cfg = {
|
||||||
|
.fs_magic = 0x99abcfef,
|
||||||
|
.total_fs_size = EE_BANK_SIZE, /* 32K bytes (2x16KB sectors) */
|
||||||
|
.arena_size = 0x00004000, /* 64 * slot size = 16K bytes = 1 sector */
|
||||||
|
.slot_size = 0x00000100, /* 256 bytes */
|
||||||
|
|
||||||
|
.start_offset = EE_BANK_BASE, /* start after the bootloader */
|
||||||
|
.sector_size = 0x00004000, /* 16K bytes */
|
||||||
|
.page_size = 0x00004000, /* 16K bytes */
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "pios_flash.h"
|
||||||
|
|
||||||
|
#endif /* PIOS_INCLUDE_FLASH */
|
||||||
|
|
||||||
|
|
||||||
#if defined(PIOS_INCLUDE_SPI)
|
#if defined(PIOS_INCLUDE_SPI)
|
||||||
|
|
||||||
#include <pios_spi_priv.h>
|
#include <pios_spi_priv.h>
|
||||||
|
@ -13,15 +13,36 @@ OPENOCD_JTAG_CONFIG := stlink-v2.cfg
|
|||||||
OPENOCD_CONFIG := stm32f4xx.stlink.cfg
|
OPENOCD_CONFIG := stm32f4xx.stlink.cfg
|
||||||
#OPENOCD_CONFIG := stm32f4xx.cfg
|
#OPENOCD_CONFIG := stm32f4xx.cfg
|
||||||
|
|
||||||
|
# Flash memory map for OSD:
|
||||||
|
# Sector start size use
|
||||||
|
# 0 0x0800 0000 16k BL
|
||||||
|
# 1 0x0800 4000 16k BL
|
||||||
|
# 2 0x0800 8000 16k EE
|
||||||
|
# 3 0x0800 C000 16k EE
|
||||||
|
# 4 0x0801 0000 64k Unused
|
||||||
|
# 5 0x0802 0000 128k FW
|
||||||
|
# 6 0x0804 0000 128k FW
|
||||||
|
# 7 0x0806 0000 128k FW
|
||||||
|
# 8 0x0808 0000 128k Unused
|
||||||
|
# .. ..
|
||||||
|
# 11 0x080E 0000 128k Unused
|
||||||
|
|
||||||
# Note: These must match the values in link_$(BOARD)_memory.ld
|
# Note: These must match the values in link_$(BOARD)_memory.ld
|
||||||
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
|
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
|
||||||
BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region
|
BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region
|
||||||
|
|
||||||
# Leave the remaining 16KB and 64KB sectors for other uses
|
|
||||||
|
# Leave the remaining 16KB for settings storage
|
||||||
|
|
||||||
|
EE_BANK_BASE := 0x08008000 # EEPROM storage area
|
||||||
|
EE_BANK_SIZE := 0x00008000 # Size of EEPROM storage area
|
||||||
|
|
||||||
|
# Leave the reamaining 64KB sectors for other uses
|
||||||
|
|
||||||
FW_BANK_BASE := 0x08020000 # Start of firmware flash
|
FW_BANK_BASE := 0x08020000 # Start of firmware flash
|
||||||
FW_BANK_SIZE := 0x00060000 # Should include FW_DESC_SIZE
|
FW_BANK_SIZE := 0x00060000 # Should include FW_DESC_SIZE
|
||||||
|
|
||||||
|
|
||||||
FW_DESC_SIZE := 0x00000064
|
FW_DESC_SIZE := 0x00000064
|
||||||
|
|
||||||
OSCILLATOR_FREQ := 8000000
|
OSCILLATOR_FREQ := 8000000
|
||||||
|
@ -112,9 +112,6 @@ BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
|
|||||||
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
|
||||||
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
|
||||||
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
|
||||||
BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
|
|
||||||
BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
|
|
||||||
BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
|
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
CDEFS += $(BLONLY_CDEFS)
|
CDEFS += $(BLONLY_CDEFS)
|
||||||
|
@ -95,6 +95,15 @@ endif
|
|||||||
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
#ADEFS = -DUSE_IRQ_ASM_WRAPPER
|
||||||
ADEFS = -D__ASSEMBLY__
|
ADEFS = -D__ASSEMBLY__
|
||||||
|
|
||||||
|
# Provide board-specific defines
|
||||||
|
CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
|
||||||
|
CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
|
||||||
|
CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
|
||||||
|
|
||||||
|
CDEFS += -DEE_BANK_BASE=$(EE_BANK_BASE)
|
||||||
|
CDEFS += -DEE_BANK_SIZE=$(EE_BANK_SIZE)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flag to set the C Standard level.
|
# Compiler flag to set the C Standard level.
|
||||||
# c89 - "ANSI" C
|
# c89 - "ANSI" C
|
||||||
# gnu89 - c89 plus GCC extensions
|
# gnu89 - c89 plus GCC extensions
|
||||||
@ -122,6 +131,7 @@ CFLAGS += -Wall
|
|||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||||
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
||||||
|
|
||||||
|
|
||||||
# FIXME: STM32F4xx library raises strict aliasing and const qualifier warnings
|
# FIXME: STM32F4xx library raises strict aliasing and const qualifier warnings
|
||||||
ifneq ($(MCU),cortex-m4)
|
ifneq ($(MCU),cortex-m4)
|
||||||
CFLAGS += -Werror
|
CFLAGS += -Werror
|
||||||
|
Loading…
Reference in New Issue
Block a user