From: henryk@ploetzli.ch Date: Fri, 1 Jan 2010 14:56:25 +0000 (+0000) Subject: Make the bootrom correctly nack in case of flash write error (e.g. due to lock bits) X-Git-Tag: v1.0.0~415 X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/4ab6281664b86264408b661038c050d0d5932fd7 Make the bootrom correctly nack in case of flash write error (e.g. due to lock bits) --- diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index f98c1108..83794d9f 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -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: diff --git a/include/proxmark3.h b/include/proxmark3.h index 8cbb98c4..41cf3f56 100644 --- a/include/proxmark3.h +++ b/include/proxmark3.h @@ -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)