Skip to content

Update STM DFU mode software implementation. #6961

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

Merged
merged 2 commits into from
Sep 29, 2022

Conversation

flom84
Copy link

@flom84 flom84 commented Sep 29, 2022

Hello,

I found a couple of issues with my first implementation of the STM DFU mode #6919

  1. the size of the interrupt clear array was not computed correctly
  2. the recommendation to disable interrupts using NVIC from ARM (nested vector interrupt controller) was not followed

I retested with my STM32 Nucleo-F446RE board, attached picture bellow:

image

 - fix for sizeof array calculation.

 - follow ARM recommendation to turn off interruptions with NVIC.
jepler
jepler previously approved these changes Sep 29, 2022
Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Thanks! One note, if you want to change it before I merge this PR, you could consider use of MP_ARRAY_SIZE. If not, can merge as-is too.


// Clear all pending interrupts
for (uint8_t i = 0; i < (sizeof(NVIC->ICPR) / NVIC->ICPR[0]); ++i) {
Copy link

Choose a reason for hiding this comment

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

I looked at this many times before I spotted the problem.

In CircuitPython, you can use MP_ARRAY_SIZE(arr) (in py/misc.h) to compute the size of the array. Note that if the expression arr is actually a pointer instead, it will NOT be detected as an error. (the implementation is just sizeof(arr) / sizeof(arr[0]), more or less)

Copy link
Author

Choose a reason for hiding this comment

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

@jepler did the changes. Testing now.

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Thanks again!

@jepler jepler merged commit 6637260 into adafruit:main Sep 29, 2022
@flom84
Copy link
Author

flom84 commented Sep 29, 2022

@jepler thank you !

@flom84 flom84 deleted the stm32f4-dfu-mode-fixes branch October 1, 2022 08:32
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.

2 participants