mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
chg: flashmem adaptions
This commit is contained in:
parent
089beed4f4
commit
3d956e686b
4 changed files with 152 additions and 151 deletions
|
@ -363,6 +363,7 @@ void printUSBSpeed(void) {
|
||||||
void SendStatus(void) {
|
void SendStatus(void) {
|
||||||
BigBuf_print_status();
|
BigBuf_print_status();
|
||||||
Fpga_print_status();
|
Fpga_print_status();
|
||||||
|
Flashmem_print_status();
|
||||||
printConfig(); //LF Sampling config
|
printConfig(); //LF Sampling config
|
||||||
printUSBSpeed();
|
printUSBSpeed();
|
||||||
Dbprintf("Various");
|
Dbprintf("Various");
|
||||||
|
@ -417,7 +418,7 @@ void printStandAloneModes(void) {
|
||||||
DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)");
|
DbpString(" HF Mifare ultra fast sniff/sim/clone - aka VIGIKPWN (Colin Brigato)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DbpString("Running ");
|
//DbpString("Running ");
|
||||||
//Dbprintf(" Is Device attached to USB| %s", USB_ATTACHED() ? "Yes" : "No");
|
//Dbprintf(" Is Device attached to USB| %s", USB_ATTACHED() ? "Yes" : "No");
|
||||||
//Dbprintf(" Is USB_reconnect value | %d", GetUSBreconnect() );
|
//Dbprintf(" Is USB_reconnect value | %d", GetUSBreconnect() );
|
||||||
//Dbprintf(" Is USB_configured value | %d", GetUSBconfigured() );
|
//Dbprintf(" Is USB_configured value | %d", GetUSBconfigured() );
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "flashmem.h"
|
#include "flashmem.h"
|
||||||
|
|
||||||
#define address_length 3
|
|
||||||
|
|
||||||
/* here: use NCPS2 @ PA10: */
|
/* here: use NCPS2 @ PA10: */
|
||||||
#define SPI_CSR_NUM 2 // Chip Select register[] 0,1,2,3 (at91samv512 has 4)
|
#define SPI_CSR_NUM 2 // Chip Select register[] 0,1,2,3 (at91samv512 has 4)
|
||||||
|
|
||||||
|
@ -11,7 +9,7 @@
|
||||||
#define PCS_2 ((1<<0)|(1<<1)|(0<<2)|(1<<3)) // 0xB - 1011
|
#define PCS_2 ((1<<0)|(1<<1)|(0<<2)|(1<<3)) // 0xB - 1011
|
||||||
#define PCS_3 ((1<<0)|(1<<1)|(1<<2)|(0<<3)) // 0x7 - 0111
|
#define PCS_3 ((1<<0)|(1<<1)|(1<<2)|(0<<3)) // 0x7 - 0111
|
||||||
|
|
||||||
/* TODO: ## */
|
// TODO
|
||||||
#if (SPI_CSR_NUM == 0)
|
#if (SPI_CSR_NUM == 0)
|
||||||
#define SPI_MR_PCS PCS_0
|
#define SPI_MR_PCS PCS_0
|
||||||
#elif (SPI_CSR_NUM == 1)
|
#elif (SPI_CSR_NUM == 1)
|
||||||
|
@ -33,10 +31,7 @@
|
||||||
擦除指令,擦除指令后必须将CS拉高,否则不会执行
|
擦除指令,擦除指令后必须将CS拉高,否则不会执行
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void FlashSetup(void) {
|
||||||
// 初始化Flash
|
|
||||||
void FlashSetup()
|
|
||||||
{
|
|
||||||
// PA1 -> SPI_NCS3 chip select (MEM)
|
// PA1 -> SPI_NCS3 chip select (MEM)
|
||||||
// PA10 -> SPI_NCS2 chip select (LCD)
|
// PA10 -> SPI_NCS2 chip select (LCD)
|
||||||
// PA11 -> SPI_NCS0 chip select (FPGA)
|
// PA11 -> SPI_NCS0 chip select (FPGA)
|
||||||
|
@ -83,14 +78,10 @@ void FlashSetup()
|
||||||
( 0 << 0); // Clock Polarity inactive state is logic 0
|
( 0 << 0); // Clock Polarity inactive state is logic 0
|
||||||
|
|
||||||
// read first, empty buffer
|
// read first, empty buffer
|
||||||
if (AT91C_BASE_SPI->SPI_RDR == 0)
|
if (AT91C_BASE_SPI->SPI_RDR == 0) {};
|
||||||
;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// end up SPI
|
void FlashStop(void) {
|
||||||
void FlashStop(void)
|
|
||||||
{
|
|
||||||
//* Reset all the Chip Select register
|
//* Reset all the Chip Select register
|
||||||
AT91C_BASE_SPI->SPI_CSR[0] = 0;
|
AT91C_BASE_SPI->SPI_CSR[0] = 0;
|
||||||
AT91C_BASE_SPI->SPI_CSR[1] = 0;
|
AT91C_BASE_SPI->SPI_CSR[1] = 0;
|
||||||
|
@ -106,12 +97,13 @@ void FlashStop(void)
|
||||||
// SPI disable
|
// SPI disable
|
||||||
AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIDIS;
|
AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIDIS;
|
||||||
|
|
||||||
Dbprintf("FlashStop");
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("FlashStop");
|
||||||
|
|
||||||
|
StopTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送一个字节 send one byte
|
// send one byte over SPI
|
||||||
uint16_t FlashSendByte(uint32_t data)
|
uint16_t FlashSendByte(uint32_t data) {
|
||||||
{
|
|
||||||
uint16_t incoming = 0;
|
uint16_t incoming = 0;
|
||||||
|
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
@ -132,239 +124,249 @@ uint16_t FlashSendByte(uint32_t data)
|
||||||
return incoming;
|
return incoming;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send last one byte
|
// send last byte over SPI
|
||||||
uint16_t FlashSendLastByte(uint32_t data) {
|
uint16_t FlashSendLastByte(uint32_t data) {
|
||||||
return FlashSendByte(data | AT91C_SPI_LASTXFER);
|
return FlashSendByte(data | AT91C_SPI_LASTXFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read state register 1
|
// read state register 1
|
||||||
uint8_t Flash_ReadStat1(void) {
|
uint8_t Flash_ReadStat1(void) {
|
||||||
FlashSendByte(READSTAT1);
|
FlashSendByte(READSTAT1);
|
||||||
uint8_t stat1 = FlashSendLastByte(0xFF);
|
uint8_t stat1 = FlashSendLastByte(0xFF);
|
||||||
Dbprintf("stat1 [%02x]", stat1);
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("stat1 [%02x]", stat1);
|
||||||
return stat1;
|
return stat1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read state register 2
|
// read state register 2
|
||||||
uint8_t Flash_ReadStat2(void) {
|
uint8_t Flash_ReadStat2(void) {
|
||||||
FlashSendByte(READSTAT2);
|
FlashSendByte(READSTAT2);
|
||||||
uint8_t stat2 = FlashSendLastByte(0xFF);
|
uint8_t stat2 = FlashSendLastByte(0xFF);
|
||||||
Dbprintf("stat2 [%02x]", stat2);
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("stat2 [%02x]", stat2);
|
||||||
return stat2;
|
return stat2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether FLASHMEM is busy
|
// determine whether FLASHMEM is busy
|
||||||
bool Flash_CheckBusy(uint16_t times){
|
bool Flash_CheckBusy(uint16_t times){
|
||||||
bool bRet = (Flash_ReadStat1() & BUSY);
|
bool ret = (Flash_ReadStat1() & BUSY);
|
||||||
|
|
||||||
if (!bRet || !times || !(times--))
|
if (!ret || !times || !(times--))
|
||||||
return bRet;
|
return ret;
|
||||||
|
|
||||||
while (times)
|
while (times) {
|
||||||
{
|
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
SpinDelayUs(1000); // wait 1ms
|
WaitMS(1);
|
||||||
bRet = (Flash_ReadStat1() & BUSY);
|
ret = (Flash_ReadStat1() & BUSY);
|
||||||
if (!bRet)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
times--;
|
times--;
|
||||||
}
|
}
|
||||||
return bRet;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read ID out
|
// read ID out
|
||||||
uint8_t Flash_ReadID(void) {
|
uint8_t Flash_ReadID(void) {
|
||||||
|
|
||||||
if (Flash_CheckBusy(1000))
|
if (Flash_CheckBusy(1000)) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Manufacture ID / device ID
|
// Manufacture ID / device ID
|
||||||
uint8_t t0 = FlashSendByte(ID);
|
FlashSendByte(ID);
|
||||||
uint8_t t1 = FlashSendByte(0x00);
|
FlashSendByte(0x00);
|
||||||
uint8_t t2 = FlashSendByte(0x00);
|
FlashSendByte(0x00);
|
||||||
uint8_t t3 = FlashSendByte(0x00);
|
FlashSendByte(0x00);
|
||||||
|
|
||||||
uint8_t man_id = FlashSendByte(0xFF);
|
uint8_t man_id = FlashSendByte(0xFF);
|
||||||
uint8_t dev_id = FlashSendLastByte(0xFF);
|
uint8_t dev_id = FlashSendLastByte(0xFF);
|
||||||
|
|
||||||
Dbprintf(" [%02x] %02x %02x %02x | %02x %02x", t0,t1,t2,t3, man_id, dev_id);
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("Flash ReadID | Man ID %02x | Device ID %02x", man_id, dev_id);
|
||||||
|
|
||||||
|
if ( (man_id == WINBOND_MANID ) && (dev_id == WINBOND_DEVID) )
|
||||||
|
return dev_id;
|
||||||
|
|
||||||
//WINBOND_MANID
|
return 0;
|
||||||
if ( man_id == WINBOND_MANID ) {
|
|
||||||
Dbprintf("Correct read of Manucaturer ID [%02x] == %02x", man_id, WINBOND_MANID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (man_id != WINBOND_MANID)
|
|
||||||
dev_id = 0;
|
|
||||||
|
|
||||||
return dev_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取数据 address buffer length
|
// read unique id for chip.
|
||||||
uint8_t Flash_ReadDate(uint32_t Address, uint8_t *Buffer, uint16_t len)
|
void Flash_UniqueID(uint8_t *uid) {
|
||||||
{
|
|
||||||
|
if (Flash_CheckBusy(1000)) return;
|
||||||
|
|
||||||
|
// reading unique serial number
|
||||||
|
FlashSendByte(UNIQUE_ID);
|
||||||
|
FlashSendByte(0x00);
|
||||||
|
FlashSendByte(0x00);
|
||||||
|
FlashSendByte(0x00);
|
||||||
|
FlashSendByte(0x00);
|
||||||
|
|
||||||
|
uid[3] = FlashSendByte(0xFF);
|
||||||
|
uid[2] = FlashSendByte(0xFF);
|
||||||
|
uid[1] = FlashSendByte(0xFF);
|
||||||
|
uid[0] = FlashSendLastByte(0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Flash_ReadData(uint32_t address, uint8_t *out, uint16_t len) {
|
||||||
// length should never be zero
|
// length should never be zero
|
||||||
if (!len || Flash_CheckBusy(1000))
|
if (!len || Flash_CheckBusy(1000)) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
FlashSendByte(READDATA);
|
FlashSendByte(READDATA);
|
||||||
FlashSendByte((Address >> 16) & 0xFF);
|
FlashSendByte((address >> 16) & 0xFF);
|
||||||
FlashSendByte((Address >> 8) & 0xFF);
|
FlashSendByte((address >> 8) & 0xFF);
|
||||||
FlashSendByte((Address >> 0) & 0xFF);
|
FlashSendByte((address >> 0) & 0xFF);
|
||||||
|
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
for (; i < (len - 1); i++)
|
for (; i < (len - 1); i++)
|
||||||
Buffer[i] = FlashSendByte(0xFF);
|
out[i] = FlashSendByte(0xFF);
|
||||||
|
|
||||||
Buffer[i] = FlashSendLastByte(0xFF);
|
out[i] = FlashSendLastByte(0xFF);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入数据 地址 address 缓冲区 buffer 长度length
|
// Write data
|
||||||
uint8_t Flash_WriteDate(uint32_t Address, uint8_t *Buffer, uint16_t len)
|
uint8_t Flash_WriteData(uint32_t address, uint8_t *in, uint16_t len) {
|
||||||
{
|
|
||||||
// length should never be zero
|
// length should never be zero
|
||||||
if (!len || Flash_CheckBusy(1000))
|
if (!len || Flash_CheckBusy(1000)) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
// 不能跨越 256 字节边界
|
// 不能跨越 256 字节边界
|
||||||
if (((Address & 255) + len) > 256)
|
if (((address & 255) + len) > 256) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
FlashSendByte(PAGEPROG);
|
FlashSendByte(PAGEPROG);
|
||||||
FlashSendByte((Address >> 16) & 0xFF);
|
FlashSendByte((address >> 16) & 0xFF);
|
||||||
FlashSendByte((Address >> 8) & 0xFF);
|
FlashSendByte((address >> 8) & 0xFF);
|
||||||
FlashSendByte((Address >> 0) & 0xFF);
|
FlashSendByte((address >> 0) & 0xFF);
|
||||||
|
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
for (; i < (len - 1); i++)
|
for (; i < (len - 1); i++)
|
||||||
FlashSendByte(Buffer[i]);
|
FlashSendByte(in[i]);
|
||||||
|
|
||||||
FlashSendLastByte(Buffer[i]);
|
FlashSendLastByte(in[i]);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// enable the flash write
|
// enable the flash write
|
||||||
void Flash_WriteEnable()
|
void Flash_WriteEnable() {
|
||||||
{
|
|
||||||
FlashSendLastByte(WRITEENABLE);
|
FlashSendLastByte(WRITEENABLE);
|
||||||
Dbprintf("Flash WriteEnabled");
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("Flash Write enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase 4K at one time
|
// erase 4K at one time
|
||||||
bool Flash_Erase4k(uint32_t Address)
|
bool Flash_Erase4k(uint32_t address) {
|
||||||
{
|
if (address & (4096 - 1)) {
|
||||||
if (Address & (4096 - 1))
|
if ( MF_DBGLEVEL > 1 ) Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
||||||
{
|
|
||||||
Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashSendByte(SECTORERASE);
|
FlashSendByte(SECTORERASE);
|
||||||
FlashSendByte((Address >> 16) & 0xFF);
|
FlashSendByte((address >> 16) & 0xFF);
|
||||||
FlashSendByte((Address >> 8) & 0xFF);
|
FlashSendByte((address >> 8) & 0xFF);
|
||||||
FlashSendLastByte((Address >> 0) & 0xFF);
|
FlashSendLastByte((address >> 0) & 0xFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase 32K at one time
|
// erase 32K at one time
|
||||||
bool Flash_Erase32k(uint32_t Address)
|
bool Flash_Erase32k(uint32_t address) {
|
||||||
{
|
if (address & (32*1024 - 1)) {
|
||||||
if (Address & (32*1024 - 1))
|
if ( MF_DBGLEVEL > 1 ) Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
||||||
{
|
|
||||||
Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FlashSendByte(BLOCK32ERASE);
|
FlashSendByte(BLOCK32ERASE);
|
||||||
FlashSendByte((Address >> 16) & 0xFF);
|
FlashSendByte((address >> 16) & 0xFF);
|
||||||
FlashSendByte((Address >> 8) & 0xFF);
|
FlashSendByte((address >> 8) & 0xFF);
|
||||||
FlashSendLastByte((Address >> 0) & 0xFF);
|
FlashSendLastByte((address >> 0) & 0xFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase 64k at one time
|
// erase 64k at one time
|
||||||
bool Flash_Erase64k(uint32_t Address)
|
bool Flash_Erase64k(uint32_t address) {
|
||||||
{
|
|
||||||
if (Address & (64*1024 - 1))
|
if (address & (64*1024 - 1)) {
|
||||||
{
|
if ( MF_DBGLEVEL > 1 ) Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
||||||
Dbprintf("Flash_Erase4k : Address is not align at 4096");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FlashSendByte(BLOCK64ERASE);
|
FlashSendByte(BLOCK64ERASE);
|
||||||
FlashSendByte((Address >> 16) & 0xFF);
|
FlashSendByte((address >> 16) & 0xFF);
|
||||||
FlashSendByte((Address >> 8) & 0xFF);
|
FlashSendByte((address >> 8) & 0xFF);
|
||||||
FlashSendLastByte((Address >> 0) & 0xFF);
|
FlashSendLastByte((address >> 0) & 0xFF);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase all
|
// Erase chip
|
||||||
void Flash_EraseChip(void)
|
void Flash_EraseChip(void) {
|
||||||
{
|
|
||||||
FlashSendLastByte(CHIPERASE);
|
FlashSendLastByte(CHIPERASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
bool FlashInit(void)
|
bool FlashInit(void) {
|
||||||
{
|
|
||||||
FlashSetup();
|
FlashSetup();
|
||||||
|
|
||||||
if (Flash_CheckBusy(1000))
|
StartTicks();
|
||||||
|
|
||||||
|
if (Flash_CheckBusy(1000)) {
|
||||||
|
StopTicks();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Dbprintf("FlashInit");
|
if ( MF_DBGLEVEL > 3 ) Dbprintf("FlashInit OK");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXFLASH_TEST(void)
|
void EXFLASH_TEST(void) {
|
||||||
{
|
uint8_t data[256] = { 0x00, 0x01, 0x02 };
|
||||||
uint8_t Data[256] = { 0x00, 0x01, 0x02 };
|
uint8_t data2[256] = { 0x00};
|
||||||
uint8_t Data2[256] = { 0x00};
|
|
||||||
uint32_t FlashSize = 0;
|
|
||||||
|
|
||||||
if (!FlashInit()) return;
|
if (!FlashInit()) return;
|
||||||
|
|
||||||
Flash_ReadStat1();
|
Flash_ReadStat1();
|
||||||
|
|
||||||
switch (Flash_ReadID())
|
|
||||||
{
|
|
||||||
case 0x11: // W25X20CL
|
|
||||||
FlashSize = 2048*1024;
|
|
||||||
break;
|
|
||||||
case 0x10: // W25X10CL
|
|
||||||
FlashSize = 1024*1024;
|
|
||||||
break;
|
|
||||||
case 0x05: // W25X05CL
|
|
||||||
FlashSize = 512*1024;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dbprintf("Flash Size = %dk", FlashSize / 1024);
|
|
||||||
|
|
||||||
if (FlashSize != 2048*1024)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Dbprintf("Flash test write: 012 to 0x00 0x01 0x02");
|
Dbprintf("Flash test write: 012 to 0x00 0x01 0x02");
|
||||||
Flash_WriteEnable();
|
Flash_WriteEnable();
|
||||||
Flash_Erase4k(0x00);
|
Flash_Erase4k(0x00);
|
||||||
if (Flash_CheckBusy(1000))
|
if (Flash_CheckBusy(1000)) {
|
||||||
{
|
|
||||||
Dbprintf("Flash_Erase4k CheckBusy Error.");
|
Dbprintf("Flash_Erase4k CheckBusy Error.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Flash_ReadDate(0, Data2, 256);
|
|
||||||
|
Flash_ReadData(0, data2, 256);
|
||||||
Flash_WriteEnable();
|
Flash_WriteEnable();
|
||||||
Flash_WriteDate(0x12, Data, sizeof(Data)); // this will never run, cuz out of 256byte boundary
|
Flash_WriteData(0x12, data, sizeof(data)); // this will never run, cuz out of 256byte boundary
|
||||||
Flash_WriteDate(0x12, Data, 3);
|
Flash_WriteData(0x12, data, 3);
|
||||||
if (Flash_CheckBusy(1000))
|
|
||||||
{
|
if (Flash_CheckBusy(1000)) {
|
||||||
Dbprintf("Flash_WriteDate CheckBusy Error.");
|
Dbprintf("Flash_WriteDate CheckBusy Error.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Flash_ReadDate(0, Data2, 256);
|
Flash_ReadData(0, data2, 256);
|
||||||
|
|
||||||
FlashStop();
|
FlashStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Flashmem_print_status(void) {
|
||||||
|
DbpString("Flash memory");
|
||||||
|
|
||||||
|
if (!FlashInit()) {
|
||||||
|
DbpString(" init....................FAIL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DbpString(" init....................OK");
|
||||||
|
|
||||||
|
uint8_t dev_id = Flash_ReadID();
|
||||||
|
switch (dev_id) {
|
||||||
|
case 0x11 :
|
||||||
|
DbpString(" Memory size.............2 mbits / 256kb");
|
||||||
|
break;
|
||||||
|
case 0x10 :
|
||||||
|
DbpString(" Memory size..... .......1 mbits / 128kb");
|
||||||
|
break;
|
||||||
|
case 0x05 :
|
||||||
|
DbpString(" Memory size.............512 kbits / 64kb");
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
DbpString(" Device ID............... --> Unknown <--");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t uid[4] = {0,0,0,0};
|
||||||
|
Flash_UniqueID(uid);
|
||||||
|
Dbprintf(" Unique ID...............0x%02x%02x%02x%02x %", uid[3], uid[2], uid[1], uid[0]);
|
||||||
|
|
||||||
|
FlashStop();
|
||||||
|
}
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
|
#include "ticks.h"
|
||||||
|
|
||||||
// Used Command
|
// Used Command
|
||||||
#define ID 0x90
|
#define ID 0x90
|
||||||
|
@ -53,7 +54,6 @@
|
||||||
|
|
||||||
#define UNIQUE_ID 0x4B
|
#define UNIQUE_ID 0x4B
|
||||||
|
|
||||||
|
|
||||||
// Not used or not support command
|
// Not used or not support command
|
||||||
#define RELEASE 0xAB
|
#define RELEASE 0xAB
|
||||||
#define POWERDOWN 0xB9
|
#define POWERDOWN 0xB9
|
||||||
|
@ -120,4 +120,10 @@ uint16_t FlashSendByte(uint32_t data);
|
||||||
bool FlashInit();
|
bool FlashInit();
|
||||||
void EXFLASH_TEST(void);
|
void EXFLASH_TEST(void);
|
||||||
|
|
||||||
#endif
|
void Flash_UniqueID(uint8_t *uid);
|
||||||
|
uint8_t Flash_ReadID(void);
|
||||||
|
uint8_t Flash_ReadData(uint32_t address, uint8_t *out, uint16_t len);
|
||||||
|
uint8_t Flash_WriteData(uint32_t address, uint8_t *in, uint16_t len);
|
||||||
|
void Flashmem_print_status(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -59,18 +59,10 @@ void SetupSpi(int mode) {
|
||||||
// PA14 -> SPI_SPCK Serial Clock
|
// PA14 -> SPI_SPCK Serial Clock
|
||||||
|
|
||||||
// Disable PIO control of the following pins, allows use by the SPI peripheral
|
// Disable PIO control of the following pins, allows use by the SPI peripheral
|
||||||
AT91C_BASE_PIOA->PIO_PDR =
|
AT91C_BASE_PIOA->PIO_PDR = GPIO_NCS0 | GPIO_MISO | GPIO_MOSI | GPIO_SPCK;
|
||||||
GPIO_NCS0 |
|
|
||||||
GPIO_MISO |
|
|
||||||
GPIO_MOSI |
|
|
||||||
GPIO_SPCK;
|
|
||||||
|
|
||||||
// Peripheral A
|
// Peripheral A
|
||||||
AT91C_BASE_PIOA->PIO_ASR =
|
AT91C_BASE_PIOA->PIO_ASR = GPIO_NCS0 | GPIO_MISO | GPIO_MOSI | GPIO_SPCK;
|
||||||
GPIO_NCS0 |
|
|
||||||
GPIO_MISO |
|
|
||||||
GPIO_MOSI |
|
|
||||||
GPIO_SPCK;
|
|
||||||
|
|
||||||
// Peripheral B
|
// Peripheral B
|
||||||
//AT91C_BASE_PIOA->PIO_BSR |= GPIO_NCS2;
|
//AT91C_BASE_PIOA->PIO_BSR |= GPIO_NCS2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue