summaryrefslogtreecommitdiff
path: root/extra/usb_updater/usb_updater2.c
Commit message (Collapse)AuthorAgeFilesLines
* usb_updater2: fix incorrect console outputTing Shen2021-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | argv[optind] is the index of next arg to be processed, what we want to print here is actually argv[optind - 1]. BUG=None TEST=Run `usb_updater2 -d 18d1:503c -p 208.0_2.0.bin` on Krane and check console output. Before this CL: read 65536(0x10000) bytes from (null) After: read 65536(0x10000) bytes from 208.0_2.0.bin BRANCH=main Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I45f584672f9c264d350374b43a3dd074b4a4ff7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2623990 Tested-by: Ting Shen <phoenixshen@chromium.org> Auto-Submit: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@chromium.org>
* tree: rename strtoul to strtoull since it is 64-bitJett Rink2020-11-111-2/+2
| | | | | | | | | | | | | | | A long is 32-bit, but a long long is 64-bit. The function name should be strtoull if it is returning 64 bits of data. BRANCH=none BUG=b:172592963 TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I04c40f9256ed37eb1cf9b6bd1b0ef0320fe49b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2530874 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* board/hammer: Fix masterball touchpad settingsNicolas Boichat2019-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Fix the dimensions, and also the size, and make sure that updating the FW actually works (it seems like increasing the timeout to 2000ms is needed). BRANCH=kukui BUG=b:140596094 TEST=Flash masterball, no warning in console on start TEST= Host: make TOUCHPAD_FW=S8648A-15H0_FW01.bin BOARD=masterball -j USE=updater_utils emerge-kukui -av ec-utils cros deploy $IP ec-utils DUT: usb_updater2 -d 18d1:503c -r; sleep 0.5; \ usb_updater2 -d 18d1:503c -s; usb_updater2 -d 18d1:503c ec.bin usb_updater2 -d 18d1:503c -p S8648A-15H0_FW01.bin Change-Id: Ia473ac420b42f52ad1639f950a3f08ff5d32df09 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1847512 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org>
* usb_updater2: fix compiler warningRuben Rodriguez Buchillon2019-08-221-1/+1
| | | | | | | | | | | | | | | | | | The compiler complained about this, noting that error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]. This seems to fix it. BUG=b:120921028 BRANCH=None TEST=manual testing sudo emerge ec-devutils -j32 // warning disappears Change-Id: I4a4392ec7e6bc7af06dc54b6382e52a1f2c91252 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1761467 Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater2: increase send timeout to 2sRuben Rodriguez Buchillon2018-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | To 'successfully' flash sweetberry the 1s timeout is not sufficient. Increase to 2s. BRANCH=None BUG=b:120449224 TEST=manual test sudo servo_updater --board sweetberry ... offset: writable at 0x40000 sending 0xb580 bytes to 0x40000 ------- update complete image updated ... Change-Id: I38bf8c852caf97069fcf67f4b77f9c0a30008235 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1369507 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* touchpad_st: make panel initialization synchronousWei-Han Chen2018-10-091-1/+1
| | | | | | | | | | | | | | | | the entire process would take up to 2 seconds. CQ-DEPEND=CL:1264236 BRANCH=nocturne BUG=b:117203130 TEST=manual on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I0cdcdb8caf3b1d9cf6a5787b93bf8cdb13832a74 Reviewed-on: https://chromium-review.googlesource.com/1264237 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_update: add extra command "UPDATE_EXTRA_CMD_CONSOLE_READ_*"Wei-Han Chen2018-09-031-16/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to corressponding host commands, we can read uart console buffer by following ways: A. Read from the beginning of buffer to the end of buffer: # 1. set snapshot before reading UPDATE_EXTRA_CMD_CONSOLE_READ_INIT while (true) { # 2. read 64 bytes back UPDATE_EXTRA_CMD_CONSOLE_READ_NEXT CONSOLE_READ_NEXT # 3. if (2) returns an empty string, break, otherwise, continue. } B. Mimic `dmesg -w` (keep reading new messages) while (true) { # 1. set snapshot before reading UPDATE_EXTRA_CMD_CONSOLE_READ_INIT while (true) { # 2. read 64 bytes back UPDATE_EXTRA_CMD_CONSOLE_READ_NEXT CONSOLE_READ_RECENT # 3. if (2) returns an empty string, break, otherwise, continue. } } Add argument `-l` to usb_updater2, which will perform (B). Note that the update interface will be occupied while `usb_updater2 -l` is still running, so you can't use other updater command at the same time. BRANCH=none BUG=b:112877237 TEST=test on whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8d2010f84602ca6b84034a0cabe42ae7441614e0 Reviewed-on: https://chromium-review.googlesource.com/1177293 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater2: pretty print touchpad_infoWei-Han Chen2018-08-151-2/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | e.g. on whiskers, the command will behave like: > usb_updater2 -d 18d1:5030 --tp_info < ... < status: 0x00 < vendor: 0x0483 < fw_address: 0x80000000 < fw_size: 0x00020000 < allowed_fw_hash: < 20 0f eb 01 98 34 cf 86 8b 4e 94 1f 51 41 e7 64 < e1 0c 4f ac 88 bd 97 1c 79 ae c5 74 e3 0b 14 6d < id: 0x3936 < fw_version: 0x0011 < fw_fw_checksum: 0xb49f BRANCH=none BUG=b:70482333 TEST=manually on device Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Iffe6720eec33cc57498cdab15ac2e132fdd76808 Reviewed-on: https://chromium-review.googlesource.com/1175506 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* servo_updater: support old and new updaterNick Sanders2018-05-111-2/+7
| | | | | | | | | | | | | | | | | | | Add support for usb_updater2 in servo_updater. This allows update back and forth between servo-9040.B releases and builds from master, although they have different updater enpoint interfaces. Also add '-n' no force reboot to usb_updater2 as force reboot is incompatible with servo_updater's flow. BRANCH=None BUG=b:69016431 TEST=update servo v4 Change-Id: I18809590c2e7e1cfcf60c4c97e956dfc22d85856 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1056157 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater2: match by serial numberNick Sanders2018-05-101-8/+70
| | | | | | | | | | | | | | | Add a serial number match to allow update of servo or other usb devices, where mutliple devices may be attached to one system. BRANCH=None BUG=chromium:718688 TEST=usb_updater2 -d 18d1:501b --serial=[C1706311869|fail] Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: Id6ec944139e685948433af703555fd185e91a9d4 Reviewed-on: https://chromium-review.googlesource.com/1050971 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* usb_updater2: Increase touchpad debug buffer length to 50 bytes.Nicolas Boichat2017-12-141-2/+2
| | | | | | | | | | | | | | | We would like to use all 64-bytes of the buffer as parameter to UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG (12 bytes for update_frame_header, 2 bytes for the extra command type, leaving 50 bytes of payload). BRANCH=none BUG=b:63993891 TEST=./usb_updater2 -g 00 -d 18d1:502b Change-Id: I023aa760f1a4cf9cacf9262a758cba1120d4f380 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/780372 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* usb_updater2: Add support for touchpad debugging featureNicolas Boichat2017-11-141-16/+61
| | | | | | | | | | | | | | Add support for touchpad debugging in usb_updater2, allowing an arbitrary parameter to be passed. BRANCH=none BUG=b:63993891 TEST=./usb_updater2 -g 00 -d 18d1:502b Change-Id: I1242e3bab9dc69ec3a92dd158c85606211e40f21 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/763575 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* g: rename usb_updater into gsctoolVadim Bendebury2017-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usb_updater utility has long been not just an updater, and has long been using other interfaces in addition to USB. gsctool is a much more suitable name. CQ-DEPEND=CL:709776 BRANCH=cr50 BUG=b:67007500 TEST=verified that make -C ./extra/usb_updater generates ./extra/usb_updater/gsctool: $ ./extra/usb_updater/gsctool --help Usage: gsctool [options] <binary image> This updates the Cr50 RW firmware over USB. The required argument is the full RO+RW image. Options: [...] $ Change-Id: I3ab70c28acf3664ddefaa923a87ba1fd5c3c437b Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/709738 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* usb_updater2: Add support for trackpad update over USB updaterNicolas Boichat2017-09-031-10/+35
| | | | | | | | | | | | | | BRANCH=none BUG=b:63993173 TEST=./usb_updater2 -p SA459C-1211_ForGoogleHammer_3.0.bin Change-Id: I49fed10e408c7c8c63bea10109760fc0f02ab74c Signed-off-by: Nicolas Boichat <drinkcat@google.com> Signed-off-by: Chun-Ta Lin <itspeter@google.com> Reviewed-on: https://chromium-review.googlesource.com/593374 Commit-Ready: Chun-ta Lin <itspeter@chromium.org> Tested-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* usb_updater2: Add code to fetch touchpad informationNicolas Boichat2017-08-311-9/+35
| | | | | | | | | | | BRANCH=none BUG=b:63418037 TEST=./usb_updater2 -t Change-Id: Ibed7cfc1d706f0f0ff8072f3ec08997f40a89038 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/593001 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* usb_updater2: Add support for INJECT_ENTROPY commandNicolas Boichat2017-08-231-11/+45
| | | | | | | | | | | | | | | | | Necessary for pairing support. Cleaner implementation to be moved to hammerd. BRANCH=none BUG=b:38487027 TEST=Flash hammer. On host, reboot hammer to RO: usb_updater2 -r; sleep 0.5; usb_updater2 -s usb_updater2 -e (adds entropy) EC console: check that rollbackinfo shows secret is updated Change-Id: I7b354c7bb1b6d4260939dc33fe6cb4ab4ecd50e0 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/513809 Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
* usb_updater2: USB updater for common code ECNicolas Boichat2017-05-211-0/+961
This is copied chip/g version as of commit 0e5497db6, plus the following uncommited usb_update patch (CL:458469): a0176a1cc usb_updater: Flush all data from endpoint before trying to update On top of that, a good number of common-code specific modifications are added: new extra commands, new first_response_pdu format, use of FMAP. BRANCH=none BUG=b:35587170 TEST=usb_updater binary identical before and after this change. TEST=make BOARD=hammer -j && \ ( cd extra/usb_updater && make && \ time sudo ./usb_updater2 ../../build/hammer/ec.bin ) TEST=cd extra/usb_updater; make # Jump to RW sudo ./usb_updater2 -j sleep 0.5 # Update RO, then reboot sudo ./usb_updater2 ../../build/hammer/ec.bin sleep 0.5 # Update RW (first tell RO to not jump to RW) sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin TEST=cd extra/usb_updater; make # Tell RW to jump back to RO sudo ./usb_updater2 -w sleep 0.5 # Update RW, then reboot sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin TEST=usb_updater2 can update hammer, and read its version, rollback version and key version. Change-Id: I09da894d83e2b4d6c2e46cab301522c27fa0160c Reviewed-on: https://chromium-review.googlesource.com/458468 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org>