diff --git a/flight/pios/common/pios_flash_eeprom.c b/flight/pios/common/pios_flash_eeprom.c index 0f344f648..6d64229df 100644 --- a/flight/pios/common/pios_flash_eeprom.c +++ b/flight/pios/common/pios_flash_eeprom.c @@ -132,11 +132,10 @@ int32_t PIOS_Flash_EEPROM_ReadSinglePage(struct flash_eeprom_dev *flash_dev, uin if (address > 0xFFFF) { return -2; } - uint16_t address16 = address & 0xFFFF; uint8_t mem_address[] = { - (address16 & 0xff00) >> 8, // MSB - (address16 & 0xFF) // LSB + (address & 0xFF00) >> 8, // MSB + (address & 0xFF) // LSB }; const struct pios_i2c_txn txn_list[] = { diff --git a/flight/pios/stm32f4xx/link_STM32F4xx_RN_bl_memory.ld b/flight/pios/stm32f4xx/link_STM32F4xx_RN_bl_memory.ld index 13f9a61b3..25061dbc2 100644 --- a/flight/pios/stm32f4xx/link_STM32F4xx_RN_bl_memory.ld +++ b/flight/pios/stm32f4xx/link_STM32F4xx_RN_bl_memory.ld @@ -2,8 +2,8 @@ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x008000 - 0x000080 BD_INFO (r) : ORIGIN = 0x08008000 - 0x80, LENGTH = 0x000080 - RSVD (rx) : ORIGIN = 0x08008000, LENGTH = 0x020000 - 0x008000 - FW (rx) : ORIGIN = 0x08010000, LENGTH = 0x060000 - SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x018000 + RSVD (rx) : ORIGIN = 0x08008000, LENGTH = 0x010000 - 0x008000 + FW (rx) : ORIGIN = 0x08010000, LENGTH = 0x030000 + SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x010000 } REGION_ALIAS("CCSRAM", SRAM); diff --git a/flight/pios/stm32f4xx/link_STM32F4xx_RN_fw_memory.ld b/flight/pios/stm32f4xx/link_STM32F4xx_RN_fw_memory.ld index 3b7116ac1..86adaa201 100644 --- a/flight/pios/stm32f4xx/link_STM32F4xx_RN_fw_memory.ld +++ b/flight/pios/stm32f4xx/link_STM32F4xx_RN_fw_memory.ld @@ -1,8 +1,9 @@ MEMORY { + BL (rx) : ORIGIN = 0x08000000, LENGTH = 0x008000 - 0x000080 BD_INFO (r) : ORIGIN = 0x08008000 - 0x80, LENGTH = 0x000080 - RSVD (rx) : ORIGIN = 0x08008000, LENGTH = 0x020000 - 0x008000 - FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 0x060000 - SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x018000 + RSVD (rx) : ORIGIN = 0x08008000, LENGTH = 0x010000 - 0x008000 + FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 0x030000 + SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x010000 } REGION_ALIAS("CCSRAM", SRAM); diff --git a/flight/targets/boards/revonano/board_hw_defs.c b/flight/targets/boards/revonano/board_hw_defs.c index 5f3f43b56..3d7f59b99 100644 --- a/flight/targets/boards/revonano/board_hw_defs.c +++ b/flight/targets/boards/revonano/board_hw_defs.c @@ -1312,3 +1312,25 @@ void PIOS_WS2811_irq_handler(void) PIOS_WS2811_DMA_irq_handler(); } #endif // PIOS_INCLUDE_WS2811 + + +#ifdef PIOS_INCLUDE_FLASH_OBJLIST +#include +struct flashfs_cfg flash_main_fs_cfg = { + .table_magic = 0x01020304, + .obj_magic = 0x19293949, + .obj_table_start = 0, + .obj_table_end = 0xC000, // spaces for 192 UAVOs + .sector_size = 0xFF, + .chip_size = 0x10000 +}; +#endif /* PIOS_INCLUDE_FLASH_OBJLIST */ + +#ifdef PIOS_INCLUDE_FLASH_EEPROM +#include +struct pios_flash_eeprom_cfg flash_main_chip_cfg = { + .page_len = 128, + .total_size = 0x10000, +}; +// .i2c_address = 0x50, +#endif /* PIOS_INCLUDE_FLASH_EEPROM */ diff --git a/flight/targets/boards/revonano/firmware/Makefile b/flight/targets/boards/revonano/firmware/Makefile index 12684caaf..32181d95c 100644 --- a/flight/targets/boards/revonano/firmware/Makefile +++ b/flight/targets/boards/revonano/firmware/Makefile @@ -38,8 +38,8 @@ MODULES += Receiver MODULES += Actuator MODULES += GPS MODULES += TxPID -MODULES += CameraStab -MODULES += Battery +#MODULES += CameraStab +#MODULES += Battery MODULES += FirmwareIAP #MODULES += PathPlanner #MODULES += PathFollower @@ -72,7 +72,10 @@ ifndef TESTAPP SRC += $(FLIGHTLIB)/instrumentation.c SRC += $(OPUAVTALK)/uavtalk.c SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/uavobjectpersistence.c SRC += $(OPUAVOBJ)/eventdispatcher.c + SRC += $(PIOSCOMMON)/pios_flash_eeprom.c + SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c #ifeq ($(DEBUG), YES) SRC += $(OPSYSTEM)/dcc_stdio.c diff --git a/flight/targets/boards/revonano/firmware/inc/FreeRTOSConfig.h b/flight/targets/boards/revonano/firmware/inc/FreeRTOSConfig.h index 36075f8bf..47f6749b1 100644 --- a/flight/targets/boards/revonano/firmware/inc/FreeRTOSConfig.h +++ b/flight/targets/boards/revonano/firmware/inc/FreeRTOSConfig.h @@ -26,7 +26,7 @@ #define configTICK_RATE_HZ ((portTickType)1000) #define configMAX_PRIORITIES ((unsigned portBASE_TYPE)5) #define configMINIMAL_STACK_SIZE ((unsigned short)512) -#define configTOTAL_HEAP_SIZE ((size_t)(70 * 1024)) // this is minimum, not total +#define configTOTAL_HEAP_SIZE ((size_t)(50 * 1024)) // this is minimum, not total #define configMAX_TASK_NAME_LEN (16) #define configUSE_PREEMPTION 1 diff --git a/flight/targets/boards/revonano/firmware/inc/pios_config.h b/flight/targets/boards/revonano/firmware/inc/pios_config.h index f7a375ed9..8f7e418e5 100644 --- a/flight/targets/boards/revonano/firmware/inc/pios_config.h +++ b/flight/targets/boards/revonano/firmware/inc/pios_config.h @@ -119,9 +119,11 @@ /* #define PIOS_OVERO_SPI */ /* #define PIOS_INCLUDE_SDCARD */ /* #define LOG_FILENAME "startup.log" */ -// #define PIOS_INCLUDE_FLASH +#define PIOS_INCLUDE_FLASH // #define PIOS_INCLUDE_FLASH_INTERNAL // #define PIOS_INCLUDE_FLASH_LOGFS_SETTINGS +#define PIOS_INCLUDE_FLASH_OBJLIST +#define PIOS_INCLUDE_FLASH_EEPROM #define FLASH_FREERTOS /* #define PIOS_INCLUDE_FLASH_EEPROM */ diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index 85f3c5fec..9deb74dcf 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -102,7 +102,6 @@ static const struct pios_ms5611_cfg pios_ms5611_cfg = { }; #endif /* PIOS_INCLUDE_MS5611 */ - /** * Configuration for the MPU6000 chip */ @@ -318,25 +317,24 @@ void PIOS_Board_Init(void) PIOS_DEBUG_Assert(0); } #endif -#if defined(PIOS_INCLUDE_FLASH) - /* Connect flash to the appropriate interface and configure it */ - -#if 0 - uintptr_t flash_id = 0; - - // Initialize the external USER flash - if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1)) { - PIOS_DEBUG_Assert(0); - } - - if (PIOS_FLASHFS_Logfs_Init(&pios_uavo_settings_fs_id, &flashfs_external_system_cfg, &pios_jedec_flash_driver, flash_id)) { - PIOS_DEBUG_Assert(0); - } - - if (PIOS_FLASHFS_Logfs_Init(&pios_user_fs_id, &flashfs_external_user_cfg, &pios_jedec_flash_driver, flash_id)) { +#ifdef PIOS_INCLUDE_I2C + if (PIOS_I2C_Init(&pios_i2c_pressure_adapter_id, &pios_i2c_pressure_adapter_cfg)) { PIOS_DEBUG_Assert(0); } #endif +#if defined(PIOS_INCLUDE_FLASH) + /* Connect flash to the appropriate interface and configure it */ + + uintptr_t flash_id = 0; + + // Initialize the external USER flash + if (PIOS_Flash_EEPROM_Init(&flash_id, &flash_main_chip_cfg, pios_i2c_pressure_adapter_id, 0x50)) { + PIOS_DEBUG_Assert(0); + } + + if (PIOS_FLASHFS_Init(&pios_uavo_settings_fs_id, &flash_main_fs_cfg, &pios_EEPROM_flash_driver, flash_id)) { + PIOS_DEBUG_Assert(0); + } #endif /* if defined(PIOS_INCLUDE_FLASH) */ @@ -729,10 +727,6 @@ void PIOS_Board_Init(void) }; GPIO_Init(GPIOA, &gpioA8); - if (PIOS_I2C_Init(&pios_i2c_pressure_adapter_id, &pios_i2c_pressure_adapter_cfg)) { - PIOS_DEBUG_Assert(0); - } - PIOS_DELAY_WaitmS(50); #if defined(PIOS_INCLUDE_ADC) diff --git a/flight/targets/boards/revoproto/firmware/Makefile b/flight/targets/boards/revoproto/firmware/Makefile index 4e6b710b0..a5343fb60 100644 --- a/flight/targets/boards/revoproto/firmware/Makefile +++ b/flight/targets/boards/revoproto/firmware/Makefile @@ -77,7 +77,6 @@ ifndef TESTAPP SRC += $(OPUAVOBJ)/eventdispatcher.c SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c - #ifeq ($(DEBUG), YES) SRC += $(OPSYSTEM)/dcc_stdio.c