|
|
View previous topic :: View next topic |
Author |
Message |
joe06 Guest
|
Main() - Bootloader addresses issue !? |
Posted: Tue Feb 18, 2003 7:02 am |
|
|
Hi All,
in order to make my 16F877 bootloader working, I need to have the main() compiled at a fixed address.
Indeed, It seems CCS doesn't allow to modify the reset vector code to directly jump to the bootloader.
What I intend to do is as follow :
void Program_Main Loop(void)
{
loop_main:
Here is the normal program code
Compiled at a non fixed address
goto loop_main;
}
#org PROGRAM_ENTRY_POINT, PROGRAM_ENTRY_POINT_END
void main(void)
{
bootloader();
Program_Main_Loop();
}
#org 0x1F00
void bootloader (void)
{
if must_bootload
{
here is the bootloader code
finish with a jump to reset vector 0x0000
}
else
return // should jump to a FIXED address
}
In the above code, the reset vector jumps to the Main, which is at a fixed address(PROGRAM_ENTRY_POINT). Then the main calls bootloader, which is at a fixed address 0x1F00, the bootloader executes bootloading function if required and jumps to reset vector, otherwise, return to the caller (main at a fixed address).
After the bootloader returned to the main, the main goes to the main program loop (Program_Main Loop(void))
In this way, the reset jumps always to Main at fixed adress, the main jumps to the bootloader (at fixed address), the bootloader jumps to caller main (at fixed address), the main then jump to the main program loop (at NON fixed adress)
Any comments, suggestions, advises are welcome !
My question is :
When looking to the ASM, CCS adds some initializations at the beginning of the void main (void), here they are :
#org PROGRAM_ENTRY_POINT, PROGRAM_ENTRY_POINT_END
void main (void)
{
1EE7: CLRF 04 // CCS makes initializations from here
1EE8: BCF 03.7 // ...
1EE9: MOVLW 1F // ...
1EEA: ANDWF 03,F // ...
1EEB: MOVLW 0F // ...
1EEC: BSF 03.5 // ...
1EED: MOVWF 1F // ...
1EEE: MOVWF 1F // ...
1EEF: BCF 03.5 // ...
1EF0: CLRF 22 // ...
1EF1: CLRF 23 // ...
1EF2: CLRF 24 // ...
1EF3: CLRF 25 // ...
1EF4: CLRF 26 // ...
1EF5: BSF 03.5 // ...
1EF6: CLRF 4A // ...
1EF7: CLRF 48 // ...
1EF8: CLRF 49 // ...
1EF9: BCF 03.5 // ... TO Here
.................... Bootloader();
1EFA: GOTO 700
.................... Program_Main Loop();
1EFB: BCF 0A.3
1EFC: GOTO 0FF
1EFD: BSF 0A.3
.................... }
1EFE: SLEEP // Should be never reached
My question is : Is the initilization that CCS adds to the void main (void) always the same ? I mean the 18 Asm lines shown above ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 11826 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Main() - Bootloader addresses issue !? |
Posted: Tue Feb 18, 2003 1:16 pm |
|
|
:=My question is : Is the initilization that CCS adds to the void main (void) always the same ? I mean the 18 Asm lines shown above ?
------------------------------------------------------
No, it's not always the same. It varies, depending on the
type of PIC, and also depending upon the version of the
compiler.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11839 |
|
|
joe06 Guest
|
Re: Main() - Bootloader addresses issue !? |
Posted: Tue Feb 18, 2003 5:53 pm |
|
|
:=No, it's not always the same. It varies, depending on the
:=type of PIC, and also depending upon the version of the
:=compiler.
hmmm .. the idea is to make the bootloader stable just for a 16f877, how do you jump back to the main (at a fixed address) with your bootlader ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 11852 |
|
|
Gary Smithson Guest
|
Re: Main() - Bootloader addresses issue !? |
Posted: Tue Feb 18, 2003 7:29 pm |
|
|
Joe, Hi,
A lot of people seem to struggle with the reset vector. And code-flow between the bootloader and the user application. I don't know your requirements but the problem that you are having may be because everything has gotten very complicated. Take a few minutes and look at this post <a href="http://www.pic-c.com/forum/general/posts/10485.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/10485.html</a> and check out the mentioned bootloader source code (CCS PCM). The reset vector management is about as simple as it gets. You as the programmer don't do anything, just let it happen.
Good luck,
Gary S.
:=Hi All,
:=in order to make my 16F877 bootloader working, I need to have the main() compiled at a fixed address.
:=Indeed, It seems CCS doesn't allow to modify the reset vector code to directly jump to the bootloader.
:=What I intend to do is as follow :
:=
:=void Program_Main Loop(void)
:={
:=loop_main:
:= Here is the normal program code
:= Compiled at a non fixed address
:= goto loop_main;
:=}
:=
:=
:=#org PROGRAM_ENTRY_POINT, PROGRAM_ENTRY_POINT_END
:=void main(void)
:={
:= bootloader();
:= Program_Main_Loop();
:=}
:=
:=#org 0x1F00
:=void bootloader (void)
:={
:= if must_bootload
:= {
:= here is the bootloader code
:= finish with a jump to reset vector 0x0000
:= }
:= else
:= return // should jump to a FIXED address
:=}
:=
:=In the above code, the reset vector jumps to the Main, which is at a fixed address(PROGRAM_ENTRY_POINT). Then the main calls bootloader, which is at a fixed address 0x1F00, the bootloader executes bootloading function if required and jumps to reset vector, otherwise, return to the caller (main at a fixed address).
:=After the bootloader returned to the main, the main goes to the main program loop (Program_Main Loop(void))
:=
:=In this way, the reset jumps always to Main at fixed adress, the main jumps to the bootloader (at fixed address), the bootloader jumps to caller main (at fixed address), the main then jump to the main program loop (at NON fixed adress)
:=
:=Any comments, suggestions, advises are welcome !
:=
:=My question is :
:=
:=When looking to the ASM, CCS adds some initializations at the beginning of the void main (void), here they are :
:=
:=#org PROGRAM_ENTRY_POINT, PROGRAM_ENTRY_POINT_END
:=void main (void)
:={
:=1EE7: CLRF 04 // CCS makes initializations from here
:=1EE8: BCF 03.7 // ...
:=1EE9: MOVLW 1F // ...
:=1EEA: ANDWF 03,F // ...
:=1EEB: MOVLW 0F // ...
:=1EEC: BSF 03.5 // ...
:=1EED: MOVWF 1F // ...
:=1EEE: MOVWF 1F // ...
:=1EEF: BCF 03.5 // ...
:=1EF0: CLRF 22 // ...
:=1EF1: CLRF 23 // ...
:=1EF2: CLRF 24 // ...
:=1EF3: CLRF 25 // ...
:=1EF4: CLRF 26 // ...
:=1EF5: BSF 03.5 // ...
:=1EF6: CLRF 4A // ...
:=1EF7: CLRF 48 // ...
:=1EF8: CLRF 49 // ...
:=1EF9: BCF 03.5 // ... TO Here
:=.................... Bootloader();
:=1EFA: GOTO 700
:=.................... Program_Main Loop();
:=1EFB: BCF 0A.3
:=1EFC: GOTO 0FF
:=1EFD: BSF 0A.3
:=.................... }
:=1EFE: SLEEP // Should be never reached
:=
:=My question is : Is the initilization that CCS adds to the void main (void) always the same ? I mean the 18 Asm lines shown above ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 11855 |
|
|
Michael Thompson Guest
|
Re: Main() - Bootloader addresses issue !? |
Posted: Fri Mar 07, 2003 1:02 pm |
|
|
Joe,
Try this:
// this code needs to be added if the bootloader is used
// this code reserves the reset and interrupt vectors and program // memory
#build(reset=0x200)
#build(interrupt=0x208)
#org 0x0000,0x01FF {} ; this is for the 18F8720, boot block
; is 0x0000 to 0x01FF
void bootloader()
{
#asm
nop
#endasm
}
The bootloader would then have code such as:
ORG 0x0000 ; Re-map Reset vector
bra Setup
bra StartWrite
ORG 0x0008
VIntH
bra RVIntH ; Re-map Interrupt vector
ORG 0x0018
VIntL
bra RVIntL ; Re-map Interrupt vector
; ******************************
ORG 0x200
RVReset
ORG 0x208
RVIntH
ORG 0x218
RVIntL
The above assembly code is from the Microchip bootloader from AN00851.
:=:=No, it's not always the same. It varies, depending on the
:=:=type of PIC, and also depending upon the version of the
:=:=compiler.
:=
:=hmmm .. the idea is to make the bootloader stable just for a 16f877, how do you jump back to the main (at a fixed address) with your bootlader ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 12462 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|