cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in upgrading STM32F4discovery firmware using USB

ali
Associate II
Posted on June 21, 2013 at 09:36

Hello everyone,

I'm working on STM32F4discovery board. I used the example in the firmware and it worked. But when i wanted to upgrade firmware with my own codes, it didn't work. I even used the codes in the board firmware (Demonstration code) and convert it to .BIN file.

everything is performed correctly and uploaded code and downloaded code are the same but application code didn't work.

I appreciate if anyone could help me
6 REPLIES 6
Posted on June 21, 2013 at 15:47

This is where one would normally use a debugger, and examine what is going on, and how the code is behaving. Is this technique not working for you?

Programming how via USB? STLINK, DfuSe?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ali
Associate II
Posted on June 21, 2013 at 20:54

I used debugger but it showed that the code was stock in infinite loop or hard fault function.

I program board via USB and it works fine. The problem starts when I want to upgrade USB with my own codes not the codes in the binary directory.

Posted on June 21, 2013 at 22:27

Tools like Keil permit you to uncheck ''Run to main()'' to debug startup code. You don't mention what tools you are using.

The Hard Fault might occur if you haven't enabled the FPU properly and the code is using instructions that depend on it. You would need to check the code in SystemInit().

You should be able to examine the processor state and stack to determine the faulting instruction. Knowing which instruction faulted with enable a determination of the cause.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ali
Associate II
Posted on June 22, 2013 at 03:53

Dear clive1,

Thanks for your replies. I use Keil ver. 4.53. But I think we have sort of misunderstanding.

As you may aware, In upgrading firmware by USB, we have to codes: first is the firmware which checks USB and download image file of it and second is application code which is set on specific address of Flash memory (Say 0x08008000). The first code is working properly; I debugged it and checked some parameters and they are accurate and downloaded and uploaded file are current BUT when this code wants to jump to application code, nothing works. By default, all codes will be placed on 0x08000000 address. I want to know is there any changes are needed to perform in order to place application code in other address?

Thank you 🙂

Posted on June 22, 2013 at 04:15

You would need to go to the Target tab, and change the IROM base and size to reflect your load address.

You would need to modify system_stm32f4xx.c SystemInit() to set the Vector Table address (SCB->VTOR at the end) to reflect the new base address where it now exists.

But still, you can use debuggers to step across the jump into the secondary application space, and examine the registers at the fault to understand why something failed.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ali
Associate II
Posted on June 22, 2013 at 20:09

Dear clive1,

I have to thank you for your responses. Today, my problem was solved. I read application note AN3990 more carefully and as you said, i performed changes you were mentioned above. These changes are mentioned in Section 2.3 of application note