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

[Enhancement] Soft-DFU upload protocol tested to work on STM32F072B-DISCO #1175

Conversation

ekawahyu
Copy link

@ekawahyu ekawahyu commented Sep 15, 2020

The current built-in STM32 DFU upload requires user to pull BOOT0 pin to 3.3V and perform system reset. With this enhancement, users do not require to press reset button nor pulling BOOT0 pin to 3.3V to upload new binary. The protocol is based on reading magic number over USBCDC (same magic number as Maple board '1EAF') and then it jumps to built-in DFU mode and ready to accept binary from there.

This enhancement has been tested to work on STM32F072B Discovery board with softdfu_upload from here:

https://github.com/SnapBloks/Arduino_Tools/tree/feature/softdfu_upload

Uploading with Soft-DFU on STM32F072B-DISCO requires dependency of upload tool from here:

stm32duino/Arduino_Tools#69

Please review and comment. Thank you.

…lling BOOT0 to 3.3V nor pressing RESET button
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

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

Thanks for this PR anyway this is not enough generic and bring some conflict in the menu.

@fpistm fpistm added this to In progress in STM32 core based on ST HAL via automation Sep 15, 2020
@ekawahyu
Copy link
Author

@fpistm I think we can keep the variant.cpp as it were by moving all of those changes out as a new file, somewhere not in each variant folders. And then all 3 macro definitions are defined as compiler flags in boards.txt

The second option, we may be able to merge the code, like with bootloader.c maybe? SInce it uses the same magic word 1EAF

The last thing about the startup code, it is basically the exact same copy from CMSIS, but I added one liner in there: bl __initialize_hardware_early(). I don't know what would be the best thing to do to make it generic, maybe a simple patch will do? I need to dig deep about how I got this one liner added in the past. I thought it was the STM32CubeMX that generated this one liner.

@fpistm
Copy link
Member

fpistm commented Sep 15, 2020

Honestly, modifying only one variant for this stuff is not the proper way.
From my point of view your change is more a user customization and should be used like this:
https://github.com/stm32duino/wiki/wiki/Custom-board-based-on-a-core

I will soon works on this PR: #710 which I guess is more generic to achieve the same goal.

@fpistm
Copy link
Member

fpistm commented Sep 15, 2020

Just a quick though, as it seems __initialize_hardware_early doesn't exists anymore (as I can see it was available on old SPL drivers) maybe it can simply check at the beginning of SystemInit?

@ekawahyu
Copy link
Author

ekawahyu commented Sep 15, 2020

Just a quick though, as it seems __initialize_hardware_early doesn't exists anymore (as I can see it was available on old SPL drivers) maybe it can simply check at the beginning of SystemInit?

It is not gonna work, because dfu_reset_to_bootloader_magic variable will get initialized when we do it in SystemInit (or maybe not? I have to try this)

EDIT: confirmed that it does not work when I put it at the beginning of SystemInit()

@ekawahyu
Copy link
Author

ekawahyu commented Sep 15, 2020

Honestly, modifying only one variant for this stuff is not the proper way.
From my point of view your change is more a user customization and should be used like this:
https://github.com/stm32duino/wiki/wiki/Custom-board-based-on-a-core

I will soon works on this PR: #710 which I guess is more generic to achieve the same goal.

I have SnapBloks specific variants that use F072C8T6, and those will reside in Arduino/hardware as customized boards. This pull request, however, is an enhancement on STM32F072B-DISCOVERY. If you guys can implement this somehow and become mainline, then the rest of Discovery kits may get the same benefit of Soft-DFU upload protocol. I can help to work on the rest of Discovery kits out there. But you are right, it needs to be generic. First thing we need to figure out, is how we can replace __initialize_hardware_early in there. Because this has dependency on older SPL.

The startup codes do not change at all, and look the same from when I compared it to my old work with HALMX. In the old HALMX startups, there are additional two liners that allows user to insert C code very early and right before SystemInit():

  • __initialize_hardware_early()
  • __initialize_hardware()

Not sure if it is a good idea to bring it back. There must be a good reason of removing these in the past. But in order to jump into any built-in bootloader, bl __initialize_hardware_early is required in there.

@fpistm fpistm added this to Needs review in STM32duino libraries Jun 16, 2021
@fpistm fpistm marked this pull request as draft November 18, 2021 09:24
@fpistm fpistm added enhancement New feature or request abandoned No more work on this and removed New feature labels Jul 16, 2024
@fpistm fpistm closed this Jul 18, 2024
STM32duino libraries automation moved this from Needs review to Done Jul 18, 2024
STM32 core based on ST HAL automation moved this from In progress to Done Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned No more work on this enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

2 participants