summaryrefslogtreecommitdiff
path: root/util/flash_fp_mcu
Commit message (Collapse)AuthorAgeFilesLines
* flash_fp_mcu: Add FPMCU power cycleCraig Hesling2021-08-051-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a workaround for the dartmonkey RO flash init bug, where a boot loop occurs when HW-WP is disabled, but SW-WP is still enabled. We force a true power-on-reset so that flash init function in RO sees that SW-WP cannot be removed (and is "stuck"). BRANCH=none BUG=b:146428434,b:187387061,b:143374692 TEST=# Test on helios, bard, and nocturne scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} ectool --name=cros_fp reboot_ec ssh ${DUT_HOSTNAME} ectool --name=cros_fp uptimeinfo # No power-on reset flag should be set. ssh ${DUT_HOSTNAME} flash_fp_mcu # Check that power-on reset flag is set. # If you were to check the uptimeinfo after flash_fp_mu # finished, you would see a few seconds later that the # power-on flag is gone. This is because biod's startup # would reinitialize entropy and cause reset. TEST=# Test on morphius scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu # Just make sure we didn't break the script. Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ib8e239c6c0d5e5de66da2e664374a80479eb4098 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3032665 Commit-Queue: Josie Nordrum <josienordrum@google.com> Reviewed-by: Josie Nordrum <josienordrum@google.com>
* flash_fp_mcu: Fix nocturne/nami kernelnextCraig Hesling2021-07-221-11/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nocturne and Nami are legacy kernel v4.4 devices. The spidev char device naming changed between their v4.4 and newer v5.4. Since these devices have a kernelnext build+tests, we need an alternative configuration that uses the new spidev name. This is achieved by allowing for specific alt configs that match the full platform name, like "nami-kernelnext". If a config is not provided for the full platform name, it will fallback to using the normal base config name, like "nami". BRANCH=none BUG=b:194004525 TEST=# Run the following commands on a nocturne, nocturne-kernelnext, # nami, nami-kernelnext, and hatch setups. # # Note, you get a kernelnext setup by flashing the base platform # device with an xbuddy line similar to # xbuddy://remote/nami-kernelnext/latest-dev/test scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello # Check that full platform name and base name was identified # correctly. # Check that it succeeded. Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ib2ad991291639ef33799abb4bc3379c1659f754d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3035686 Reviewed-by: Jora Jacobi <jora@google.com>
* flash_fp_mcu: Fix interrupt to unbind race caused by pwr_enCraig Hesling2021-07-161-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Taking control of the pwr_en line causes the FPMCU to power cycle. This causes an interrupt to the cros-ec driver. The interrupt handler then races with the subsequent cros-ec unbind attempt. This can manifest in multiple ways, but one common way is for the later binding of spidev to fail, since the interrupt handler reinitialized the cros-ec driver (due to crrev.com/c/1903814). The spidev attempt then errors out because there are still resources associated with the device (the reallocated cros-ec objects). The need to take control of the power enable line to simply keep FPMCU power enabled is no longer needed on any device. * The need for this arose during nocturne development, when the pwr_en line was associated with the SPI interface in ACPI. This can be seen in https://crrev.com/c/1084686. This pwr_en control was then added to flash_fp_mcu in https://crrev.com/c/1114743. * The pwr_line was then quickly disassociated with the SPI interface a few days later in https://crrev.com/c/1155565, but wasn't removed from flash_fp_mcu. To this day, the FP pwr_en line is controlled in coreboot manually. It remains powered on when the Chromebook is powered on, irrespective of drivers. BRANCH=none BUG=b:190744837 TEST=Run the following on nocturne, nami, kohaku, dratini, and volteer. scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello ssh ${DUT_HOSTNAME} flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Icc64f7056e21180efd19b2f650b9fe5804cd2906 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3027129 Tested-by: Patryk Duda <patrykd@google.com> Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Josie Nordrum <josienordrum@google.com>
* flash_fp_mcu: Log actions to kernel logCraig Hesling2021-07-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | We note our flash_fp_mcu actions to the kernel log in order to be able to debug what action of the script may have triggered a kernel warning or error. This is for debugging current and future issues with the kernel and flash_fp_mcu. BRANCH=none BUG=b:190744837 TEST=# On Nami and Zork scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello dmesg Change-Id: Ie57b1042d20284065a652b0a805c081a9591280c Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3010624 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Jora Jacobi <jora@google.com>
* Revert "flash_fp_mcu: Add debug spi bytes activity"Craig Hesling2021-07-161-33/+0
| | | | | | | | | | | | | | | | | This reverts commit 9a40c7dbadf8c577660a09807287d9133373803b. This change turned out to not be very useful and non-functional on kernel v4.4. BRANCH=none BUG=b:190744837 TEST=none Change-Id: If5d51e0240f93b43410040e99eb48cb5e080f0e3 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3027128 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Jora Jacobi <jora@google.com>
* flash_fp_mcu: Add debug spi bytes activityCraig Hesling2021-06-121-0/+33
| | | | | | | | | | | | | | | | | | | | In an effort to understand why we see "Device or resource busy" when binding the raw spidev driver, we add a few byte count prints to indicate if spi activity occurred between certain operations. This should be removed when a fix for the linked bug is determined. BRANCH=none BUG=b:190744837 TEST=# On Hatch and Zork scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I400ca76ee3451f1e155d7912a7c25613d9f68846 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2954304 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
* flash_fp_mcu: Abort if raw driver bind failsCraig Hesling2021-06-121-0/+5
| | | | | | | | | | | | | | | | This helps simplify the errors being reported. BRANCH=none BUG=b:190744837 TEST=# On Hatch and Zork scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello Change-Id: I74d57ec0d7fc4bda3fae144fe649124af5c61ba9 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2954919 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
* flash_fp_mcu: Add a config for the Brya fingerprint MCUZhuohao Lee2021-06-071-0/+21
| | | | | | | | | | | | | | | | To enable the fingerprint MCU firmware update, we add the config for the Brya. BUG=b:181635081 BRANCH=None TEST=use 'flash_fp_mcu ${BINARY_PATH}', the firmware is programmed correctly. Change-Id: Ic54b9bb25a7b21a871445a7052d605041e1c79d2 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2944308 Reviewed-by: Alex Levin <levinale@google.com> Commit-Queue: Alex Levin <levinale@google.com>
* flash_fp_mcu: Add automatic service stop/restartCraig Hesling2021-06-011-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The normal invocation of flash_fp_mcu is without biod and timberslide being stopped. This is a problem, since this script unbinds/bind drivers that biod and timberslide have open and can interact with. BRANCH=none BUG=b:188985272 b:181635081 TEST=# On Nocturne scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello # Ensure that the biod and timebrslide were stopped and restarted. # No warnings about other services having files open should occur. ssh dut1 flash_fp_mcu --noservices --hello # Ensure that no services were stopped/started and a warning should # be emitted about processes with the device file open. ssh dut1 flash_fp_mcu --noservices --hello # Should see that the warnings shown now show that the open file # was deleted. Cq-Depend: chromium:2918383, chromium:2918638 Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I021b922fb58defcbe608492239e311a5f5296fca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2914502 Reviewed-by: Josie Nordrum <josienordrum@google.com>
* flash_fp_mcu: Add warnings for conflicting processesCraig Hesling2021-05-271-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BRANCH=none BUG=b:188985272 b:181635081 TEST=# Run with biod start on helios scp util/flash_fp_mcu root@${DUT}:/usr/local/bin/flash_fp_mcu flash_fp_mcu --hello # Ensure warning triggered. stop biod stop timberslide LOG_PATH=/sys/kernel/debug/cros_fp/console_log flash_fp_mcu --hello # Ensure no warnings are shown echo spi-PRP0001:02 >/sys/bus/spi/drivers/cros-ec-spi/unbind flash_fp_mcu --hello # Ensure the warning about cros-ec driver not being bound was # emitted # Bind raw driver and hold it open echo spi-PRP0001:02 >/sys/bus/spi/drivers/cros-ec-spi/unbind echo spidev >/sys/bus/spi/devices/spi-PRP0001\:02/driver_override echo spi-PRP0001:02 >/sys/bus/spi/drivers/spidev/bind exec 10<>/dev/spidev1.1 flash_fp_mcu --hello # Ensure warnings about cros-ec bound + raw bound + raw file open # are emitted. Change-Id: I1dded083ad158307ec54866952cf3ed59f30caf5 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2912371
* flash_fp_mcu: Add defaults for image file argCraig Hesling2021-05-251-7/+38
| | | | | | | | | | | | | | | | | | | | | | | This simplifies instructions where we mention using flash_fp_mcu to remove sw write protect and reduces complexity of integration tests that need to put the fpmcu into a working state. It also just makes it easier to use when debugging. BRANCH=none BUG=none TEST=flash_fp_mcu TEST=flash_fp_mcu -r TEST=flash_fp_mcu --hello TEST=# Dratini touch /opt/google/biod/fw/bloonchipper-2.bin flash_fp_mcu # should fail Change-Id: I8a00500fde15d7599596039f1a96fed599874164 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2870945 Reviewed-by: Patryk Duda <patrykd@google.com>
* flash_fp_mcu: Remove coachz driver gpio override hackCraig Hesling2021-05-031-8/+0
| | | | | | | | | | | | BRANCH=none BUG=b:179530529 TEST=# Tested many times using flash_fp_mcu --hello Change-Id: I33e1000e9e2d24e5580ab4a88ad7b5f1f0fd899c Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2865034 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Make exit status more distinctiveCraig Hesling2021-05-031-15/+23
| | | | | | | | | | | | | | | | | | | | | This helps with parsing errors in tast. BRANCH=none BUG=none TEST=# dut1 is a dratini device scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello; echo "Status $?" # Should exit with 0 ssh dut1 touch /tmp/exists ssh dut1 flash_fp_mcu -r /tmp/exists; echo "Status $?" # Should exit with 5 TEST=# Really stared at the code to make sure it looks right. Change-Id: I1f525b99334ea3ff866fca35112119604866f939 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2862548 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Factor out gpio chip checkCraig Hesling2021-05-011-22/+13
| | | | | | | | | | | | | | | | | | This somewhat simplified the exit on failure. It is possible that future gpio systems won't use this interface, but can still be conveyed through variable configs. BRANCH=none BUG=none TEST=# dut1 is a dratini device scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello; echo "Status $?" Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Icd163b59f08d8366be08ea9f3ee2726be0f3185b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2862547 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Truncate board name to base board nameCraig Hesling2021-04-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | This allows the script to work properly on derivative built targets, like hatch-arc-r and hatch-borealis. This is important for tast tests. BRANCH=none BUG=b:186697064 TEST=# dut1 is a dratini device scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello; echo "Status $?" # Should succeed ssh dut1 flash_fp_mcu '/opt/google/biod/fw/bloonchipper*'; echo "Status $?" # Should succeed ssh dut1 flash_fp_mcu; echo "Status $?" # Should error out about no filename ssh dut1 touch /root/alreadyexists ssh dut1 flash_fp_mcu -r /root/alreadyexists; echo "Status $?" # Should fail citing that the output file already exists Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I2d14c5254d7159d63bf0e9bde5ba77e74670bfa2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858277 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Refactor to use main functionCraig Hesling2021-04-291-48/+53
| | | | | | | | | | | | | | | | | | | | https://google.github.io/styleguide/shellguide.html#s7.8-main BRANCH=none BUG=b:176500425 TEST=# dut1 is a dratini device scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello; echo "Status $?" # Should succeed ssh dut1 flash_fp_mcu '/opt/google/biod/fw/bloonchipper*'; echo "Status $?" # Should succeed ssh dut1 flash_fp_mcu; echo "Status $?" # Should error out about no filename Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I2f5f0c05e6c0a83a67948c5f914470b08a5d2c56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2858276 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Change to simpler driver_override for spidevCraig Hesling2021-04-291-2/+2
| | | | | | | | | | | | | | | | | | | This allows for reverting the spidev fallback hack, which overwrites the user visible modalias on ARM. https://crrev.com/c/2715605 BRANCH=none BUG=b:179533783 TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=# Same thing as above, but more generic. tast run -var=servo=localhost:9999 dut1 \ firmware.FpFlashFpMcuHello Cq-Depend: chromium:2851901 Change-Id: I221da42778f5bb31d8dc84fb39ff939fd55b3ed1 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2851634
* flash_fp_mcu: Simplify and make shellcheck happyCraig Hesling2021-04-291-12/+13
| | | | | | | | | | | | | | BRANCH=none BUG=none TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=shellcheck util/flash_fp_mcu Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I719c70efebca9817ba702b1661a1e3b49aabf4e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2687826 Reviewed-by: Josie Nordrum <josienordrum@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Fix gpio get error propagation issueCraig Hesling2021-04-291-6/+22
| | | | | | | | | | | | BRANCH=none BUG=none TEST=# Verified on initial version of CoachZ TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I4c8d95234862b6b4b4a344586ab373e9bf17a5e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2688155
* flash_fp_mcu: Clarify subshell func return behaviorCraig Hesling2021-04-291-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Change functions whose return value we are interested in evaluating to return (instead of exit). Reserve exit syntax for explicit aborts from the script. Fix get_platform_name error case. BRANCH=none BUG=none TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=# Add "return 1" in the top of get_spiid function. scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello TEST=# Add "return 1" to the top of get_platform_name function. scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I3acc8ef3b345db4e77b2e151f90707336c2bcead Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686925 Reviewed-by: Josie Nordrum <josienordrum@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Add delay to consider bootloader startupSujit Kautkar2021-04-231-0/+8
| | | | | | | | | | | | | | | | | Add delay of 100 ms to consider minimum bootloader start time for stm32. This fix prevents triggering stm32mon before bootloader is finished. BRANCH=none BUG=b:185074067 TEST=Multiple 'flash_fp_mcu <fpfw>' Tested on coachz, nocturne and morphius boards Change-Id: Ic60e9e67c29664ce22bfc66bec6eaf76ffc80454 Signed-off-by: Sujit Kautkar <sujitka@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2837485 Tested-by: Sujit Kautkar <sujitka@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Sujit Kautkar <sujitka@chromium.org>
* flash_fp_mcu: Change dw-apb-uart changed from AMD0020:XX to AMDI0020:XXBhanu Prakash Maiya2021-03-181-3/+3
| | | | | | | | | | | | | | | The dw-apb-uart node was changed to match UEFI naming convention. BRANCH=none BUG=b:181349369 TEST=1. Run flash_fp_mcu on Zork device with FW 13434.212 and TOT OS image. Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Change-Id: I33c313a8de3842c37611199a7ffd31be4cd50f3f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2770509 Commit-Queue: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Raul E Rangel <rrangel@chromium.org>
* flash_fp_mcu: Fix Guybrush's gpiochip base from 320 -> 256Bhanu Prakash Maiya2021-03-011-6/+6
| | | | | | | | | | | | BRANCH=none BUG=b:181349369 TEST=None. Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Change-Id: I822d91e26448e3ed9ee0bd2f6abe2ffdc016b345 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727864 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Fix Zork's gpiochip base from 320 -> 256Bhanu Prakash Maiya2021-03-011-6/+6
| | | | | | | | | | | | | | | | | On Zork's SoC change was caused by changing the amount of reserved space for GPIO banks from 0x300 to 0x400. This resulted in base change. Previous: 512 - 192 = 320 Current: 512 - 256 = 256 BRANCH=none BUG=b:181349369 TEST=1. Run flash_fp_mcu on Zork device with FW 13434.212 Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Change-Id: Ied4a5fd9281d59f1bfa30a4ee9677f9a0a11387e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727863 Commit-Queue: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Minor spacing fixCraig Hesling2021-02-121-1/+1
| | | | | | | | | | | BRANCH=none BUG=none TEST=none Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Iece845abd9897abd1e341a8dbae6b0fe2aa85a29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686924 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Add initial support for strongbadCraig Hesling2021-02-111-1/+36
| | | | | | | | | | | | | | | | | | Caveats * Need to fix modalias for strongbad * Need to fix driver binding so that the gpios are not reset * Need to fix external nrst pull BRANCH=none BUG=b:145245345, b:172966748, b:179533783, b:179530529, b:179839337 TEST=emerge-strongbad chromeos-base/ec-utils-test cros deploy dut1 chromeos-base/ec-utils-test ./flash_fp_mcu custom-strongbad-evt-image.bin Change-Id: I33d8fee21a2afbf8f5c399e6cb47c2095d833f57 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2654737 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Add check for drivers that change nrst and boot0Craig Hesling2021-02-111-1/+15
| | | | | | | | | | | | | | This helps identifying driver/device-tree configs that are tampering with the nrst and boot0 pin states. BRANCH=none BUG=b:179530529 TEST=Deploy to coachz with driver that reset nrst and boot0 pins Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ia5d603f8ce49022e48b7b1d623c3b2da6926a6ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686579 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Refactor to use gpio functionCraig Hesling2021-02-111-20/+41
| | | | | | | | | | | | | | This makes the script a bit more readable and allows for implementing more generic gpio handling. BRANCH=none BUG=b:145245345 TEST=Test on hatch Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I80e3b9c7e322d53bb3eecfcb9da47cacc3de919c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2658367 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Add config for guybrushBhanu Prakash Maiya2021-02-061-0/+16
| | | | | | | | | | | BRANCH=none BUG=b:176826659 TEST=None. Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Change-Id: Ia5139265f3f8af6aec7d0c41685f3d3bfa861d1c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2679782 Reviewed-by: Craig Hesling <hesling@chromium.org>
* flash_fp_mcu: Remove trailing spaceCraig Hesling2020-10-311-1/+1
| | | | | | | | | | | | | No functional change. BRANCH=none BUG=none TEST=none Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Iccee7262549ca3355d5cb1c9d19fa484c99612e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2513130 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* flash_fp_mcu: Add comment about zork pwr enable gpioCraig Hesling2020-10-311-1/+2
| | | | | | | | | | | | | No functional change. BRANCH=none BUG=none TEST=Tested manual pwr cycling on a Zork variant. Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I3420746d97f169ad252180876fc0b739210b2779 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2513129 Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
* flash_fp_mcu: Add config zork, uart transport and gpiosBhanu Prakash Maiya2020-10-061-41/+112
| | | | | | | | | | | | | | | | | Zork devices have FPMCU connected to AP via UART. Changes in this patch will let developer flash STM32 in chip's bootloader mode via UART. BUG=b:162368367 TEST=1. Run script on Zork device and confirm firmware flash. 2. Run script on Hatch devices and confirm that SPI functionality is intact. Signed-off-by: Bhanu Prakash Maiya <bhanumaiya@google.com> Change-Id: I9464ae7602e2b6b21d7d31283c6c242a4d603fe5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2444457 Commit-Queue: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org>
* flash_fp_mcu: fix the volteer gpio settingZhuohao Lee2020-06-081-15/+15
| | | | | | | | | | | | | | | | | Due to the latest coreboot change, the gpiochip252 and gpiochip445 were removed and the gpiochip152 was added. Besides, the GPIO pin also changed. This patch fixes the gpio pin setting. BUG=b:156993750 BRANCH=none TEST=ran flash_fp_mcu on the Volteer Change-Id: I54082eea90e85746976d427523cfc0b53e87ddda Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2214876 Tested-by: Jesper Lin <jesper_lin@wistron.corp-partner.google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Alex Levin <levinale@chromium.org>
* util: Fix platform name in flash_fp_mcuTom Hughes2020-05-211-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | cros_config /identity platform-name is specific to mosys and not guaranteed to be the same as the board name. Always use CHROMEOS_RELEASE_BOARD from /etc/lsb-release instead. BRANCH=none BUG=b:156650654 TEST=On ekko: flash_fp_mcu /opt/google/biod/fw/nami*.bin TEST=On kohaku: flash_fp_mcu /opt/google/biod/fw/dartmonkey*.bin TEST=On nocturne: flash_fp_mcu /opt/google/biod/fw/nocturne*.bin TEST=On dratini: flash_fp_mcu /opt/google/biod/fw/bloonchipper*.bin Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ic395e1c6bfdd5c9d4e397a50e594c03d2cf91af1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2212689 Commit-Queue: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* flash_fp_mcu: Add a config for the Volteer fingerprint MCUZhuohao Lee2020-04-071-0/+21
| | | | | | | | | | | | | | | To enable the flash_fp_mcu to update the fingerprint MCU firmware, we need to add a config for the Volteer fingerprint MCU. BUG=b:147687800 BRANCH=None TEST=use 'flash_fp_mcu ${BINARY_PATH}', the firmware is programmed correctly. Change-Id: Ib62ae29ca805985e0256c2ebee5fee633ccef082 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2089214 Reviewed-by: Alex Levin <levinale@chromium.org>
* flash_fp_mcu: Add hello test modeCraig Hesling2020-02-081-20/+23
| | | | | | | | | | | | | | | | | | Add a "hello" mode to flash_fp_mcu that bypasses file operations. The function is to only say hello to the bootloader, in order to conduct stress tests with flash_fp_mcu. BRANCH=nocturne,hatch BUG=b:143374692,b:144729003 TEST=# Ensure PS crrev.com/c/1921705 is applied. # Run http://go/bit/hesling/5791510394044416 Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Iadcc52f11f8186dfea35445ce5ffbb6fb40d7a36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1921705 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org> Tested-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Simplify flags buildingCraig Hesling2020-02-081-10/+10
| | | | | | | | | | | | | | | | | | | | This does not change the behavior of flash_fp_mcu. It simply removes two unnecessary variables and simplifies the flag building logic. BRANCH=nocturne,hatch BUG=b:143374692,b:144729003 TEST=# Nocturne flash_fp_mcu /opt/google/biod/fw/*.bin TEST=# Ensure PS crrev.com/c/1921705 is applied. # Run http://go/bit/hesling/5791510394044416 Change-Id: Icf96d837ed1c8a00e881fb79b42b8f8ccd893ca5 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2036602 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org> Tested-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Factor out retries into constantsCraig Hesling2020-02-081-2/+5
| | | | | | | | | | | | | | | | | | | | This does not change the default behavior of flash_fp_mcu. It does, however, allow the number of retries to be overridden using env variables. BRANCH=nocturne,hatch BUG=b:143374692,b:144729003 TEST=# Nocturne flash_fp_mcu /opt/google/biod/fw/*.bin TEST=# Ensure PS crrev.com/c/1921705 is applied. # Run http://go/bit/hesling/5791510394044416 Change-Id: Ieba0cec022f3463b529655ecc204753db7404f7d Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2036601 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org> Tested-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Add retry logicCraig Hesling2020-02-081-11/+29
| | | | | | | | | | | | | | | | | | | This CL adds reset and retry logic. This is important because stm32mon sometimes fails to get the stm32 bootloader's attention on startup, so we need to reset the chip and try again. BRANCH=nocturne,hatch BUG=b:143374692,b:144729003 TEST=# Nocturne flash_fp_mcu /opt/google/biod/fw/*.bin TEST=# Ensure PS crrev.com/c/1921705 is applied. # Run http://go/bit/hesling/5791510394044416 Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I755d9b8cbb8813fe961f359c128c674e4c395ebb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1913626 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* flash_fp_mcu: Fix spidev flakinessCraig Hesling2019-11-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | This small 100ms sleep is necessary to stabilize the spidev driver. Without it, we have seen that stm32mon is unable to catch the stm32h743 bootloader on the first attempt. This issue became more noticeable with the STM32H743 Rev V. Among other things, the following log shows test results from before adding this sleep and the flash_fp_mcu stress test results after adding this sleep: https://drive.google.com/open?id=1opJn5fPXxUMjMZz0VDtmqpCXN0mVnBr5 BRANCH=nocturne,hatch BUG=b:143374692,b:144729003,b:135033816 TEST=# Ensure PS crrev.com/c/1921705 is applied. # Run http://go/bit/hesling/5791510394044416 TEST=See the testing done in the above Google Drive log. Change-Id: I1777c894e1dd8911df4d407e33dc677373146eb1 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1925174 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* flash_fp_mcu: Add pwr enable for hatch followersCraig Hesling2019-10-101-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | This change ensures that the power is enabled for the FPMCU. This change is valid for all hatch followers. BRANCH=hatch BUG=b:142001487 TEST=cros_workon --board=hatch start chromeos-base/ec-utils-test emerge-hatch chromeos-base/ec-utils-test cros deploy --root=/usr/local dut1 chromeos-base/ec-utils-test # Manually power off the fpmcu cd /sys/class/gpio echo 467 >export echo out >gpio467/direction echo 0 >gpio467/value echo 467 >unexport # ectool --name=cros_fp version # should fail # flash_fp_mcu prior to this CL should fail here, also # determine the proper firmware for fp board and replace below flash_fp_mcu /opt/google/biod/fw/*.bin # Ensure that flash_fp_mcu succeeds Change-Id: Ia96690d49bb4e5bb25aeebddcc08687b13a43b0b Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845781
* flash_fp_mcu: add options for flash read/write protectionTom Hughes2019-09-181-3/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Defaults to disabling both read and write flash protection, but you can disable either or both with these new commandline flags. This is primarily going to be used for testing (e.g., RDP1 to RDP0 causing mass erase). BRANCH=nocturne,nami BUG=chromium:890059 TEST=dut-control fw_wp_state:force_off flash_fp_mcu /opt/google/biod/fw/nami_fp_v2.2.133-31dfe0b1a.bin ectool --name=cros_fp version TEST=flash_fp_mcu -r /tmp/rb.bin diff /tmp/rb.in /opt/google/biod/fw/nami_fp_v2.2.133-31dfe0b1a.bin TEST=dut-control fw_wp_state:force_on ectool --name=cros_fp flashprotect enable ectool --name=cros_fp reboot_ec dut-control fw_wp_state:force_off flash_fp_mcu -r --noremove_flash_read_protect /tmp/rb.bin echo $? => 1 ectool --name=cros_fp version => works flash_fp_mcu -r /tmp/rb-erase.bin hexdump /tmp/rb-erase.bin => all 0xff Change-Id: I42f7daf08dcf229a4980c88a24e6882be7c0e8d6 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1474743
* util: Unify separate flash_fp_mcu scripts into single common oneTom Hughes2019-07-231-0/+265
For fingerprint firmware we are moving towards a model where the "board" (in EC terminology) is a specific MCU+FP_SENSOR combination and not tied to the main system board that it's connected to (e.g., "hatch", "nocturne", etc.). This change decouples flash_fp_mcu from the EC "board". BRANCH=none BUG=b:136678758,b:137108509 TEST=make buildall -j hatch: flash_fp_mcu /opt/google/biod/fw/hatch_fp_v2.0.1359-6f54be08d.bin nocturne: flash_fp_mcu /opt/google/biod/fw/nocturne_fp_v2.0.1765+87bb17a39.bin nami: flash_fp_mcu /opt/google/biod/fw/nami_fp_v2.2.144-7a08e07eb.bin Cq-Depend:chromium:1705055 Change-Id: Idfe298f59ab9df8657a570cc47e956b4e94ee1a1 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1704808 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>