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.

Status
Not open for further replies.

#### AtomSoft

##### Well-Known Member

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

Im lost any C18 examples out there?

#### AtomSoft

##### Well-Known Member
ok i understand a bunch of this:
https://www.electro-tech-online.com/custompdfs/2009/06/00851b.pdf

but i dont get how the hell the code gets called when done loading.

Like ok if it goes to a normal reset:
Code:
    ORG 0x200
RVReset
ORG 0x208
RVIntH
ORG 0x218
RVIntL

Now when the code gets written does it go after the RVReset ? If so what happens to the other interrups? dont they get overwritten?

#### gaspode42

##### Member
AtomSoft

Not sure if this helps - or not !

#### AtomSoft

##### Well-Known Member
it may help if you can verify this:
Code:
void _reset (void)
{
_asm goto _startup _endasm
}

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

#### gaspode42

##### Member
My Guess Is

Yes, I believe that is the way that it functions, although to be absolutely honest I have not tried it

#### 3v0

##### Coop Build Coordinator
Forum Supporter
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

#### 3v0

##### Coop Build Coordinator
Forum Supporter

_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

#### AtomSoft

##### Well-Known Member
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?

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?

#### 3v0

##### Coop Build Coordinator
Forum Supporter
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).

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.

#### AtomSoft

##### Well-Known Member
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

#### AtomSoft

##### Well-Known Member

I hate reading code lol i get lost but heh i guess its the best way, Ill take a look at it Nigel thanks

#### 3v0

##### Coop Build Coordinator
Forum Supporter
Nice work collecting all that info into one place.

Failed to Connect

#### AtomSoft

##### Well-Known Member
sorry let me upload to my new site lol 1 minute

EDIT:

Last edited:

#### AtomSoft

##### Well-Known Member
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?

#### AtomSoft

##### Well-Known Member
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.

#### 3v0

##### Coop Build Coordinator
Forum Supporter
I have been holding back on this question. Why do you need your own version of a bootloader ?

#### AtomSoft

##### Well-Known Member
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.

Replies
5
Views
2K
Replies
3
Views
852
Replies
4
Views
863
Replies
5
Views
2K
Replies
2
Views
1K