mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-12-26 10:01:07 +08:00
version info also for client, still cmake to do
This commit is contained in:
parent
86ba6c8330
commit
ef586c2a41
12 changed files with 69 additions and 53 deletions
|
@ -244,8 +244,7 @@ void ReadMem(int addr) {
|
|||
Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x", addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
||||
}
|
||||
|
||||
/* osimage version information is linked in */
|
||||
extern struct version_information version_information;
|
||||
/* osimage version information is linked in, cf commonutil.h */
|
||||
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
||||
extern char *_bootphase1_version_pointer, _flash_start, _flash_end, __data_src_start__;
|
||||
static void SendVersion(void) {
|
||||
|
@ -265,10 +264,12 @@ static void SendVersion(void) {
|
|||
} else {
|
||||
FormatVersionInformation(temp, sizeof(temp), " bootrom: ", bootrom_version);
|
||||
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
}
|
||||
|
||||
FormatVersionInformation(temp, sizeof(temp), " os: ", &version_information);
|
||||
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
|
||||
#if defined(__clang__)
|
||||
strncat(VersionString, " compiled with Clang/LLVM "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1);
|
||||
|
|
|
@ -289,40 +289,6 @@ int BUTTON_HELD(int ms) {
|
|||
return BUTTON_ERROR;
|
||||
}
|
||||
|
||||
/* 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 - 1);
|
||||
if (v->magic != VERSION_INFORMATION_MAGIC) {
|
||||
strncat(dst, "Missing/Invalid version information\n", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
if (v->versionversion != 1) {
|
||||
strncat(dst, "Version information not understood\n", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
if (!v->present) {
|
||||
strncat(dst, "Version information not available\n", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
strncat(dst, v->gitversion, len - strlen(dst) - 1);
|
||||
if (v->clean == 0) {
|
||||
strncat(dst, "-unclean", len - strlen(dst) - 1);
|
||||
} else if (v->clean == 2) {
|
||||
strncat(dst, "-suspect", len - strlen(dst) - 1);
|
||||
}
|
||||
|
||||
strncat(dst, " ", len - strlen(dst) - 1);
|
||||
strncat(dst, v->buildtime, len - strlen(dst) - 1);
|
||||
strncat(dst, "\n", len - strlen(dst) - 1);
|
||||
}
|
||||
|
||||
bool data_available(void) {
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
return usb_poll_validate_length() || (usart_rxdata_available() > 0);
|
||||
|
|
|
@ -91,7 +91,6 @@ void SpinUp(uint32_t speed);
|
|||
|
||||
int BUTTON_CLICKED(int ms);
|
||||
int BUTTON_HELD(int ms);
|
||||
void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_information);
|
||||
bool data_available(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -179,7 +179,8 @@ CORESRCS = uart/uart_posix.c \
|
|||
scandir.c \
|
||||
crc16.c \
|
||||
crc32.c \
|
||||
comms.c
|
||||
comms.c \
|
||||
version.c
|
||||
|
||||
CMDSRCS = crapto1/crapto1.c \
|
||||
crapto1/crypto1.c \
|
||||
|
@ -308,7 +309,7 @@ CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
|
|||
OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
|
||||
|
||||
BINS = proxmark3
|
||||
CLEAN = $(BINS) src/*.moc.cpp src/ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
|
||||
CLEAN = $(BINS) src/version.c src/*.moc.cpp src/ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
|
||||
# transition: cleaning also old path stuff
|
||||
CLEAN += flasher *.moc.cpp ui/ui_overlays.h
|
||||
|
||||
|
@ -426,6 +427,11 @@ zlib:
|
|||
|
||||
.PHONY: all clean install uninstall tarbin liblua jansson tinycbor reveng hardnested amiibo cliparser whereami mbedtls zlib
|
||||
|
||||
# version.c should be remade on every compilation
|
||||
src/version.c: default_version.c
|
||||
$(info [=] GEN $@)
|
||||
$(Q)sh ../tools/mkversion.sh > $@ || perl ../tools/mkversion.pl > $@ || $(CP) $^ $@
|
||||
|
||||
# easy printing of MAKE VARIABLES
|
||||
print-%: ; @echo $* = $($*)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "ui.h"
|
||||
#include "cmdhw.h"
|
||||
#include "cmddata.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -688,7 +689,9 @@ void pm3_version(bool verbose, bool oneliner) {
|
|||
|
||||
if (oneliner) {
|
||||
// For "proxmark3 -v", simple printf, avoid logging
|
||||
printf("Client: RRG/Iceman compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH "\n");
|
||||
char temp[PM3_CMD_DATA_SIZE - 12]; // same limit as for ARM image
|
||||
FormatVersionInformation(temp, sizeof(temp), "Client: ", &version_information);
|
||||
printf("%s compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH "\n", temp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -701,9 +704,11 @@ void pm3_version(bool verbose, bool oneliner) {
|
|||
SendCommandNG(CMD_VERSION, NULL, 0);
|
||||
|
||||
if (WaitForResponseTimeout(CMD_VERSION, &resp, 1000)) {
|
||||
char temp[PM3_CMD_DATA_SIZE - 12]; // same limit as for ARM image
|
||||
PrintAndLogEx(NORMAL, "\n " _YELLOW_("[ Proxmark3 RFID instrument ]"));
|
||||
PrintAndLogEx(NORMAL, "\n " _YELLOW_("[ CLIENT ]"));
|
||||
PrintAndLogEx(NORMAL, " client: RRG/Iceman"); // TODO version info?
|
||||
FormatVersionInformation(temp, sizeof(temp), " client: ", &version_information);
|
||||
PrintAndLogEx(NORMAL, "%s", temp);
|
||||
PrintAndLogEx(NORMAL, " compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH);
|
||||
|
||||
if (IfPm3Flash() == false && IfPm3Smartcard() == false && IfPm3FpcUsartHost() == false) {
|
||||
|
|
|
@ -8,6 +8,40 @@
|
|||
// Utility functions used in many places, not specific to any piece of code.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "commonutil.h"
|
||||
#include <string.h>
|
||||
|
||||
/* 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_info) {
|
||||
struct version_information *v = (struct version_information *)version_info;
|
||||
dst[0] = 0;
|
||||
strncat(dst, prefix, len - 1);
|
||||
if (v->magic != VERSION_INFORMATION_MAGIC) {
|
||||
strncat(dst, "Missing/Invalid version information", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
if (v->versionversion != 1) {
|
||||
strncat(dst, "Version information not understood", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
if (!v->present) {
|
||||
strncat(dst, "Version information not available", len - strlen(dst) - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
strncat(dst, v->gitversion, len - strlen(dst) - 1);
|
||||
if (v->clean == 0) {
|
||||
strncat(dst, "-unclean", len - strlen(dst) - 1);
|
||||
} else if (v->clean == 2) {
|
||||
strncat(dst, "-suspect", len - strlen(dst) - 1);
|
||||
}
|
||||
|
||||
strncat(dst, " ", len - strlen(dst) - 1);
|
||||
strncat(dst, v->buildtime, len - strlen(dst) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
ref http://www.csm.ornl.gov/~dunigan/crc.html
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
# define NTIME(n) for (int _index = 0; _index < n; _index++)
|
||||
#endif
|
||||
|
||||
extern struct version_information version_information;
|
||||
void FormatVersionInformation(char *dst, int len, const char *prefix, void *version_info);
|
||||
|
||||
uint32_t reflect(uint32_t v, int b); // used in crc.c ...
|
||||
uint8_t reflect8(uint8_t b); // dedicated 8bit reversal
|
||||
uint16_t reflect16(uint16_t b); // dedicated 16bit reversal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "proxmark3_arm.h"
|
||||
#include "common.h"
|
||||
/* This is the default version.c file that Makefile.common falls back to if neither sh nor perl are available */
|
||||
const struct version_information __attribute__((section(".version_information"))) version_information = {
|
||||
VERSION_INFORMATION_MAGIC,
|
|
@ -36,6 +36,16 @@
|
|||
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
#define VERSION_INFORMATION_MAGIC 0x56334d50 // "PM3V"
|
||||
struct version_information {
|
||||
int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */
|
||||
char versionversion; /* Must be 1 */
|
||||
char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */
|
||||
char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */
|
||||
char gitversion[50]; /* String with the git revision */
|
||||
char buildtime[30]; /* string with the build time */
|
||||
} PACKED;
|
||||
|
||||
// debug
|
||||
#define DBG_NONE 0 // no messages
|
||||
#define DBG_ERROR 1 // errors only
|
||||
|
|
|
@ -115,15 +115,7 @@
|
|||
//NVDD goes LOW when USB is attached.
|
||||
#define USB_ATTACHED() !((AT91C_BASE_PIOA->PIO_PDSR & GPIO_NVDD_ON) == GPIO_NVDD_ON)
|
||||
|
||||
#define VERSION_INFORMATION_MAGIC 0x56334d50 // "PM3V"
|
||||
struct version_information {
|
||||
int magic; /* Magic sequence to identify this as a correct version information structure. Must be VERSION_INFORMATION_MAGIC */
|
||||
char versionversion; /* Must be 1 */
|
||||
char present; /* 1 if the version information could be created at compile time, otherwise 0 and the remaining fields (except for magic) are empty */
|
||||
char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */
|
||||
char gitversion[50]; /* String with the git revision */
|
||||
char buildtime[30]; /* string with the build time */
|
||||
} PACKED;
|
||||
// VERSION_INFORMATION is now in common.h
|
||||
|
||||
#define COMMON_AREA_MAGIC 0x43334d50 // "PM3C"
|
||||
#define COMMON_AREA_COMMAND_NONE 0
|
||||
|
|
|
@ -64,7 +64,7 @@ $fullgitinfo =~ s/(\s)//g;
|
|||
$fullgitinfo = substr $fullgitinfo, 0, 49;
|
||||
|
||||
print <<EOF
|
||||
#include "proxmark3_arm.h"
|
||||
#include "common.h"
|
||||
/* Generated file, do not edit */
|
||||
const struct version_information __attribute__((section(".version_information"))) version_information = {
|
||||
VERSION_INFORMATION_MAGIC,
|
||||
|
|
|
@ -47,7 +47,7 @@ if [ "$fullgitinfoextra" != "$fullgitinfo" ]; then
|
|||
fullgitinfo="${fullgitinfo46}..."
|
||||
fi
|
||||
cat <<EOF
|
||||
#include "proxmark3_arm.h"
|
||||
#include "common.h"
|
||||
/* Generated file, do not edit */
|
||||
const struct version_information __attribute__((section(".version_information"))) version_information = {
|
||||
VERSION_INFORMATION_MAGIC,
|
||||
|
|
Loading…
Reference in a new issue