Need to change Vector table Address

Post here all questions related to LibMaple core if you can't find a relevant section!
sankarAMP2
Posts: 27
Joined: Mon Feb 10, 2020 2:50 pm
Answers: 1
Location: India

Need to change Vector table Address

Post by sankarAMP2 »

Hello,
I am trying to develop bootloader by using this https://github.com/darkspr1te/stm32f107vc_sd_bootloader it works fine but I am using roger clark's library for arduino ide i.e. https://github.com/rogerclarkmelbourne/Arduino_STM32.
Now the problem is this library works for vector table address 0x8000000 normally, but I want my application to run from 0x8010000 address for that I changed vector table address in boards.txt file, No use.
what should i do to rum my application from my custom location, which files are need to be changed in roger's library.
Thanks in advance.
by sankarAMP2 » Mon Jun 08, 2020 10:26 am
Thank you every one for your great support.
Now its working fine.
bug in bootloader code only.
by commenting __set_MSP(*mcuFirstPageAddr); this line is going to work.
Go to full post
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Need to change Vector table Address

Post by darkspr1te »

In order to change the boot address in rogerclarke you must adjust the define VECT_TAB_FLASH=0x08000000 ,
it's used in target-config.mk and a few other area of the builds,
it's defined in boards.txt as

Code: Select all

discovery_f103.build.vect_flags=-DUSER_ADDR_ROM=0x08000000
and the the build system does something like

Code: Select all

#define VECT_TAB_FLASH USER_ADDR_ROM

if you use platformio + official stm32duino libs the you just add

Code: Select all

build_flags   =-DVECT_TAB_FLASH=0x08010000
to your platformio.ini under [env:whateverenvyounamedit]



darkspr1te
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Need to change Vector table Address

Post by darkspr1te »

Please also note that in the bootloader itself you must also change the bootvect address

Code: Select all

MAIN_PR_OFFSET =0x7000
to

Code: Select all

MAIN_PR_OFFSET=0x10000


darkspr1te
sankarAMP2
Posts: 27
Joined: Mon Feb 10, 2020 2:50 pm
Answers: 1
Location: India

Re: Need to change Vector table Address

Post by sankarAMP2 »

Thank you @darkspr1te
First of all I am using RET6 controller and new to work in core level. As you said I've changed in target-config.mk file

Code: Select all

ifeq ($(MEMORY_TARGET), flash)
VECT_BASE_ADDR := 0x8000000
endif
and in file boards.txt

Code: Select all

genericSTM32F103R.build.vect=VECT_TAB_ADDR=0x8010000

Code: Select all

genericSTM32F103R.menu.device_variant.STM32F103RE.upload.maximum_size=458752
genericSTM32F103R.menu.device_variant.STM32F103RE.upload.ram.maximum_size=65536
genericSTM32F103R.menu.device_variant.STM32F103RE.upload.flash.maximum_size=458752
but it's not running from 0x8010000 and runs fine from 0x8000000 location.

Is there anything more to do? Am I doing any fault?
sankarAMP2
Posts: 27
Joined: Mon Feb 10, 2020 2:50 pm
Answers: 1
Location: India

Re: Need to change Vector table Address

Post by sankarAMP2 »

darkspr1te wrote: Thu Jun 04, 2020 3:13 pm Please also note that in the bootloader itself you must also change the bootvect address

Code: Select all

MAIN_PR_OFFSET =0x7000
to

Code: Select all

MAIN_PR_OFFSET=0x10000


darkspr1te
This was done before you said thank you.
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Need to change Vector table Address

Post by darkspr1te »

At this point the things I would do to diagnose this issue is add a Hardfault handler to your source code ( see bootloader for a example ) and then use SWD debug to see where the program is once the bootloader has handed over and see if any output on uart.

Are you able to provide me with a test bin file to confirm the build environment is in fact setting it up for 0x8010000 and not 0x8000000 or 0x80007000.
You said you are using Keil, I have never used that before (i use stmcube, platformio, arduino,eclipse all for stm)
so forgive me if i dont understand how keil builds.

For clarity am just going to cover the items we need to confirm,
1. Bootloader is setup for 0x10000 as boot address AND flash write address.
2. application is setup for vect table at 0x8010000
3. bin file is created and placed on sdcard
4. application sets up clocks and gpio as bootloader shuts them down prior to app jump.
5. your flash.ld file is adjusted to take into account smaller flash available to application on initial boot

original flash.ld for boot at 0x8000000

Code: Select all

_estack = 0x20020000;    /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x2000;      /* required amount of heap  */
_Min_Stack_Size = 0x4000; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 256K 
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 48K
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}

altered flash.ld for bootable app at 0x7000

Code: Select all

/* Highest address of the user mode stack */
_estack = 0x2000C000;    /* end of 48K RAM */

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x2000;      /* required amount of heap  */
_Min_Stack_Size = 0x2000; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08007000, LENGTH = 256K - 24K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 48K
  MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}

darkspr1te
sankarAMP2
Posts: 27
Joined: Mon Feb 10, 2020 2:50 pm
Answers: 1
Location: India

Re: Need to change Vector table Address

Post by sankarAMP2 »

darkspr1te wrote: Fri Jun 05, 2020 7:36 am You said you are using Keil, I have never used that before (i use stmcube, platformio, arduino,eclipse all for stm)
so forgive me if i dont understand how keil builds.
Sorry, Actually I am Developing bootloader in keil with your reference code and my second application is developing in Arduino with roger's core
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Need to change Vector table Address

Post by darkspr1te »

Are you stuck in that environment? as you can build both in platformio/vscode and have a lot more control over the build but thats my personal preference.
beyond what i've mentioned in prior post I can offer no more advice yet



darkspr1te
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Need to change Vector table Address

Post by stevestrong »

If it is working with Keil, then compare the build process of Keil with the build process of Arduino, then you will figure out what you have to change.
It also depends what kind of upload method do you select in Arduino.
Comparing the build messages for different upload methods also helps to understand the underlying principle.

Basically, it is as @darkspr1te already mentioned:
- change the VECT_TAB address in boards.txt
- change ORIGIN value for FLASH in ld linker script.
sankarAMP2
Posts: 27
Joined: Mon Feb 10, 2020 2:50 pm
Answers: 1
Location: India

Re: Need to change Vector table Address

Post by sankarAMP2 »

Thanks @stevestrong
stevestrong wrote: Fri Jun 05, 2020 9:25 am If it is working with Keil, then compare the build process of Keil with the build process of Arduino, then you will figure out what you have to change.

Comparing the build messages for different upload methods also helps to understand the underlying principle.
Right I will check the build process in keil and arduino.
stevestrong wrote: Fri Jun 05, 2020 9:25 am Basically, it is as @darkspr1te already mentioned:
- change the VECT_TAB address in boards.txt
- change ORIGIN value for FLASH in ld linker script.
I've made changes there but its not working from my custom location.
Post Reply

Return to “General discussion”