Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable factory reset from software #21

Merged
merged 1 commit into from
Apr 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SPARK_Firmware_Driver/inc/hw_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ extern uint8_t LED_RGB_OVERRIDE;
extern uint16_t CORE_FW_Version_SysFlag;
extern uint16_t NVMEM_SPARK_Reset_SysFlag;
extern uint16_t FLASH_OTA_Update_SysFlag;
extern uint16_t Factory_Reset_SysFlag;

extern unsigned char wlan_rx_buffer[];
extern unsigned char wlan_tx_buffer[];
Expand Down
17 changes: 14 additions & 3 deletions SPARK_Firmware_Driver/src/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ uint16_t CORE_FW_Version_SysFlag = 0xFFFF;
uint16_t NVMEM_SPARK_Reset_SysFlag = 0xFFFF;
uint16_t FLASH_OTA_Update_SysFlag = 0xFFFF;
uint16_t OTA_FLASHED_Status_SysFlag = 0xFFFF;
uint16_t Factory_Reset_SysFlag = 0xFFFF;

uint32_t WRPR_Value = 0xFFFFFFFF;
uint32_t Flash_Pages_Protected = 0x0;
Expand Down Expand Up @@ -1267,6 +1268,9 @@ void Load_SystemFlags(void)

OTA_FLASHED_Status_SysFlag = (*(__IO uint16_t*) Address);
Address += 2;

Factory_Reset_SysFlag = (*(__IO uint16_t*) Address);
Address += 2;
}

void Save_SystemFlags(void)
Expand Down Expand Up @@ -1307,6 +1311,11 @@ void Save_SystemFlags(void)
while(FLASHStatus != FLASH_COMPLETE);
Address += 2;

/* Program Factory_Reset_SysFlag */
FLASHStatus = FLASH_ProgramHalfWord(Address, Factory_Reset_SysFlag);
while(FLASHStatus != FLASH_COMPLETE);
Address += 2;

/* Locks the FLASH Program Erase Controller */
FLASH_Lock();
}
Expand Down Expand Up @@ -1611,10 +1620,12 @@ void FLASH_Read_CorePrivateKey(uint8_t *keyBuffer)

void FACTORY_Flash_Reset(void)
{
//Restore the Factory programmed application firmware from External Flash
FLASH_Restore(EXTERNAL_FLASH_FAC_ADDRESS);
// Restore the Factory programmed application firmware from External Flash
FLASH_Restore(EXTERNAL_FLASH_FAC_ADDRESS);

Finish_Update();
Factory_Reset_SysFlag = 0xFFFF;

Finish_Update();
}

void BACKUP_Flash_Reset(void)
Expand Down