From bcb66764e2f80b021b89dbc824f453d0f3192f29 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Tue, 11 Dec 2012 23:44:12 -0500 Subject: [PATCH] logfs: use logfs on all targets that have serial flash Conflicts: flight/targets/FlyingF4/Makefile flight/targets/FlyingF4/System/pios_board.c flight/targets/Freedom/Makefile flight/targets/Freedom/System/pios_board.c flight/targets/Quanton/Makefile flight/targets/Quanton/System/pios_board.c flight/targets/board_hw_defs/flyingf4/board_hw_defs.c flight/targets/board_hw_defs/freedom/board_hw_defs.c flight/targets/board_hw_defs/quanton/board_hw_defs.c --- flight/targets/CopterControl/Makefile | 50 ++++++++++--------- .../targets/CopterControl/System/pios_board.c | 49 ++++-------------- flight/targets/RevoMini/Makefile | 22 ++++---- flight/targets/RevoMini/System/pios_board.c | 34 ++++--------- flight/targets/Revolution/Makefile | 22 ++++---- flight/targets/Revolution/System/pios_board.c | 42 ++++++---------- .../coptercontrol/board_hw_defs.c | 50 ++++++++++++++++--- .../board_hw_defs/revolution/board_hw_defs.c | 32 +++++++++--- .../board_hw_defs/revomini/board_hw_defs.c | 32 +++++++++--- 9 files changed, 182 insertions(+), 151 deletions(-) diff --git a/flight/targets/CopterControl/Makefile b/flight/targets/CopterControl/Makefile index a532ce927..2749e6950 100644 --- a/flight/targets/CopterControl/Makefile +++ b/flight/targets/CopterControl/Makefile @@ -1,26 +1,28 @@ - ##### - # Project: OpenPilot - # - # - # Makefile for OpenPilot project build PiOS and the AP. - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation; either version 3 of the License, or - # (at your option) any later version. - # - # This program is distributed in the hope that it will be useful, but - # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - # for more details. - # - # You should have received a copy of the GNU General Public License along - # with this program; if not, write to the Free Software Foundation, Inc., - # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ##### +############################################################################### +# @file Makefile +# @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. +# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 +# @addtogroup +# @{ +# @addtogroup +# @{ +# @brief Makefile to build firmware for the CopterControl board. +############################################################################### +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) @@ -253,7 +255,7 @@ SRC += $(PIOSCOMMON)/pios_usb_util.c ## PIOS Hardware (Common) SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c +SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c SRC += $(PIOSCOMMON)/pios_adxl345.c SRC += $(PIOSCOMMON)/pios_mpu6000.c diff --git a/flight/targets/CopterControl/System/pios_board.c b/flight/targets/CopterControl/System/pios_board.c index ab624825b..9072f1e84 100644 --- a/flight/targets/CopterControl/System/pios_board.c +++ b/flight/targets/CopterControl/System/pios_board.c @@ -1,15 +1,13 @@ /** - ****************************************************************************** + ***************************************************************************** + * @file pios_board.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 * @addtogroup OpenPilotSystem OpenPilot System * @{ * @addtogroup OpenPilotCore OpenPilot Core * @{ - * - * @file pios_board.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Defines board specific static initializers for hardware for the OpenPilot board. - * @see The GNU Public License (GPL) Version 3 - * + * @brief Defines board specific static initializers for hardware for the CopterControl board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -124,33 +122,6 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { }; #endif /* PIOS_INCLUDE_MPU6000 */ -static const struct flashfs_cfg flashfs_w25x_cfg = { - .table_magic = 0x85FB3C35, - .obj_magic = 0x3015AE71, - .obj_table_start = 0x00000010, - .obj_table_end = 0x00001000, - .sector_size = 0x00001000, - .chip_size = 0x00080000, -}; - -static const struct pios_flash_jedec_cfg flash_w25x_cfg = { - .sector_erase = 0x20, - .chip_erase = 0x60 -}; - -static const struct flashfs_cfg flashfs_m25p_cfg = { - .table_magic = 0x85FB3D35, - .obj_magic = 0x3015A371, - .obj_table_start = 0x00000010, - .obj_table_end = 0x00010000, - .sector_size = 0x00010000, - .chip_size = 0x00200000, -}; - -static const struct pios_flash_jedec_cfg flash_m25p_cfg = { - .sector_erase = 0xD8, - .chip_erase = 0xC7 -}; #include /** * PIOS_Board_Init() @@ -191,14 +162,16 @@ void PIOS_Board_Init(void) { #endif + uint32_t flash_id; + uint32_t fs_id; switch(bdinfo->board_rev) { case BOARD_REVISION_CC: - PIOS_Flash_Jedec_Init(pios_spi_flash_accel_id, 1, &flash_w25x_cfg); - PIOS_FLASHFS_Init(&flashfs_w25x_cfg); + PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1, &flash_w25x_cfg); + PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id); break; case BOARD_REVISION_CC3D: - PIOS_Flash_Jedec_Init(pios_spi_flash_accel_id, 0, &flash_m25p_cfg); - PIOS_FLASHFS_Init(&flashfs_m25p_cfg); + PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0, &flash_m25p_cfg); + PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id); break; default: PIOS_DEBUG_Assert(0); diff --git a/flight/targets/RevoMini/Makefile b/flight/targets/RevoMini/Makefile index 4b54cdd73..964eb27be 100644 --- a/flight/targets/RevoMini/Makefile +++ b/flight/targets/RevoMini/Makefile @@ -1,11 +1,13 @@ -##### -# Project: OpenPilot RevoMini -# -# -# Makefile for OpenPilot RevoMini project -# -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012. -# +############################################################################### +# @file Makefile +# @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012. +# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 +# @addtogroup +# @{ +# @addtogroup +# @{ +# @brief Makefile to build firmware for the RevoMini board. +############################################################################### # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +22,7 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -##### +# WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) @@ -163,7 +165,7 @@ SRC += $(PIOSCOMMON)/pios_rfm22b.c SRC += $(PIOSCOMMON)/pios_rcvr.c SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c -SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c +SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c diff --git a/flight/targets/RevoMini/System/pios_board.c b/flight/targets/RevoMini/System/pios_board.c index 5e065c348..965b32b36 100644 --- a/flight/targets/RevoMini/System/pios_board.c +++ b/flight/targets/RevoMini/System/pios_board.c @@ -1,15 +1,13 @@ /** ****************************************************************************** - * @addtogroup Revolution Revolution configuration files - * @{ - * @brief Configures the revolution board - * @{ - * * @file pios_board.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. - * @brief Defines board specific static initializers for hardware for the Revolution board. - * @see The GNU Public License (GPL) Version 3 - * + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @brief Defines board specific static initializers for hardware for the revomini board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -188,20 +186,6 @@ static const struct pios_mpu6000_cfg pios_mpu6000_cfg = { }; #endif /* PIOS_INCLUDE_MPU6000 */ -static const struct flashfs_cfg flashfs_m25p_cfg = { - .table_magic = 0x85FB3D35, - .obj_magic = 0x3015A371, - .obj_table_start = 0x00000010, - .obj_table_end = 0x00010000, - .sector_size = 0x00010000, - .chip_size = 0x00200000, -}; - -static const struct pios_flash_jedec_cfg flash_m25p_cfg = { - .sector_erase = 0xD8, - .chip_erase = 0xC7 -}; - /* One slot per selectable receiver group. * eg. PWM, PPM, GCS, SPEKTRUM1, SPEKTRUM2, SBUS * NOTE: No slot in this map for NONE. @@ -317,8 +301,10 @@ void PIOS_Board_Init(void) { #if defined(PIOS_INCLUDE_FLASH) /* Connect flash to the approrpiate interface and configure it */ - PIOS_Flash_Jedec_Init(pios_spi_telem_flash_id, 1, &flash_m25p_cfg); - PIOS_FLASHFS_Init(&flashfs_m25p_cfg); + uint32_t flash_id; + PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1, &flash_m25p_cfg); + uint32_t fs_id; + PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id); #endif /* Initialize UAVObject libraries */ diff --git a/flight/targets/Revolution/Makefile b/flight/targets/Revolution/Makefile index 3d8a8ad1e..9e6c28044 100644 --- a/flight/targets/Revolution/Makefile +++ b/flight/targets/Revolution/Makefile @@ -1,11 +1,13 @@ -##### -# Project: OpenPilot INS -# -# -# Makefile for OpenPilot INS project -# -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. -# +############################################################################### +# @file Makefile +# @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. +# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 +# @addtogroup +# @{ +# @addtogroup +# @{ +# @brief Makefile to build firmware for the Revolution board. +############################################################################### # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +22,7 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -##### +# WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../../) @@ -177,7 +179,7 @@ SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_rcvr.c SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c -SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c +SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c diff --git a/flight/targets/Revolution/System/pios_board.c b/flight/targets/Revolution/System/pios_board.c index 37c9810b3..18a49bdd7 100644 --- a/flight/targets/Revolution/System/pios_board.c +++ b/flight/targets/Revolution/System/pios_board.c @@ -1,15 +1,13 @@ /** - ****************************************************************************** - * @addtogroup Revolution Revolution configuration files - * @{ - * @brief Configures the revolution board - * @{ - * + ***************************************************************************** * @file pios_board.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. - * @brief Defines board specific static initializers for hardware for the Revolution board. - * @see The GNU Public License (GPL) Version 3 - * + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @brief Defines board specific static initializers for hardware for the revolution board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -271,21 +269,6 @@ static const struct pios_l3gd20_cfg pios_l3gd20_cfg = { }; #endif /* PIOS_INCLUDE_L3GD20 */ - -static const struct flashfs_cfg flashfs_m25p_cfg = { - .table_magic = 0x85FB3D35, - .obj_magic = 0x3015A371, - .obj_table_start = 0x00000010, - .obj_table_end = 0x00010000, - .sector_size = 0x00010000, - .chip_size = 0x00200000, -}; - -static const struct pios_flash_jedec_cfg flash_m25p_cfg = { - .sector_erase = 0xD8, - .chip_erase = 0xC7 -}; - /* One slot per selectable receiver group. * eg. PWM, PPM, GCS, SPEKTRUM1, SPEKTRUM2, SBUS * NOTE: No slot in this map for NONE. @@ -398,11 +381,16 @@ void PIOS_Board_Init(void) { if (PIOS_SPI_Init(&pios_spi_flash_id, &pios_spi_flash_cfg)) { PIOS_DEBUG_Assert(0); } - PIOS_Flash_Jedec_Init(pios_spi_flash_id, 0, &flash_m25p_cfg); + /* Connect flash to the approrpiate interface and configure it */ + uint32_t flash_id; + PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0, &flash_m25p_cfg); #else - PIOS_Flash_Jedec_Init(pios_spi_accel_id, 1, &flash_m25p_cfg); + /* Connect flash to the approrpiate interface and configure it */ + uint32_t flash_id; + PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1, &flash_m25p_cfg); #endif - PIOS_FLASHFS_Init(&flashfs_m25p_cfg); + uint32_t fs_id; + PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id); /* Initialize UAVObject libraries */ EventDispatcherInitialize(); diff --git a/flight/targets/board_hw_defs/coptercontrol/board_hw_defs.c b/flight/targets/board_hw_defs/coptercontrol/board_hw_defs.c index 403657199..fdd95a1e5 100644 --- a/flight/targets/board_hw_defs/coptercontrol/board_hw_defs.c +++ b/flight/targets/board_hw_defs/coptercontrol/board_hw_defs.c @@ -1,15 +1,13 @@ /** ****************************************************************************** + * @file board_hw_defs.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 * @addtogroup OpenPilotSystem OpenPilot System * @{ * @addtogroup OpenPilotCore OpenPilot Core * @{ - * - * @file board_hw_defs.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @brief Defines board specific static initializers for hardware for the OpenPilot board. - * @see The GNU Public License (GPL) Version 3 - * + * @brief Defines board specific static initializers for hardware for the CopterControl board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -401,6 +399,46 @@ void PIOS_SPI_flash_accel_irq_handler(void) #endif /* PIOS_INCLUDE_SPI */ +#if defined(PIOS_INCLUDE_FLASH) +#include "pios_flashfs_logfs_priv.h" +#include "pios_flash_jedec_priv.h" + +static const struct flashfs_logfs_cfg flashfs_w25x_cfg = { + .fs_magic = 0x89abcdef, + .total_fs_size = 0x00080000, /* 512K bytes (128 sectors = entire chip) */ + .arena_size = 0x00010000, /* 256 * slot size */ + .slot_size = 0x00000100, /* 256 bytes */ + + .start_offset = 0, /* start at the beginning of the chip */ + .sector_size = 0x00001000, /* 4K bytes */ + .page_size = 0x00000100, /* 256 bytes */ +}; + +static const struct pios_flash_jedec_cfg flash_w25x_cfg = { + .sector_erase = 0x20, + .chip_erase = 0x60 +}; + +static const struct flashfs_logfs_cfg flashfs_m25p_cfg = { + .fs_magic = 0x89abceef, + .total_fs_size = 0x00200000, /* 2M bytes (32 sectors = entire chip) */ + .arena_size = 0x00010000, /* 256 * slot size */ + .slot_size = 0x00000100, /* 256 bytes */ + + .start_offset = 0, /* start at the beginning of the chip */ + .sector_size = 0x00010000, /* 64K bytes */ + .page_size = 0x00000100, /* 256 bytes */ +}; + +static const struct pios_flash_jedec_cfg flash_m25p_cfg = { + .sector_erase = 0xD8, + .chip_erase = 0xC7 +}; + +#include "pios_flash.h" + +#endif /* PIOS_INCLUDE_FLASH */ + /* * ADC system */ diff --git a/flight/targets/board_hw_defs/revolution/board_hw_defs.c b/flight/targets/board_hw_defs/revolution/board_hw_defs.c index 7df06e4e9..f6d3560ca 100644 --- a/flight/targets/board_hw_defs/revolution/board_hw_defs.c +++ b/flight/targets/board_hw_defs/revolution/board_hw_defs.c @@ -1,15 +1,13 @@ /** ****************************************************************************** + * @file board_hw_defs.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 * @addtogroup OpenPilotSystem OpenPilot System * @{ * @addtogroup OpenPilotCore OpenPilot Core * @{ - * - * @file board_hw_defs.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @brief Defines board specific static initializers for hardware for the OpenPilot board. - * @see The GNU Public License (GPL) Version 3 - * + * @brief Defines board specific static initializers for hardware for the Revolution board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -449,6 +447,28 @@ void PIOS_SPI_flash_irq_handler(void) #endif /* PIOS_INCLUDE_SPI */ +#if defined(PIOS_INCLUDE_FLASH) +#include "pios_flashfs_logfs_priv.h" +#include "pios_flash_jedec_priv.h" + +static const struct flashfs_logfs_cfg flashfs_m25p_cfg = { + .fs_magic = 0x89abceef, + .total_fs_size = 0x00200000, /* 2M bytes (32 sectors = entire chip) */ + .arena_size = 0x00010000, /* 256 * slot size */ + .slot_size = 0x00000100, /* 256 bytes */ + + .start_offset = 0, /* start at the beginning of the chip */ + .sector_size = 0x00010000, /* 64K bytes */ + .page_size = 0x00000100, /* 256 bytes */ +}; + +static const struct pios_flash_jedec_cfg flash_m25p_cfg = { + .sector_erase = 0xD8, + .chip_erase = 0xC7 +}; + +#endif /* PIOS_INCLUDE_FLASH */ + #if defined(PIOS_OVERO_SPI) /* SPI3 Interface * - Used for flash communications diff --git a/flight/targets/board_hw_defs/revomini/board_hw_defs.c b/flight/targets/board_hw_defs/revomini/board_hw_defs.c index bb65069cf..41a56894b 100644 --- a/flight/targets/board_hw_defs/revomini/board_hw_defs.c +++ b/flight/targets/board_hw_defs/revomini/board_hw_defs.c @@ -1,15 +1,13 @@ /** ****************************************************************************** + * @file board_hw_defs.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 * @addtogroup OpenPilotSystem OpenPilot System * @{ * @addtogroup OpenPilotCore OpenPilot Core * @{ - * - * @file board_hw_defs.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @brief Defines board specific static initializers for hardware for the OpenPilot board. - * @see The GNU Public License (GPL) Version 3 - * + * @brief Defines board specific static initializers for hardware for the RevoMini board. *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -564,6 +562,28 @@ const struct pios_rfm22b_cfg * PIOS_BOARD_HW_DEFS_GetRfm22Cfg (uint32_t board_re #endif /* PIOS_INCLUDE_SPI */ +#if defined(PIOS_INCLUDE_FLASH) +#include "pios_flashfs_logfs_priv.h" +#include "pios_flash_jedec_priv.h" + +static const struct flashfs_logfs_cfg flashfs_m25p_cfg = { + .fs_magic = 0x89abceef, + .total_fs_size = 0x00200000, /* 2M bytes (32 sectors = entire chip) */ + .arena_size = 0x00010000, /* 256 * slot size */ + .slot_size = 0x00000100, /* 256 bytes */ + + .start_offset = 0, /* start at the beginning of the chip */ + .sector_size = 0x00010000, /* 64K bytes */ + .page_size = 0x00000100, /* 256 bytes */ +}; + +static const struct pios_flash_jedec_cfg flash_m25p_cfg = { + .sector_erase = 0xD8, + .chip_erase = 0xC7 +}; + +#endif /* PIOS_INCLUDE_FLASH */ + #include #ifdef PIOS_INCLUDE_COM_TELEM