From 8d57d8ff761fb2f025cdd3892d08689890b14719 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 5 May 2013 21:23:35 +0200 Subject: [PATCH] Internal flash settings for F1 Conflicts: flight/pios/stm32f10x/pios_flash_internal.c --- .../link_STM32103CB_OPLINKMINI_memory.ld | 4 ++-- .../targets/boards/oplinkmini/board-info.mk | 19 +++++++++++++-- .../targets/boards/oplinkmini/board_hw_defs.c | 23 +++++++++++++++++++ .../boards/oplinkmini/firmware/Makefile | 3 +++ .../oplinkmini/firmware/inc/pios_config.h | 5 ++-- .../boards/oplinkmini/firmware/pios_board.c | 9 ++++++++ 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/flight/pios/stm32f10x/link_STM32103CB_OPLINKMINI_memory.ld b/flight/pios/stm32f10x/link_STM32103CB_OPLINKMINI_memory.ld index 80b110bba..1429d5637 100644 --- a/flight/pios/stm32f10x/link_STM32103CB_OPLINKMINI_memory.ld +++ b/flight/pios/stm32f10x/link_STM32103CB_OPLINKMINI_memory.ld @@ -2,7 +2,7 @@ MEMORY { BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x03000 - 0x00080 BD_INFO (r) : ORIGIN = 0x08003000 - 0x80, LENGTH = 0x00080 - FLASH (rx) : ORIGIN = 0x08003000, LENGTH = 0x20000 - 0x03000 - 0x00400 - EE_FLASH (rw) : ORIGIN = 0x0801FC00, LENGTH = 0x00400 + FLASH (rx) : ORIGIN = 0x08003000, LENGTH = 0x20000 - 0x03000 - 0x04000 + EE_FLASH (rw) : ORIGIN = 0x0801C000, LENGTH = 0x04000 SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x05000 } diff --git a/flight/targets/boards/oplinkmini/board-info.mk b/flight/targets/boards/oplinkmini/board-info.mk index b526c5fa1..d106c63f1 100644 --- a/flight/targets/boards/oplinkmini/board-info.mk +++ b/flight/targets/boards/oplinkmini/board-info.mk @@ -12,12 +12,27 @@ MODEL_SUFFIX := _PX OPENOCD_JTAG_CONFIG := stlink-v2.cfg OPENOCD_CONFIG := stm32f1x.stlink.cfg +# Flash memory map for OPLM: +# Sector start size use +# 0 0x0800 0000 1k BL +# 1 0x0800 0400 1k BL +# .. .. +# 10 0x0800 2C00 1k BL +# 11 0x0800 3000 1k FW +# 12 0x0800 1000 1k FW +# .. .. +# 125 0x0801 F400 1k FW +# 126 0x0801 F800 1k EE +# 127 0x0801 FC00 1k EE + + # Note: These must match the values in link_$(BOARD)_memory.ld BL_BANK_BASE := 0x08000000 # Start of bootloader flash BL_BANK_SIZE := 0x00003000 # Should include BD_INFO region FW_BANK_BASE := 0x08003000 # Start of firmware flash FW_BANK_SIZE := 0x0001CC00 # Should include FW_DESC_SIZE -EE_BANK_BASE := 0x0801FC00 # EEPROM storage area -EE_BANK_SIZE := 0x00000400 # Size of EEPROM storage area +FW_BANK_SIZE := 0x00019000 # Should include FW_DESC_SIZE +EE_BANK_BASE := 0x0801C000 # EEPROM storage area +EE_BANK_SIZE := 0x00004000 # Size of EEPROM storage area FW_DESC_SIZE := 0x00000064 diff --git a/flight/targets/boards/oplinkmini/board_hw_defs.c b/flight/targets/boards/oplinkmini/board_hw_defs.c index ad8b4eacc..55399732d 100644 --- a/flight/targets/boards/oplinkmini/board_hw_defs.c +++ b/flight/targets/boards/oplinkmini/board_hw_defs.c @@ -99,6 +99,29 @@ const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (__attribute__((unused) #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, /* 2K bytes (2x1KB sectors) */ + .arena_size = 0x00002000, /* 4 * slot size = 1K bytes = 1 sector */ + .slot_size = 0x00000100, /* 256 bytes */ + + .start_offset = EE_BANK_BASE, /* start after the bootloader */ + .sector_size = 0x00000400, /* 1K bytes */ + .page_size = 0x00000400, /* 1K bytes */ +}; + +#include "pios_flash.h" + +#endif /* PIOS_INCLUDE_FLASH */ + + #if defined(PIOS_INCLUDE_SPI) #include diff --git a/flight/targets/boards/oplinkmini/firmware/Makefile b/flight/targets/boards/oplinkmini/firmware/Makefile index ffbbe8213..78fe7efb7 100644 --- a/flight/targets/boards/oplinkmini/firmware/Makefile +++ b/flight/targets/boards/oplinkmini/firmware/Makefile @@ -56,6 +56,9 @@ else SRC += $(OPTESTS)/$(TESTAPP).c endif +CDEFS += -DEE_BANK_BASE=$(EE_BANK_BASE) +CDEFS += -DEE_BANK_SIZE=$(EE_BANK_SIZE) + # Optional component libraries include $(FLIGHTLIB)/rscode/library.mk diff --git a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h index 6d149e4f1..8e58eda34 100644 --- a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h +++ b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h @@ -105,8 +105,9 @@ /* #define PIOS_OVERO_SPI */ /* #define PIOS_INCLUDE_SDCARD */ /* #define LOG_FILENAME "startup.log" */ -/* #define PIOS_INCLUDE_FLASH */ -/* #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS */ +#define PIOS_INCLUDE_FLASH +#define PIOS_INCLUDE_FLASH_INTERNAL +#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS /* #define FLASH_FREERTOS */ #define PIOS_INCLUDE_FLASH_EEPROM diff --git a/flight/targets/boards/oplinkmini/firmware/pios_board.c b/flight/targets/boards/oplinkmini/firmware/pios_board.c index ae2668a32..26675e7f5 100644 --- a/flight/targets/boards/oplinkmini/firmware/pios_board.c +++ b/flight/targets/boards/oplinkmini/firmware/pios_board.c @@ -82,6 +82,15 @@ void PIOS_Board_Init(void) { /* Delay system */ PIOS_DELAY_Init(); +#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 */ EventDispatcherInitialize(); UAVObjInitialize();