Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(heater-shaker): add firmware upload capability #10307

Merged
merged 19 commits into from
Jul 27, 2022
Merged

Conversation

pmoegenburg
Copy link
Member

@pmoegenburg pmoegenburg commented May 17, 2022

Updated upload_via_dfu method, which uses the dfu-util tool.

Closes #9634

@pmoegenburg pmoegenburg self-assigned this May 17, 2022
@pmoegenburg pmoegenburg requested a review from a team as a code owner May 17, 2022 00:02
@codecov
Copy link

codecov bot commented May 17, 2022

Codecov Report

Merging #10307 (fb7057d) into edge (c4584b3) will increase coverage by 1.10%.
The diff coverage is 34.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #10307      +/-   ##
==========================================
+ Coverage   73.64%   74.74%   +1.10%     
==========================================
  Files        2085     2052      -33     
  Lines       57605    55304    -2301     
  Branches     5741     5728      -13     
==========================================
- Hits        42421    41338    -1083     
+ Misses      13946    12728    -1218     
  Partials     1238     1238              
Flag Coverage Δ
hardware-testing ?
notify-server 89.17% <ø> (ø)
ot3-gravimetric-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/src/opentrons/drivers/heater_shaker/driver.py 93.15% <ø> (ø)
.../src/opentrons/hardware_control/modules/mod_abc.py 81.73% <ø> (ø)
...i/src/opentrons/hardware_control/modules/update.py 28.78% <19.04%> (ø)
...drivers/asyncio/communication/serial_connection.py 96.92% <100.00%> (ø)
...pentrons/hardware_control/modules/heater_shaker.py 80.56% <100.00%> (ø)
...rdware/opentrons_hardware/drivers/can_bus/build.py 62.50% <0.00%> (-23.22%) ⬇️
shared-data/js/helpers/index.ts 56.89% <0.00%> (-19.69%) ⬇️
hardware/opentrons_hardware/sensors/mmr920C04.py 83.33% <0.00%> (-7.58%) ⬇️
...pentrons_hardware/drivers/can_bus/can_messenger.py 86.58% <0.00%> (-3.07%) ⬇️
update-server/otupdate/buildroot/__init__.py 86.84% <0.00%> (-2.05%) ⬇️
... and 96 more

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Couple things I think we should change, but nice!

api/src/opentrons/hardware_control/modules/update.py Outdated Show resolved Hide resolved
api/src/opentrons/hardware_control/modules/update.py Outdated Show resolved Hide resolved
api/src/opentrons/hardware_control/modules/update.py Outdated Show resolved Hide resolved
api/src/opentrons/hardware_control/modules/update.py Outdated Show resolved Hide resolved
@pmoegenburg pmoegenburg requested a review from sfoster1 May 17, 2022 21:17
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@laviera laviera added the heater-shaker heater shaker software support label Jun 10, 2022
@sanni-t
Copy link
Member

sanni-t commented Jul 12, 2022

Adding info for testing:

  1. Grab the latest ot2_system build file and upload it to the robot.
  2. Push this branch to the robot
  3. Download the latest firmware zip, extract files. Rename the .bin file to [email protected] (or whatever the latest version is) and scp it onto the robot's /usr/lib/firmware/ directory.
  4. Restart the robot-server
  5. With the heater-shaker connected to the robot, open the app and go to devices->your robot -> pipettes & modules. The heater-shaker entry should say 'firmware update available'. Click on it!
    The update should complete within a minute.

@@ -442,7 +442,10 @@ async def close_labware_latch(self) -> None:
await self._wait_for_labware_latch(HeaterShakerLabwareLatchStatus.IDLE_CLOSED)

async def prep_for_update(self) -> str:
return "no"
await self._poller.stop_and_wait() # Check if this is really needed
Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's a good idea to stop sending get_temp/rpm/latch_status messages (via poller) before sending the dfu gcode

Copy link
Member

Choose a reason for hiding this comment

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

Oh absolutely. I just meant that it might not be required because the poller might be implicitly getting stopped because of the module connection closing. But we need to check that definitely happens in order to remove this.

stdout, stderr = await proc.communicate()

if stdout is None and stderr is None:
# This probably needs to be refactored into just a check for empty stdout
Copy link
Member Author

Choose a reason for hiding this comment

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

shouldn't we check for stderr?

Copy link
Member

Choose a reason for hiding this comment

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

You're right. We want to retry only if there is no output and no error.
I don't remember why I wanted to refactor this so we can tag that comment for removal if we don't run into any problems during testing.

# which dfu device to upload firmware to, then we can specify the device serial
# (or the vid:pid) in the command. This will take care of the super rare case where
# a robot has two stm32 devices plugged in and a user initiates firmware upload for
# both of them in quick succession. It's a rare case but has happened before.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the device serial will change after entering bootloader, making it difficult to check for a specific module. I added a check for multiple bootloader devices (1 module lists 2 devices, so check is for greater than 2 devices). Since find_dfu_device checks only for devices in the bootloader state, shouldn't it be rare (or can we make it impossible) for multiple modules to update firmware concurrently?

Copy link
Member

Choose a reason for hiding this comment

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

definitely a "make it impossible" sort of thing, yeah. could put a lock in the module manager

Copy link
Member

Choose a reason for hiding this comment

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

@pmoegenburg yes, it's rare, but has happened before where an update was initiated on both temp and mag modules in quick succession and that resulted in the mag module getting the temp module's firmware and vice versa. It happened because they both had the same bootloader identity.

@sfoster1 will the lock prevent the firmware from going to the wrong module's bootloader? Or will Peter's check for 2+ DFUs alongwith the lock make it impossible for two modules to switch to the bootloader at the same time?

Copy link

Choose a reason for hiding this comment

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

@pmoegenburg @sfoster1 - The need to close out firmware update for our internal testing (and production build 7/25) is imminent. Do we know when this will be complete ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sfoster1 what would that lock look like?

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Awesome, looks great to me if it works!

Copy link
Member

@sanni-t sanni-t left a comment

Choose a reason for hiding this comment

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

Tested and it works!
We should still add unit tests for send_dfu_command but I'm fine leaving a TODO for it and adding it later so we can start using the upload feature. Another todo would be to test if the upload lock works by trying to update two heater-shakers at once.

PR is good to merge once my outdated inline comments are removed! (Let me know if you want me to remove them)

@pmoegenburg pmoegenburg merged commit a77b08d into edge Jul 27, 2022
@pmoegenburg pmoegenburg deleted the HS_upload_via_dfu branch August 3, 2022 19:34
@pmoegenburg pmoegenburg restored the HS_upload_via_dfu branch August 3, 2022 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
heater-shaker heater shaker software support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

heater-shaker: add firmware upload capability
4 participants