mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-21 05:43:23 -07:00
Implement version information storage and retrieval for the bootrom and the osimage.
Use perl to create the version information (thereby re-creating the perl dependency and adding an svn dependency) but fall back in case of missing perl or svn
This commit is contained in:
parent
42bc3be31c
commit
8a6aec16d8
13 changed files with 171 additions and 13 deletions
|
@ -13,6 +13,7 @@ THUMBSRC = start.c \
|
|||
lfops.c \
|
||||
iso15693.c \
|
||||
util.c \
|
||||
version.c \
|
||||
usb.c
|
||||
|
||||
# These are to be compiled in ARM mode
|
||||
|
@ -43,6 +44,7 @@ clean:
|
|||
$(DELETE) $(OBJDIR)$(PATHSEP)*.s19
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.map
|
||||
$(DELETE) $(OBJDIR)$(PATHSEP)*.d
|
||||
$(DELETE) version.c
|
||||
|
||||
.PHONY: all clean help
|
||||
help:
|
||||
|
|
|
@ -236,10 +236,28 @@ void ReadMem(int addr)
|
|||
DbpIntegers(0, data[i], data[i+1]);
|
||||
}
|
||||
|
||||
/* osimage version information is linked in */
|
||||
extern struct version_information version_information;
|
||||
void SendVersion(void)
|
||||
{
|
||||
char temp[48]; /* Limited data payload in USB packets */
|
||||
DbpString("Prox/RFID mark3 RFID instrument");
|
||||
|
||||
/* Try to find the bootrom version information. For the time being, expect
|
||||
* to find a pointer at address 0x1001fc, perform slight sanity checks on
|
||||
* the pointer, then use it.
|
||||
*/
|
||||
void *bootrom_version = *(void**)0x1001fc;
|
||||
if( bootrom_version < (void*)0x100000 || bootrom_version > (void*)0x101000 ) {
|
||||
DbpString("bootrom version information appears invalid");
|
||||
} else {
|
||||
FormatVersionInformation(temp, sizeof(temp), "bootrom: ", bootrom_version);
|
||||
DbpString(temp);
|
||||
}
|
||||
|
||||
FormatVersionInformation(temp, sizeof(temp), "os: ", &version_information);
|
||||
DbpString(temp);
|
||||
|
||||
FpgaGatherVersion(temp, sizeof(temp));
|
||||
DbpString(temp);
|
||||
}
|
||||
|
|
|
@ -112,5 +112,6 @@ void LED(int led, int ms);
|
|||
void LEDsoff();
|
||||
int BUTTON_CLICKED(int ms);
|
||||
int BUTTON_HELD(int ms);
|
||||
void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,7 @@ SECTIONS
|
|||
*(.text.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.version_information)
|
||||
} >osimage
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
|
|
|
@ -235,3 +235,37 @@ void SpinDelay(int ms)
|
|||
// convert to uS and call microsecond delay function
|
||||
SpinDelayUs(ms*1000);
|
||||
}
|
||||
|
||||
/* Similar to FpgaGatherVersion this formats stored version information
|
||||
* into a string representation. It takes a pointer to the struct version_information,
|
||||
* verifies the magic properties, then stores a formatted string, prefixed by
|
||||
* prefix in dst.
|
||||
*/
|
||||
void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information)
|
||||
{
|
||||
struct version_information *v = (struct version_information*)version_information;
|
||||
dst[0] = 0;
|
||||
strncat(dst, prefix, len);
|
||||
if(v->magic != VERSION_INFORMATION_MAGIC) {
|
||||
strncat(dst, "Missing/Invalid version information", len);
|
||||
return;
|
||||
}
|
||||
if(v->versionversion != 1) {
|
||||
strncat(dst, "Version information not understood", len);
|
||||
return;
|
||||
}
|
||||
if(!v->present) {
|
||||
strncat(dst, "Version information not available", len);
|
||||
return;
|
||||
}
|
||||
|
||||
strncat(dst, v->svnversion, len);
|
||||
if(v->clean == 0) {
|
||||
strncat(dst, "-unclean", len);
|
||||
} else if(v->clean == 2) {
|
||||
strncat(dst, "-suspect", len);
|
||||
}
|
||||
|
||||
strncat(dst, " ", len);
|
||||
strncat(dst, v->buildtime, len);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue