Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
add: 'mem info' - rudamentary support for new command.
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed May 6, 2018
1 parent 110a7b2 commit 6b78192
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
22 changes: 19 additions & 3 deletions armsrc/appmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
LED_B_OFF();
break;
}
case CMD_WIPE_FLASH_MEM:
case CMD_WIPE_FLASH_MEM: {
LED_B_ON();
uint8_t page = c->arg[0];
uint8_t initalwipe = c->arg[1];
Expand All @@ -1186,6 +1186,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
cmd_send(CMD_ACK, isok, 0, 0, 0, 0);
LED_B_OFF();
break;
}
case CMD_DOWNLOAND_FLASH_MEM: {

LED_B_ON();
Expand All @@ -1197,8 +1198,6 @@ void UsbPacketReceived(uint8_t *packet, int len) {
// arg0 = startindex
// arg1 = length bytes to transfer
// arg2 = RFU
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, c->arg[2]);

for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);

Expand All @@ -1215,6 +1214,23 @@ void UsbPacketReceived(uint8_t *packet, int len) {
LED_B_OFF();
break;
}
case CMD_INFO_FLASH_MEM: {

LED_B_ON();
rdv40_validation_t *info = (rdv40_validation_t*)BigBuf_malloc( sizeof(rdv40_validation_t) );

bool isok = Flash_ReadData(FLASH_MEM_SIGNATURE_OFFSET, info->signature, FLASH_MEM_SIGNATURE_LEN);

if (FlashInit()) {
Flash_UniqueID( info->flashid);
FlashStop();
}
cmd_send(CMD_ACK, isok, 0, 0, info, sizeof(rdv40_validation_t));
BigBuf_free();

LED_B_OFF();
break;
}
#endif
case CMD_SET_LF_DIVISOR:
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
Expand Down
31 changes: 30 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.

//
//-----------------------------------------------------------------------------
// Interlib Definitions
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -46,6 +46,35 @@ extern int MF_DBGLEVEL;
#endif
#define RAMFUNC __attribute((long_call, section(".ramfunc")))

// RDV40 Section
#ifndef FLASH_MEM_BLOCK_SIZE
# define FLASH_MEM_BLOCK_SIZE 256
#endif

#ifndef FLASH_MEM_MAX_SIZE
# define FLASH_MEM_MAX_SIZE 0x3FFFF
#endif

#ifndef FLASH_MEM_ID_LEN
# define FLASH_MEM_ID_LEN 8
#endif

#ifndef FLASH_MEM_SIGNATURE_LEN
# define FLASH_MEM_SIGNATURE_LEN 128
#endif

#ifndef FLASH_MEM_SIGNATURE_OFFSET
# define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN)
#endif


// RDV40, validation structure to help identifying that client/firmware is talking with RDV40
typedef struct {
uint8_t magic[4];
uint8_t flashid[FLASH_MEM_ID_LEN];
uint8_t signature[FLASH_MEM_SIGNATURE_LEN];
} __attribute__((__packed__)) rdv40_validation_t;


#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion include/usb_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ typedef struct{
#define CMD_DOWNLOAD_EML_BIGBUF 0x0110
#define CMD_DOWNLOADED_EML_BIGBUF 0x0111

// For Flash memory operations
// RDV40, Flash memory operations
#define CMD_READ_FLASH_MEM 0x0120
#define CMD_WRITE_FLASH_MEM 0x0121
#define CMD_WIPE_FLASH_MEM 0x0122
#define CMD_DOWNLOAND_FLASH_MEM 0x0123
#define CMD_DOWNLOADED_FLASHMEM 0x0124
#define CMD_INFO_FLASH_MEM 0x0125

// For low-frequency tags
#define CMD_READ_TI_TYPE 0x0202
Expand Down

0 comments on commit 6b78192

Please sign in to comment.