cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152RET6 usb dfu bootload

oallen
Associate
Posted on July 17, 2015 at 16:19

I am trying to initiate a bootload via firmware from a STM32L152RET6 over USB.

When I have Boot0 and Boot1 pin configured via jumper hardware and reset processor the Dfuse program recognize the bootloader and I can download firmware over the USB port.

I found several posts on this forum on how to jump to the booload section but none of them work.

I have tried the following based on the forum suggestions but it does not work

In the startup file, startup_stm32l152xe.s I added the following

Reset_Handler

        LDR     R0, =0x2000FFF0  ;check for memory location

        LDR     R1, =0xDEADBEEF  ;for this magic number to determine if

        LDR     R2, [R0, #0]     ;program should start or jump to bootloader

        STR     R0, [R0, #0] ; Invalidate

        CMP     R2, R1

        BEQ     Reboot_Loader

        LDR     R0, =SystemInit

        BLX     R0

        LDR     R0, =__iar_program_start

        BX      R0

Reboot_Loader

                

        LDR     R0, =0x40023820 ; RCC_APB2ENR (+0x20)

        LDR     R1, =0x00000001 ; ENABLE SYSCFG CLOCK

        STR     R1, [R0, #0]                

        LDR     R0, =0x40010000 ; SYSCFG_CFGR1 (+0x00)

        LDR     R1, =0x00000001 ; MAP ROM AT ZERO

        STR     R1, [R0, #0]

        LDR     R0, =0x1FF00000 ; ROM BASE (STM32L1xxE)

        ;;LDR     R0, =0x00000000 ;  OR GENERICALLY MAPPED AT ZERO

        LDR     R1, [R0, #0]    ; SP @ +0

        MOV     SP, R1

        LDR     R0, [R0, #4]    ; PC @ +4

        BX      R0

In my main application when I need to initiate the bootload I have this

*((unsigned long *)0x2000FFF0) = 0xDEADBEEF;

    HAL_NVIC_SystemReset();

Is there something else that I need to set or do in order to initiate the firmware update over USB frm my application?

I do not have an available spare UART on this device as all ports are being used and so all updates must be over USB.

Any help would be appreciated.

Thanks
3 REPLIES 3
Posted on July 17, 2015 at 16:48

Does it actually get to this code?

If you build a test image, where you don't check the SRAM setting, and then turn OFF ''run to main()'' in the debugger, and just step through the code does it work then.

Confirm you can see the ROM mapped at 0x00000000

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
oallen
Associate
Posted on July 17, 2015 at 17:19

Thanks for the quick reply.

I stepped through the code as you directed and it does get to the reboot_loader section but the address ranges that it ends up in is 0x1FF0xxxx, which is the bootloader address per AN2606 for the STM32L152Ret6. SO if it does get there why doesn't the dfu programmer set it. Are there additional registers that the Boot0 and Boot1 pins set that I should set as well?

Posted on July 17, 2015 at 18:10

I don't know, I don't have an L152 with a USB connection.

The register settings appear to be correct. It's possible the System Loader checks other things, and the BOOTx pins. You can't change those in software. I'd have to disassemble the L1 ROM to understand what it's dependencies are, not got a strong driver to do that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..