43 #include <px4_platform_common/px4_config.h> 44 #include <px4_platform_common/module.h> 62 static void usage(
const char *reason)
65 printf(
"%s\n\n", reason);
68 PRINT_MODULE_DESCRIPTION(
"Tool to print various version information");
70 PRINT_MODULE_USAGE_NAME(
"ver",
"command");
71 PRINT_MODULE_USAGE_COMMAND_DESCR(
"hw",
"Hardware architecture");
72 PRINT_MODULE_USAGE_COMMAND_DESCR(
"mcu",
"MCU info");
73 PRINT_MODULE_USAGE_COMMAND_DESCR(
"git",
"git version information");
74 PRINT_MODULE_USAGE_COMMAND_DESCR(
"bdate",
"Build date and time");
75 PRINT_MODULE_USAGE_COMMAND_DESCR(
"gcc",
"Compiler info");
76 PRINT_MODULE_USAGE_COMMAND_DESCR(
"bdate",
"Build date and time");
77 PRINT_MODULE_USAGE_COMMAND_DESCR(
"px4guid",
"PX4 GUID");
78 PRINT_MODULE_USAGE_COMMAND_DESCR(
"uri",
"Build URI");
80 PRINT_MODULE_USAGE_COMMAND_DESCR(
"all",
"Print all versions");
81 PRINT_MODULE_USAGE_COMMAND_DESCR(
"hwcmp",
"Compare hardware version (returns 0 on match)");
82 PRINT_MODULE_USAGE_ARG(
"<hw> [<hw2>]",
83 "Hardware to compare against (eg. PX4_FMU_V4). An OR comparison is used if multiple are specified",
false);
84 PRINT_MODULE_USAGE_COMMAND_DESCR(
"hwtypecmp",
"Compare hardware type (returns 0 on match)");
85 PRINT_MODULE_USAGE_ARG(
"<hwtype> [<hwtype2>]",
86 "Hardware type to compare against (eg. V2). An OR comparison is used if multiple are specified",
false);
98 if (argv[1] != NULL) {
101 if (argc >= 3 && argv[2] != NULL) {
104 for (
int i = 2; i < argc; ++i) {
105 if (strcmp(board_name, argv[i]) == 0) {
111 PX4_ERR(
"Not enough arguments, try 'ver hwcmp PX4_FMU_V2'");
118 if (argc >= 3 && argv[2] != NULL) {
121 for (
int i = 2; i < argc; ++i) {
122 if (strcmp(board_type, argv[i]) == 0) {
128 PX4_ERR(
"Not enough arguments, try 'ver hwtypecmp {V2|V2M|V30|V31}'");
139 #if defined(BOARD_HAS_VERSIONING) 146 snprintf(vb,
sizeof(vb),
"0x%08X", v);
150 snprintf(rb,
sizeof(rb),
"0x%08X", r);
154 printf(
"HW version: %s\n", vb);
155 printf(
"HW revision: %s\n", rb);
164 unsigned major = (fwver >> (8 * 3)) & 0xFF;
165 unsigned minor = (fwver >> (8 * 2)) & 0xFF;
166 unsigned patch = (fwver >> (8 * 1)) & 0xFF;
167 unsigned type = (fwver >> (8 * 0)) & 0xFF;
170 printf(
"FW version: Release %u.%u.%u (%u)\n", major, minor, patch, fwver);
173 printf(
"FW version: %u.%u.%u %x (%u)\n", major, minor, patch, type, fwver);
179 if (git_branch && git_branch[0]) {
180 printf(
"FW git-branch: %s\n", git_branch);
185 major = (fwver >> (8 * 3)) & 0xFF;
186 minor = (fwver >> (8 * 2)) & 0xFF;
187 patch = (fwver >> (8 * 1)) & 0xFF;
188 type = (fwver >> (8 * 0)) & 0xFF;
192 printf(
"OS version: Release %u.%u.%u (%u)\n", major, minor, patch, fwver);
195 printf(
"OS version: %u.%u.%u %u (%u)\n", major, minor, patch, type, fwver);
201 printf(
"OS git-hash: %s\n", os_git_hash);
209 printf(
"Build datetime: %s %s\n", __DATE__, __TIME__);
228 char px4guid_fmt_buffer[PX4_GUID_FORMAT_SIZE];
230 board_get_px4_guid_formated(px4guid_fmt_buffer,
sizeof(px4guid_fmt_buffer));
231 printf(
"PX4GUID: %s\n", px4guid_fmt_buffer);
238 const char *revstr = NULL;
239 const char *errata = NULL;
241 int chip_version = board_mcu_version(&rev, &revstr, &errata);
243 if (chip_version < 0) {
244 printf(
"UNKNOWN MCU\n");
247 printf(
"MCU: %s, rev. %c\n", revstr, rev);
249 if (errata != NULL) {
250 printf(
"\nWARNING WARNING WARNING!\n" 251 "Revision %c has a silicon errata:\n" 253 "\nhttps://docs.px4.io/en/flight_controller/silicon_errata.html\n\n", rev, errata);
261 PX4_ERR(
"unknown command");
266 usage(
"Error, input parameter NULL.");
270 usage(
"Error, not enough parameters.");
const char * px4_os_name(void)
name of the operating system
static const char * px4_board_sub_type(void)
get the board sub type
uint32_t px4_firmware_version(void)
get the PX4 Firmware version
const char * px4_toolchain_version(void)
Toolchain version used to compile PX4 (no particular format)
static const char mcu_ver_str[]
static const char px4_guid_str[]
static const char sz_ver_hwtypecmp_str[]
const char * px4_firmware_git_branch(void)
get the git branch name (can be empty, for example if HEAD points to a tag)
const char * px4_toolchain_name(void)
Toolchain name used to compile PX4.
static const char sz_ver_hw_str[]
uint32_t px4_os_version(void)
operating system version
__EXPORT int ver_main(int argc, char *argv[])
static int px4_board_hw_revision(void)
get the board HW revision
static __BEGIN_DECLS const char * px4_board_name(void)
get the board name as string (including the version if there are multiple)
const char * px4_firmware_version_string(void)
Firmware version as human readable string (git tag)
const char * px4_build_uri(void)
get the build URI (used for crash logging)
Tools for system version detection.
static const char sz_ver_bdate_str[]
static const char sz_ver_all_str[]
static const char sz_ver_hwcmp_str[]
static void usage(const char *reason)
static const char sz_ver_buri_str[]
static const char sz_ver_gcc_str[]
static int px4_board_hw_version(void)
get the board HW version
const char * px4_os_version_string(void)
Operating system version as human readable string (git tag)
static const char sz_ver_git_str[]