AnsweredAssumed Answered

JM60 Bootloader with Interrupts

Question asked by Richard Jones on Mar 18, 2014

I've inherited a JM60 application built using Processor Expert on CW 10.2.  It has a serial connection to our main processor over SCI2 and uses interrupts and a custom protocol.  My task is to create a bootloader so that we can remotely update the application firmware in the field.  To that end, I've read a ton of discussions on here and (after a lot of wasted time and hair-pulling) realized that my only options are to implement a soft vector jump table or implement my bootloader without interrupts.


I have already implemented an interrupt-driven version by re-using the serial protocol from our application. I'd really like to keep it that way so that I can use common code.  With a little rework, I'm sure I could abstract it a little better so that it could work either way, but I'm intrigued by an elegant jump table suggestion by kef in the following post: Re: Bootloader and Interrupt.  I prefer this solution if possible because it should allow any interrupts to be used in the future by the application without having to manually redirect each one in the bootloader.  It also keeps the bootloader as small as possible because I don't need those redirect functions.


I've implemented a JumpTable.c and h based on his code sample, and it appears to set everything up correctly, but I get a reset due to invalid opcode apparently when an interrupt is called.


When I browse the memory after initializing the jump table, I see that the vector table is set up correctly.


     0x0000FFC0  FFFFFFFF 1960195D 195A1957 19541951

     0x0000FFD0  194E194B  19481945 1942193F 193C1939

     0x0000FFE0  19361933   1930192D 192A1927 1921191E

     0x0000FFF0  191B1918   19151912 190F190C 1909F0AD


0xF0AD is the address of _EntryPoint, and 0x1909 is the start address of the jump table in RAM.


Similarly, the correct jump offsets in RAM have the correct addresses according to the map file.


     0x00001940  70FC7DF0 FD1EDF33 CCF069CC EFAFCCF0

     0x00001950  0F4B5CA0 92CAAC54 A0844322   80F0FD34


  • 0x1948 has 0xCCF069, where 0xF069 which is AS1_InterruptError
  • 0x194B has 0xCCEFAF, where 0xEFAF which is AS1_InterruptRx
  • 0x194E has 0xCCF00F, where 0xF00F which is AS1_InterruptTx


Map file:

     AS1_InterruptRx                           EFAF      60      96       1   .text    

     AS1_InterruptTx                           F00F      5A      90       1   .text    

     AS1_InterruptError                        F069      11      17       1   .text    

     _EntryPoint                                 F0AD      51      81       0   .text    


Strangely, now that I've cleaned up the code to make it more presentable to post, I don't get the reset, and instead the MCU seems to go off into space.  When I switch from using the jump table back to using the standard vector table, it all works fine, and I get proper serial communication.  It seems that the problem has something to do with the way the ISRs are called and/or return, but I can't figure it out, so any help is appreciated!




Original Attachment has been moved to: