summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* cmsg: use two byte ints to send function name string indicesstabilize-sylas-13019.B-cr50_stabstabilize-13020.87.B-cr50_stabstabilize-13020.67.B-cr50_stabstabilize-13020.55.B-cr50_stabrelease-R83-13020.B-cr50_stabVadim Bendebury2020-04-012-6/+13
| | | | | | | | | | | | | | | | | | | | | | When a string parameter __func__ ie encountered in the source code, the function name is saved in the format strings dictionary, and then packet is prepared, instead of sending the string, a byte of 0xff is sent and then the four byte value which is the string index. But two bytes is enough to send the string index, as it is a 16 bit value by design. This patch modifies both transmit and receive sides to start using 2 byte indices for __func__. BUG=b:149964350 TEST=built the new image, tried running it, observed correct function names in the console output. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I682dd18cb4dd434e6982d33f1918ef398d5caa20 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131046 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* util_precompile: add ability to reuse previously created blobsVadim Bendebury2020-04-012-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | Most strings in the Cr50 image are not going to change any time soon, the most likely change is the addition of new strings. With this in mind, it makes sense to keep the string dictionary around and just keep updating it when building a new image, maybe adding new strings, or most often just reusing the ones already in the blob. This patch tries reading the blob before processing the inputs, and if the blob is read and unzipped/unpickled successfully, its contents are used to seed the string dictionary before the inputs are processed. With this approach 100% compatibility between the Cr50 image and the blob is not required, most of the strings would be interpreted properly even with older blobs. A test case is being added to verify this behavior. BUG=b:149964350 TEST=./util/test_util_precompile.py Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I761d6b043dfc85b54352aadaa66d24d4027e95f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2119144
* Make acroterm work with Cr50Vadim Bendebury2020-03-312-93/+383
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the difference between Acropora and Cr50 is such that in case of Acropora the format strings are transferred within packets, and in case of Cr50 only the index of the string is passed in the packet, the string itself is obtained from the list prepared by running util_precompile.py. Another difference is that in Acropora each console packet message represents a full line, in Cr50 the message could be representing just a part of the line, down to a single character. These differences require modifications of the packet header on the DUT side and modifications of the Packet class in Acroterm. Cr50Packet class inherits from Packet, to abstract header structure differences a class specific method of unpack_ph() is being added. The new method extracts packet fields, returning fields common for both packet formats, and saving the class unique values in the object attributes. This allows to consolidate the packet validation function and only divert processing when decode_packet() is invoked. Cr50Packet constructor is passed the list of format strings, the str_index field from packet header is the index of the format string in the list. The Cr50Term class inherits from Acroterm, the only difference is that Cr50Term uses Cr50Packet for packet processing, and prepares the list of strings, retrieving it from the blob created by util_precompile.py. Two new command line options are being added: --cr50_mode enables Cr50 packet mode console support --cr50_str_blob points at the strings blob, by default build/cr50/RW/str_blob is used. Note that on the DUT the Cr50 packet mode is disabled by default. To start using console packet one needs to add the line to board/cr50/board.h and rebuild the image. BUG=b:149964350 TEST=./util/test_acroterm.py succeeds. When Cr50 is built with the suggested modification of board/cr50/board.h, acroterm invoked as $ util/acroterm.py --tty /dev/ttyUSBx --cr50_mode allows to open terminal sessions with USB and UART consoles. Change-Id: I301a5515a0994dba91f2cb40a77c4b59c3becd45 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2116277 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Prepare for transitioning to packet mode consoleVadim Bendebury2020-03-317-9/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A very few changes are needed to support the packet mode: - provide functions to report how much room is left in USB/UART transmit buffers; - compile out cprintf/cprints/cputs just in case to be able to catch cases where util_precompile.py fails to convert them for whatever reason; - do not add CR to every LF, this messes up packet transmissions, and the terminal is doing the right thing anyways - there is a problem with the USB channel in packet mode: the device reboots as soon as an attempt to send something to the host is undertaken. The problem can be rectified by disabling the deferred function path in the Cr50 console USB channel. A bug was open to track it down, but in packet mode using deferred function in this path is less critical, as the amount of sent data always is at least as much as the packet header size BUG=b:149964350, b:152116489 TEST=with the rest of the patches applied packet mode console works fine. When packet mode is disabled the conventional mode console works fine. Change-Id: Ib010cede36adc87cf80f49e5d76ec9e274d9e608 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114238 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* cmsg.c, console packet mode driverVadim Bendebury2020-03-314-3/+428
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a console driver for packet mode. The driver processes information prepared by util_precomplie.py when processing printf invocations in the source code. Each invocation is replaced by a cmsgX function, where X is the number of format arguments. cmsgX functions prepare an array of parameters of size X and invoke a common function, passing it the array and an integer value, consisting of up to 8 4 bit fields, describing the parameters. Since both console drivers need to be able to filter logical console channels, the channel_mask variable is made global. BUG=b:149964350 TEST=with the rest of patches applied and packet mode enabled, verified proper operation of both Cr50 consoles (USB and UART). Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I1f6ef5ea50bffbe14d3e3850fff0191c54f37033 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2113931 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* make: add preprocessor stageVadim Bendebury2020-03-315-1/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | For the upcoming introduction of transitioning Cr50 console communications to packet mode, there is a need to be able to replace all print function invocations in the code with calls to packet sending function. This replacement is easiest to make in C preprocessor outputs, as there all macros are replaced with actual function invocations. This patch adds a configuration option CONFIG_EXTRACT_PRINTF_STRINGS, when enabled, building of the image object files starts happening in three steps instead of one, instead of .c => .o transition, the steps are .c => .E => .Ep => .o, where .E is the C preprocessor output, and .Ep is result of post processing by ./util/util_precompile.py. BUG=b:149964350 TEST=image layout does not change if CONFIG_EXTRACT_PRINTF_STRINGS is not defined. With the rest of the patches applied defining the above config option allows to build a Cr50 image supporting packet console communications mode. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I20b8ba7c5d13cb54ac6adbdbce856d92023ce997 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2113122 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* script for processing preprocessor outputVadim Bendebury2020-03-312-0/+715
| | | | | | | | | | | | | | | | | | | | This script is customized to be used in Chrome OS EC codebase, where functions cprintf(), cprints() and cputs()are used to generate console output. The operation of the script is extensively described in the docstring of the file, a unit test is provided to verify basic functionality. BUG=b:149964350 TEST=./util/test_util_precompile.py succeeds with the rest of the patches applied built a Cr50 image, verified that using a verified version of Acroterm one can communicate with Cr50 console the same way it works today over regular UART. Change-Id: I2c92088a8b08dcf7fdb606a01fbc94ab0d2df6e6 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2106863 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Modify ec_comm command to corrupt NVMEM copy of kernel secdataNamyoon Woo2020-03-315-25/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'ec_comm corrupt' used to corrupt a copy of EC-RW hash in ec_efs.c for test purpose. This patch makes it corrupt the copy stored in the TPM NVMEM cache first, and then read it into the cache in ec_efs.c. 'corrupt' option is available for regular image as well onl if CCD is opened. 'reload' option is obsolete. BUG=b:150650877 TEST=checked the behavior in the sequence below: 0. program regular image cr50> ec_comm corrupt CCD is not opened Access Denied Usage: ec_comm [corrupt] 1. open ccd. 2. Checked the original hash code. cr50> ec_comm ... ec_hash_sec_data : /* original hash code, Hm. */ 3. Corrupt the hash code. cr50> ec_comm corrupt ... ec_hash_sec_data : /* corrupted hash code, Hc. */ 4. Reboot EC. ec> reboot ap-off 5. Check the boot mode is NO_BOOT mode. chroot$ gsctool --getbootmode ... Boot mode = 0x01: NO_BOOT 6. Turn on AP by tapping the power button. Check AP rewrites the secdata, and Cr50 reloads it. cr50> ec_comm ... ec_hash_sec_data : /* original hash code, Hm. */ Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: Id34239911da204e1eacd285fa601a9b5db03c4ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2119130 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org> Tested-by: Namyoon Woo <namyoon@chromium.org>
* Print EC-EFS2 boot-mode upon ec_comm uart commandNamyoon Woo2020-03-281-0/+7
| | | | | | | | | | | | | | | | | | | | This patch makes ec_comm uart command to display EC-EFS2 boot mode, either 'NORMAL' or 'NO_BOOT'. This shall be used for test purpose. BUG=b:150650877 TEST=manually checked on uart. > ec_comm ... ec_hash : LOADED secdata_error_code : 0x00000000 boot_mode : NORMAL Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: Ia2ac1bf9fdecc641558856754f9df2c917434d95 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2125155 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* cr50: prepare to release 0.{3,4}.27Mary Ruthven2020-03-272-2/+2
| | | | | | | | | | BUG=none TEST=none Change-Id: I67d8c30ee7ee1bfb9e75cee478a67f46feb19f88 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2124951 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Add .pylintrcVadim Bendebury2020-03-261-0/+170
| | | | | | | | | | | | | | | | | | This is a renamed copy of the recommended platform/dev/contrib/pylintrc@8021dab with a single addition: 12a13 > max-line-length = 80 replacing default limit of 100 chars. BUG=none TEST='cros lint <py file>' Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Ie9647f5b38faf39a4839b9b9fdefa8bd85f483ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2122768 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* Bring in acroterm from the Dauntless project.Vadim Bendebury2020-03-252-0/+1191
| | | | | | | | | | | | | acroterm.py is a copy taken as if from Acropora core tree at sha 80bf39f and modified to add the Chromium OS authors headers. BUG=b:149964350 TEST=./util/test_acroterm.py Change-Id: I48e866e205ef62f6e776e6c50b0f970c9df5202a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114240 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* tpm2: clean up stubs.cVadim Bendebury2020-03-251-17/+4
| | | | | | | | | | | | | | | Drop the unused function and use ccprintf() instead of uart_printf(). Using ccprintf() will make it easier to use this code when packet mode is enabled. Used tabs in the changed lines s to pacify repo upload. BUG=b:149964350 TEST=make buildall -j Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I97522e9278a4393ef75b9a6a90e6995ba2449f30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2114237
* cr50: Configure clang-format to AlignConsecutiveMacrosstabilize-12997.B-cr50_stabLouis Collard2020-03-231-0/+1
| | | | | | | | | | | | | BUG=none BRANCH=cr50 TEST=git-clang-format Signed-off-by: Louis Collard <louiscollard@chromium.org> Change-Id: I2618d7b6d731200e605e207bc7343930e4701293 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2111912 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* g: add CONFIG_USB_CONSOLE_DEFAULT_DISABLEDMarius Schilder2020-03-202-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | To avoid some sort of race in private-cr52 endpoint initialization, which results in a reboot loop. Calling usb_console_enable() in HOOK_LAST instead appears stable, at cost of missing some early console output. While at it, reduce some SRAM usage and improve legibility by moving to bool from int. Strictly opt-in; behavior unchanged for existing code. BUG=chromium:1063240 BRANCH=cr50 TEST=make buildall; cr52 build w/ usb_console now enumerates w/o resets. Signed-off-by: mschilder@google.com Change-Id: I352edb4c045df401cb99573da5765b88deb45d0d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2111450 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org> Commit-Queue: Marius Schilder <mschilder@chromium.org> Tested-by: Marius Schilder <mschilder@chromium.org> Auto-Submit: Marius Schilder <mschilder@chromium.org>
* Makefile.rules: prevent unnecessary updates of ec_version.hVadim Bendebury2020-03-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While working on a different issue it was discovered that $(out)/RW/board/cr50/board.o is rebuilt every time make is ran, even if there has been no changes. Further investigation has shown that the problem is that $(out)/RW/board/cr50/board.o depends on $(out)/ec_version.h, which is not rebuilt unless something changed, but is declared .PHONY in Makefile.rules Turns out the declaration is supposed to be conditional on actual change in ec_version.h, but the condition is always True. This in turn was due to the fact that when checking if there is a change, some relevant make variables (CR50_DEV, CR50_SQA, and CRYPTO_TEST) were not set when invoking ./util/getversion.sh. When the variables are set, ec_version.h is not decalred PHONY, no unnecessary compilation is invoked. BUG=none TEST=repetitive running of make BOARD=cr50 CR50_DEV=1 build/cr50/RW/board/cr50/board.o does not trigger recompilation of board.o any more Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Ibe75bcda9a774e748f973d85841bbde9c29fd104 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108920 Reviewed-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* PRESUBMIT.cfg does not need to enforce BRANCH=Vadim Bendebury2020-03-181-1/+0
| | | | | | | | | | | | | | | This is the cr50_stab branch, pretty much all patches will have to be cherry picked into cr50-prepvt and cr50-mp, no need to add noise to patch descriptions. BUG=none TEST='repo upload' does not complain about missing BRANCH= in the patch descriptions. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: Iaac7c4576317025c750872fb6b9c56e64c82cc15 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108719 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* remove CONFIG_USB_HID_KEYBOARD and CONFIG_USB_UPDATENamyoon Woo2020-03-136-1107/+0
| | | | | | | | | | | | | | | | | | | | | | This path removes CONFIG_USB_HID_KEYBOARD support and CONFIG_USB_UPDATE support because they are not used in any cr5X board configuration. Ths patch also removes some subsidiary configs as upload hook script guides. > CONFIG_USB_PAIRING > CONFIG_TOUCHPAD_VIRTUAL_OFF > CONFIG_USB_CONSOLE_READ BUG=none BRANCH=cr50 TEST=make buildall Signed-off-by: Namyoon Woo <namyoon@google.com> Change-Id: Iafa553fdf58772744b1d9a5c7f5460f42264f468 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2103045 Tested-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* change the init proiorities of ec_efs_init() and ec_comm_init()release-R82-12974.B-cr50_stabNamyoon Woo2020-03-124-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch reprioritizes ec_comm_init() and ec_efs_init() so that they won't be executed prior to board_init(), which executes nvmem_init(). BUG=b:151187315 BRANCH=cr50 TEST=let cr50 reboot a few times, and checked the console message and the ec_comm command output that Kernel secdata was reloaded without error. Swapped cr50 image from normal to dev, vice versa, and repeated the rebooting. [Reset cause: hard] [0.003799 Inits done] strap pin readings: a1:2 a9:3 a6:0 a12:0 [0.005893 Valid strap: 0xe properties: 0xa00041] [0.007991 init_jittery_clock_locking_optional: run level high, ... [0.045539 init took 29953] [0.051185 tpm_rst_asserted] [0.052074 EC-COMM: Initializtion] Console is enabled; type HELP for help. ... > ec_comm ... response : 0xec00 ec_hash : LOADED secdata_error_code : 0x00000000 > Change-Id: Ia695896986374ac9d23ac111fe0086ec6a13923e Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2093102 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* add corrupt and reload options to 'ec_comm' console cmdNamyoon Woo2020-03-113-2/+39
| | | | | | | | | | | | | | | | | | | | Two new options for 'ec_comm' are for test usage only. - ec_comm corrupt: it corrupts the ECRW hash in ec_comm module. Hash corruption will cause EC-FW verification failure. It can be useful to check how AP firmware performs software sync on this failure. - ec_comm reload: it forces Cr50 to reload ECRW hash from tpm nvmem. This is to restore the EC EFS2 status in Cr50 from corrupted status. BUG=b:150650877 BRANCH=cr50 TEST=manually ran 'ec_comm corrupt' or 'ec_comm reload' with dev image. Checked cr50 normal image refuses those command lines. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ib4aa9532132e1ee786e623bd658a68987e4681dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094781 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* introducing an unittest of EC-EFSNamyoon Woo2020-03-1116-19/+620
| | | | | | | | | | | | | | | This patch adds a test case for EC-EFS functions. BUG=b:150650877 BRANCH=cr50 TEST=make run-ec_comm make runhosttests make buildall -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I90cdc3aa73cf8946da4cf094de5ca0adfaaa0a7c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2096338 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* minor cleanup on EC-EFS2 implementationNamyoon Woo2020-03-112-2/+1
| | | | | | | | | | | | | | usart.h doesn't need to be included in ec_comm.c. This patch also fixes nit output format in cprints. BUG=none BRANCH=cr50 TEST=make run-ec_comm Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Icadf0d860cee8d3cf882cdb4571aaa2bc325adf9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094751 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* allowing repeating an EC-EFS command, SET_BOOT_MODENamyoon Woo2020-03-111-2/+27
| | | | | | | | | | | | | | | | This patch allows the repeating SET_BOOT_MODE command except one case that attempts to change the boot mode from NO_BOOT to NORMAL. Cr50 resets EC on those violating commands. This patch adds error handling for an unknown boot mode parameter. BUG=none BRANCH=cr50 TEST=ran unittest, 'make run-ec_comm'. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ib6c97596ed9c7b7563fbe5e6497cbd668f57a474 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2096840 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* system: avoid printing one character at a timeVadim Bendebury2020-03-111-13/+35
| | | | | | | | | | | | | | | | | | | | With the upcoming transition to handling console traffic in packet mode it is very expensive to be shipping one character at a time, each character results in sending a packet of 16 or so bytes. This patch modifies print_build_string() such that it splits the long build version string into manageable substrings and prints them instead of printing one character at a time. BRANCH=cr50, cr50-mp BUG=b:149964350 TEST=built a Cr50 image, verified that build string is printed as expected. Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Change-Id: I743205932892b0f14c161ade5ea856a658fb26e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2097444 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* gpio_commands: reduce number of vararg parametersVadim Bendebury2020-03-111-17/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | The extended GPIO state support command uses a lot of format elements when trying to report properties of the GPIOs. The upcoming source code processing scripts do not support more than eight format elements per format string. On top of that there is no need to even try to generate the string in case extended GPIO command mode is supported. Let's move generating the string with properties into the conditionally compiled section, to make sure that it is generated/processed only when needed, and let's use snprintf() first to reduce the number of format elements in the following ccprintf invocation. BRANCH=cr50, cr50-mp BUG=b:149964350 TEST=verified proper 'gpiog' command output when code is compiled both with and without CONFIG_CMD_GPIO_EXTENDED Change-Id: I0836a350d1f787c84d2079f10de3652523a8a5a9 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2097442 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* move ec_comm implementation to common directoryNamyoon Woo2020-03-107-2/+8
| | | | | | | | | | | | | | | This patch moves ec_comm.c and ec_efs.c from board/cr50 to common/, so that they can be shared with other board configuration (like host). This is to build unittest for those files. BUG=none BRANCH=cr50 TEST=make buildall -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I67ac313054ebe4604848a176f0a42e3483957e74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094076 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* fix in EC-EFS command, SET_BOOT_MODENamyoon Woo2020-03-101-1/+1
| | | | | | | | | | | | | | | | This patch changes fixes the pre-condition to check before it processes the command, SET_BOOT_MODE. It should check if the current boot mode is NORMAL mode, but it used to check if the input parameter value is NORMAL mode. BUG=none BRANCH=cr50 TEST=make buildall -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: I85e0a3a1ed27a276262a7b9d3889c826cca14d19 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094075 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* util: add flash_cr50 script for updating cr50.Mary Ruthven2020-03-091-0/+771
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a flash_cr50 script for updating cr50. The script supports updating through gsctool and cr50-rescue. BUG=b:144048851 BRANCH=none TEST=manual python util/flash_cr50.py -i $IMAGE -p 9999 -c cr50-rescue on octopus. python util/flash_cr50.py -i $IMAGE -p 9999 --method=cr50_reset_odl -c cr50-rescue python util/flash_cr50.py -i $IMAGE -c 'sudo gsctool' python util/flash_cr50.py -i $IMAGE -s $SERIAL Change-Id: Ibdd213446fea4cb66f77c6b7249c02914bd0712a Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1907469 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> (cherry picked from commit ba216cfef2a005717938b28ceab15b79406f7f3b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2092916 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* bs: use platform/cr50 as EC_ROOTMary Ruthven2020-03-071-1/+1
| | | | | | | | | | | | | BUG=none BRANCH=none TEST=manual sudo CR50_BOARD_ID="FFFF:0:10" H1_DEVIDS="${DEVID}" ./util/signer/bs Change-Id: I54f149bf5c0248a8672514258b596455d442ef69 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2088552 Reviewed-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cr50: remove create_released_imageMary Ruthven2020-03-071-232/+0
| | | | | | | | | | | BUG=none BRANCH=none TEST=none Change-Id: I63a586c946f1b69547197767753e60f3319aad90 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2092211 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* gsctool: get the current system boot modeNamyoon Woo2020-03-061-2/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gsctool -g or --getbootmode can get the current system boot mode. BUG=b:141578322 BRANCH=cr50 TEST=ran on helios. $ ./extra/usb_updater/gsctool --getbootmode finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Boot mode = 0x00: NORMAL $ ./extra/usb_updater/gsctool -g finding_device 18d1:5014 Found device. found interface 3 endpoint 4, chunk_len 64 READY ------- Getting boot mode Boot mode = 0x00: NORMAL Change-Id: Id024ac94fb08b680bd5e190bc7eeb2de301b70a2 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2058128 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* gsctool: add 'force_ro' optionstabilize-12951.B-cr50_stabVadim Bendebury2020-02-282-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | By design gsctool does not update the inactive RO unless the running RO version is lower than the version in the Cr50 image being transferred. With transition to the new RO version, keys and rollback map state, there is a need to enforce that both ROs on the device are updated. This patch adds a command line option which allows to update the inactive RO to the contents of the Cr50 image. BRANCH=none BUG=b:136284186 TEST=running 'gsctool -q cr50.bin' updates the inactive RO section. Change-Id: I79c21fc2cd41c40070352d8fbce0b71dd3ae2b1f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1949547 Reviewed-by: Namyoon Woo <namyoon@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> (cherry picked from commit 53f59f6b361e8cf0a8d1af70306146db90ffae23) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2058127 Tested-by: Namyoon Woo <namyoon@chromium.org> Commit-Queue: Namyoon Woo <namyoon@chromium.org>
* cr50_rma_open: fix linter errorsMary Ruthven2020-02-281-193/+178
| | | | | | | | | | | | | | | | Fix errors from pylint. Use logging to print messages instead of print. BUG=b:149405690 BRANCH=none TEST=RMA open a device and enable testlab mode. Change-Id: I63a8b108b0f436291659f2f787ebcf72e8f4a523 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052269 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 63e6072b454d41e85fd3763abff412d73090ce2d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080634
* cr50_rma_open: port to python 3Mary Ruthven2020-02-281-43/+50
| | | | | | | | | | | | | | BUG=b:149405690 BRANCH=none TEST=run with python3 Change-Id: I42bcccec83c7c582450c0b599f46b3fbf0ab3f80 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052268 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 356f6719d9060523f8302eb93f67be97134831c7) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080593
* cr50_rma_open: only disable timestamps with servodMary Ruthven2020-02-281-2/+5
| | | | | | | | | | | | | | | | | | | cr50_rma_open can be run without servod. dut-control cr50_uart_timestamp:off fails if the script isn't running through servod. This change moves disabling timestamps, so it's only done on servod. BUG=none BRANCH=none TEST=run with and withoout servod Change-Id: Icc80d021dd7cbad8ae3632625b32b30368e5a94c Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1960919 Reviewed-by: Evan Green <evgreen@chromium.org> (cherry picked from commit 633bca2829532c6cad19cf49774a57f6baf8d1bf) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080633 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* cr50_rma_open: Disable UART timestampsEvan Green2020-02-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | The log timestamps are unexpected by the script, and cause issues. Send a dut-control command to disable UART timestamps. Also fix the regex in the board ID portion to accept a colon as well as a comma, whichever comes first. BUG=None TEST=Try cr50_rma_unlock.py BRANCH=None Change-Id: Ie9e54e65b86c52aef120fa3249453bfc090cf6f0 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1921703 Reviewed-by: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 2f814c9a297f2be7a508676a17052c7fe652c1d2) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080632 Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org>
* cr50: prepare to release 0.{3,4}.26Mary Ruthven2020-02-272-2/+2
| | | | | | | | | | | BRANCH=cr50, cr50-mp BUG=none TEST=none Change-Id: I1dffd37d08c7d6209fafb9c18c7c5a87a1b20cba Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2076503 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* cr50: Provision DIOM4 as inputVadim Bendebury2020-02-271-0/+10
| | | | | | | | | | | | | | | | | This will allow using this pin a physical presence indicator on certain platforms. BRANCH=cr50,cr50-mp BUG=b:144455668 TEST=tried the new image on the red board, observed DIOM4 level changing when shorting it to ground. Change-Id: I7c20b094d73d49321921c5afa67e0db9825ea82f Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2076499 Reviewed-by: Yicheng Li <yichengli@chromium.org> Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org>
* capitalize enum tpm_read_rv and tpm_write_rvstabilize-volteer-12931.B-cr50_stabNamyoon Woo2020-02-225-25/+25
| | | | | | | | | | | | This patch fixes a coding style violation in enum name. BUG=none BRANCH=cr50 TEST=none Change-Id: I53eb8aa0905ecfc841a4fe7a738df74d571e321b Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2065493
* EC-CR50 communicationNamyoon Woo2020-02-225-14/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch supports EC-CR50 communication. EC activates EC-CR50 communication by setting high DIOB3, and send a command packet to CR50 through UART_EC_TX_CR50_RX. Cr50 processes the packet, and sends a response packet back to EC. EC deactivates EC-CR50 communication by putting low DIOB3. This patch supports two kinds of EC-CR50 commands: - CR50_COMM_CMD_SET_BOOT_MODE - CR50_COMM_CMD_VERIFY_HASH Cr50 stores some of EC-EFS context in a powerdown register before deep sleep and restores it after wakeup. This patch increases flash usage by 1456 bytes. BUG=b:119329144 BRANCH=cr50 TEST=Checked "ec_comm" console command on Octopus and reworked Helios. Checked uart_stress_tester.py running without character loss. Change-Id: I23e90b9f3e860a3d198dcee718d7d11080d06e40 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1961145 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cr50: add TPM vendor-specific commands to support EC-EFS2Namyoon Woo2020-02-223-0/+49
| | | | | | | | | | | | | | | | | | | Based on the design in go/ec-efs2, this patch adds two TPM vendor-specific commands: - VENDOR_CC_GET_BOOT_MODE - VENDOR_CC_RESET_EC BUG=b:141578322 BRANCH=cr50 TEST=tested with EC-EFS supporting EC/AP firmware. With CR50 dev image, tested with gsctool on Octopus and Helios by sending each of new vendor commands. Checked flash_ec working on Scarlet in bitbang mode. Change-Id: Ia8f38a7b9cc45b172a1a1ef7e216034e520b79c7 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1956409 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* read EC Firmware hash from kernel secdata during board initNamyoon Woo2020-02-226-2/+95
| | | | | | | | | | | | | | Cr50 reads EC Firmware hash from kernel secdata. This data shall be used for EC-EFS (Early Firmware Selection) procedure. BUG=chromium:1020578, b:148489182 BRANCH=cr50 TEST=none Change-Id: Id8942b5b49dd5b0412d198a12ee0bf87fd59d47f Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1956159 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* Reinstate util/chargenVadim Bendebury2020-02-211-0/+69
| | | | | | | | | | | | | | | | Cr50 related utilities should be coming from the cr50_stab branch of the EC tree. This patch brings back the ToT version of the util/chargen script which was previously dropped. BRANCH=cr50, cr50-mp BUG=b:149350081 TEST=with the rest of the patches applied installed chargen is taken from platform/cr50 Change-Id: I407c2e8676b28ecc894a59e977feb474f89e880a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2067163 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* ccdblock can block EC-CR50 communicationNamyoon Woo2020-02-203-4/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces 'EC_CR50_COMM' a new option for ccdblock console command. It can be useful for system rescue purpose like you want to force cr50 to yield EC_UART (especially TX) port to servo. BUG=chromium:1047287 BRANCH=cr50, cr50-mp TEST=ran manually ccdblock. > ccdstate AP: off AP UART: off EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTEC+TX I2C SPI CCD ports blocked: (none) > > > ccdblock EC_CR50_COMM enable CCD ports blocked: EC_CR50_COMM > [73.386550 CCD state: UARTEC I2C SPI] > > ccdstate AP: off AP UART: off EC: on Rdd: connected Servo: disconnected CCD EXT: enabled State flags: UARTEC I2C SPI CCD ports blocked: EC_CR50_COMM > > > ccdblock EC_CR50_COMM disable CCD ports blocked: (none) > [104.781623 CCD state: UARTEC+TX I2C SPI] ccdstate AP: off AP UART: off EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTEC+TX I2C SPI CCD ports blocked: (none) Change-Id: I7816c201054f1793906bd19d4b58755593d2fbac Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2042118 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* restructure EC-EFS moduleNamyoon Woo2020-02-2010-21/+148
| | | | | | | | | | | | | | | - add ec_efs, which tracks the system boot mode. - add ec_comm.h header file for EC-EFS related functions. - revised vboot.h header file. BUG=b:141143112 BRANCH=cr50 TEST=none Change-Id: Iec1bf466b832bac5ad6be8a52304c1d699a38fb2 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2055363 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* utils: script for calculating Cr50 version fingerprintVadim Bendebury2020-02-191-0/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | This scrip copies the Chrome OS run time code which calculates Cr50 image hash, used as the UMA key to keep track of various TPM versions. BRANCH=none BUG=none TEST=verified that generated fingerprint values match previously generated values: $ for b in /opt/google/cr50/firmware/*; do gsctool -b $b util/tpm_hash_gen.py $b done read 524288(0x80000) bytes from ... RO_A:0.0.11 RW_A:0.4.24[FFFF:00000000:00000010]... 37564a12 928401938 /opt/google/cr50/firmware/cr50.bin.prepvt read 524288(0x80000) bytes from ... RO_A:0.0.11 RW_A:0.3.24[00000000:00000000:00000000]... 795daf5c 2036182876 /opt/google/cr50/firmware/cr50.bin.prod $ Change-Id: Ie129227cea3c68937223c81c068612b044cd5c8b Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051306 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* optimize read_tpm_nvmem()Namyoon Woo2020-02-193-5/+8
| | | | | | | | | | | | | | | | | | This patch optimizes read_tpm_nvmem() by replacing NvGetIndexData() and NvGetIndexInfo() with NvReadIndexDta() and NvReadIndexInfo() respectively. This will reduce NvFindHandle() calls from three to one. BUG=b:148489182 BRANCH=cr50, cr50-mp TEST=The function execution time reduces from 1.2 msec to 550 usec. Cq-Depend:chromium:2038108 Change-Id: I6659480d8b60578f3d0b9dc3f62a677ae8489a57 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2037920 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* control UART_EC RX/TX based on EC-CR50 communication statusNamyoon Woo2020-02-192-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows EC-CR50 communication to enable EC UART only if EC is on and bitbang mode is disabled. EC UART shall be enabled even when CCD_CAP_GSC_TX_EC_RX is disabled, EC UART is ccdblocked, or servo is connected. EC-CR50 comm supporting boards are supposed to have H1 dominate EC UART TX line against servo. Servo detection, which is checked every second, shall be delayed during EC-CR50 communication because EC UART TX pin (GPIO_SERVO_DETECT) is used as an output. Servo state shall be held as it was. Once EC-CR50 communication is done, the servo detection will resume or CCD state gets updated based on what it used to be before EC-CR50 communication. BUG=chromium:1035706 BRANCH=cr50 TEST=manually tested on a reworked Helios. // CCD connection only > ccdstate AP: off AP UART: off EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTEC+TX I2C SPI CCD ports blocked: (none) > ecrst pulse Pulsing EC reset EC_RST_L is deasserted // Servo connection only > ccdstate AP: off AP UART: off EC: on Rdd: disconnected Servo: connected CCD EXT: disabled State flags: I2C CCD ports blocked: (none) Change-Id: I02667bee004d237d846393a18f247970982c71b7 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2023239 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* control EC USB-UART bridgeNamyoon Woo2020-02-193-8/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL separates the control on USB-UART bridge of EC device from EC UART control. USB-UART bridge shall be enabled if CCD connection is detected and the CCD capability is enabled. Otherwise, EC USB-UART shall be disabled. By doing so, CCD capability can be observed even when EC-CR50 communication enables EC UART. This patch increases the flash usage by 204 bytes BUG=b:148247228 BRANCH=cr50, cr50_mp TEST=ran firmware_Cr50CCDServoCap on Helios. > ccd State: Locked Password: none Flags: 0x000001 Capabilities: 0000000000000000 ... > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: connected CCD EXT: enabled State flags: UARTAP UARTEC I2C USBEC > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: disconnected CCD EXT: enabled State flags: UARTAP+TX UARTEC USBEC CCD ports blocked: (none) > ccd State: Opened Password: none Flags: 0x800001 Capabilities: 5555454115000000 ... > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: connected CCD EXT: enabled State flags: UARTAP UARTEC I2C USBEC+TX CCD ports blocked: (none) > ccdstate AP: on AP UART: on EC: on Rdd: connected Servo: undetectable CCD EXT: enabled State flags: UARTAP+TX UARTEC+TX I2C SPI USBEC+TX CCD ports blocked: (none) Change-Id: I6bb560a05831105ff68a9e13e4b28b002ed98096 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2018061 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* cr50: add Asurada strapMary Ruthven2020-02-191-0/+7
| | | | | | | | | | | BUG=b:147835918 BRANCH=cr50 TEST=none Change-Id: I07d4071c4fe99df0a030be1e087f43a696081c3c Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051101 Reviewed-by: Namyoon Woo <namyoon@chromium.org>