From 2b7728cd9d306648328d505c6f4700c6918506fa Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 11 Jan 2016 20:47:36 +0100 Subject: sysmobts-calib: Warn about firmware and header mismatch sysmobts-calib might be easily patched by a user that does not know that firmware and firmware headers form a contract that should be matched. Compare the version numbers and print a warning if it does not look correct. This should be enough for a user to see that something is not right. Continue anyway as the firmware might still be compatible (because the ABI has not changed). Fixes: SYS#1172 --- contrib/sysmobts-calib/sysmobts-layer1.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/sysmobts-calib/sysmobts-layer1.c b/contrib/sysmobts-calib/sysmobts-layer1.c index ddc4e2e2..4b34f50e 100644 --- a/contrib/sysmobts-calib/sysmobts-layer1.c +++ b/contrib/sysmobts-calib/sysmobts-layer1.c @@ -310,19 +310,36 @@ int print_system_info() #ifdef FEMTOBTS_NO_BOARD_VERSION #define BOARD_REV(x) -1 #define BOARD_OPT(x) -1 +#define COMPILED_MAJOR (FEMTOBTS_API_VERSION >> 16) +#define COMPILED_MINOR ((FEMTOBTS_API_VERSION >> 8) & 0xff) +#define COMPILED_BUILD (FEMTOBTS_API_VERSION & 0xff) #else #define BOARD_REV(x) x.u.systemInfoCnf.boardVersion.rev #define BOARD_OPT(x) x.u.systemInfoCnf.boardVersion.option +#define COMPILED_MAJOR (SUPERFEMTO_API_VERSION >> 16) +#define COMPILED_MINOR ((SUPERFEMTO_API_VERSION >> 8) & 0xff) +#define COMPILED_BUILD (SUPERFEMTO_API_VERSION & 0xff) #endif - printf("DSP v%d.%d.%d FPGA v%d.%d.%d Rev: %d Option: %d\n", + printf("Compiled against: v%u.%u.%u\n", + COMPILED_MAJOR, COMPILED_MINOR, COMPILED_BUILD); + printf("Running DSP v%d.%d.%d FPGA v%d.%d.%d Rev: %d Option: %d\n", INFO_DSP(prim).major, INFO_DSP(prim).minor, INFO_DSP(prim).build, INFO_FPGA(prim).major, INFO_FPGA(prim).minor, INFO_FPGA(prim).build, BOARD_REV(prim), BOARD_OPT(prim)); + + if (COMPILED_MAJOR != INFO_DSP(prim).major || COMPILED_MINOR != INFO_DSP(prim).minor) { + printf("WARNING! WARNING! WARNING! WARNING! WARNING\n"); + printf("You might run this against an incompatible firmware.\n"); + printf("Continuing anyway but the result might be broken\n"); + } #undef INFO_DSP #undef INFO_FPGA #undef BOARD_REV #undef BOARD_OPT +#undef COMPILED_MAJOR +#undef COMPILED_MINOR +#undef COMPILED_BUILD return 0; } -- cgit v1.2.3