8000 bootloader: BTN_BOOTLOADER_INVERTED doesn't work as expected. · Issue #19364 · RIOT-OS/RIOT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bootloader: BTN_BOOTLOADER_INVERTED doesn't work as expected. #19364

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

Closed
dylad opened this issue Mar 7, 2023 · 0 comments · Fixed by #19365
Closed

bootloader: BTN_BOOTLOADER_INVERTED doesn't work as expected. #19364

dylad opened this issue Mar 7, 2023 · 0 comments · Fixed by #19365
Labels
Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@dylad
Copy link
Member
dylad commented Mar 7, 2023

Description

The logic to define the value of BTN_BOOTLOADER_INVERTED doesn't work as expected.
This lead to issue in bootloader/riotboot_dfu and bootloader/riotboot_tinyusb_dfu.
For instance, on my SAML21-XPRO, I can successfully flash any application using dfu-util after flashing bootloader/riotboot_dfu

Steps to reproduce the issue

Flash the riotboot_dfu bootloader:
make BOARD=saml21-xpro -C bootloaders/riotboot_dfu flash
Then, flash any test app:
PROGRAMMER=dfu-util USEMODULE=usbus_dfu make BOARD=saml21-xpro -C tests/shell riotboot/flash-slot0

Expected results

Application should start after flashing.

Actual results

Flash succeed, but application doesn't start.
a quick look at lsusb shows that we're stuck in the bootloader (with VID/PID: 1209:7d02)

I'll provide a PR to fix that right away.

@dylad dylad added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Mar 7, 2023
bors bot added a commit that referenced this issue Mar 8, 2023
19365: bootloaders: fix bootloader button logic r=benpicco a=dylad

### Contribution description

In lastest master, the `BTN_BOOTLOADER_INVERTED` logic doesn't work as expected.
This PR fixes the underlying logic by replacing the `BTN_BOOTLOADER_INVERTED` macro definition by a runtime function.
In fact the current code:
```
#ifndef BTN_BOOTLOADER_INVERTED
#if (BTN0_MODE == GPIO_IN_PD)
#define BTN_BOOTLOADER_INVERTED false
#else
#define BTN_BOOTLOADER_INVERTED true
#endif
#endif
```
cannot work because both `BTN0_MODE` and `GPIO_IN_PD` are not known by the precompiler as they are enum values defined at cpu level.
Thus, replaces it by a runtime function in our bootloader applications.
I've also add `GPIO_OD_PU` along side `GPIO_IN_PU` and add a new define (which can be override at board level or app level) in case an external pullup is used.

### Testing procedure
Flash the riotboot_dfu bootloader:
`make BOARD=saml21-xpro -C bootloaders/riotboot_dfu flash`
Then, flash any test app:
`PROGRAMMER=dfu-util USEMODULE=usbus_dfu make BOARD=saml21-xpro -C tests/shell riotboot/flash-slot0`

With master, the application will not start.
With this PR, the application will start after flashing.

### Issues/PRs references
Fixes #19364 


Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
@bors bors bot closed this as completed in 1a5cc2a Mar 8, 2023
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0