Page 1 of 1

PIC18F4550 - Application upload and bootloader

PostPosted: Wed Jul 10, 2019 2:43 pm
by danbakana
I have a USB bootloader to PIC18F4550 that was written using Mikro C for PIC and I have two firmware applications, one was written using Mikro C for PIC and the other using MPLAB X with XC8 compiler.With the bootloader installed, I can upload the application written in Mikro C without problem, but, with the same bootloader installed, when I try to upload the application written in MPLABX it loads untill 100% but in the end it crashes . I thought that upload the applicatoin in hex it would not be a problem and would be independant of the tool used.The version of the bootloader that I'm using is this that I found in this site:http://microcontrolandos.blogspot.com/2013/09/pic-bootloader-usb.html At this moment, my application does not need to invoke bootloader and does not need to use any I/O resources that are also used by bootloader.

I attached the main.c of bootloader's firmware that I'm using, I attached some files of the PC software used to upload the .hex files to device. Based on the function send() on the MainForm.cs, it seems that the address to upload the file is passed to the bootloader, but I'm not sure. The main.c of the bootloader is here :https://drive.google.com/open?id=1eO6eczG5P7157F6S15QUCkr-SuDnnzJE and the MainForm.cs is here: https://drive.google.com/open?id=1XGAnLal9iqJ2-mK8zfNtrKydtiCYFvzu.

I made a dummy program, identically in Mikro C and MPLAB X with XC8, just to test, and I compared the .hex files generated by both tools. The program was:

Code: Select all
void main(void) {
unsigned char teste;
while(1){
teste ^=teste;
}
}


I tried to upload it, again the Mikro C .hex file was uploaded without problem nd the MPLAB .hex file not. The PC software crashed again. But, this time, the bootloader does not stop functioning.

The comparison of the .hex files are attached. As can be seen they are very different.

Image

I don't know which difference on them that is making the .hex file written in MPLABX not be uploaded or, if it is a code overwritten problem which is making the code in MPLABX overwrites the bootloader code.

Re: PIC18F4550 - Application upload and bootloader

PostPosted: Mon Jul 15, 2019 3:54 am
by AussieSusan
This question was also asked at https://www.microchip.com/forums/m1104700.aspx.
The assumptions made about how code is laid out within the FLASH by different compilers can be very different. Where the stack is placed, where the code is started etc can all be very different.
Further, if the code is linked to a certain place what happens to be used by the bootloader then that will cause conflicts.
I suggest that you stick with one compiler - it sounds like the MikroC approach works so stick with that.
Susan