Vendor HID for upgrades (#529)
* vendor-hid for upgrades * empty argument fix * same vendor-hid usage in both deploys * forgot one board * aaand also forgot the quotes
This commit is contained in:
@@ -70,3 +70,11 @@ respectively. You can only upgrade the partition that is not currently running,
|
|||||||
so always alternate your calls to `perform_upgrade.sh`. Otherwise, this script
|
so always alternate your calls to `perform_upgrade.sh`. Otherwise, this script
|
||||||
works like `deploy.py`. You can call it even after you locked down your device,
|
works like `deploy.py`. You can call it even after you locked down your device,
|
||||||
to deploy changes to your development board.
|
to deploy changes to your development board.
|
||||||
|
|
||||||
|
If you deploy with `--vendor-hid`, also add this flag to `perform_upgrade.sh`,
|
||||||
|
for example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./deploy.py --board=nrf52840dk_opensk_a --opensk --vendor-hid
|
||||||
|
./tools/perform_upgrade.sh nrf52840dk_opensk_b --vendor-hid
|
||||||
|
```
|
||||||
|
|||||||
@@ -212,10 +212,10 @@ if __name__ == "__main__":
|
|||||||
"haven't been both programmed yet."),
|
"haven't been both programmed yet."),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--use-vendor-hid",
|
"--vendor-hid",
|
||||||
default=False,
|
default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
dest="use_vendor_hid",
|
dest="use_vendor_hid",
|
||||||
help=("Whether to configure the device using the Vendor HID interface"),
|
help=("Whether to configure the device using the Vendor HID interface."),
|
||||||
)
|
)
|
||||||
main(parser.parse_args())
|
main(parser.parse_args())
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from unittest.mock import patch
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import colorama
|
import colorama
|
||||||
@@ -172,7 +173,16 @@ def main(args):
|
|||||||
"signature": sign_firmware(signed_data, priv_key)
|
"signature": sign_firmware(signed_data, priv_key)
|
||||||
}
|
}
|
||||||
|
|
||||||
for authenticator in tqdm(get_opensk_devices(args.batch)):
|
if args.use_vendor_hid:
|
||||||
|
patcher = patch.object(hid.base, "FIDO_USAGE_PAGE", 0xFF00)
|
||||||
|
patcher.start()
|
||||||
|
info("Using the Vendor HID interface")
|
||||||
|
|
||||||
|
devices = get_opensk_devices(args.batch)
|
||||||
|
|
||||||
|
if not devices:
|
||||||
|
fatal("No devices found.")
|
||||||
|
for authenticator in tqdm(devices):
|
||||||
# If the device supports it, wink to show which device we upgrade.
|
# If the device supports it, wink to show which device we upgrade.
|
||||||
if authenticator.device.capabilities & hid.CAPABILITY.WINK:
|
if authenticator.device.capabilities & hid.CAPABILITY.WINK:
|
||||||
authenticator.device.wink()
|
authenticator.device.wink()
|
||||||
@@ -242,4 +252,11 @@ if __name__ == "__main__":
|
|||||||
dest="priv_key",
|
dest="priv_key",
|
||||||
help=("PEM file for signing the firmware."),
|
help=("PEM file for signing the firmware."),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--vendor-hid",
|
||||||
|
default=False,
|
||||||
|
action="store_true",
|
||||||
|
dest="use_vendor_hid",
|
||||||
|
help=("Whether to upgrade the device using the Vendor HID interface."),
|
||||||
|
)
|
||||||
main(parser.parse_args())
|
main(parser.parse_args())
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ set -e
|
|||||||
|
|
||||||
BOARD="$1"
|
BOARD="$1"
|
||||||
|
|
||||||
./deploy.py --board=$BOARD --opensk --programmer=none
|
./deploy.py --board="${BOARD}" --opensk --programmer=none $2
|
||||||
python3 -m tools.deploy_partition --board=$BOARD
|
python3 -m tools.deploy_partition --board="${BOARD}" $2
|
||||||
if nrfjprog --reset --family NRF52 ; then
|
if nrfjprog --reset --family NRF52 ; then
|
||||||
echo "Upgrade finished!"
|
echo "Upgrade finished!"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user