Skip to main content
HElHa
Visitor II
March 21, 2019
Question

How do i boot from one of two locations on the STM32L072RBT6? I

  • March 21, 2019
  • 9 replies
  • 2511 views

have a default location X. If want to update the code, i download it to location Y and expect the STM32 to start at location Y after reboot. However, the routine keeps rebooting from X. what am i missing?

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
March 21, 2019

The CM0 always boots from the vector table it finds starting at the base address of zero.

The BOOTx pins determine what memory that is. Typically it is the base of flash (0x08000000) which then gets mapped/shadowed at 0x00000000

It is not going to magically find your code at Y, you would have to create code at X that directs it to other locations, Y or Z

>>what am i missing?

A clear reading of the processor technical reference manual? Basic functionality of micro-controllers?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
March 21, 2019

You can change the base for the vector table of the CM0+ once it has started, the reset clears the SCB->VTOR register.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
March 21, 2019

@JMani.14​ 

I just mean you're randomly messaging me, about a guy who hasn't responded to the answer I left, and I'm missing a whole set of conversations/thoughts that goes with that.

"Not Working as Expected" isn't helpful, have you stepped the code with the debugger? Does it go into your Reset_Handlers for App1 or App2? Do interrupts stop working? What are your observations about what code is actually running and what is it doing?

You have a __disable_irq() but unless there is complementary code on the other side they will never be enabled again.

The MSP setting code is perhaps dangerous on GNU/GCC systems.

There is no sanity checking of the jump addresses, if the Flash there is blank the system will crash.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
March 23, 2019

@JMani.14​ 

Check build addresses, and output from the linker, ie .MAP files, etc

Make sure that code in SystemInit() is not changing SCB->VTOR to the wrong address.

Execution will go exactly where you tell it to go, if it goes to the wrong places you need to review why it pulls and uses those addresses. Start with the linker, and linker scripts or scatter files.

The addresses in the Vector Table are absolute, you need to ensure the images are built for the addresses they are going to be placed, or relocate them to the new address.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JMani.14
Associate
March 23, 2019

Hi, Clive

I moved to here.

JMani.14
Associate
March 23, 2019

I am using IAR, could you please let me know how to loading several hex files on STM?

Tesla DeLorean
Guru
March 23, 2019

The .HEX file contain addressing data. You can use the STM32 Cube Programmer to load and program the individual files one at a time.

You may merge multiple . HEX files, the body of the data is everything excluding the last line.

ie

BODY1

END RECORD

BODY2

END RECORD

BODY3

END RECORD

Can be recombined as

BODY1

BODY2

BODY3

END RECORD

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JMani.14
Associate
March 24, 2019

What do you mean by excluding the last line?

Tesla DeLorean
Guru
March 24, 2019

The one at the end that is different from all the others.

I​n a .HEX file with 1000 lines, line 1000. So the ones of interest being 1 thru 999.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JMani.14
Associate
March 24, 2019

I have hex file that the filesize is 40kByte. I am not clear about what the last line is.

Tesla DeLorean
Guru
March 25, 2019

Why is this such an uphill ski?

:020000040800F2 << SEGMENT ADDRESS INFO
:1000000058330020D5000008C1410008993E00087F << BODY DATA
:1000100000000000000000000000000000000000E0
:100020000000000000000000000000000F47000872
:10003000000000000000000065430008295E000881
:10004000E7000008E7000008BF450008E7000008D7
...
:1089F0000000000000000000000000000000000077
:108A00000000000000000000000000000000000066
:108A10000000000000000000000000000000000056
:108A20000000000000000000000000000000000046 << END OF BODY DATA
:04000005080000C12E << YOU COULD LOSE THIS 05 RECORD
:00000001FF << THIS 01 RECORD LINE AT THE END OF THE FILE

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JMani.14
Associate
March 25, 2019

Which tool should I use? I used winhex for merging 3 hex files - bootloader, app1, app2.

Winhex does not display data as you showed.

JMani.14
Associate
March 25, 2019

Which tool should I use? I used winhex for merging 3 hex files - bootloader, app1, app2.

Winhex does not display data as you showed.

Tesla DeLorean
Guru
March 26, 2019

They are in ASCII, use notepad or some text editor

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JMani.14
Associate
March 26, 2019

This is my hex file which is opened in STM32CubeProgrammer.

0690X0000088sX2QAI.png

Could you please let me know where the last line is?

Thank you.