mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-28 02:50:21 +08:00
Make the bootrom correctly nack in case of flash write error (e.g. due to lock bits)
This commit is contained in:
parent
0d974852ce
commit
4ab6281664
2 changed files with 11 additions and 1 deletions
|
@ -117,8 +117,16 @@ void UsbPacketReceived(BYTE *packet, int len)
|
|||
MC_FLASH_COMMAND_PAGEN((c->arg[0]-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |
|
||||
AT91C_MC_FCMD_START_PROG;
|
||||
}
|
||||
while(!(AT91C_BASE_EFC0->EFC_FSR & MC_FLASH_STATUS_READY))
|
||||
|
||||
uint32_t sr;
|
||||
|
||||
while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & MC_FLASH_STATUS_READY))
|
||||
;
|
||||
if(sr & (MC_FLASH_STATUS_LOCKE | MC_FLASH_STATUS_PROGE)) {
|
||||
dont_ack = 1;
|
||||
c->cmd = CMD_NACK;
|
||||
UsbSendPacket(packet, len);
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_HARDWARE_RESET:
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#define MC_FLASH_COMMAND_KEY ((0x5a)<<24)
|
||||
#define MC_FLASH_STATUS_READY (1<<0)
|
||||
#define MC_FLASH_STATUS_LOCKE (1<<2)
|
||||
#define MC_FLASH_STATUS_PROGE (1<<3)
|
||||
#define MC_FLASH_MODE_FLASH_WAIT_STATES(x) ((x)<<8)
|
||||
#define MC_FLASH_MODE_MASTER_CLK_IN_MHZ(x) ((x)<<16)
|
||||
#define MC_FLASH_COMMAND_PAGEN(x) ((x)<<8)
|
||||
|
|
Loading…
Reference in a new issue