Skip to content

STM32F4 DFU Mbed 6 #14320

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
tartavull opened this issue Feb 22, 2021 · 14 comments
Closed

STM32F4 DFU Mbed 6 #14320

tartavull opened this issue Feb 22, 2021 · 14 comments

Comments

@tartavull
Copy link

My application requires flashing the firmware without pressing any buttons on the device. Therefore, I would like to be able to enter DFU mode from the application.

I'm using the code suggested in #8523 (comment)

main.c

#include "mbed.h"
extern "C" void enter_dfu();

int main() {
    DigitalOut usb_dp_pin(USB_OTG_FS_DP, 1) ;
    usb_dp_pin=0;

    enter_dfu();
}

bootloader.S

    AREA asm_func, CODE, READONLY
    EXPORT enter_dfu
enter_dfu
    LDR     R0, =0x40023844 ; RCC_APB2ENR
    LDR     R1, =0x00004000 ; ENABLE SYSCFG CLOCK
    STR     R1, [R0, #0]
     
    LDR     R0, =0x40013800 ; remap ROM at zero
    LDR     R1, =0x00000001 ; SYSCFG_MEMRMP
    STR     R1, [R0, #0]
       
    LDR     R0, =0x1FFF0000 ; ROM BASE
    LDR     SP,[R0, #0]     ; SP @ +0
    LDR     R0,[R0, #4]     ; PC @ +4
    BX      R0              ; Jump to Bootloader
    END

I'm using a custom target (which I verified it is working by blinking LEDs)
custom_targets.json

    "MTS_MDOT_F405RG": {
        "inherits": ["MCU_STM32"],
        "core": "Cortex-M4F",
        "extra_labels_add": ["STM32F4", "STM32F405RG"],
        "is_disk_virtual": true,
        "macros_add": ["HSE_VALUE=26000000"],
        "features_add": ["BOOTLOADER"],
        "device_has_add": ["ANALOGOUT", "MPU"],
        "release_versions": ["2", "5"],
        "device_name": "STM32F405RG",
        "bootloader_suported": true,
	"device_has_remove": ["SERIAL_FC"]
    }
}

I'm compiling using ARMC6 with mbed-studio and using
commit 0c6753b (HEAD -> latest, tag: mbed-os-6.7.0-rc1, tag: mbed-os-6.7.0, origin/latest)

The device doesn't enter DFU mode, I would appreciate any pointers.

@ciarmcom
Copy link
Member

@tartavull This issue has an incomplete or old issue template.For future reference please use an up to date clone of the repository before raising issues. Many thanks.

@ciarmcom
Copy link
Member

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3503

@tartavull
Copy link
Author

Is there any information I can add here?

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 25, 2021

@tartavull If you can update the above to use the default template (we parse the information internally). Thanks

@ARMmbed/team-multitech Please review

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 25, 2021

@ARMmbed/team-st-mcd might help with DFU mode as well?

@jeromecoutant
Copy link
Collaborator

Maybe you can try to add a little delay before setting usb_dp_pin to 0 ?

@DheerN
Copy link

DheerN commented Feb 25, 2021

Added a 1s delay before setting usb_dp_pin to 0. Didn't seem to make a difference. Any other solutions?

@jeromecoutant
Copy link
Collaborator

@DheerN
Copy link

DheerN commented Feb 25, 2021

10ms delay hasn't worked either.

@JojoS62
Copy link
Contributor

JojoS62 commented Feb 25, 2021

what about the interrupt vector table, is it necessary to reset the SCB->VTOR ? It is set to ram in platform/source/mbed_sdk_boot.c

@tartavull
Copy link
Author

This can be closed, we got it working. Thanks a lot for the help!

@jeromecoutant
Copy link
Collaborator

@tartavull maybe you could add few details to help community in the future ? :-)

@btply
Copy link

btply commented May 5, 2021

@tartavull Could you share your solution please? I'm also having the same issue

@tartavull
Copy link
Author

tartavull commented May 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants