Commit Graph

81 Commits

Author SHA1 Message Date
Patrick Georgi
efe19b2eb9 cbootimage: allow working with paths that contain '@'
Signed-off-by: Patrick Georgi <patrick@openbios.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2016-03-14 10:13:21 -06:00
Stephen Warren
a64c3f12b1 Bump to version 1.7
This release:
- Ports RSA signature field operations to T124.
- Fixes some error handling.
- Fixes image update with small image file sizes.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
2016-02-11 13:03:22 -07:00
Alban Bedel
e7d840c83f Fix image update with image smaller than 10KiB
The BCT size check assume a quiet large image, however if the image
doesn't contains a bootloader it won't be that large. Change the size
check to only read the minimum data needed to verify the BCT version
and get the size.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
--
Changelog:
v2: * Add a comment to explain the value of NVBOOT_CONFIG_TABLE_SIZE_MIN
v3: * Only read the minimum data needed
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-12-08 17:12:48 -07:00
Alban Bedel
24095562b7 Fix the error reporting of get_bct_size_from_image() and read_bct_file()
get_bct_size_from_image() and read_bct_file() should return negative
error codes, so add the missing minus signs. Also fix the return value
check on get_bct_size_from_image(), a negative value indicate an error
not zero.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-12-08 17:12:48 -07:00
Alban Bedel
dc73894abe Add support to read and write rsa related fields on t124
This allow creating and reading signed images for secure boot on t124.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-11-11 10:01:59 -07:00
Jimmy Zhang
1f88ba7147 Bump to version 1.6
Create a release that adds rsa-pss signature support. Currently
it has only been tested on T210.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-19 17:33:29 -06:00
Jimmy Zhang
dfbdbd3147 Add a sample script to do rsa signing for T210 bootimage
sign.sh runs openssl and other linux utilities to generate rsa-pss
signatures for a prebuilt bootimage and then uses cbootimage option
--update to update bootimage's rsa signatures and rsa modulus.

Syntax: sign.sh <bootimage> <rsa_key.pem>

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-19 17:33:29 -06:00
Jimmy Zhang
aa869ed597 Add new configuration keyword "RehashBl"
This feature is needed in case an image is updated at later stage
after bootimage has been created.

How to use:
  Add keyword "RehashBl" to configuration file, for example, update.cfg:
    RehashBl;

  Invoke cbootimage to re-calculate bootloader aes hash, for example, for
  bootimage bootloader.bin:
    $ cbootimage -s tegra210 --update update.cfg bootloader.bin bootloader.bin-resigned

  Where bootloader.bin-resigned is the resigned bootimage bootloader.bin

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-19 17:33:29 -06:00
Jimmy Zhang
3c3b992a68 Add support to dump rsa related fields for t210
Add support to dump rsa pubkey, bct's rsa-pss signature and
bootloader's rsa-pss signature.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-19 17:33:24 -06:00
Jimmy Zhang
dc126cfdc1 Add support for update pubkey and rsa-pss signatures
Create new configuration keywords:
   RsaKeyModulusFile: pubkey modulus
   RsaPssSigBlFile:   bootloader rsa pss signature
   RsaPssSigBctFile:  bct rsa pss signature

Sample Configuration file update_bl_sig.cfg
   RsaKeyModulusFile = pubkey.mod;
   RsaPssSigBlFile = bl.sig;

where pubkey.mod and bl.sig are files that contain the public key
modulus and bootloader's rsa-pss signature respectively.

public key modulus and signature are created through utilities
outside cbootimage.

Command line example:
 $ cbootimage -s tegra210 -u update_bl_sig.cfg image.bin image.bin-bl-signed

Above three new keywords added in this CL are only implemented to support
for T210.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-19 17:33:18 -06:00
Allen Martin
d4d2e8a65c Add man pages
Add man pages for cbootimge(1) and bct_dump(1)

Signed-off-by: Allen Martin <amartin@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-08 16:20:30 -06:00
Allen Martin
ee5c65e7c2 Add generated files to .gitignore
Add generated and temporary files to .gitignore rules to prevent them from
cluttering up git status or being accidently committed.

Signed-off-by: Allen Martin <amartin@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-08 15:47:37 -06:00
Jimmy Zhang
cf84e7ea18 Enable -u | --update option support for t210
Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
[swarren, minor capitalization fix]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-10-06 17:12:39 -06:00
Jimmy Zhang
b7d5b2d6a6 Bump to version 1.5
Create a release that includes Tegra210 support.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-03-25 08:21:31 -06:00
Jimmy Zhang
38beeed21c Remove misleading message "deprecated"
Since option "-t" is still fully supported, correct the
help messages.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-03-25 08:21:31 -06:00
Jimmy Zhang
623a1ad096 Add support for Tegra210
This patch adds support for Tegra210. The command option is

--soc tegra210 or -s tegra210

T210 specific files are added under src/t210 directory.

Main changes from earlier soc are many new fileds are added to
structure nvboot_sdram_params and the number of boot devices
that can be defined within bct is reduced from 4 to 1.

Signed-off-by: Jimmy Zhang <jimmzhang@nvidia.com>
Tested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-03-25 08:21:16 -06:00
Stephen Warren
2065a9d219 Add a README file
This provides a brief introduction to the project, and information re:
how to submit patches.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
2015-02-24 15:34:02 -07:00
Scott Duplichan
2eb9a86724 cbootimage: Add 'b' (binary) flag when using fopen to open a binary file.
Add 'b' (binary) flag when using fopen to open a binary file.
This keeps Windows from expanding \n to \r\n and interpreting
<ctrl>z as end of file. The change is to support a Windows
hosted coreboot build environment.

Signed-off-by: Scott Duplichan <scott@notabs.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-12-15 10:33:44 -07:00
Patrick Georgi
024108eecd set: check seek success
This could silently fail which leads to surprising behaviour.

Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2014-11-10 10:03:39 +01:00
Patrick Georgi
57f67537af data_layout: fail better on file access errors
fread could return only a partial result
(eg. NVBOOT_CONFIG_TABLE_SIZE_MAX - 1 bytes),
which right now would be accepted and only
resolved by later code.

Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-10-02 17:07:09 -06:00
Patrick Georgi
4bc982c3a8 data_layout: improve memory handling
- free empty_blk if it's allocated and there's an error
- only free empty_blk if it's non-NULL. While POSIX
  requests such free()s to be safe, some implementations
  (eg Solaris) aren't compliant.

Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-10-02 17:07:09 -06:00
Patrick Georgi
141409fb20 cbootimage: simplify code
Testing for e == 0 after exiting the function in any other
case a couple of lines earlier is useless.

Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-10-02 17:07:09 -06:00
Patrick Georgi
11eeab462a configure.ac: Don't search for c++ compiler
There is no C++ code to be compiled in the repository.

Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-10-02 17:07:09 -06:00
Allen Martin
62a83faac0 Bump to version 1.4
Create a release that includes Tegra132 support.

Signed-off-by: Allen Martin <amartin@nvidia.com>
2014-07-15 21:45:18 -07:00
Vince Hsu
2c4e6a5cda Dump MTS information by bct_dump utility.
The MTS is only for Tegra132 now.

Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Acked-by: Allen Martin <amartin@nvidia.com>
2014-07-15 21:43:05 -07:00
Vince Hsu
456b8aa442 Add Tegra132 support for the cbootimage utility
This patch adds support for Tegra132. This are only slight
differences between Tegra124 and Tegra132. The command line
usage is exactly the same as other platforms like Tegra124.

The structure nvboot_mts_info is added into the bct for Tegra132.
So the bootrom and first stage bootloader know where to load the
preboot and mts images. Two parse items "Mts=" and "MtsPreboot="
are added to embedded MTS images in BCT image like what we do for
bootloader. The syntax is also the same. For example:

MtsPreboot = <preboot_image>,<load_address>,<entry_address>,Complete;
Mts        = <mts_image>,<load_address>,<entry_address>,Complete;

The load and entry addresses depned on your board design.

Four files are added in src/t132:

nvbctlib_t132.c - is cloned from nvbctlib_t124.c and adds mts
                  information getter and setter.
nvboot_bct_t132.h - adds mts structure into bct
nvboot_sdram_param_t132.h - clone of nvboot_sdram_param_t124.h
parse_t132.c - clone of parse_t124.c

Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Acked-by: Allen Martin <amartin@nvidia.com>
2014-07-15 21:42:46 -07:00
Vince Hsu
3717d5efb0 Rename last_bl_blk to last_blk
Also update the next_bct_blk. Then we have the correct pointer
to the next block for the next image write.

Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Acked-by: Allen Martin <amartin@nvidia.com>
2014-07-15 21:13:07 -07:00
Stephen Warren
502b180226 Bump to version 1.3
Create a release that includes support for JTAG control, chip UUID, and
the ability to update an existing image.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-16 10:57:24 -06:00
Penny Chiu
ef386340a6 Add update BCT configs feature
This feature reads the BCT data from BCT or BCT with bootloader
appended binary, updates the BCT data based on config file, then
writes to new image file.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:07 -06:00
Penny Chiu
5f0b21a2b6 Add Tegra124 bct data access for jtag control and chip uid
Add support for read secure_jtag_control and unique_chip_id from
cfg file and write them into BCT structure, and bct_dump can also
parse the two fields and show the data.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:06 -06:00
Penny Chiu
19eae541aa Use block_size and page_size tokens when dump BCT data
Change to use block_size and page_size tokens instead of
block_size_log2 and page_size_log2 tokens when dump BCT
data.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:06 -06:00
Penny Chiu
0cb60abe4a Add token_supported function
Add a function called token_supported in cbootimage_soc_config.
It is used to check if the input token is supported in specific
tegra soc.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:06 -06:00
Penny Chiu
b81d219677 Accept void pointer as input data type for get/set_value functions
This change uses void * as input data type for
cbootimage_soc_config.get/set_value and context_set_value functions.
This makes the functions can accept various data types based on
different tokens.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:06 -06:00
Penny Chiu
ee24d10641 Add page_size validation when setting page_size value
The valid page_size value should be a power of two, so add this
check when setting page_size value.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:05 -06:00
Penny Chiu
3d0bff52c4 Add format functions to express BCT and bootloader data value
Add a new field to the value_data table, which is the function to
use to format the data value.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2014-04-15 12:02:05 -06:00
Stephen Warren
fac5875bae Bump to version 1.2
Create a release that includes Tegra124 support.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
2013-08-28 08:53:46 -06:00
Stephen Warren
ebf44ed327 Implement --soc command-line option
Implement command-line option "-s tegra20" and "--soc tegra20". These
mirror the existing -t/--tegra option, but require the full chip name
(tegra20) rather than an abbreviated name (-t20). This is more consistent
with just about everything else upstream.

Suggested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
2013-08-28 08:53:16 -06:00
Penny Chiu
7a4b402df1 Add Tegra124 support
Add the Tegra124 chip support to cbootimage. User can use "-t124" as
option to parse .cfg and generate BCT/image for Tegra124.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
[swarren, modified change to usage() to avoid re-indenting it all]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-08-27 10:40:55 -06:00
Stephen Warren
ce1847a2b3 crypto: produce consistent hash for zero-length data
In real-world use-cases, hashing zero-length data likely never happens.
However, it is relevant when testing cbootimage with a dummy zero-length
bootloader binary, e.g.:

touch u-boot.bin
cbootimage -t30 ../tamonten-ng/tegra30.img.cfg tegra30-tec-ng.img

In this scenario, it's useful to create a consistent hash, so that one
can compare the resultant images before and after applying patches, to
check for regressions.

Hence, zero out the hash data so it has consistent content if it isn't
written to.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
2013-08-27 10:04:16 -06:00
Stephen Warren
902a58b463 autogen.sh: allow spaces in configure arguments
Using "$@" (rather than #@) quotes any arguments if required. This is
useful if you want to run ./autogen.sh CFLAGS="-ggdb -O0".

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
2013-08-26 14:02:57 -06:00
Stefan Agner
14574161a6 Add automake option subdir-objects to prevent warnings
The SoC specific code is in subdirectories which leads to warnings in
newer
automake versions. The option subdir-objects prevents those warnings.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-08-23 10:43:06 -06:00
Allen Martin
30ffca1748 Bump version to 1.1
Signed-off-by: Allen Martin <amartin@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
2013-06-12 14:17:46 -07:00
Penny Chiu
737ec8332c Add support for Tegra114 SPI boot device
This patch adds SpiFlashParams to generate/dump BCT for SPI flash.

Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Acked-by: Allen Martin <amartin@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-06-10 12:27:16 -06:00
Marc Dietrich
79789fd80d Fix assert with help output only
This moves an assert down if only "-h" and not SOC is given on the
command line.

Signed-off-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2013-04-12 13:09:18 -06:00
Allen Martin
624cec685c Add autotools support
Remove previous hardcoded GNUmakefile and replace with autoconf/automake
generated configure script and Makefile.

Signed-off-by: Allen Martin <amartin@nvidia.com>
Change-Id: I48d3f6f20423109dc662418b92900876a8f8d1da
Reviewed-on: http://git-master/r/217547
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
2013-04-09 11:18:26 -07:00
Allen Martin
480901aba3 Add missing header files
This is in preparation of switching to autotools, add explicit #includes
for header files where there was an implicit dependency.

Signed-off-by: Allen Martin <amartin@nvidia.com>
Change-Id: I8ca5832638ac7043f2b4e687c52bbe6e0a755eef
Reviewed-on: http://git-master/r/217546
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
2013-04-09 11:18:02 -07:00
Allen Martin
f536ef21b1 Move all source files to subdir "src"
This is in preparation for adding autotools support to help separate the source
code from the build support files.

Signed-off-by: Allen Martin <amartin@nvidia.com>
Change-Id: I128c258db7bbf2c1adf34fbaad188ea7678b79ff
Reviewed-on: http://git-master/r/217545
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
2013-04-09 11:17:38 -07:00
Marc Dietrich
8e0070a2a8 Add install target
This adds an install target to the Makefile. cbootimage and bct_dump
are installed to /usr/bin.

Signed-off-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Change-Id: Ib4aba674a7ca206d5de998c649b65772312d510c
Reviewed-on: http://git-master/r/200182
Reviewed-by: Allen Martin <amartin@nvidia.com>
Reviewed-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
2013-02-12 15:06:02 -08:00
Stephen Warren
acbfad4efb Fix type of variable used to store fgetc() result
fgetc() returns an int. Fix process_config_file() to store the result in
an int, so that comparisons against EOF succeed.

Previously, If "char" defaulted to unsigned (which may be true for armhf),
then when fgetc() returned -1, it would be truncated to 255 when stored
in the char, and then zero-filled rather than sign-extended when comparing
against EOF, which would then fail.

See http://code.google.com/p/chromium-os/issues/detail?id=25632.

Reported-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Change-Id: I018e32df9a87b7c6f9fe24d108e091a7b31a50c8
Reviewed-on: http://git-master/r/192151
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Allen Martin <amartin@nvidia.com>
2013-01-17 14:07:42 -08:00
Penny Chiu
0bbfaf91d1 Add Tegra114 support for emmc boot device
Add the Tegra114 chip support to cbootimage. User can use "-t114" as
option to parse .cfg and generate BCT/image for Tegra114.

Change-Id: I02bd3f633afccd2c9c0b01d43ed4660fa4b82ae0
Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Reviewed-on: http://git-master/r/169619
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
2013-01-11 08:37:01 -08:00