History log of /external/vboot_reference/tests/cgptlib_test.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
f3f7fca07fbcb6bb9655a71257f09c71b0a1458d 02-Jan-2015 Dan Ehrenberg <dehrenberg@chromium.org> nand: vboot support for small GPTs

This patch makes some small modifications to cgpt and vboot to
root out the last vestigates of a fixed 128-entry GPT:
- Get rid of the TOTAL_ENTRIES_SIZE constant and all users.
- Reduce MAX_NUMBER_OF_ENTRIES to 128 (which is what the GPT
spec specifies) so that this can be used for things like memory
allocations without additional overhead.
- Base the amount of GPT read/written on the number of entries
specified in the GPT header on disk/flash.

BUG=chromium:433433
TEST=make runalltests
TEST=Modified fmap to make an 8k RW_GPT, wrote a GPT with cgpt, then
rebooted and found that the GPT was correctly read after restarting
and the appropriate mtd partitions were present.
BRANCH=none

Change-Id: I45317377da20259caf04a7a4fa077a892b03c45f
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/238245
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
3200401242aec1521e7c4a8b1906366fcabfb1a2 12-Dec-2014 Nam T. Nguyen <namnguyen@chromium.org> cgpt: Support non-standard (smaller) entries table

The standard says that entries table must be at least 16384 bytes. On
some of our devices, the NOR section is only 8 KiB and used to store
both primary and secondary tables. On this device, we can only store 24
entries.

Therefore, this CL adds support for non-standard entry table. It adjusts
the MIN_NUMBER_OF_ENTRIES to 16, and replaces GPT_ENTRIES_SECTORS with
CalculateEntriesSectors.

BUG=chromium:441812
BRANCH=none
TEST=unittest

Change-Id: I6b85b35ce5612c7abb22142f8252bd0d45b676c5
Reviewed-on: https://chromium-review.googlesource.com/234996
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
b3d38f5c620da89662deb1a08971c5025d6c1132 09-Dec-2014 Dan Ehrenberg <dehrenberg@chromium.org> vboot: GPT interface cleanup

- Rename drive_sectors to streaming_drive_sectors, to contrast with
gpt_drive_sectors
- Replace stored_on_device field with flags field for future
extensibility

BUG=chromium:433433
TEST=make runtests
BRANCH=none

Change-Id: I785a3b735b8eb96f647a334659329db3ee43eb80
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/234283
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
8577b5360ca4c9514d9091ed9aded2bb3193f1f0 25-Nov-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: Remove FTS code

flash_ts driver (from Android) was pulled to support Sonic. But now we
go a different route, this CL is to drop the FTS code.

BUG=chromium:436597
BRANCH=none
TEST=unittest

Change-Id: I86d6273f9f5f642b504ccb6a76e005cda12d0e78
Reviewed-on: https://chromium-review.googlesource.com/231896
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
a524a3a51591618c1395cb9e1238ee72b3f5e767 07-Nov-2014 Dan Ehrenberg <dehrenberg@chromium.org> vboot: cgpt: fix my_lba of the secondary GPT

Previously, my_lba of the secondary GPT was recorded as if that
GPT was written at the end of the device. This patch tweaks
my_lba to report where it is in the random-access GPT address space,
namely at the end of that space.

TEST=Compiled it into the firmware and observed the firmware to update
the my_lba field of the secondary GPT.
BRANCH=none
BUG=chromium:425677

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>

Change-Id: I88791fb2cff1086351ca8a3adeef675c4a88cc9a
Reviewed-on: https://chromium-review.googlesource.com/228942
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Daniel Ehrenberg <dehrenberg@chromium.org>
Tested-by: Daniel Ehrenberg <dehrenberg@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
6ee52d9a929d00e871e7316240b54f381146fbc6 24-Oct-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Support writing GPT structs to NOR flash

This CL allows the GPT headers and partition entry arrays to be stored
in a NOR flash device. Instead of treating both the NOR and NAND devices
as one (in a sandwich way), this CL writes and reads the GPT structs
independently of the actual device that houses the partitions.
Therefore, the first usable LBA of the partitions will be at 0, and the
last usable LBA is at the end of the NAND.

+------------------------+
| NOR houses GPT structs |
+------------------------+
|
0 | Index into
v v
+------------------------+
| NAND houses partitions |
+------------------------+

Note that the "my_lba", "alternate_lba", "entries_lba" in the GPT headers
are no longer meaningful.

Consumers of cgptlib will have to set "stored_on_device" to either
GPT_STORED_ON_DEVICE or GPT_STORED_OFF_DEVICE, and "gpt_drive_sectors"
to the number of 512-byte sectors available to store GPT structs.

The NOR read and write operations are done by "flashrom".

BUG=chromium:425677
BRANCH=none
TEST=unittest
TEST=build with DEBUG, cgpt create/add/show on a stumpy-moblab

Change-Id: I083b3c94da3b0bb3da1a7b10c6969774080a2afd
Reviewed-on: https://chromium-review.googlesource.com/226800
Reviewed-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
5ce8325f4ac4662d0daef63878c85462a8e59ff4 30-Oct-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Check for NULL entry array.

When GptLoad() fails to validate a header, it will not load the
corresponding entry array, and hence will not allocate memory. The
"*_entries" pointer then stay NULL. This CL checks for NULL pointer in
CheckEntries() in the same way that CheckHeader() does.

BUG=none
BRANCH=none
TEST=unittest

Change-Id: I9f72e843590fbcbcf90d55640f86c782446e8755
Reviewed-on: https://chromium-review.googlesource.com/226778
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
88458d9b5281aca162821a369707781ac9abb44e 28-Aug-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot_reference: Rename *_SECTOR to *_SECTORS

This CL renames GPT_PMBR_SECTOR to GPT_PMBR_SECTORS and GPT_HEADER_SECTOR to
GPT_HEADER_SECTORS to better indicate that these are constants for sizes, not
location.

BRANCH=None
BUG=None
TEST=unittest

Change-Id: I26ed6d45d77dcb1eb714135edbb9e4124b54e953
Reviewed-on: https://chromium-review.googlesource.com/214830
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
a2d72f70c18905aba25eb0971f6f601dd1fa5a60 23-Aug-2014 Nam T. Nguyen <namnguyen@chromium.org> vboot: cgpt: Refer to partition entries by entries_lba.

This CL accesses the partition entry array through its header's
entries_lba value.

Previously, we assume the primary entry array lies on third sector, and
the secondary array lies (1 + 32) sectors from disk end. This assumption
was fine, even Wikipedia assumed the same.

But in order for us to support writing boot code to the third sector (as
required by some Freescale board), the primary entry array must be moved
to another location. Therefore, we must use "entries_lba" to locate the
arrays from now on.

BRANCH=none
BUG=chromium:406432
TEST=unittest
TEST=`cgpt create -p` and then `cgpt show`. Make sure the table
header and entries are properly moved.

Change-Id: Ia9008b0bb204f290b1f6240df562ce7d3a9bbff2
Reviewed-on: https://chromium-review.googlesource.com/213861
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
f510973497a430c1bb41d9b7e996d02fb7f7179e 26-Aug-2014 Alex Deymo <deymo@chromium.org> Fix include quotes.

System libraries such as string.h and errno.h should be included with
<> instead of "" to avoid including them from the local directory.

BRANCH=None
BUG=None
TEST=FEATURES="test" emerge-link vboot_reference

Change-Id: I6734e14223fdad9060c6518790f52f1bcfcdf8e0
Reviewed-on: https://chromium-review.googlesource.com/214058
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
18e03706df6ab4256a89f4e578ecf0f165641c8a 24-Jun-2014 Bill Richardson <wfrichar@chromium.org> Clean up exported Mtd* functions

A lot of functions were added some time ago, nominally to support keeping
the firmware in an MTD device that wasn't formatted with the GPT headers.
That work was never completed, so these functions aren't used anywhere.

We may want to resurrect this work at some future point. Until then, this CL
just moves some of the functions into an "unused" file.

BUG=chromium:231567
BRANCH=ToT
TEST=manual

All tests pass, all firmware and external repos build.

Change-Id: I420dd52d1cea0418cedf2f8e834c61145915f20c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207037
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
289b604f6154b118f3c47aa35b09e99a4e144814 25-Jun-2013 Albert Chaulk <achaulk@chromium.org> Port MTD structures to use 64-bit byte offsets instead of sectors.

As per the discussion on issue 221745 we will be using 64-bit byte offsets
for the MTD partition table and converting to/from sectors internally in cgpt.
Existing interfaces do not change, eg sizes are still reported in sectors, only
the on-disk representation is affected.

BRANCH=none
BUG=chromium:221745
TEST=unit tests pass

Change-Id: Id312d42783acfdabe6eb8aea11dcbd298e00a100
Reviewed-on: https://gerrit.chromium.org/gerrit/60919
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
534723a6519267461855441279b321e6fc1e4e90 20-Mar-2013 Albert Chaulk <achaulk@chromium.org> Integrate the flash key-value store code into cgpt.

Integrates the FTS driver into cgpt. This driver is binary-format compatible
with the linux driver for interoperabiilty. The cgpt changes load & store a
hex-encoded mtd partition table in the FTS; we need some sort of encoding
because FTS only stores NUL-terminated strings.

Currently, the mtd code paths aren't executed in cgpt, only in the tests. It's
also not hooked up to the vboot code yet, we will need to do that eventually.

BUG=chromium:221745
TEST=new unit test added
BRANCH=none

Change-Id: I94eb0389d29aca0beb9d9a644465c7d86161b3c2
Original-Change-Id: I9fe2fa91b666572563426adb8fa9d426f9b60bbf
Reviewed-on: https://gerrit.chromium.org/gerrit/46796
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49789
/external/vboot_reference/tests/cgptlib_test.c
5c9e4532b9bc45cff22f37d3556da679809a60a7 21-Mar-2013 Albert Chaulk <achaulk@chromium.org> Implement cgptlib for MTD devices.

Defines MTD on-disk structures & API in mtdlib.h/c that closely mirrors
the existing cgpt implementation. Currently, the disk structures do not
contain guids or labels, and the number of available partition types and
quantities are limited, exactly what we want to support should be decided
before we ship this.

Adds appropriate test coverage to the unit test library - either by modifying
existing tests, or copying them and changing them accordingly.

BUG=chromium:221745
TEST=added appropriate tests to the unittests
BRANCH=none

Change-Id: Iee19864498024c72229bc3c7811594fe762f52de
Original-Change-Id: I031eca69d6c8e825b02bd0522d57e92b05eb191a
Reviewed-on: https://gerrit.chromium.org/gerrit/46082
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48793
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
ac8805e7e9bd40c03baf44e37b26f28d9b763ab5 16-Mar-2013 Gabe Black <gabeblack@chromium.org> Get rid of some crufty macros.

These were macros that were never used, or that were only set to one thing and
could be substituted up front.

I left in code guarded by the HAVE_ENDIAN_H and HAVE_LITTLE_ENDIAN macros even
though those are never defined because they guard a reportedly significantly
faster implementation of some functionality, at least according to a comment
in the source. It would be a good idea to enable that code path and see if it
really does make a big difference before removing it entirely.

BUG=None
TEST=Built for Link, Daisy, and the host with FEATURES=test. Built depthcharge
for Link and booted in normal mode.
BRANCH=None

Change-Id: I934a4dd0da169ac018ba07350d56924ab88b1acc
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/45687
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
0bda13f5154afc8068e7d2d4563ff20b152f1c87 24-Jan-2013 Randall Spangler <rspangler@chromium.org> Improve coverage of cgptlib.c

BUG=chromium-os:38139
BRANCH=none
TEST=make runtests

Change-Id: I5719c6b8aa1a23fc65bf38d7096320479152f0ca
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41955
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
e9213a7c133681d6f565adbf218bafa7a3115c22 24-Jan-2013 Randall Spangler <rspangler@chromium.org> Reformat cgptlib_test

No code changes, just reformat to kernel style

BUG=none
BRANCH=none
TEST=make runtests

Signed-off-by: Randall Spangler <rspangler@chromium.org>

Change-Id: Icfcf54327c4da607392f1769fddcbc33f889395c
Reviewed-on: https://gerrit.chromium.org/gerrit/41954
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
65d3c277a2098d6149fb79f7881da5d78133ae57 25-Sep-2012 Vadim Bendebury <vbendeb@chromium.org> Make cgpt_add error messages a little more verbose

When the cgpt utility complaints about parameter errors, it is
impossible to tell what exactly went wrong. This change consolidates
error definitions and adds a function to convert integer error values
into text messages.

BRANCH=none
BUG=none
TEST=manual
. emerge-link vbooot_reference
. copy generated `cgpt' to a Link device
. run command with wrong arguments with respect to the existing GPT:
localhost var # ./cgpt add -i 3 -b 3985408 -s 1757184 -t rootfs -l ROOT-A /dev/sda
ERROR: cgpt add: Starting LBA overlaps
ERROR: cgpt add: -i 3 -l ROOT-A -b 3985408 -s 1757184 -t 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC
. on the host, in the chroot in src/platform/vboot_reference run

$ make && make runtests

observe all tests succeed

Change-Id: Ibd23ca0430a875f70524adc99e0509b26ae699b2
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34003
Reviewed-by: Randall Spangler <rspangler@chromium.org>
/external/vboot_reference/tests/cgptlib_test.c
2c21fe6693480e437ccedd03f32cda135cd11c68 07-Sep-2010 Randall Spangler <rspangler@chromium.org> Successful partitions are never marked bad by cgptlib.

Change-Id: I70e54f59b540e9115bb6bd77ae51f49a1f4ab671

BUG=chromeos-partner:1029
TEST=make && make runtests

Review URL: http://codereview.chromium.org/3315014
/external/vboot_reference/tests/cgptlib_test.c
aa8eda4f97f43a51bfec4fc096635565617a89e0 27-Aug-2010 Bill Richardson <wfrichar@chromium.org> More cgptlib tests

Add some extra cases to SanityCheckTest() to test both header and entries
being garbled at either end of the disk.

Add DuplicateUniqueGuidTest() to check that GPTs having duplicate
UniqueGuids in the entries are rejected. We can only check this per-disk, of
course.

Made some changes to the library to enforce the UniqueGuid requirement that
I just started testing for.

BUG=chromium-os:4854

Review URL: http://codereview.chromium.org/3135044

Change-Id: I86458faf9cc99aa3f29aac0d5b144dbd05067181
/external/vboot_reference/tests/cgptlib_test.c
3ecaf776d82d29573be083b2e5c6ddc5b9f49c70 25-Jun-2010 vbendeb <vbendeb@chromium.org> Make vboot_reference build in MSVC command line environment.

This is a mostly NOOP change which modifies the source code
to compile cleanly in the MSVC command line build
environment.

A new makefile is introduced (msc/nmakefile) along with a
README.txt in the same directory explaining how to build
the code in the DOS window. As of this submission the build
is running in a 32 bit environment, the intention is to use
the same makefile for 64 bit builds in the future.

Enabling high compilation warnings level allowed to
identify a couple of bugs in the code which are being fixed.

Not all sources are being compiled in the MSVC environment,
only those in firmware/ and most of those in test/
subdirectories. The benchmark calculations require porting
of the timer facilities and are being postponed.

TEST

Built in DOS and linux environments. Ran unit tests in
linux environment.

Review URL: http://codereview.chromium.org/2809037
/external/vboot_reference/tests/cgptlib_test.c
81d0996901387619cc782ca258fcb4a9f3f591e7 23-Jun-2010 Randall Spangler <rspangler@chromium.org> Assorted integration fixes.

MSVC does not like bitfields with extra bits in them, so it made the GptEntry struct too big.

Fixed a missing return value in LoadFirmware().

Added some debug output.

Fixed calls to SetupTPM().

Tested with 'make && make runtests'. No errors.

Review URL: http://codereview.chromium.org/2865014
/external/vboot_reference/tests/cgptlib_test.c
f7a45cc01d7e4056482b2cdc23080bfabbbffc76 21-Jun-2010 vbendeb <vbendeb@chromium.org> Reduce attributes size to comply with msc limitations.

It turned out that shared verified boot library fails to
work properly when compiled by msc in BIOS environment.

The culprit was identified as failing 64 bit logical
operations by preprocessor. It is probably possible to
come up with a certain compile flag set to fix the
operations, but it is not easy to modify and control the BIOS
compilation environment.

The alternative solution is to limit the size of the field
in question to 16 bits (especially since this is the only
part of the attributes field which is supposed to be
altered by firmware.

A union is being introduced in firmware/lib/cgptlib/include/gpt.h:GptEntry to allow
accessing the field both as a 64 bit entity and a top
16 bit field. All places where this field is used are
being modified appropriately.

tests/Makefile is being fixed to allow controlling test run
from the top level directory.

Tested by building everything and running tests.
All tests pass.

Review URL: http://codereview.chromium.org/2799019
/external/vboot_reference/tests/cgptlib_test.c
f1372d9109d638fbb1a177a89ebaf64e7ee0637e 11-Jun-2010 Bill Richardson <wfrichar@chromium.org> Nearly complete rewrite of cgpt tool.

This fixes a number of bugs, adds a bunch of commands, and essentially makes
cgpt ready to use as a replacement for gpt. Still to do is to add commands
and options that will let it generated intentionally bad partitions, for use
in testing.

Review URL: http://codereview.chromium.org/2719008
/external/vboot_reference/tests/cgptlib_test.c
31066a4515824c6d8cf8f69f5cecfb4b508bddba 04-Jun-2010 Bill Richardson <wfrichar@chromium.org> Ignore the AlternateLBA field in the GPT headers.

We know where to look, and we'll look there regardless. We don't care where
the header creator thinks it should be.

Update tests to match.

Oh, and don't assume that I mean "/dev/FOO" if I just say "FOO". That's
really annoying.

Review URL: http://codereview.chromium.org/2606002
/external/vboot_reference/tests/cgptlib_test.c
afdd058ebc239c6f3c51d3f8d8f84404d781a862 03-Jun-2010 Colin Chow <colinc@google.com> fix int reference to unint64 from http://codereview.chromium.org/2438005

Review URL: http://codereview.chromium.org/2550001
/external/vboot_reference/tests/cgptlib_test.c
3dcf9dce04301d6d735f265652625fffb6758430 02-Jun-2010 Randall Spangler <rspangler@chromium.org> Much rearranging of cgptlib. Passes all its (new) unit tests.

Also includes part of LoadKernel(), which I'll split into a separate
CL. With some hacks, gets into VerifyKernel() before dying because
I'm not passing in the right key blob.

cgptlib is now pretty stable, and worth looking at. LoadKernel() less so.

Thanks,
Randall

Review URL: http://codereview.chromium.org/2438005
/external/vboot_reference/tests/cgptlib_test.c
3003c1dd5048dde791e69850333539edc1c767eb 27-May-2010 Randall Spangler <rspangler@chromium.org> Moved cgptlib into vboot_firmware
Moved cgptlib tests into tests

Review URL: http://codereview.chromium.org/2303003
/external/vboot_reference/tests/cgptlib_test.c