RS232 bootloader

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
zorgcorp
Posts: 110
Joined: 28 Mar 2011 10:17

RS232 bootloader

#1 Post by zorgcorp » 15 May 2013 14:12

Hello,
I am forced to develop a standard rs232 bootloader on the fusion board first then apply it on our custom board.

Two main thing remains to be solved:

1) In my bootloader how can the code jump to the user application, does that work:(microchip based code)? compiler mikroePRO PIC 32 accepts it.

#define USER_APP_RESET_ADDRESS 0x9D005490
void JumpToApp(void)
{
void (*fptr)(void);
fptr = (void (*)(void))USER_APP_RESET_ADDRESS;
fptr();
}

2) USER_APP_RESET_ADDRESS is at 0x9D005490 do we have to place in the user application the void main like that or do we have to do anything else:

void main() org 0x9D005490{
...
}

thanks if anyone can help
Alex

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: RS232 bootloader

#2 Post by janko.kaljevic » 16 May 2013 09:47

Hello,

the best would be to check out our Serial bootloader code for PIC controllers.
The code is available in mikroC PRO for PIC compiler and you can take a look at it to see details.

Also this depends on your approach to this problem and you PC application that you will use to load hex files.

Your bootloader code must have jump to application start address ad you described.

For example in our bootloader, firmware writes user application start address and user does not need to take care of that in his own code.

Best regards.

zorgcorp
Posts: 110
Joined: 28 Mar 2011 10:17

Re: RS232 bootloader

#3 Post by zorgcorp » 16 May 2013 15:02

Thanks Janko,
This is what I am looking for and I posted my post for it because I DID NOT FIND the code "Serial bootloader code for PIC controllers". Are you talking about the "USB HID Bootloader" or else? because I found USB HID but nothing else.

If there is any other code that might put me in the right direction I would be glad to get the URL in order to download it...

Best regards
Alex

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: RS232 bootloader

#4 Post by janko.kaljevic » 17 May 2013 09:14

Hello,

In PIC32 compilers we have provided only USB HID bootlaoder.

But you can find very simple USRT Bootlaoder in our PIC compiler for 8bit controllers:
http://www.mikroe.com/mikroc/pic/

This code you can use as reference for your bootloader.

Best regards.

zorgcorp
Posts: 110
Joined: 28 Mar 2011 10:17

Re: RS232 bootloader

#5 Post by zorgcorp » 17 May 2013 10:18

Two more things:

First: Can I apply or inspire my future code from this PIC bootloader on mikro C PIC32?
Second: I saw that our tread is under: mikroPascal compiler for PIC » mikroPascal FAQ, can you move it to mikroC for PIC or PIC32, for other users information?

Thanks for all Janko
Alex

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: RS232 bootloader

#6 Post by janko.kaljevic » 20 May 2013 17:28

Hello,

No problem at all.
You can use tour provided codes in your project.

Also I have moved this topic in mikroC PRO for PIC32 General.

Best regards.

zorgcorp
Posts: 110
Joined: 28 Mar 2011 10:17

Re: RS232 bootloader

#7 Post by zorgcorp » 22 May 2013 09:19

Hello Janko,
I would like to go further by making my own bootloader based on our previous talk and, with your help, build up further this post to help others to get a simple bootloader by maybe presenting it in an other way than a post...to be discussed.

I will start simple and step by step using fusion board, PIC32MX795F512L and using serial USB UART A.

Here is the first step, just tell me if I do right:

My_bootloader:
#define BOOTLOADER_START_ADDR 0xBFC00000
#define START_PROGRAM_ADDR 0x9D005000
#pragma orgall BOOTLOADER_START_ADDR

void Start_Program() org START_PROGRAM_ADDR
{

}

void main ()
{
if (condition_Bootloader)
{
TRISD=0;
LATD=0xFF;
Delay_ms(10000);
// here will come all necessary code to catch the hex file from UART and flash the memory
}
Start_Program();
}

then it gives My_bootloader.lst:
//** Routines locations **
//ADDRESS SIZE PROCEDURE
//----------------------------------------------
0x9D005000 [8] _Start_Program
0x9FC00390 [24] ___GenExcept
0x9FC003A8 [24] ___BootGenExcept
0x9FC003C0 [56] _main
0xBFC00000 [296] ___BootStartUp
//** Variables locations **
//ADDRESS SIZE VARIABLE
//----------------------------------------------



My_Application:
#define START_PROGRAM_ADDR 0x9D005000
#pragma orgall START_PROGRAM_ADDR

void main()
{
TRISD=0;
while(1)
{
LATD=0xFF;
Delay_ms(1000);
LATD=0;
Delay_ms(1000);
}
}

then it gives My_Application.lst:
//** Routines locations **
//ADDRESS SIZE PROCEDURE
//----------------------------------------------
0x9D005000 [24] ___GenExcept
0x9D005018 [24] ___BootGenExcept
0x9D005030 [84] _main
0xBFC00000 [296] ___BootStartUp
//** Variables locations **
//ADDRESS SIZE VARIABLE
//----------------------------------------------

For me it looks ok. My question is: In the bootloader code, do we have to flash the entire My_Application.hex or do we have to skip something. I guess we have to skip at least ___BootStartUp but do we have to skip the rest? like ___GenExcept,___BootGenExcept in order to reach the bootloader first at each reset..

Thanks for your response
Alex

Post Reply

Return to “mikroC PRO for PIC32 General”