• AVR Freaks

Hot!pic24f bootloader AN1157 issue

Author
Prashtandale
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2017/01/18 06:07:03
  • Location: 0
  • Status: offline
2019/11/25 02:00:57 (permalink)
0

pic24f bootloader AN1157 issue

Hi,
 
After reading AN1157 and trying to work out bootloader application and after reading various posts on forum(related to AN1157) i am posting below issue of my project. I am sure i will get some solution here.
 
I am trying for microchips pic24f bootloader application AN1157. Below are the details of tools i am using.
controller: pic24fv16km204
compiler: xc16 v1.36
Mplabx IDE v5.20
 
I have bootloader code from AN1157 and my application code.
i have created linker file for both please check attachments for the same.
 
Below are the steps that i did:
>> Created linker file both.
>> In application code defined USE_VECTOR_SPACE for .BLreset
unsigned int userReset __attribute__ ((space(prog),section(".BLreset"))) = 0xC00 ; 
unsigned int timeout __attribute__ ((space(prog),section(".BLreset"))) = 0;
>> Matched configuration bit settings of bootloader code and application code. Attached file for the same.
>> Mapped interrupt vectors like below:
definition in application code with vector address
void __attribute__((interrupt, address(0x001200), no_auto_psv)) _U1RXInterrupt(void)
mapped in bootloader linker file like below
__U1RXInterrupt = 0x001200;
LONG( DEFINED(__U1RXInterrupt) ? ABSOLUTE(__U1RXInterrupt) :
ABSOLUTE(__DefaultInterrupt));
 
Problems:
1. With above all changes i tried bootloader operation its working fine with basic code of LED blinking.
But after adding my entire application code it is not executing.(confirmed this by checking LED blinking)
i debugged this for a while and found some weird observation.
if i will declare extra variable and initialize it in while(1) in main loop then the application is not executing and after commenting single line in while(1) it is working fine. below is the code.
while (1)
{
LATAbits.LATA9 = ~LATAbits.LATA9;
__delay_ms(100);
test_p_0 = 1; 
test_p_1 = 1;    //commenting this line can result i  working bootloader application.
}
 
2. Device is resetting automatically after some time.
 
Thanks in advance,
Prashant.
post edited by Prashtandale - 2019/11/25 02:20:31
#1

8 Replies Related Threads

    BobAGI
    Super Member
    • Total Posts : 1725
    • Reward points : 0
    • Joined: 2011/03/09 00:04:35
    • Location: Texas and Sweden
    • Status: offline
    Re: pic24f bootloader AN1157 issue 2019/11/25 04:28:34 (permalink)
    0
    You are not supposed to use interrupts at all inside the boot loader AN1157!
    This serves no purpose other than hurting functionality since the boot loader has no other task than to receive serial commands and execute them.
    So do NOT set up ANY interrupts in the boot loader code.
    Look at the 1157 code and you will find no use of interrupts there.
    You have to realize that in an actual PIC both your application and the boot loader are present simultaneously, so if the application and boot loader both use interrupts there will be a clash!
    So remove the boot loader interrupt, it is not needed.

    --
    Bo B
    Sweden & Texas
     
    #2
    Prashtandale
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2017/01/18 06:07:03
    • Location: 0
    • Status: offline
    Re: pic24f bootloader AN1157 issue 2019/11/26 02:23:35 (permalink)
    0
    Hi Bob,
     
    Thanks for the reply.
     
    I am not using any interrupt in bootloader code.
     
    [
    >> Mapped interrupt vectors like below:
    definition in application code with vector address:
    void __attribute__((interrupt, address(0x001200), no_auto_psv)) _U1RXInterrupt(void)
    mapped in bootloader linker file like below:
    __U1RXInterrupt = 0x001200;
    LONG( DEFINED(__U1RXInterrupt) ? ABSOLUTE(__U1RXInterrupt) :
    ABSOLUTE(__DefaultInterrupt));
    ]
     
    The part i shown above is about interrupt vector address mapping. I am just providing address in bootloader linker file.
    Before this i was struggling with verify errors. After doing above change of interrupt vector mapping my application code flashed successfully(using pic24qp.exe utility) and it was running successfully.
    But now i am getting issue for using a variable in while(1) loop. It seems very strange because i feel it should not cause any problem.
     
    I feel there might be some configuration setting issue or some initialization is missing.
     
    If i load program normally(using MPLABX) its running fine. When i load with bootloader(using pic24qp.exe utility)) then application code is not running.
     
    -Prashant
    post edited by Prashtandale - 2019/11/26 02:27:12
    #3
    Prashtandale
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2017/01/18 06:07:03
    • Location: 0
    • Status: offline
    Re: pic24f bootloader AN1157 issue 2019/12/02 03:43:27 (permalink)
    0
    Hi,
     
    Still stuck at this issue.
     
    After debugging for a while it looks like problem is memory size but only 60% of code memory is used.
    Concluding this because any part of added code gives problem.
    I am not getting where is the mistake.
     
    Any help will be really appreciable.
     
    Thanks,
    Prashant.
     
    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 18043
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: pic24f bootloader AN1157 issue 2019/12/02 06:35:34 (permalink)
    0
    60% of the code is used by the main application?
    And what percent for the bootloader?
    #5
    Prashtandale
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2017/01/18 06:07:03
    • Location: 0
    • Status: offline
    Re: pic24f bootloader AN1157 issue 2019/12/03 01:24:29 (permalink)
    0
    bootloader code program memory is 90% as per linker file.
     
    bootloader code starts at 0x400 length is 0x800.
    application code starts at 0xC00 length is 0x1FFE.
     
    Linker file of both is attached already.
     
    I have doubt of somewhere memory is overwriting.
     
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 18043
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: pic24f bootloader AN1157 issue 2019/12/03 07:52:48 (permalink)
    0
    So it is 60% of what you told it it has.
    I’m assuming your linker script lets it know where the boot loader is.
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 18043
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: pic24f bootloader AN1157 issue 2019/12/03 11:04:53 (permalink)
    0
    You can compare the hex files for overlaps
    Or
    Merge them with Hexmate.
    Or
    directly in MPLabX.
    #8
    Prashtandale
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2017/01/18 06:07:03
    • Location: 0
    • Status: offline
    Re: pic24f bootloader AN1157 issue 2019/12/03 21:27:36 (permalink)
    0
    I compared the hex files but there is no problem of memory overlapping there. I was suspecting in application code itself there can be some memory overlapping at IVT area etc.
     
    Everything works fine till one point of code after increasing the size of code it is failing.
    I checked one more thing by keeping LED blinking in init part, there i got to know application code is running but before coming to while(1) it is crashing or going to somewhere else.
     
    My point is till one part of code it is working all fine that means my configuration bits and linker file might be correct, Then why issue is observed after increasing the code.
     
     
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5