Commit Graph

19 Commits

Author SHA1 Message Date
Vadim Bendebury
38650d0b5d util: move 'dirty' marker to be a prefix, not a suffix
With longer git SHA1s reported by git commands and longer version
strings, the entire SHA1 could be not fitting into the 32 byte version
of the VERSION string. So, instead of adding the 'dirty' marker to the
end of SHA1 let's replace the prefix dash with it in case the tree is
dirty.

This way the length of the version string does not change (as long as
the 'dirty' marker is one character long).

BRANCH=cr50
BUG=b:64698702
TEST=verified output of running getversion.sh with a clean tree

   $ ./util/getversion.sh  | grep VERSION32
   #define CROS_EC_VERSION32 "_v1.1.7046-591608e2e"

  and a 'dirty' tree

   $ ./util/getversion.sh  | grep VERSION32
   #define CROS_EC_VERSION32 "_v1.1.7046+591608e2e"

Change-Id: I42684522beaff9e9714206cfaddaf97e6cd644be
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/665958
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-15 08:46:32 -07:00
Vadim Bendebury
187d57f292 cr50: change DEV to DBG in debug images version strings
There are two types of signing of CR50 images - prod and dev.
Designating images built with CR50_DEV variable set in the environment
as DEV is confusing, as this has nothing to do with the signing type
(dev vs prod), and is in fact indicating an image with many debug
features enabled.

This patch changes the string to "DBG".

BRANCH=cr50
BUG=none

TEST=verified that the modified image has correct string in the
     version field:
  > vers
  Chip:    g cr50 B2-D
  Board:   0
  RO_A:  * 0.0.10/29d77172
  RO_B:    -1.-1.-1/ffffffff
  RW_A:    0.0.16/DBG/cr50_v1.1.6137-1624610+
  RW_B:  * 0.0.16/cr50_v1.1.6137-1624610+
  Build:   0.0.16/cr50_v1.1.6137-1624610+
           tpm2:v0.0.287-1a68fe6
           cryptoc:v0.0.8-6283eee
           2017-03-06 16:51:15 vbendeb@eskimo.mtv.corp.google.com
   >

Change-Id: I06a97a6aff5418a4d02e71ca23813e6d2005da5c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/450903
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-03-07 04:17:32 -08:00
Simon Glass
b6c1d0d490 Makefile: Suppress 'Not a git repository' errors
We get a lot of these errors when running the EC Makefile from an ebuild.
They are not useful since of course there is no git repo when the source
code is built from a copy. An empty date (as produced in this case) is
presumably good enough.

Suppress these errors by redirecting stderr.

BUG=chromium:680243
BRANCH=none
TEST=V=0 emerge-reef chromeos-ec; See that the git output is gone

Change-Id: Ia3d1e2046c87e0ca88d0c18e432467f9d23b7e9f
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/428156
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-01-14 10:20:02 -08:00
Daisuke Nojiri
ce3e350ade getversion: Fix lucid failing because of version strings
make build=lucid fails if there is an uncommitted change in the tree
because '-dirty' is appended to version strings, which causes the image
to exceed the flash size limit.

BUG=chromium:654549
BRANCH=none
TEST=make buildall -j

Change-Id: Ie4a7b4c7dc70846108aed953215f79dc30a10fca
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/396617
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-14 16:05:47 -07:00
Bill Richardson
c5d03154ee Cr50: Remove private-cr51 from version string
We no longer depend on this directory, so there's no need to
include its sha1sum in the version string.

BUG=chrome-os-partner:54101
BRANCH=none
TEST=make buildall; try on Cr50 hardware

Before

> version
Chip:    g cr50 B2
Board:   0
RO_A:  * 0.0.9/0088a3eb
RO_B:    0.0.3/8fe06b9e
RW_A:  * 0.0.6/DEV/cr50_v1.1.5333-cca986c
RW_B:    0.0.6/DEV/cr50_v1.1.5334-115b338
Build:   0.0.6/DEV/cr50_v1.1.5333-cca986c
         private-cr51:v0.0.87-24457f2
         tpm2:v0.0.264-5e5aaa3
         cryptoc:v0.0.4-5319e83
         2016-09-16 21:59:31 wfrichar@wintermute.mt
>

After

> version
Chip:    g cr50 B2
Board:   0
RO_A:  * 0.0.9/0088a3eb
RO_B:    0.0.3/8fe06b9e
RW_A:    0.0.6/DEV/cr50_v1.1.5333-cca986c
RW_B:  * 0.0.6/DEV/cr50_v1.1.5334-36b2cee
Build:   0.0.6/DEV/cr50_v1.1.5334-36b2cee
         tpm2:v0.0.264-5e5aaa3
         cryptoc:v0.0.4-5319e83
         2016-09-19 17:48:17 wfrichar@wintermute.mtv.corp.google.com
>

Change-Id: I785dff86e6b970219da87c8674f2a324fa074987
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/387238
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-09-21 19:37:13 -07:00
Bill Richardson
30f978d9c1 Cr50: Flag unofficial images in the version string
We often find it handy to build test images that are unlocked or
have special powers. To avoid confusing these with production
images, this adds a "DEV/" to the version string:

"make BOARD=cr50" looks like this:

  > version
  Chip:    g cr50 B2
  Board:   0
  RO_A:  * 0.0.9/0088a3eb
  RO_B:    0.0.8/710d4375
  RW_A:  * 0.0.6/cr50_v1.1.5261-4848d7e
  RW_B:    0.0.6/cr50_v1.1.5261-4848d7e
  [...]

"CR50_DEV=1 make BOARD=cr50" looks like this:

  > version
  Chip:    g cr50 B2
  Board:   0
  RO_A:  * 0.0.9/0088a3eb
  RO_B:    0.0.8/710d4375
  RW_A:    0.0.6/cr50_v1.1.5261-4848d7e
  RW_B:  * 0.0.6/DEV/cr50_v1.1.5261-4848d7e
  [...]

BUG=chrome-os-partner:55557
BRANCH=none
TEST=make buildall; also..

Build both with and without the CR50_DEV=1 environment variable.
Observe that the version string differs even if nothing else
does.

Change-Id: Ifee9fbf922c2bbb40a1a9d0a716d2d11aa0d3ec2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/382851
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-09-08 11:22:30 -07:00
Vadim Bendebury
ea91c71c08 util: do not generate unrelated version information
The recent addition of the multicomponent version string for cr50,
requires further tweaking of the version generating script. In
particular, the CROS_EC_VERSION32 variable used by the "verson" cli
command is not supposed to include any information about subcomponents
of the image, it should reflect the EC version only.

Separating everything after the first space accomplishes that.

BRANCH=none
BUG=chrome-os-partner:55373
TEST=verified that RO_x and RW_x versions are printed properly:
  > vers
  Chip:    g cr50 B2
  Board:   0
  RO_A:    0.0.1/84e2dde7
  RO_B:  * 0.0.3/8fe06b9e
  RW_A:    cr50_v1.1.4992-7c9f891+ private
  RW_B:  * cr50_v1.1.4989-52b3cc6+
  ...

Change-Id: I192eb29816dfa963b08aa97f749b978b1367d6b7
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364490
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-29 21:37:54 -07:00
Vadim Bendebury
33bbf37d2a util: collect cr50 versions from multiple git trees
The cr50 code comes from four different repositories. This patch
introduces an array of the repositories where version information is
supposed to come from.

For all boards but cr50 this array includes just the local repository,
for cr50 the array is extended with the three other components.

This patch also allows to change the 'tree dirty' marker appended to
the sha1s of the 'dirty' trees, having a shorter marker helps to keep
multicomponent version strings shorter.

All external component's version information in the generated combined
version string is prepended by the component's root directory name.

BRANCH=ToT
BUG=chrome-os-partner:55373
TEST=ran the script for two EC boards, kevin and cr50, verified the
     output:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is clean, use the commit date of the last commit */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

then introduced some local changes in the ec and tpm2 directories and
ran the script again. Note the '+' used as the 'dirty' marker in the
cr50 string:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ BOARD=kevin ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is dirty, using time of last compilation */
$
$ BOARD=cr50 ./util/getversion.sh
/* This file is generated by util/getversion.sh */
/* Version string for use by common/version.c */
/* Version string, truncated to 31 chars (+ terminating null = 32) */
/* Sub-fields for use in Makefile.rules and to form build info string
 * in common/version.c. */
/* Repo is dirty, using time of last compilation */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Change-Id: I4b4ec23ce003970c09442e8d8aeed2306d4e5dd8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363917
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2016-07-28 22:57:21 -07:00
Vadim Bendebury
3531d6123b util: refactor getversion.sh
It is necessary to collect information about more then one git
repositories status for the cr50 board. To facilitate this, separate
the code retrieving build version information into a function,
get_tree_version().

The function returns a two element string, the version information and
the 'dirty' marker in case the tree has any uncommitted changes. The
0x01 character is used to join the elements of the string, which makes
it easier to split the string when processing it.

BRANCH=ToT
BUG=chrome-os-partner:55373
TEST=ran the script before and after changes, observed that generated
      output is identical.

Change-Id: I2c211cbda8c3cab3c8c21b4430e4b3102691e74a
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362849
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-28 20:20:44 -07:00
Shawn Nematbakhsh
0e532c6044 cleanup: Remove SHIFT_CODE_FOR_TEST handling
SHIFT_CODE_FOR_TEST images were used for an old FAFT test but is no
longer in use today.

BUG=chromium:616806
BRANCH=None
TEST=`make buildall -j`
CQ-DEPEND=CL:349281

Change-Id: I1b4e8c2560e2a7ff507cf2275dbbbdabf435866b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/349272
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Tom Tam <waihong@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-06-03 03:00:08 -07:00
Shawn Nematbakhsh
4b10eb6c09 getversion: Use commit date for date stamp
The git author date usually reflects the time a CL was first pushed to
gerrit, not the time it lands to the tree. Therefore, the author date is
misleading when used as a timestamp. Use the git commit date instead.

BUG=chromium:554675
BRANCH=None
TEST=Cherry-pick CL:293345 and verify date stamp is today, not last
August.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I4fb042d7a706fbb86897b3e383b3242602af242b
Reviewed-on: https://chromium-review.googlesource.com/313022
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-11-17 22:06:48 -08:00
Bill Richardson
5d138b379d Make builds repeatable.
We have been using the time of compilation to determine the
version string. This CL will keep doing that if the git repo has
uncommitted changes, but if the repo is clean we'll just use the
author date of the last commit. This ensures that the same source
will produce bitwise-identical builds (assuming no toolchain
changes, of course).

BUG=chrome-os-partner:45616
BRANCH=none
TEST=manual

  cd src/platform/ec
  make buildall
  mv build build.one
  make buildall
  md5sum build{,.one}/*/ec.bin | sort

Observe that successive builds produce identical binaries.

Change-Id: Ie2ef44b216586097589c9c15f12e05c87a53f991
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302140
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-24 12:46:28 -07:00
Vincent Palatin
decd6a545f add hash for locally emerged builds
When the EC is built using "emerge-<board> chromeos-ec" on a developer
workstation with the chromeos-ec package "cros-worked'on", put
"1.1.9999-<git-sha1>" rather than "no_version" in the version string.

Emerge is exporting the current git SHA-1 hash in the VCSID id but the
.git repository is not available during the build.

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

BRANCH=none
BUG=none
TEST=try the following build setups:
- local emerge
$ emerge-smaug chromeos-ec
$ strings /build/smaug/firmware/ec.bin | grep ryu
ryu_p4p5_1.1.9999-ebe18ef
- local build
$ make BOARD=ryu_p4p5
$ strings build/ryu_p4p5/ec.bin | grep ryu
ryu_p4p5_v1.1.3127-ebe18ef-dirt
- trybot build
$ cbuildbot --remote -g 270554 smaug-firmware
$ tar xvjf firmware_from_sources.tar.bz2
$ strings ec.bin | grep ryu
ryu_p4p5_v1.1.3137-9b52578

Change-Id: I386f80d82d95b5e99a1660a1eb242c47c54d17ef
Reviewed-on: https://chromium-review.googlesource.com/270554
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-13 22:23:06 +00:00
Bill Richardson
8a94ea4fbd Add USE_GIT_DATE=1 to make args to build repeatable images
Up until now, every image includes the time of compilation in the
build information. This makes it impossible to verify that a
particular image came from a particular source code snapshot.

With this change, specifying USE_GIT_DATE=1 to the make command
will use the author date of HEAD as the timestamp. That means
that successive builds from the same source will produce
bitwise-identical output (assuming the same toolchain, of
course).

BUG=none
BRANCH=none
TEST=manual

Do this twice:

  \rm -rf build
  make BOARD=cr50 USE_GIT_DATE=1
  md5sum build/cr50/ec.bin

The md5sum should be the same for both runs.

Change-Id: If64307101a453cb13c62fa003f1bf432f4998273
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/252751
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-25 03:33:18 +00:00
Anton Staaf
8513e23df1 USB: Remove special case for iVersion string descriptor
Previously the version string was special cased in the USB stack
because the build system prevented the inclusion of ec_version.h in
any file other than common/version.c.  This lead to common/version.c
being the only place that the USB version string could be computed
and thus the special case of filling in the version string descriptor
at run time.  This made the USB stack more complex, and lead to the
common/version.c file including usb.h, which is actually STM32
specific.

Now, the portion of ec_version.h that is deterministic is only
updated when something in the tree actually changes (by way of a
conditional in the makefile), and ec_version.h no longer has to
depend on all object files (other than the special version.o).
This allows anyone to include ec_version.h as needed.  In particular,
each board that wants to define a USB version string can directly
include ec_version.h and do so.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     touch files and verify rebuilds happen correctly

Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49
Reviewed-on: https://chromium-review.googlesource.com/227211
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-11-04 21:34:39 +00:00
Randall Spangler
fe76b51da0 Truncate version string to 32 characters
The version struct and EC_CMD_GET_VERSION assume 32-character version
strings.  But if the git tree is dirty and the board name is long, the
version string overflows that limit.

This change truncates what's stored in the version string to fit.

The build info still contains the full version string, as it did before.

BUG=chrome-os-partner:21156
BRANCH=none
TEST=build BOARD=mccroskey with a dirty tree; it should build.
     Then cat build/mccroskey/ec_version.h to see CROS_EC_VERSION32 has
     truncated the version string.  Then build a platform of your choice
     and type 'version' to see that the version string and build info is
     still reported correctly.

Change-Id: Ie71b8efd99a83315f8b4d5ad10c51e48781b12f4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62649
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-07-19 18:01:55 -07:00
Vic Yang
096ffbb04e Append "shift" to version string in shifted image
For EC update test, we produce binary-wise shifted image. To make it
easier to tell if update has succeeded, let's append "shift" to the
verison in this image.

BUG=chrome-os-partner:10264
TEST=Build shifted image and check the version string.

Change-Id: I16187611cf61fc97a74bc3707a77ad9ad5274f37
Reviewed-on: https://gerrit.chromium.org/gerrit/27577
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-16 20:52:00 -07:00
Vincent Palatin
5877a40923 fix version generation script
Fix the quoting for git local change detection.

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

BUG=None
TEST=run ./util/getversion.sh on a repository with and without local
changes and observe we no longer have a spurious output on stderr.

Change-Id: I40ea4505d175c9135027ba7cf2b787c08eff6f70
2012-03-02 22:37:36 +00:00
Vincent Palatin
a94e3277b3 update versioning information stored in the EC
Add build information (date/time/builder) which can be displayed at the
EC console.

Generate a version from the board name and the branch tag.

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

BUG=chromium-os:27013
TEST=on BDS, run version command on the console.
inspect the built binary.

Change-Id: Idb1f68898ba6b811d02919f17ab4536ed9f8934a
2012-03-02 16:46:26 +00:00