Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Bootloader

Status
Not open for further replies.

AtomSoft

Well-Known Member
I know this is not the first time i asked about a bootloader but heh....

I need some general info on how to start this off...

ever bootloader i have seen is written in asm and i write in C now.

So im not sure where to start in C18 :D

Im lost any C18 examples out there?
 
AtomSoft

Not sure if this helps - or not !:(
 
it may help if you can verify this:
Code:
void _reset (void)
{
    _asm goto _startup _endasm
}

That "_startup" part... is it on the newly downloaded hex? Like when the hex is downloaded to the pic. would that jump to the "main" in the newly downloaded hex?

Code:
void main(void){
//is this the _startup?
}
 
My Guess Is

Yes, I believe that is the way that it functions, although to be absolutely honest I have not tried it :D
 
I am guessing you only want to write the uC end of the bootloader?

For starters I would look at Microchip AN851. It should provide you most of you need to know. In particular the memory map and the 10 commands used by the loader.

The PACKET FORMAT can be found under communication protocol.

That should cover about everything you need to write a C version. If you get stuck you can always look at the source code.

3v0
 
It does not jump to void main(void).

It causes a jump to
_startup

which is in the c018 startup code.

c018 is part of the users C program (downloaded hex). When it finishes doing its work it will jump to the users code at void main (void).

3v0
 
3v0 if you look above thats what i was reading...

The problem is how does one intertwine the 2?

Like if i write a bootloader or use one from there. when i write the MAIN code i want to use in the chip do i need to alter the C018 file? or is that only for the bootloader portion?

Bootloader..... check if user wants to upgrade/download new hex if not then
main code... this is whats messing me up... can i write a normal file?

Like i have some older projects like my Nokia 7110 code. Can i alter the PIC to use a bootloader and without changing nothing download my old hex into it using the bootloader?
 
The right linker script should solve most or all of your problems. See APPENDIX D: LINKER SCRIPT EXAMPLES

3v0 if you look above thats what i was reading...
I must have missed that part.
The problem is how does one intertwine the 2?
The bootloader specific linker script sorts out memory allocation etc. The user program has to be linked to start after the boot loader, where the boot loader expects it to be ! So a non-bootloader build will not work.
Like if i write a bootloader or use one from there. when i write the MAIN code i want to use in the chip do i need to alter the C018 file? or is that only for the bootloader portion?
You do not alter the C018 file, it is taken care of for you. The C018 file is used to configure the PIC system to run C, mostly it sets up the stack and inits vars. IF you write your bootloader in C there will be a C018 associated with the loader and another that is part of the users program (his hex).

When you build a program for bootloading the bootloader specific linker command file/script should setup the memory map to work with the bootloader.
Bootloader..... check if user wants to upgrade/download new hex if not then
main code... this is whats messing me up... can i write a normal file?
Are you trying to write a hex file not intended for the boot loader. Remember it must be built with a special linker script.
Like i have some older projects like my Nokia 7110 code. Can i alter the PIC to use a bootloader and without changing nothing download my old hex into it using the bootloader?
See above.

When i was playing with the USB bitwacker I looked at this stuff enough to figure how to link the code so I could build it with or without the bootloader. IIRC the only difference is the linker script used.
 
ok ok i think i got it sort of lol....

I will try to code something in about 20-30 minutes. If all goes well then i will post the complete project and all ok....

... if i run into a problem then ill ask some more lol
 
1 question before i start also...

Those USB to SERIAL by FTDI can be used for this also right? I mean all you would have to do is setup the COM on the PC side since its a Virtual Com port right?
 
I made up my mind and i will code the BOOTLOADER in ASM and the main hex files in C.

This way i can copy the Microchips bootloader alter it a bit to fit my needs then write some C. Then some VB for the Bootloader windows app.
 
i dont but i would like to be able to edit one to work the way i want to lol

Like i want to make my own Widows side also with secret commands and such.
Also want to know how it works well.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top