Files
OpenCellular/common/version.c
Vincent Palatin 46102d3b4e usb: export firmware version
Remove the meaningless version string in iSerialNumber, which was incorrect
since this string should be unique to a device if it exists.

Export the firmware version string as the configuration string, so it's
traceable to a given firmware build/sources.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=samus
BUG=none
TEST=make buildall
from a workstation, do "sudo lsusb -v" and see the full version string
exported as the configuration name.

Change-Id: I557df2936421e2926ac0fc0003888370cec3e201
Reviewed-on: https://chromium-review.googlesource.com/222877
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-11 07:29:15 +00:00

59 lines
1.2 KiB
C

/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Embed firmware version number in the binary */
#include <stdint.h>
#include "common.h"
#include "ec_version.h"
#include "usb.h"
#include "version.h"
const struct version_struct version_data
__attribute__((section(".rodata.ver"))) = {
CROS_EC_VERSION_COOKIE1,
CROS_EC_VERSION32,
CROS_EC_VERSION_COOKIE2
};
const char build_info[] __attribute__((section(".rodata.buildinfo"))) =
CROS_EC_VERSION " " DATE " " BUILDER;
#ifdef CONFIG_USB
/* UTF-16 encoded USB string descriptor */
const void * const usb_fw_version = USB_STRING_DESC(CROS_EC_VERSION32);
#endif
uint32_t ver_get_numcommits(void)
{
int i;
int numperiods = 0;
uint32_t ret = 0;
/*
* Version string is formatted like:
* name_major.branch.numcommits-hash[dirty]
* we want to return the numcommits as an int.
*/
for (i = 0; i < 32; i++) {
if (version_data.version[i] == '.') {
numperiods++;
if (numperiods == 2)
break;
}
}
i++;
for (; i < 32; i++) {
if (version_data.version[i] == '-')
break;
ret *= 10;
ret += version_data.version[i] - '0';
}
return (i == 32 ? 0 : ret);
}