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

Compatibility with gpiod 2.x #50

Merged
merged 9 commits into from
Dec 21, 2023
Merged

Compatibility with gpiod 2.x #50

merged 9 commits into from
Dec 21, 2023

Conversation

puddly
Copy link
Collaborator

@puddly puddly commented Nov 30, 2023

Resetting the GPIO pin state after releasing the line is now apparently deprecated, as the new kernel API reverts the pins to an unknown "default" state after the last line request is released.

@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2023

Codecov Report

Attention: 27 lines in your changes are missing coverage. Please review.

Comparison is base (44754ed) 60.76% compared to head (bc347fd) 60.71%.

Files Patch % Lines
universal_silabs_flasher/gpio.py 23.52% 26 Missing ⚠️
universal_silabs_flasher/common.py 80.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #50      +/-   ##
==========================================
- Coverage   60.76%   60.71%   -0.05%     
==========================================
  Files          13       14       +1     
  Lines        1631     1642      +11     
==========================================
+ Hits          991      997       +6     
- Misses        640      645       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@darkxst
Copy link
Contributor

darkxst commented Dec 20, 2023

as the new kernel API reverts the pins to an unknown "default" state after the last line request is released.

I not so sure this is the case, I seem to get stuck in bootloader with this as is.

python -m universal_silabs_flasher --device /dev/ttyS4 --bootloader-reset ihost probe
2023-12-20 23:43:40 a0d7b954-ssh universal_silabs_flasher.flasher[658] INFO Triggering ihost bootloader
2023-12-20 23:43:40 a0d7b954-ssh universal_silabs_flasher.flasher[658] INFO Probing ApplicationType.GECKO_BOOTLOADER at 115200 baud
2023-12-20 23:43:40 a0d7b954-ssh universal_silabs_flasher.flasher[658] WARNING No application can be launched
2023-12-20 23:43:40 a0d7b954-ssh universal_silabs_flasher.flasher[658] INFO Detected bootloader version '1.A.3' (1.3)
2023-12-20 23:43:40 a0d7b954-ssh universal_silabs_flasher.flasher[658] INFO Detected ApplicationType.GECKO_BOOTLOADER, version '1.A.3' (1.3) at 115200 baudrate (bootloader baudrate 115200)

Adding a 4th pin state to reset both GPIO lines to True fixes it though.

@puddly
Copy link
Collaborator Author

puddly commented Dec 20, 2023

gpiod 2.x is posing a really annoying problem right now that I'm unsure of how to solve:

  1. It not providing binary wheels means that the flasher can't be pip installed unless you have a full build environment set up.
  2. We can pin gpiod<2, but Home Assistant OS already includes a wheel for gpiod 2. This would cause a dependency conflict.
  3. We can't migrate to setup.py to dynamically compute dependencies (i.e. support both versions but install the pure-Python one if none is available) because Pyodide only works with wheels!

Possible solutions:

  1. Support both versions and have the default package depend on gpiod < 2 but also provide universal-silabs-flasher[gpiod2]. Problem: I don't think you can override dependencies in pyproject.toml like this using optional dependencies.
  2. Manually distribute wheels with the web flasher so that we can downgrade back to setup.py. This may be difficult to accomplish but I think it's possible to make the web flasher entirely self-contained, without it actually downloading any packages from the internet.
  3. Support both versions of gpiod in the package but depend explicitly on gpiod < 2 in this package. It may be possible to have Home Assistant ignore the dependency conflict.

@puddly
Copy link
Collaborator Author

puddly commented Dec 20, 2023

I'm pinning gpiod==1.5.4 for now to ensure installation always works but breaking out GPIO communication to a separate module, to ensure compatibility with both versions of gpiod.

@puddly puddly changed the title Migrate to gpiod 2.x Compatibility with gpiod 2.x Dec 20, 2023
@darkxst
Copy link
Contributor

darkxst commented Dec 21, 2023

  • Support both versions and have the default package depend on gpiod < 2 but also provide universal-silabs-flasher[gpiod2]. Problem: I don't think you can override dependencies in pyproject.toml like this using optional dependencies.

This would probably only work in reverse to downgrade the dep i.e. universal-silabls-flasher[gpiod1]. Which is not particularly user friendly!

@puddly puddly merged commit 68e1448 into NabuCasa:dev Dec 21, 2023
4 checks passed
@puddly puddly mentioned this pull request Dec 22, 2023
robarnold referenced this pull request in marinatedconcrete/config Jan 4, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[universal-silabs-flasher](https://togithub.com/NabuCasa/universal-silabs-flasher)
| `==0.0.15` -> `==0.0.16` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/universal-silabs-flasher/0.0.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/universal-silabs-flasher/0.0.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/universal-silabs-flasher/0.0.15/0.0.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/universal-silabs-flasher/0.0.15/0.0.16?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>NabuCasa/universal-silabs-flasher
(universal-silabs-flasher)</summary>

###
[`v0.0.16`](https://togithub.com/NabuCasa/universal-silabs-flasher/releases/tag/v0.0.16)

[Compare
Source](https://togithub.com/NabuCasa/universal-silabs-flasher/compare/v0.0.15...v0.0.16)

#### What's Changed

- Compatibility with gpiod 2.x by
[@&#8203;puddly](https://togithub.com/puddly) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/50](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/50)
- Migrate to zigpy CI and pre-commit hooks by
[@&#8203;puddly](https://togithub.com/puddly) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/53](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/53)
- Bootloader reset improvements by
[@&#8203;darkxst](https://togithub.com/darkxst) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/51](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/51)
- Disconnect stream writer without closing the transport by
[@&#8203;puddly](https://togithub.com/puddly) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/58](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/58)
- EBL parsing by [@&#8203;puddly](https://togithub.com/puddly) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/11](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/11)
- Update README.md with bootloader reset option by
[@&#8203;darkxst](https://togithub.com/darkxst) in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/54](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/54)
- Run `isort` to fix CI by [@&#8203;puddly](https://togithub.com/puddly)
in
[https://github.com/NabuCasa/universal-silabs-flasher/pull/59](https://togithub.com/NabuCasa/universal-silabs-flasher/pull/59)

**Full Changelog**:
NabuCasa/universal-silabs-flasher@v0.0.15...v0.0.16

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/marinatedconcrete/config).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants