|
18 | 18 | ) |
19 | 19 |
|
20 | 20 | logger = logging.getLogger(__name__) |
21 | | -PROJECT_NAME = 'with_mcumgr' |
22 | 21 |
|
23 | 22 |
|
24 | | -def create_signed_image(build_dir: Path, version: str) -> Path: |
| 23 | +def create_signed_image(build_dir: Path, app_build_dir: Path, version: str) -> Path: |
25 | 24 | image_to_test = Path(build_dir) / 'test_{}.signed.bin'.format( |
26 | 25 | version.replace('.', '_').replace('+', '_')) |
27 | 26 | origin_key_file = find_in_config( |
28 | 27 | Path(build_dir) / 'mcuboot' / 'zephyr' / '.config', |
29 | 28 | 'CONFIG_BOOT_SIGNATURE_KEY_FILE' |
30 | 29 | ) |
31 | 30 | west_sign_with_imgtool( |
32 | | - build_dir=Path(build_dir) / PROJECT_NAME, |
| 31 | + build_dir=Path(app_build_dir), |
33 | 32 | output_bin=image_to_test, |
34 | 33 | key_file=Path(origin_key_file), |
35 | 34 | version=version |
@@ -62,7 +61,8 @@ def test_upgrade_with_confirm(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): |
62 | 61 | """ |
63 | 62 | logger.info('Prepare upgrade image') |
64 | 63 | new_version = '0.0.2+0' |
65 | | - image_to_test = create_signed_image(dut.device_config.build_dir, new_version) |
| 64 | + image_to_test = create_signed_image(dut.device_config.build_dir, |
| 65 | + dut.device_config.app_build_dir, new_version) |
66 | 66 |
|
67 | 67 | logger.info('Upload image with mcumgr') |
68 | 68 | dut.disconnect() |
@@ -111,12 +111,13 @@ def test_upgrade_with_revert(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): |
111 | 111 | 8) Verify that MCUboot reverts update |
112 | 112 | """ |
113 | 113 | origin_version = find_in_config( |
114 | | - Path(dut.device_config.build_dir) / PROJECT_NAME / 'zephyr' / '.config', |
| 114 | + Path(dut.device_config.app_build_dir) / 'zephyr' / '.config', |
115 | 115 | 'CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION' |
116 | 116 | ) |
117 | 117 | logger.info('Prepare upgrade image') |
118 | 118 | new_version = '0.0.3+0' |
119 | | - image_to_test = create_signed_image(dut.device_config.build_dir, new_version) |
| 119 | + image_to_test = create_signed_image(dut.device_config.build_dir, |
| 120 | + dut.device_config.app_build_dir, new_version) |
120 | 121 |
|
121 | 122 | logger.info('Upload image with mcumgr') |
122 | 123 | dut.disconnect() |
@@ -178,14 +179,14 @@ def test_upgrade_signature(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr, key |
178 | 179 | key_file = Path(origin_key_file).parent / key_file |
179 | 180 | assert key_file.is_file() |
180 | 181 | assert not key_file.samefile(origin_key_file) |
181 | | - image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin' |
| 182 | + image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin' |
182 | 183 | logger.info('Sign second image with an invalid key') |
183 | 184 | else: |
184 | | - image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin' |
| 185 | + image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin' |
185 | 186 | logger.info('Sign second imagewith no key') |
186 | 187 |
|
187 | 188 | west_sign_with_imgtool( |
188 | | - build_dir=Path(dut.device_config.build_dir) / PROJECT_NAME, |
| 189 | + build_dir=Path(dut.device_config.app_build_dir), |
189 | 190 | output_bin=image_to_test, |
190 | 191 | key_file=key_file, |
191 | 192 | version='0.0.3+4' # must differ from the origin version, if not then hash is not updated |
|
0 commit comments