Files
OpenCellular/common/version.c
Alec Berg b7f1d52619 zinger: samus_pd: change zinger SW ver to report commit count
Change the zinger software version returned by VDO_CMD_READ_INFO
to report the commit count portion of the version string to make
the software version automatically change. This software version
is important for debugging and is printed to PD console every time
a zinger is attached.

BUG=none
BRANCH=none
TEST=load onto zinger and samus, plug in zinger and see:
Dev:1 SW:2147 RW:0
compare to the version string in zinger binary and we see:
zinger_v1.1.2147-...

Change-Id: Ieafe89b4b16cee076be17bcbc6774bbd7fc24f8e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/214428
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-28 20:12:52 +00:00

52 lines
1.1 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 "ec_version.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;
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);
}