Jump to content
Sign in to follow this  
emte

C Bootloader Thread

Recommended Posts

Alright, this is where i am at:

i have figured out how to hijack the

void _startup(void)
function, but

it is not allowing me to redefine the contents.

 

This is an issue because it chews up 4 instructions just going into main, and to load

most bootloaders you need to issue the bootloader jump within the first four instructions.

 

So my question is how to redefine or override _startup? It should be possible as a pure asm

file works just fine.

 

The code compiles without an issue, i belive it is a linker problem or perhaps a flag that i am

missing.

The nice semiObscure error is:

Failure
NoSourceFile function redefinition: _startup(void) in C:\TEMP\EE-Bootloader\main.c

Which i can only guess that "NoSourceFile" might actually mean not allowed to define in a

source file. If that is the case, work around anyone?

Edited by emte

Share this post


Link to post
Share on other sites
Alright, this is where i am at:

i have figured out how to hijack the

void _startup(void)
function, but

it is not allowing me to redefine the contents.

 

This is an issue because it chews up 4 instructions just going into main, and to load

most bootloaders you need to issue the bootloader jump within the first four instructions.

 

So my question is how to redefine or override _startup? It should be possible as a pure asm

file works just fine.

Overridding the startup code is not possible.

 

If I was trying to right a bootloader I would do it like this:

1) Split program into 2, application and bootloader.

2) Compile BootLoader in low memory.

3) Compile application to use memory above bootloader - use linker option -rb

Bootloader code will get executed first for both reset and interrupt.

Pass control onto application code using somthing like:

//Jump To Application Code
asm
{
   //Set pclath
#if defined( _16F877 ) || defined( _16F876 )
   movlw0x1E
#elif defined( _16F874 ) || defined( _16F873 )
   movlw0x0E
#elif defined( _16F871 ) || defined( _16F870 )
   movlw0x06
#endif   
   movwf_pclath
//set pcl
   movlw0x00
   movwf_pcl
}

This code is from the EK Bootloader on the samples page.

 

Regards

Dave

Share this post


Link to post
Share on other sites

hmmm...

 

so your suggesting placing the bootloader at the start instead of the normal ICD debug space?

 

Your idea of breaking it up has given me another idea though, lets see if it pans out.

Edited by emte

Share this post


Link to post
Share on other sites

emte,

hmmm...

 

so your suggesting  placing the bootloader at the start instead of the normal ICD debug space?

Yep.

Microchip provide configuration bits on some devices that allow the low memory area to be protected from flash table writes eg PIC18F4520 has 0x800 bytes of ROM that can be protected for boot loader usage.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...