relocate application to use a bootloader

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
TorstenG
Posts: 2
Joined: 09 Oct 2014 08:55

relocate application to use a bootloader

#1 Post by TorstenG » 09 Oct 2014 10:10

Hi,

I am developing a Bootloader that shall update the application via CAN. I am familiar with CAN and the STM32 and did that already using other C compilers but now I want to do that for a customer who wants me to use mikroPascal. It is my second project with mikroPascal.

In brief the bootloader is located at the beginning of the FLASH and the application may start at 0x2000. The bootloader shall start, check if the application is valid and then jump to the application.

My questions is know how to relocate the application, the interrupt vector table of the application and the stack pointer of the application?
In other C compilers (e.g. gcc) I would use linker files to do that.
If have managed to move the application by using the orgall directive, but I also like to move the interrupt vector table.

Can you please point me to some more information about that if possible?
I do not know, if that is related, but I also wonder if it is possible to get the source code of the _Lib_System_4XX.mpas file.

Best Regards
Torsten

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: relocate application to use a bootloader

#2 Post by dejan.odabasic » 10 Oct 2014 16:21

Hello,

I believe I have contacted you via support Ticket regarding this issue.
Unfortunately, it's not possible to reallocate the interrupt vectors.
Source code of the _Lib_System_4XX.mpas file is not publicly available.

Best regards.

TorstenG
Posts: 2
Joined: 09 Oct 2014 08:55

Re: relocate application to use a bootloader

#3 Post by TorstenG » 28 Jan 2015 20:14

Hello,

Despite the statement, that it is not possible, I have managed to write a bootloader in mikropascal, to write an application with relocated interrupt vectors and to update the application via CAN. And to jump from the bootloader to the application and vice versa.

If you like to know details, you may contact me.

Best Regards
Torsten

HardWareMan
Posts: 57
Joined: 09 Oct 2014 17:39

Re: relocate application to use a bootloader

#4 Post by HardWareMan » 29 Jan 2015 09:12

Did you look at USB HID Bootloader's method?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: relocate application to use a bootloader

#5 Post by filip » 29 Jan 2015 12:38

Hi,

Could you please share this with us on the forum ?

Regards,
Filip.

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: relocate application to use a bootloader

#6 Post by Pelikan » 29 Jan 2015 14:17

Hello,

even if Libs are faulty, mirkoE holds the source code secret.
The company does not understand that it's like suicide.
I've always written my applications without Libs of mirkoE.

With Greeting
Peter

mklau
Posts: 34
Joined: 19 Aug 2013 03:41

Re: relocate application to use a bootloader

#7 Post by mklau » 20 Feb 2015 12:04

TorstenG wrote:Hello,

Despite the statement, that it is not possible, I have managed to write a bootloader in mikropascal, to write an application with relocated interrupt vectors and to update the application via CAN. And to jump from the bootloader to the application and vice versa.

If you like to know details, you may contact me.

Best Regards
Torsten
Hi Torsten,

I am trying to do the same thing in MiKroC with the following test code to test whether we can change the vector table for my future OTA (over-the-air software update) application:

void app (void) org 0x3000
{
FLASH_Write_Word(0x8009010, 0x12345678); // write buffer with 32 long words
}

void main(void) org 0x5000
{
NVIC_VTOR = (0x4000 << 8); // Vector table offset register
FLASH_Write_Word(0x8004004, 0x03000); // write buffer with 32 long words

delay_ms(100);

SystemReset(); //force system reset
delay_ms(1000); // needed as a time delay for the system to reset
k = 1;
// app();
}

The MCU is STM32F103. The idea of the code is to relocate the vector table to 0x4000 and the reset pointer (0x4004) of the vector table is set to 0x03000 by the Flash_Write_Word function. The code will do a software reset with the internal function 'SystemReset()' and jumps to the 'app' function (located at 0x3000 by org directive). It will write 0x12345678 in flash location 0x8009010 for indication. The MCU does get reseted but not executing the 'app' function since the content in flash location 0x8009010 is still blank.

The same question was posted in the forum and MiKroC directed me to contact you.

Could you advise how I could build the bootloader?

Thanks in advance,

Henry

emb
Posts: 8
Joined: 20 Feb 2020 10:01

Re: relocate application to use a bootloader

#8 Post by emb » 21 Feb 2020 07:52

TorstenG wrote:Hello,

Despite the statement, that it is not possible, I have managed to write a bootloader in mikropascal, to write an application with relocated interrupt vectors and to update the application via CAN. And to jump from the bootloader to the application and vice versa.

If you like to know details, you may contact me.

Best Regards
Torsten
can u please send me the code?

Pelikan
Posts: 219
Joined: 22 Nov 2012 07:58

Re: relocate application to use a bootloader

#9 Post by Pelikan » 24 Feb 2020 11:01

schow mei source..
thermo_boot: check, update application and start via CAN
thermo_slave:the app

without Libs of mirkoE

mit gruß
Peter
Attachments
Boot_App.ZIP
(27.52 KiB) Downloaded 158 times

Post Reply

Return to “mikroPascal PRO for ARM General”