Skip to content

Commit

Permalink
fix(jetson-cboot): save firmware version file to standby slot (#303)
Browse files Browse the repository at this point in the history
This PR fixes jetson-cboot post-update that not saving firmware version file to standby slot. This might result in firmware version control not working as expected as standby slot's firmware version file is missing after every OTA.
  • Loading branch information
Bodong-Yang authored May 15, 2024
1 parent 406f587 commit 3c5fea7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions otaclient/app/boot_control/_jetson_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _nv_firmware_update(self) -> Optional[bool]:
new_bsp_v = parse_bsp_version(_new_bsp_v_fpath.read_text())
except Exception as e:
logger.warning(f"failed to detect new image's BSP version: {e!r}")
logger.info("skip firmware update due to new image BSP version unknown")
logger.warning("skip firmware update due to new image BSP version unknown")
return

logger.info(f"BUP package version: {new_bsp_v=}")
Expand Down Expand Up @@ -481,7 +481,6 @@ def _nv_firmware_update(self) -> Optional[bool]:
standby_bootloader_slot, new_bsp_v
)
return True
logger.info("no firmware payload BUP available, skip firmware update")

# APIs

Expand Down Expand Up @@ -529,14 +528,17 @@ def post_update(self) -> Generator[None, None, None]:
)

# ------ firmware update ------ #
_fw_update_result = self._nv_firmware_update()
if _fw_update_result:
# update the firmware_bsp_version file on firmware update applied
self._firmware_ver_control.write_standby_firmware_bsp_version()
firmware_update_result = self._nv_firmware_update()
if firmware_update_result:
self._firmware_ver_control.write_current_firmware_bsp_version()
elif _fw_update_result is not None:
elif firmware_update_result is None:
logger.info("no firmware update occurs")
else:
raise JetsonCBootContrlError("firmware update failed")

# ------ preserve BSP version files to standby slot ------ #
self._firmware_ver_control.write_standby_firmware_bsp_version()

# ------ preserve /boot/ota folder to standby rootfs ------ #
preserve_ota_config_files_to_standby(
active_slot_ota_dirpath=self._mp_control.active_slot_mount_point
Expand All @@ -548,6 +550,7 @@ def post_update(self) -> Generator[None, None, None]:
)

# ------ for external rootfs, preserve /boot folder to internal ------ #
# NOTE: the copy must happen AFTER all the changes to active slot's /boot done.
if self._cboot_control._external_rootfs:
logger.info(
"rootfs on external storage enabled: "
Expand Down

1 comment on commit 3c5fea7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py50100% 
__main__.py110%16
_utils
   __init__.py31583%69–71, 86, 88
   linux.py471176%45–47, 53, 63, 68, 70, 102–103, 127–128
   logging.py291451%41–44, 49–52, 54–55, 57–58, 62–63
   typing.py150100% 
app
   __main__.py110%16
   common.py3843989%65, 145, 251, 254–256, 271, 278–280, 346–348, 358, 367–369, 475, 487, 606, 610, 698, 700, 732–734, 736, 762–765, 770, 774–778, 804–805
   configs.py750100% 
   downloader.py2634483%70, 83–84, 299, 304, 308, 326–327, 377–381, 400–402, 405–406, 409–410, 431–434, 438–439, 443–444, 448–449, 458, 533–535, 551, 571–573, 577, 579, 582, 587–589
   errors.py1130100% 
   interface.py50100% 
   log_setting.py53590%54, 56, 65–67
   main.py29293%44–45
   ota_client.py39814563%60–61, 81, 187–188, 201, 204, 208, 211, 248–251, 263–266, 269–270, 274–279, 289–292, 297–298, 300, 309, 312, 315, 317–318, 320–327, 330, 332, 335, 377–380, 385, 389, 392, 405–408, 411–418, 421–428, 434–437, 466, 469–470, 472, 475–478, 480–481, 486–487, 490, 504–511, 518, 521–527, 574–577, 585, 621, 626–629, 634–636, 639–640, 642–643, 645–646, 648, 708–709, 712, 720–721, 724, 735–736, 739, 747–748, 751, 762, 781, 808, 827, 845
   ota_client_call.py38684%42–44, 80–82
   ota_client_service.py27388%55–57
   ota_client_stub.py39410972%76–78, 80–81, 89–92, 95–97, 101, 106–107, 109–110, 113, 115–116, 119–121, 124–125, 128–130, 135–140, 144, 147–151, 153–154, 162–164, 167, 204–206, 211, 247, 272, 275, 278, 382, 406, 408, 432, 478, 535, 605–606, 645, 664–666, 672–675, 679–681, 688–690, 693, 697–700, 753, 840–842, 849, 879–880, 883–887, 896–905, 912, 918, 921–922, 926, 929
   ota_metadata.py3153289%143, 148, 184–185, 195–196, 199, 211, 269, 279–282, 321–324, 404, 407, 415–417, 430, 439–440, 443–444, 717–718, 721, 725, 728
   ota_status.py14285%34, 42
   update_stats.py105298%159, 169
app/boot_control
   __init__.py40100% 
   _common.py2347667%73–74, 95–97, 113–114, 134–135, 154–155, 174–175, 194–195, 210–211, 232, 240, 258, 266, 285–286, 289–290, 313, 315–324, 326–335, 337–339, 358, 361, 369, 377, 393–395, 397–402, 495, 500, 505, 618, 622–623, 626, 634, 636–637, 711–712, 722, 740
   _grub.py41812869%216, 264–267, 273–277, 314–315, 322–327, 330–336, 339, 342–343, 348, 350–352, 361–367, 369–370, 372–374, 383–385, 387–389, 468–469, 473–474, 526, 532, 558, 580, 584–585, 600–602, 626–629, 641, 645–647, 649–651, 710–713, 738–741, 764–767, 779–780, 783–784, 819, 825, 845–846, 848, 860, 863, 866, 869, 873–875, 893–896, 924–927, 932–940, 945–953
   _jetson_cboot.py27121421%66–67, 74–75, 93–102, 114, 121–122, 134, 140–141, 151–153, 165–166, 177–178, 181–182, 185–186, 189–193, 196–197, 201–202, 207–208, 210–214, 216–222, 224–225, 230, 233, 236–237, 240, 244–245, 249–250, 254, 257, 260, 264–270, 272–274, 279, 282, 285, 289, 296, 298–301, 314, 317, 321, 323–325, 329, 336, 338, 341, 347–348, 353, 361, 369–371, 380–381, 383–385, 391, 394–396, 400–401, 403, 406, 415–417, 420, 423, 426–431, 433–435, 438, 441, 445–450, 454–456, 461–462, 466–467, 470, 473, 476–477, 480, 483, 488, 491, 494–495, 497, 499, 502, 505, 507–508, 511–515, 520–521, 523, 531–535, 537, 540, 543, 554–555, 560, 570, 573–581, 586–594, 599–607, 613–615, 618, 621
   _jetson_common.py1436653%52, 76, 131–136, 138, 143–145, 150–153, 161–162, 169–170, 175–176, 192–193, 195–197, 200–202, 205, 209, 213, 217–219, 225–226, 228, 261, 287–288, 290–292, 296–299, 301–302, 304–308, 310, 317–318, 321, 323, 333, 336–337, 340, 342
   _rpi_boot.py25912252%84–86, 92–93, 95–97, 99, 102–103, 108–109, 118–119, 123, 125, 129, 133–136, 141–143, 147–150, 174–176, 182–184, 197–199, 205–207, 220–227, 229, 233–235, 238–241, 244–245, 250, 254, 258, 262, 296, 323–325, 335–338, 342–348, 388–390, 432–436, 455–458, 463, 466, 490–493, 498–506, 511–519, 533–536, 542–544, 547
   configs.py460100% 
   protocol.py40100% 
   selecter.py382631%44–46, 49–50, 54–55, 58–60, 63, 65, 69, 77–79, 81–82, 84–85, 89, 91–93, 95, 97
app/create_standby
   __init__.py12558%28–30, 32, 34
   common.py2164380%61, 64–65, 69–71, 73, 77–78, 80, 126, 174–176, 178–180, 182, 185–188, 192, 203, 275–276, 278–283, 295, 339, 342–344, 360–361, 375, 379, 402–403
   interface.py60100% 
   rebuild_mode.py89198%103
app/proto
   __init__.py31390%37, 44–45
   _common.py3994588%87, 165, 172, 184–186, 205, 210, 221, 257, 263, 268, 299, 303, 307, 402, 462, 469, 472, 492, 499, 501, 526, 532, 535, 537, 562, 568, 571, 573, 605, 609, 611, 625, 642, 669, 672, 676, 707, 713, 760–763, 765
   _ota_metafiles_wrapper.py841384%38, 41–43, 113–117, 123–126
   _otaclient_v2_pb2_wrapper.py2612391%86, 89–92, 131, 209–210, 212, 259, 262–263, 506–508, 512–513, 515, 518–519, 522–523, 586
   streamer.py43881%33, 48, 66–67, 72, 81–82, 100
   wrapper.py40100% 
configs
   __init__.py10100% 
   _common.py80100% 
   ecu_info.py58198%107
   proxy_info.py53296%88, 90
ota_proxy
   __init__.py31680%59, 61, 63, 72, 81–82
   __main__.py770%16–18, 20, 22–23, 25
   _consts.py150100% 
   cache_control.py68494%71, 91, 113, 121
   config.py180100% 
   db.py1461589%75, 81, 103, 113, 116, 145–147, 166, 199, 208–209, 229, 258, 300
   errors.py50100% 
   orm.py1121091%92, 97, 102, 108, 114, 141–142, 155, 232, 236
   ota_cache.py4018678%98–99, 218, 229, 256–258, 278, 294–295, 297, 320–321, 327, 331, 333, 360–362, 378, 439–440, 482–483, 553, 566–569, 619, 638–639, 671–672, 683, 717–721, 725–727, 729, 731–738, 740–742, 745–746, 750–751, 755, 802, 810–812, 891–894, 898, 901–902, 916–917, 919–921, 925–926, 932–933, 964, 970, 997, 1026–1028
   server_app.py1383971%76, 79, 85, 101, 103, 162, 171, 213–214, 216–218, 221, 226–228, 231–232, 235, 238, 241, 244, 257–258, 261–262, 264, 267, 293–296, 299, 313–315, 321–323
   utils.py23195%33
TOTAL5988136577% 

Tests Skipped Failures Errors Time
179 0 💤 0 ❌ 0 🔥 4m 55s ⏱️

Please sign in to comment.