summaryrefslogtreecommitdiff
path: root/cgpt
Commit message (Collapse)AuthorAgeFilesLines
...
* vboot: cgpt: Refer to partition entries by entries_lba.Nam T. Nguyen2014-08-284-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix include quotes.Alex Deymo2014-08-262-7/+8
| | | | | | | | | | | | | | | 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>
* Clean up exported Mtd* functionsBill Richardson2014-07-096-10/+468
| | | | | | | | | | | | | | | | | | | | 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>
* Split libvboot_host.a into external and local libraries.Bill Richardson2014-07-092-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've been creating and linking against a library called "libvboot_host.a" for two different reasons. The main purpose is to build the vboot_reference tools found in the utility/ directory. But there are some external userspace programs that would also like to use some functions in this library. This change establishes libvboot_host.a as the library for use by external userspace programs only, and creates a new libvboot_util.a library that's only used inside this source tree to build the vboot utilities. BUG=chromium:231567 BRANCH=ToT TEST=manual Build and run the local tests: make runalltests make clean Build Link firmware and all the utilities: emerge-link chromeos-base/vboot_reference \ sys-boot/depthcharge \ sys-boot/coreboot \ chromeos-base/chromeos-ec \ chromeos-base/chromeos-firmware-link \ chromeos-base/chromeos-cryptohome \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-login \ chromeos-base/verity Build Lumpy utilities, which include the 32-bit cros_installer: emerge-lumpy chromeos-base/vboot_reference \ chromeos-base/chromeos-login \ chromeos-base/verity \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-cryptohome Change-Id: Ie81ff1f74a6356cb8fab7d98471139d7758c4f19 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207016 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Remove cgpt app-specific symbols from libvboot_host.aBill Richardson2014-06-2615-29/+48
| | | | | | | | | | | | | | | | | | | | | | Three symbols used by the standalone cgpt executable were being referenced in the files used to create the external libvboot_host.a needed by non-vboot userspace applications. This cleans things up so those symbols don't have to be explictly defined by other repos just to link with that library. BUG=chromium:318536 BRANCH=ToT TEST=manual No new functionality, just code cleanup. Tested with make runtests runfutiltests runlongtests Change-Id: Ibc77fb9800c89d7109ebf38d4d6729f52665722f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205667 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix some issues with LBA vs byte offsetsAlbert Chaulk2013-07-314-6/+21
| | | | | | | | | | | | | | | | | | | In several places the existing code assumes LBA, but was improperly converted to use byte offsets, so multiply by the sector size to correct it and maintain the same interface between MTD & GPT. Also, since we will need to cgpt create on /dev/fts, which isn't a stat()able device, allow providing the disk size on the commandline. BRANCH=none BUG=chromium:221745 TEST=make runtests; cgpt create -s 12345 on MTD image Change-Id: Icc89a4505aba9a3dfc39b176a372f6e12d106aed Reviewed-on: https://gerrit.chromium.org/gerrit/62675 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Add labels to MTD partitions.Albert Chaulk2013-07-312-37/+48
| | | | | | | | | | | | | | | Add labels to MTD partitions and clean up some of the show code, adding more info on the MTD prints and eliminating duplicated code. BRANCH=none TEST=make runtests & manual cgpt add -l "label"; cgpt show to verify labels BUG=none Change-Id: I59736128f394c2aca937a3a0bb5fc5d42b0149a9 Reviewed-on: https://gerrit.chromium.org/gerrit/63367 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* Don't always enable MTD mode unless MTD device is specifiedfactory-4455.Bfactory-4455.228.BAlbert Chaulk2013-07-244-48/+69
| | | | | | | | | | | | | | | | On MTD devices, don't always enable MTD mode - the installer needs to be able to access both the GPT disk and the MTD disk, so only enable it if we install to /dev/fts BRANCH=none BUG=chromium:221745 TEST=make runtests Change-Id: I7688e6bc758ef47cfb9d468c1224ef43b2043d02 Reviewed-on: https://gerrit.chromium.org/gerrit/62662 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* MTD: When running on the host (as during install) use the host FTS if possible.Albert Chaulk2013-07-165-7/+83
| | | | | | | | | | | | BUG=chromium:252331 TEST='make runtests' still passes BRANCH=none Change-Id: I1deb70766b811b070f0f412cb5cfa583250dd687 Reviewed-on: https://gerrit.chromium.org/gerrit/61328 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* Port MTD structures to use 64-bit byte offsets instead of sectors.Albert Chaulk2013-07-034-26/+32
| | | | | | | | | | | | | | | | | 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>
* MTD modification commands: add & prioritizeAlbert Chaulk2013-07-032-39/+112
| | | | | | | | | | | | | | | | | | | | | Additionally renames the new functions in add to be CamelCase style BUG=chromium:221745 TEST=MTD version of run_cgpt_tests.sh passes BRANCH=none Original-Change-Id: Ic173f99d7ca4af025403ab11f37061c33c9d59ea Reviewed-on: https://gerrit.chromium.org/gerrit/47173 Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit c3aad2fd06a21097cffd10ec5b168e728616b868) Change-Id: Ib3bb947ffcd5c0f40398a27a721e392b895c9da0 Reviewed-on: https://gerrit.chromium.org/gerrit/49795 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* MTD search commands: show & findstabilize-daisy-4319.96.Brelease-R29-4319.BAlbert Chaulk2013-06-242-60/+284
| | | | | | | | | | | | | | | BUG=chromium:221745 TEST=MTD version of run_cgpt_tests.sh passes BRANCH=none Change-Id: I8a5c1afab238eb10f38d865405ea2828715685d8 Original-Change-Id: I3d72fecbb3ef95252aa35d56885288340537b1c5 Reviewed-on: https://gerrit.chromium.org/gerrit/47175 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49794 Reviewed-by: Albert Chaulk <achaulk@chromium.org>
* Bugfixes & MTD create commandAlbert Chaulk2013-06-244-54/+79
| | | | | | | | | | | | | | | | | | | | | | | | | Fix some bugs in the cgpt implementation of the flash I/O functions & load logic, it was validating too much at load time. Implement the create command for MTD BUG=chromium:221745 TEST=MTD version of run_cgpt_tests.sh passes BRANCH=none Original-Change-Id: I2f52637d82962f4d805aa827c5c37685f10e76ea Reviewed-on: https://gerrit.chromium.org/gerrit/47172 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> (cherry picked from commit 931544744ba410dad267064b87d504b0b4c24772) Change-Id: If9364155fb2c030645adc6ee6f3fbe5373bcc153 Reviewed-on: https://gerrit.chromium.org/gerrit/49793 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
* cgpt: do not show length of 1 for undefined partitionsMike Frysinger2013-06-241-2/+7
| | | | | | | | | | | | | | | If a partition isn't "defined", then don't declare its size as 1. BUG=chromium:236941 TEST=`cbuildbot {x86,amd64,arm}-generic-full` pass TEST=`cgpt show -i 100 -s chromiumos_image.bin` shows 0 BRANCH=none Change-Id: I538546b6b37a9137958d6f926a58753cf52c946a Reviewed-on: https://gerrit.chromium.org/gerrit/50074 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* Enables MTD mode via command line option.Albert Chaulk2013-06-213-1/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables MTD mode with a command line option of -N=<write page bytes>,<write pages per erase block>, <erase block offset to fts partition>,<erase block size of fts partition> The problem is that we need to know exactly where the fts store partition is and what the layout of the flash chip is in order to be able to use it properly. This will vary per-device however, so for flexibility and testing purposes, this command line option allows specification of arbitrary layouts. BUG=chromium:221745 BRANCH=none TEST=verified during development via prints Original-Change-Id: I88640e777d5ccd4ffd3b39e1f131dc1d362c6b2c Reviewed-on: https://gerrit.chromium.org/gerrit/46920 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit 2b768f99d246823f3711bbe4cf50ea9ab4588a06) Change-Id: I35591d4fbec13c3887beef11fdefc84fc90b8e05 Reviewed-on: https://gerrit.chromium.org/gerrit/49792 Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Provide MTD version of common functionsfactory-4290.BAlbert Chaulk2013-06-182-42/+121
| | | | | | | | | | | | | | | | | | | | | Provide an MTD implementation of several common functions in cgpt_common.c BUG=chromium:221745 BRANCH=none TEST=none Original-Change-Id: Ib3248c283ca31e33a91b9ea0c14b2f72ea7c5850 Reviewed-on: https://gerrit.chromium.org/gerrit/47029 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit b0bd7e4cf8dd15cc3c371dac157093c7e7c7a874) Change-Id: I243c2bf98a88d0019c332b274868459b5f1b8ea1 Reviewed-on: https://gerrit.chromium.org/gerrit/49791 Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Implement no-op commandsstabilize-4287.Bfactory-pit-4280.BAlbert Chaulk2013-06-143-0/+22
| | | | | | | | | | | | | | | | | | | | | | | Provide implementations for "boot" and "legacy" that error out in MTD mode and "repair" that is a no-op. Eventually if/when we add redundancy, repair will do something, but boot/legacy never will. BUG=chromium:221745 BRANCH=none TEST=none Original-Change-Id: Ie537f20d8dff9d14fb83d0431bd48453bff0217d Reviewed-on: https://gerrit.chromium.org/gerrit/46883 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> (cherry picked from commit 00c4bc52e35c7c77ebe73322693a457b3dd072f9) Change-Id: I90e6118114554a05245fb8cfcec9567c4705ea96 Reviewed-on: https://gerrit.chromium.org/gerrit/49790 Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org>
* Integrate the flash key-value store code into cgpt.stabilize-4255.BAlbert Chaulk2013-06-103-95/+345
| | | | | | | | | | | | | | | | | | | | | | 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
* Refactor CgptAdd and CgptPrioitize to remove gpt-specific codeAlbert Chaulk2013-05-067-232/+225
| | | | | | | | | | | | | | | | | | | | - Refactor cgpt_prioitize.c to completely remove gpt-specific code. - Refactor cgpt_add.c to isolate gpt-dependence to one helper function and the backup/restore logic - Change several common apis to take a struct drive* rather than a GptData*, this provides a path to cleanly implement mtd versions BUG=chromium:221745 TEST=no functional changes, existing tests cover this BRANCH=none Change-Id: I27ed166aae390aa5dc83062f62939e45122edc76 Original-Change-Id: I1b0a73509efbf22411c4ae5cf044feede0a49a33 Reviewed-on: https://gerrit.chromium.org/gerrit/46548 Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49788
* Massive refactoring of external header files.Bill Richardson2013-04-0220-198/+39
| | | | | | | | | | | | | | | | | | | | | | | | This reduces the number of exported header files to the minimum needed by the existing userspace utilities and firmware implementations. BUG=chromium:221544 BRANCH=none TEST=manual, trybots CQ-DEPEND=CL:47019,CL:47022,CL:47023 sudo FEATURES=test emerge vboot_reference FEATURES=test emerge-$BOARD \ vboot_reference \ chromeos-cryptohome \ chromeos-installer \ chromeos-u-boot \ peach-u-boot \ depthcharge Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47021 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Apply consistent naming scheme for hostlib functions.Bill Richardson2013-03-2019-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The chromeos-installer uses several functions from the vboot_reference userspace library, but the names of those functions are inconsistent: IsZero MapFile VbGetSystemPropertyString cgpt_add cgpt_boot cgpt_create cgpt_get_boot_partition_number cgpt_get_num_non_empty_partitions cgpt_get_partition_details cgpt_prioritize cgpt_set_attributes find_kernel_config The Google C++ style guide says types and functions should use CamelCase, while variables use lower_case_with_underscores. Kernel style (which vboot_reference tries to be more-or-less compatible with) uses lower_case_with_underscores for everything, but that really only has to apply to firmware stuff. For userspace, we can use the Google style. BUG=chromium:221544 BRANCH=none TEST=buildbot CQ-DEPEND=CL:46045 Renaming/cleanup only; no functional changes. Change-Id: I9c82c9ff8909be88586194c8ffdb435fc771195f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46044
* Rename Strncat to StrnAppend, use it instead of strncat.firmware-spring-3824.Bfirmware-spring-3824.84.Bfirmware-spring-3824.55.Bfirmware-spring-3824.4.Bfirmware-skate-3824.129.BBill Richardson2013-03-061-16/+17
| | | | | | | | | | | | | | | | | | Strncat() looks almost like strncat(), but it's completely different. Change the name to reduce confusion. Also fix a place where strncat() was misused anyway. BUG=none BRANCH=all TEST=manual sudo FEATURES=test emerge vboot_reference FEATURES=test emerge-$BOARD vboot_reference Change-Id: I39c30d391aa6566ec67461462e800720ade66a91 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/44572
* Move CgptManager from vboot_reference to installerBill Richardson2013-03-042-601/+0
| | | | | | | | | | | | | | | | | | The C++ wrapper around various vboot_reference functions doesn't belong in the vboot repo itself. Put it in the installer repo instead. BUG=chromium-os:39228 BRANCH=none TEST=auto CQ-DEPEND=CL:44441, CL:44443 Refactoring only, no new code. Everything should continue to work as before. Change-Id: I15ba416987e38905825fedcc87d7b75ebdc4fd1f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/44442 Reviewed-by: Jay Srinivasan <jaysri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* (modify and resend) Trigger sync right after writing.Louis Yung-Chieh Lo2013-01-221-0/+5
| | | | | | | | | | | | | | | | | | | | This can trigger the sync mechanism earlier so that the kernel has enough time to schedule a real disk sync before system reboots. We sent this in CL 41269, however it is reverted because the sync() and syncfs() make test cases timeout (tons of disk access). So we only sync file itself in this CL and leave the whoe system sync outside cgpt. BUG=chromium-os:35992 TEST=make && make runtests ; and trybot BRANCH=none Change-Id: I9c6b602220131f1f011e7865788a122d4c379e73 Reviewed-on: https://gerrit.chromium.org/gerrit/41345 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Yung-Chieh Lo <yjlou@chromium.org> Tested-by: Yung-Chieh Lo <yjlou@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Revert "Trigger sync right after writing."Bill Richardson2013-01-151-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f3613b60c7374dfcf54c922d46c7da8feeb22000. That commit attempts to solve a disk-syncing problem by forcing numerous sync() calls inside cgpt. However, it's too much of a sledgehammer approach. Some subset of buildbots now run a short test suite when compiling vboot_reference. On my z620, commit f3613b60c737 increases the time to run "make runcgpttests" from 1.6 seconds to over eight minutes. We need a different solution to this problem. BUG=chromium-os:35992 TEST=manual BRANCH=none To test: cd vboot_reference make && make runtests Change-Id: I0489906103dbc93edf201570bd9158621c651d54 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/41306 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Trigger sync right after writing.Louis Yung-Chieh Lo2013-01-151-0/+5
| | | | | | | | | | | | | | | This can trigger the sync mechanism earlier so that the kernel has enough time to schedule a real disk sync before system reboots. BUG=chromium-os:35992 TEST=compile only BRANCH=none Change-Id: I505fdf45d95a52c9eca7687ecd6fb9f6be8cc5f1 Reviewed-on: https://gerrit.chromium.org/gerrit/41269 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: Yung-Chieh Lo <yjlou@chromium.org> Commit-Queue: Yung-Chieh Lo <yjlou@chromium.org>
* Unify vboot build into a single makefileRandall Spangler2013-01-111-74/+0
| | | | | | | | | | | | | | | | | | This is a necessary precursor to getting coverage working. BUG=chromium-os:26317 BRANCH=none TEST=manual sudo emerge vboot_reference emerge-link vboot_reference chromeos-u-boot emerge-daisy vboot_reference chromeos-u-boot Change-Id: Ibed91c64a5ca5fa486169d64fb01a9e868ce27e5 Signed-off-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 13ed1f4812f810ee0a47b946ad990f1fa93f366c) Reviewed-on: https://gerrit.chromium.org/gerrit/40906 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Make cgpt_add error messages a little more verboseVadim Bendebury2012-09-261-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Support alternative GPT header signatureStefan Reinauer2012-09-197-1/+133
| | | | | | | | | | | | | | | | | | | | | | In order to dual boot Windows and ChromeOS, Windows must not find a GPT partition table on the disk. So change ChromeOS to cope with an alternative signature "CHROMEOS" instead of the standard "EFI PART" BUG=chrome-os-partner:6108 TEST=rebuild chromeos, install it, run cgpt legacy /dev/sda dd if=/dev/sda of=/tmp/x bs=1k hexdump -C /tmp/X see the string CHROMEOS BRANCH=link Signed-off-by: Stefan Reinauer <reinauer@chromium.org> Change-Id: Ia88eff33b9880bd73a78c1b8e026c1f8298c4557 Reviewed-on: https://gerrit.chromium.org/gerrit/31264 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Stefan Reinauer <reinauer@chromium.org> Tested-by: Stefan Reinauer <reinauer@chromium.org>
* cgpt: Fix error in modifying size of an existing partitionBill Richardson2012-08-241-2/+2
| | | | | | | | | | | | | | | | | | | Modifying the size of an existing partition without modifying the start as well assumed the start was at block 0. Sometimes it was caught, often it wasn't. Fix the error, add a test to catch the problem. BUG=chrome-os-partner:13090 BRANCH=all TEST=manual make && make runtests Change-Id: I4f5a5031a90a3e78d886ed3573f61305316a3f1f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31418 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* rename common.mk to build.mkMike Frysinger2012-08-081-1/+1
| | | | | | | | | | | | | | This is to avoid confusion with the canonical common.mk file that is a CrOS build system. BUG=chromium-os:33327 TEST=`cros_run_unit_tests --board x86-alex -p vboot_reference` still works Change-Id: I4b6719d58a4a8ab44b62c23c0e2c45b154374958 Reviewed-on: https://gerrit.chromium.org/gerrit/29578 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* Fix 'possible use of unassigned' variable 'retval'.Taylor Hutt2012-08-011-0/+1
| | | | | | | | | | | | | | This change ensures that 'retval' is set for all paths to 'done'. BUG=none TEST=Now compiles without warning. Signed-off-by: Taylor Hutt <thutt@chromium.org> Change-Id: I4ab368b5c60afbed28a5b6d5417e18bedf986e2d Reviewed-on: https://gerrit.chromium.org/gerrit/28827 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Taylor Hutt <thutt@chromium.org> Commit-Ready: Taylor Hutt <thutt@chromium.org>
* Fix "cgpt show" output for large hard drives.Shawn Nematbakhsh2012-07-301-5/+5
| | | | | | | | | | | | | | | | "cgpt show" output table can be incorrect for large hard drives due to the number of digits in the start/size parameters. Fix by adding extra printf padding. BUG=chromium-os:33082 TEST=emerge, "cgpt show -q /dev/sda" on large HDD platform. Change-Id: I21008322739f5cd4a34372a4436a71259565c6e7 Reviewed-on: https://gerrit.chromium.org/gerrit/28730 Tested-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-by: Tammo Spalink <tammo@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>
* cgpt: verify the modifications of 'cgpt add' before effected.Louis Yung-Chieh Lo2012-06-271-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code only does basic check on parameters, but doesn't validate if it can pass the CheckEntries(). So a user can accidentally break the cgpt table by: cgpt add /dev/sda -i 6 -s 0 # 0 sector is not allowed for a partition. cgpt show /dev/sda ... INVALID_ENTRIES ... This CL checks the new entry before we write it to disk. If new entry is not good, we return fail. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> BUG=None TEST=tested on link. % cgpt add /dev/sda -i 6 -s 0 ERROR: cgpt add: A given parameter is not allowed. % cgpt show /dev/sda (no error, and partition 6 is still good) Change-Id: Iee0ad24f73ca12028c0b8a0a5490b67c815488cf Reviewed-on: https://gerrit.chromium.org/gerrit/25914 Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com> Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com> Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
* cgpt: add -d option for cgpt showLouis Yung-Chieh Lo2012-06-273-33/+58
| | | | | | | | | | | | | | | | | | | | | | | | | The debug mode is used to dump GPT headers and entries no matter the they are valid or not. BUG=chromium-os:32142 TEST=tested in chroot with the bad secondary entries. % cgpt show /dev/sda -d ... 976773135 32 INVALID Sec GPT table 282624 968101888 1 Label: "STATE" Type: Linux data ... 1 1 INVALID Sec GPT header Sig: [EFI PART] Rev: 0x00010000 ... Change-Id: Ie54068353b87c9f15915ffb51b8de688e0367975 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26091 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com> Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
* respect LDFLAGS settingsrelease-R21-2465.BMike Frysinger2012-06-181-2/+3
| | | | | | | | | | | | | | | | | Libraries go into $LDLIBS while linker flags go into $LDFLAGS. Also make sure the utility subdir respects the env $LDFLAGS so that we can do things like `make LDFLAGS=-static` and get static binaries. BUG=None TEST=`emerge vboot_reference` still works TEST=`emerge-arm-generic vboot_reference` still works Change-Id: I989a21bc559bc6d471bc33c057c708bda2eda67e Reviewed-on: https://gerrit.chromium.org/gerrit/24728 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
* Fix build errors with .c and .cc files being in the libcgpt-cc.aDoug Anderson2012-05-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | When I build without this fix, I get errors like this: armv7a-cros-linux-gnueabi-strip:....libcgpt-cc.a(CgptManager.cc): Unable to recognise the format of file: File format not recognized The .a file shouldn't have .cc files in it anyway. The error appears to have been introduced in: https://gerrit.chromium.org/gerrit/16433 I'm not sure why it wasn't noticed until now, but perhaps the new toolchain is just pickier. BUG=None TEST=emerge-daisy vboot_reference works TEST=With future hardfp change, can boot U-Boot compiled with new toolchain. Change-Id: I33f15fb38d7e236000845d0a864c1e86469f32c7 Reviewed-on: https://gerrit.chromium.org/gerrit/22476 Tested-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Ready: Doug Anderson <dianders@chromium.org>
* Require -Wall -Werror for everything.Bill Richardson2012-05-039-42/+6
| | | | | | | | | | | BUG=none TEST=none Change-Id: Ib9781238274285f73d00d8fca4ecda28fc2c6678 Reviewed-on: https://gerrit.chromium.org/gerrit/21748 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* Let cgpt open devices in read-only mode when possible.Bill Richardson2012-05-029-16/+24
| | | | | | | | | | | | | | | | BUG=chromium-os:12430 TEST=manual Running "make; make runtests" in src/platform/vboot_refererence will test this change. Tests for use on a Chromebook are described in the bug report, but will require a USB or SD card that has a physical write-protect switch. Change-Id: I16a67bad3b59bec0981f4064f51fb1a29da65a90 Reviewed-on: https://gerrit.chromium.org/gerrit/21474 Tested-by: Bill Richardson <wfrichar@chromium.org> Commit-Ready: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Richard Barnette <jrbarnette@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
* Enable building of Cgpt C++ Library for 32-bit.Jay Srinivasan2012-02-237-9/+44
| | | | | | | | | | | | | | | | | | | The existing library had a bunch of dependencies which are too many to build for the 32-bit platform. So this checkin prunes the dependency list by building only things that are absolutely required for the functionality used in 32-bit Post-Installer. Made the use of libuuid restricted only to cgpt and unit tests so that libcgpt-cc.a doesn't depend on it. BUG=chromium-os:25374 TEST=Built 32-bit and 64-bit. Tested 32-bit post-install. Change-Id: Idd0826fdf507a95728fee8adac9520e26f05d469 Reviewed-on: https://gerrit.chromium.org/gerrit/16433 Reviewed-by: Don Garrett <dgarrett@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
* Implementation of CgptManager C++ library and unit tests.Jay Srinivasan2012-02-1619-47/+924
| | | | | | | | | | | | | | | | | | | | | | | | | | CgptManager exposes the cgpt commands via a C++ library so that the post-installer for 32- to 64-bit upgrade can link directly against a library and thus avoid any shell dependency. The default make target will not build libcgpt-cc.a since it requires some dependencies that are available only in chroot. A separate follow-up checkin to the vboot_reference ebuild will enable emerging the libcgpt-cc.a by default. BUG=chromium-os:25374 TEST=Tested with the new unit tests for CgptManager, ran existing cgpt unit tests, as well as running the cgpt commands manually. Built on both amd64 and x86. Tested that vboot_reference is also buildable outside of chroot. Tested that vboot_reference-firmware and vboot_reference-tests also build fine with these changes. CQ-DEPEND=I99f6c321e09c2425eaa8171d78685d2d731954c8 Change-Id: I59a896255b8ea2fc8b1b2150ae7c4ff9d0769699 Reviewed-on: https://gerrit.chromium.org/gerrit/15730 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Gaurav Shah <gauravsh@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
* Refactor of cgpt tool for 32->64 autoupdate work.release-R18-1660.BJay Srinivasan2012-01-3016-1102/+1312
| | | | | | | | | | | | | | | | | | This check-in splits the cgpt into two layers. The top layer (cmd_* files) does the command-line parsing and the bottom layer (cgpt_* files) does the actual cgpt work. This is done so that the bottom layer can be reused for the monolithic C++ post-installer code that will be done in subsequent checkins. BUG=chromium-os:25374 TEST=Tested with existing cgpt unit tests as well as running the cgpt commands manually. Change-Id: I69a31eb3e867a1430cac9a694581331368aa7bb4 Reviewed-on: https://gerrit.chromium.org/gerrit/14940 Reviewed-by: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
* Introduce GUID type for Chrome OS read/write firmware.Gabe Black2011-07-072-0/+3
| | | | | | | | | | | | | | | | | | This change teaches cgpt a new GUID type to be used for the Chrome OS read/write firmware. The GUID is CAB6E88E-ABF3-4102-A07A-D4BB9BE3C1D3. BUG=chrome-os-partner:4843 TEST=Built and installed on my host, used a separate change to repurpose partition 11 for the R/W firmware using cgpt and the "firmware" type, inspected the image using cgpt. Built and installed an image and used cgpt on the device to inspect it's GPT. Signed-off-by: Gabe Black <gabeblack@google.com> Change-Id: I3b2801b2e1f71b3275bbddbc45fb63bde5bce5a7 Reviewed-on: http://gerrit.chromium.org/gerrit/3763 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
* Add vbutil_what_keys utility to figure out how a disk image is signed.Bill Richardson2011-06-171-1/+4
| | | | | | | | | | | BUG=none TEST=none Change-Id: I8a2e0d07384f0437064b964c6b292af9c3a67ea1 Reviewed-on: http://gerrit.chromium.org/gerrit/2802 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org>
* Allow ARM uuid findNick Sanders2011-05-251-2/+5
| | | | | | | | | | BUG=chromium-os:15268 TEST=not yet Change-Id: I09c821fe58145bdfd65536e3c3c02d36fcd881ed Reviewed-on: http://gerrit.chromium.org/gerrit/1541 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org>
* Add 'prioritize' command to cgpt tool.Bill Richardson2010-11-297-21/+370
| | | | | | | | | | | | | | | | | | | | | | This lets us reorder the priority of all the kernel partitions with a single command, instead of a bunch of complicated and error-prone shell script logic. Change-Id: I21d39763ec5a748488d5319a987bcfe7c34ce4d0 BUG=chromium-os:9167 TEST=manual In the chroot, do this: cd ~/trunk/src/platform/vboot_reference make make runtests make clean Everything should pass. Review URL: http://codereview.chromium.org/5352005
* Fix for un-initialized code point variable.Louis Yung-Chieh Lo2010-11-224-31/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original CL is http://codereview.chromium.org/5025003/, but it was reverted because the compiler complains code_point variable is not initialized. This CL just initializes it. This CL also adds few lines of code to make code more robust. Change-Id: Ib1329bcaeb4a1bd9abfe9e766b61bd0e52d2c260 BUG=chromium-os:7542 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested the following commands (intentionally mix Chinese and ASCII): export C=.../cgpt export D=/tmp/hda $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C show $D $C add $D -i 1 -l abc012 $C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集 $C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated $C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"` $C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"` $C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xed\x80\x80"` $C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf\xbf"` $C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0\x80"` $C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed) Review URL: http://codereview.chromium.org/5104009
* Revert "The right implementation of CGPT label conversion between UTF8 and ↵Chris Sosa2010-11-194-199/+31
| | | | | | | | | | UTF16." This reverts commit 6965cbfed3352754f0ff9a270e3b330223b7154c. TBR=Change broke tree Change-Id: I5323799bf0bc2f9a1f2815f0c44fc90ca9a7bd77
* The right implementation of CGPT label conversion between UTF8 and UTF16.Louis Yung-Chieh Lo2010-11-194-31/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For security quick fix, the original UTF8/UTF16 conversion only supports ASCII area. This CL extends the library to support multiple code units conversion between UTF8 and UTF16. The UTF8/UTF16 encoded byte(s) would be decoded to code point first, then be encoded to UTF16/UTF8 correspondingly. Bill, please kindly review the UTF8/UTF16 conversion. Peter, please kindly comment if any security concern. Thanks. Change-Id: I99c558ff27556e0b8635ba2b8d9925d042e75cb2 BUG=chromium-os:7542 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested the following commands (intentionally mix Chinese and ASCII): export C=.../cgpt export D=/tmp/hda $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C show $D $C add $D -i 1 -l 批P踢T踢T許C夕C餐 $C find $D -l 批P踢T踢T許C夕C餐 $C add $D -i 1 -l abc012 $C add $D -i 1 -l 是否看過坊間常見的許茹芸淚海慶功宴吃蓋飯第四集 $C add $D -i 1 -l 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ # ok and truncated $C add $D -i 1 -l `printf "\xf4\x91\x81\x81"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf\xbf"` $C add $D -i 1 -l `printf "\xf4\x8f\x44\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf4\x8f\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\xbf\xbf\xbf"` $C add $D -i 1 -l `printf "\xf0\xbf\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x84\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x80\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xf0\x88\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xed\x80\x80"` $C add $D -i 1 -l `printf "\xed\xa0\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf\xbf"` $C add $D -i 1 -l `printf "\xe0\xbf\x44"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x80\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\x90\x80"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xe0\xbf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0\x80"` $C add $D -i 1 -l `printf "\xd0\x11"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xd0"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\xc0\xaf"` # (EXPECT: failed) $C add $D -i 1 -l `printf "\x80"` # (EXPECT: failed) Review URL: http://codereview.chromium.org/5025003
* Fixing the bug of CGPT when primary entry table is invalid.Louis Yung-Chieh Lo2010-11-185-13/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | http://code.google.com/p/chromium-os/issues/detail?id=9279 This issue disclosed a bug of cgpt. The bug comes from the 'show' command always reads the primary entry table when '-i partition' is specified. I added an ANY_VALID constant for GetEntry to automatically select valid entry table. Also fixed the bugs in cmd_boot.c and cmd_find.c. In cmd_add.c, stop user to continue if any header/entry table is invalid. Also fixed the bug that untrusted header size could cause segmentation failure. Hungte, this is FYI. But welcome to do review. BUG=chromium-os:9279 TEST=RUNTESTS=1 emerge-x86-generic vboot_reference Manually tested: cgpt show /tmp/test -i 1 -b cgpt show /tmp/test cgpt add /tmp/test -i 1 -l TEST cgpt find /tmp/test -l STATE cgpt boot /tmp/test -i 1 Change-Id: Iaba9c635754096a82b3ec74634af184362d4e264 Change-Id: I6f3e87e3998457676e3388d2a6ed36c0564796d8 Review URL: http://codereview.chromium.org/5115002