1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-557: Add a UAVO access method to erase the entire flash chip. Normally not

needed by users because if too much changes I change the FS magic and trigger a
wipe.

Possibly the erase should require a particular "magic" object id value to
execute?  This would make it harder to do manually through UAVOs though.
This commit is contained in:
James Cotton 2011-08-15 10:24:37 -05:00
parent 2f7f920ef3
commit 35eef66bfe
4 changed files with 21 additions and 2 deletions

View File

@ -230,6 +230,11 @@ static void objectUpdatedCb(UAVObjEvent * ev)
|| objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS) {
retval = UAVObjDeleteMetaobjects();
}
} else if (objper.Operation == OBJECTPERSISTENCE_OPERATION_FULLERASE) {
retval = -1;
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
retval = PIOS_FLASHFS_Format();
#endif
}
if(retval == 0) {
objper.Operation = OBJECTPERSISTENCE_OPERATION_COMPLETED;

View File

@ -116,6 +116,19 @@ int32_t PIOS_FLASHFS_Init()
return 0;
}
/**
* @brief Erase the whole flash chip and create the file system
* @return 0 if successful, -1 if not
*/
int32_t PIOS_FLASHFS_Format()
{
if(PIOS_Flash_W25X_EraseChip() != 0)
return -1;
if(PIOS_FLASHFS_ClearObjectTableHeader() != 0)
return -1;
return 0;
}
/**
* @brief Erase the headers for all objects in the flash chip
* @return 0 if successful, -1 if not

View File

@ -32,6 +32,7 @@
#include "uavobjectmanager.h"
int32_t PIOS_FLASHFS_Init();
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);
int32_t PIOS_FLASHFS_ObjDelete(UAVObjHandle obj, uint16_t instId);
int32_t PIOS_FLASHFS_ObjDelete(UAVObjHandle obj, uint16_t instId);

View File

@ -1,7 +1,7 @@
<xml>
<object name="ObjectPersistence" singleinstance="true" settings="false">
<description>Someone who knows please enter this</description>
<field name="Operation" units="" type="enum" elements="1" options="NOP,Load,Save,Delete,Completed"/>
<field name="Operation" units="" type="enum" elements="1" options="NOP,Load,Save,Delete,FullErase,Completed"/>
<field name="Selection" units="" type="enum" elements="1" options="SingleObject,AllSettings,AllMetaObjects,AllObjects"/>
<field name="ObjectID" units="" type="uint32" elements="1"/>
<field name="InstanceID" units="" type="uint32" elements="1"/>