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

Legacy Maple DFU boot loader support #525

Merged
merged 2 commits into from
May 29, 2019
Merged

Conversation

fpistm
Copy link
Member

@fpistm fpistm commented May 17, 2019

This PR enable only the Legacy Maple DFU boot loader support, STM32 HID bootloader from @Serasidis will come in an other PR. We currently discuss/work on it.

Should supersede #415

From @BennehBoy (#415)

This PR enables the use of the STM32 HID Bootloader 2.1 for Generic F103 & Generic F4 variants

Tested on Bluepill, Blackpill (using BP menu option), & Black407VET6.

Limitations:

* boards.txt glue probably needs to be a bit more elegant --> done in #525

* F1 boards must use the latest 2K HID bootloader -> https://github.com/Serasidis/STM32_HID_Bootloader  (hid_flash tool will warn if an older version is installed)

Usage:

First apply this PR to your STM32 tools -> stm32duino/Arduino_Tools#33. --> replaced by stm32duino/Arduino_Tools#35

HID:
Select your variant in the boards menu
Set the upload method to "HID Bootloader 3.0 (0x0800)" for F1 or "HID Bootloader 3.0 (0x4000)" for F4
Ensure that "USB Interface (if available):" is set to "CDC Full Speed" (required for DTR toggling)

DFU:
The PR applies the magic word & byte code recognition to USB_CDC_IF.cpp which also enables STM32Duino Bootloader 2.0 to work. Also included is DISC pin handling for Maple Mini. This is the same logic used in Roger Clarke's core and in STM32GENERIC
Select your variant in the boards menu
Set the upload method to "Maple DFU Bootloader 2.0" or "Maple DFU Bootloader original" depending on the BL installed.
Ensure that "USB support (if available):" is set to either CDC option (required for DTR toggling)

Require stm32duino/Arduino_Tools#35

DFU bootloader 2.0 tested under windows and linux.

Any help to test are welcome.

Cc @BennehBoy , @Serasidis

Fix #411

@fpistm fpistm self-assigned this May 17, 2019
@fpistm fpistm added enhancement New feature or request help wanted 🙏 Extra attention is needed New feature on going Currently work on this waiting feedback Further information is required labels May 17, 2019
@fpistm fpistm added this to the 1.6.0 milestone May 17, 2019
variants/FK407M1/ldscript.ld Outdated Show resolved Hide resolved
variants/FK407M1/ldscript.ld Outdated Show resolved Hide resolved
variants/FK407M1/ldscript.ld Outdated Show resolved Hide resolved
variants/FK407M1/ldscript.ld Outdated Show resolved Hide resolved
variants/FK407M1/ldscript.ld Outdated Show resolved Hide resolved
@BennehBoy
Copy link
Contributor

@fpistm what should I do with the other PR? Don't want to delete mine if it will remove the entire thread, I guess it may be useful historically?

@fpistm
Copy link
Member Author

fpistm commented May 20, 2019

It will be only closed. History will be kept.

@BennehBoy
Copy link
Contributor

BennehBoy commented May 20, 2019

Just tested against Maple Mini clone, and the same forced hardware reset requirement persists that I was attempting to track down with no luck... ie, upload works fine but the board does not do it's eventual toggle back to the newly flashed code - not sure if this is disc pin or what. (tested BL 2.0 on Blackpill and the board recycles fine). This on Windows 10

I'll attempt some HID loads on blue/blackpill next.

@BennehBoy
Copy link
Contributor

HID tested and working with BlackPill 👍

@BennehBoy
Copy link
Contributor

OK, so I just deleted a previous post - I couldn't get the maple mini behaviour to repeat so had thought it was due to the previously flashed CDC handling being overwritten on first reflash.... 5 flashes in a row with no issue. Then it started again, so it looks like there's potentially something iffy in the disc pin handling OR these clones don't like the code (this issue first arose when you refactored the disc pin handling btw, the very crude code I had included seemed to work without issue but was admittedly v ugly).

@Serasidis
Copy link
Contributor

Serasidis commented May 20, 2019

A few days ago I started working on adapting HID Bootloader (HID-BL) to the Official STM Core. I know @BennehBoy is working on it, but I have not seen the source code (any link is welcome).
So, I started from scratch adding HID-BL to this Core.

There is a new feature in the Arduino-IDE 1.8.9 Pluggable Discovery I'm working on.
This feature adds an extra Port menu that includes HIDs in addition to the available serial ports.
This is very useful if someone wants to restart the STM32 on the bootloader, but the built-in USB is configured as a HID device or any other USB device such as MIDI.

@fpistm
Copy link
Member Author

fpistm commented May 20, 2019

@BennehBoy, unfortunately, I didn't see this behavior.

@Serasidis , I saw that on your forum. Seems promising. Do not hesitate to share and ask support.
Also any feedback on this PR is welcome about HID BL support ;)

@BennehBoy
Copy link
Contributor

@Serasidis I'm not really doing anything with this at the moment, the dtr/magic word handling code was a direct copy of your STM32GENERIC code. Feel free to augment in whatever way. I didn't make any changes to the bootloader code itself at all.

@neilbalch
Copy link

I would love to help test this, but I use PlatformIO. I'm not exactly sure how to merge this PR with the tools already implemented there. Does anyone here know how that would work? I could always ask around in the PlatformIO community if the answer is no.

@BennehBoy
Copy link
Contributor

Can't help you there, I've avoided PlatformIO because the tool config just seems so obfuscated.

@fpistm
Copy link
Member Author

fpistm commented May 20, 2019

@neilbalch unfortunately no.

Enabled thanks: DTR_TOGGLING_SEQ
User can redefine its own hook by redefining:
dtr_togglingHook(uint8_t *buf, uint32_t *len)

Signed-off-by: BennehBoy <bennyboy@benneh.net>
@fpistm fpistm changed the title HID/DFU boot loader support Legacy Maple DFU boot loader support May 29, 2019
Co-authored-by: BennehBoy <bennyboy@benneh.net>
Co-authored-by: Vassilis Serasidis <avrsite@yahoo.gr>
Co-authored-by: Frederic.Pillon <frederic.pillon@st.com>
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
@fpistm fpistm removed on going Currently work on this waiting feedback Further information is required labels May 29, 2019
@fpistm fpistm merged commit 2cfddac into stm32duino:master May 29, 2019
@fpistm fpistm deleted the HID_bootloader branch May 29, 2019 13:50
@neilbalch
Copy link

👍 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted 🙏 Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enabling Bootloaders
4 participants