Tool/software:
Dear Texas Instruments Support Team,
I am currently implementing a bootloader for the MSP430F67691A and have encountered an issue where interrupts are not functioning correctly after jumping from the bootloader to the application.
I use proxy vector table in application also interrupts are not generated ,so I attached my both application and boot cmd file can you check the memory allocation is correct or not.
Does the bootloader need to explicitly reconfigure the vector table after jumping to the application?
/*application code cmd file*/ /* ============================================================================ */ /* Copyright (c) 2020, Texas Instruments Incorporated */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* * Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* * Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in the */ /* documentation and/or other materials provided with the distribution. */ /* */ /* * Neither the name of Texas Instruments Incorporated nor the names of */ /* its contributors may be used to endorse or promote products derived */ /* from this software without specific prior written permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" */ /* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, */ /* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ /* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR */ /* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, */ /* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; */ /* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, */ /* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR */ /* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* ============================================================================ */ /******************************************************************************/ /* lnk_msp430f67691a.cmd - LINKER COMMAND FILE FOR LINKING MSP430F67691A PROGRAMS */ /* */ /* Usage: lnk430 <obj files...> -o <out file> -m <map file> lnk.cmd */ /* cl430 <src files...> -z -o <out file> -m <map file> lnk.cmd */ /* */ /*----------------------------------------------------------------------------*/ /* These linker options are for command line linking only. For IDE linking, */ /* you should set your linker options in Project Properties */ /* -c LINK USING C CONVENTIONS */ /* -stack 0x0100 SOFTWARE STACK SIZE */ /* -heap 0x0100 HEAP AREA SIZE */ /* */ /*----------------------------------------------------------------------------*/ /* Version: 1.213 */ /*----------------------------------------------------------------------------*/ /****************************************************************************/ /* Specify the system memory map */ /****************************************************************************/ /* RAM Memory Addresses */ __RAM_Start = 0x1C00; /* RAM Start */ __RAM_End = 0x9BFF; /* RAM End */ /* RAM shared between App and Bootloader, must be reserved */ PassWd = 0x1C00; /* Password sent by App to force boot mode */ StatCtrl = 0x1C02; /* Status and Control byte used by Comm */ CI_State_Machine = 0x1C03; /* State machine variable used by Comm */ CI_Callback_ptr = 0x1C04; /* Pointer to Comm callback structure */ /* Unreserved RAM used for Bootloader or App purposes */ _NonReserved_RAM_Start = 0x1C08; /* Non-reserved RAM */ /* Flash memory addresses */ _Appl_Start = 0xC000; /* Start of Application area */ _Appl_End = 0xF3FF; /* End of Application area */ _Flex_Start = 0x10000; /* Start of flex space (app or download, project-dependent) */ _Flex_End = 0x8BFFF; /* End of flex space (app or download, project-dependent) */ /* Flash memory addresses */ __Flash_Start = 0xC000; /* Start of Application area */ /* Reserved Flash locations for Bootloader Area */ __Boot_Start = 0xF400; /* Boot flash */ __Boot_Reset = 0xFFFE; /* Boot reset vector */ __Boot_VectorTable = 0xFF80; /* Boot vector table */ __Boot_SharedCallbacks_Len = 6; /* Length of shared callbacks (2 calls =4B(msp430) or 8B(msp430x) */ __Boot_SharedCallbacks = 0xFF7A; /* Start of Shared callbacks */ _Appl_Proxy_Vector_Start = 0xF302; /* Proxy interrupt table */ _Appl_Reset_Vector = (__Boot_Start - 2); /* MEMORY definition, adjust based on definitions above */ MEMORY { SFR : origin = 0x0000, length = 0x0010 PERIPHERALS_8BIT : origin = 0x0010, length = 0x00F0 PERIPHERALS_16BIT : origin = 0x0100, length = 0x0100 RAM : origin = 0x1C00, length = 0x8000 INFOA : origin = 0x1980, length = 0x0080 INFOB : origin = 0x1900, length = 0x0080 INFOC : origin = 0x1880, length = 0x0080 INFOD : origin = 0x1800, length = 0x0080 FLASH : origin = 0xC002,length = 0x3300 FLASH2 : origin = 0x10000,length = 0x7BFFF /* Boundaries changed to fix CPU47 */ // Interrupt Proxy table from _App_Proxy_Vector_Start->(RESET-1) APP_PROXY_VECTORS : origin = 0xF302, length = 0xFC // App reset from _App_Reset_Vector RESET : origin = 0xF3FE, length = 0x0002 } /****************************************************************************/ /* Specify the sections allocation into memory */ /****************************************************************************/ SECTIONS { .bss : {} > RAM /* Global & static vars */ .data : {} > RAM /* Global & static vars */ /* .TI.noinit : {} > RAM For #pragma noinit */ .sysmem : {} > RAM /* Dynamic memory allocation area */ .stack : {} > RAM (HIGH) /* Software system stack */ .text:_isr : {} > FLASH /* Code ISRs */ #ifndef __LARGE_CODE_MODEL__ .text : {} >> FLASH /* CODE */ #else .text : {} >> FLASH | FLASH2 /* CODE */ #endif .cinit : {} > FLASH2 /* INITIALIZATION TABLES*/ #ifndef __LARGE_DATA_MODEL__ .const : {} >> FLASH /* CONSTANT DATA */ #else .const : {} >> FLASH2 | FLASH /* CONSTANT DATA */ #endif .cio : {} > RAM /* C I/O Buffer */ #ifdef __TI_COMPILER_VERSION__ #if __TI_COMPILER_VERSION__ >= 15009000 #ifndef __LARGE_CODE_MODEL__ .TI.ramfunc : {} load=FLASH, run=RAM, table(BINIT) #else .TI.ramfunc : {} load=FLASH | FLASH2, run=RAM, table(BINIT) #endif #endif #endif .infoA : {} > INFOA /* MSP430 INFO FLASH Memory segments */ .infoB : {} > INFOB .infoC : {} > INFOC .infoD : {} > INFOD .APP_PROXY_VECTORS : {} > APP_PROXY_VECTORS /* INTERRUPT PROXY TABLE */ .reset : {} > RESET /* MSP430 Reset vector */ } /****************************************************************************/ /* Include peripherals memory map */ /****************************************************************************/ -l msp430f67691a.cmd
/*bootcode cmd file*/ /******************************************************************************/ /* LINKER COMMAND FILE FOR MSPBoot BOOTLOADER USING msp430f67691A */ /* File generated with MSPBoot_linkergen_Flash.pl on 24-02-2025 */ /*----------------------------------------------------------------------------*/ /****************************************************************************/ /* SPECIFY THE SYSTEM MEMORY MAP */ /****************************************************************************/ /* The following definitions can be changed to customize the memory map for a different device * or other adjustments * Note that the changes should match the definitions used in MEMORY and SECTIONS * */ /* RAM Memory Addresses */ __RAM_Start = 0x1C00; /* RAM Start */ __RAM_End = 0x9BFF; /* RAM End */ /* RAM shared between App and Bootloader, must be reserved */ PassWd = 0x1C00; /* Password sent by App to force boot mode */ StatCtrl = 0x1C02; /* Status and Control byte used by Comm */ CI_State_Machine = 0x1C03; /* State machine variable used by Comm */ CI_Callback_ptr = 0x1C04; /* Pointer to Comm callback structure */ /* Unreserved RAM used for Bootloader or App purposes */ _NonReserved_RAM_Start = 0x1C08; /* Non-reserved RAM */ /* Flash memory addresses */ _Appl_Start = 0xC000; /* Start of Application area */ _Appl_End = 0xF3FF; /* End of Application area */ _Flex_Start = 0x10000; /* Start of flex space (app or download, project-dependent) */ _Flex_End = 0x8BFFF; /* End of flex space (app or download, project-dependent) */ /* Reserved Flash locations for Bootloader Area */ __Boot_Start = 0xF400; /* Boot flash */ __Boot_Reset = 0xFFFE; /* Boot reset vector */ __Boot_VectorTable = 0xFF80; /* Boot vector table */ __Boot_SharedCallbacks_Len = 6; /* Length of shared callbacks (2 calls =4B(msp430) or 8B(msp430x) */ __Boot_SharedCallbacks = 0xFF7A; /* Start of Shared callbacks */ _Appl_Proxy_Vector_Start = 0xF302; /* Proxy interrupt table */ /* Reserved Flash locations for Application Area */ _Appl_Checksum = (_Appl_Start); /* CRC16 of Application */ _Appl_Start_Memory = (_Appl_Start+2); /* Application Area */ _Appl_CRC_Size1 = (_Appl_End - _Appl_Start_Memory +1); /* Number of bytes in lower memory calculated for CRC */ _Appl_CRC_Size2 = (_Flex_End - _Flex_Start + 1); /* Number of bytes in upper memory calculated for CRC */ _Appl_Reset_Vector = (__Boot_Start - 2); /* MEMORY definition, adjust based on definitions above */ MEMORY { SFR : origin = 0x0000, length = 0x0010 PERIPHERALS_8BIT : origin = 0x0010, length = 0x00F0 PERIPHERALS_16BIT : origin = 0x0100, length = 0x0100 // RAM from _NonReserved_RAM_Start - __RAM_End RAM : origin = 0x1C08, length = 0x7FF7 // Flash from __Boot_Start -( __Boot_SharedCallbacks or INT_VECTOR_TABLE) FLASH : origin = 0xF400, length = 0xB7A // Shared callbacks from __Boot_SharedCallbacks + Len (when used) BOOT_SHARED_CALLBACKS : origin = 0xFF7A, length = 6 // Boot vector Table from __Boot_VectorTable- __Boot_Reset INT_VECTOR_TABLE : origin = 0xFF80, length = 0x7E // Boot reset from __Boot_Reset-_Flash_End RESET : origin = 0xFFFE, length = 0x0002 } /****************************************************************************/ /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ /****************************************************************************/ SECTIONS { .bss : {} > RAM /* GLOBAL & STATIC VARS */ .data : {} > RAM /* GLOBAL & STATIC VARS */ .sysmem : {} > RAM /* DYNAMIC MEMORY ALLOCATION AREA */ .stack : {} > RAM (HIGH) /* SOFTWARE SYSTEM STACK */ .text : {} >> FLASH /* CODE */ .cinit : {} > FLASH /* INITIALIZATION TABLES*/ .const : {} >> FLASH /* CONSTANT DATA */ .cio : {} > RAM /* C I/O BUFFER */ .BOOT_APP_VECTORS : {} > BOOT_SHARED_CALLBACKS /* MSP430 INTERRUPT VECTORS */ .BOOT_VECTOR_TABLE : {} > INT_VECTOR_TABLE .reset : {} > RESET /* MSP430 RESET VECTOR */ } /****************************************************************************/ /* INCLUDE PERIPHERALS MEMORY MAP */ /****************************************************************************/ -l msp430f67691a.cmd
Any guidance on best practices for handling interrupts during the bootloader-to-application transition would be greatly appreciated.
Thank you for your time and support.
Ankush
This device has the ability to locate the interrupt vectors at an alternate location. Which is at the top of RAM.
That space must be reserved so that the initial stack pointer is placed below it. You still have __RAM_End = 0x9bff so the stack would trash the vectors.
Something, bootloader, application, must copy the vectors from where they are in flash to their correct location in RAM. Then enable the alternate vector table (SYSRIVECT) , and finally enable interrupts.
The reset vector is always 0xfffe.
HI David,
I tried this process but not working .so can you please provide any example for this alternate vector table. below I attached code what I done for alternate
vector table can please check this is correct or not.
#define RAM_VECTOR_TABLE_ADDR (0x1C00) // Top of RAM for MSP430F67691A #define FLASH_VECTOR_TABLE_ADDR (0xFF80) // Start of the flash interrupt vector table #define TIMER0_A0_VECTOR (0xFFEE) // Function prototypes void init_ram_vector_table(void); void TIMER0_A0_ISR(void); void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer init_ram_vector_table(); // Initialize the RAM vector table SYSCTL |= SYSRIVECT; // Enable RAM-based interrupt vector table TA0CCTL0 = CCIE ; /* Timer interrupt enabled*/ TA0CCR0 = 16000 ; /* compare the clock frequency with the number of counts giving an interrupt every milisecond*/ TA0CTL = TASSEL__SMCLK + MC_2 + TACLR ; /* TBSSEL_1 + MC_1 + TBCLR;Timer source is ACLK, Timer in upmode (counts up to TBCL0), clear TBR*/ } __enable_interrupt(); // Enable global interrupts while (1) { __no_operation(); // Main loop } } void init_ram_vector_table(void) { volatile unsigned int *ramVectors = (unsigned int *)RAM_VECTOR_TABLE_ADDR; volatile unsigned int *flashVectors = (unsigned int *)FLASH_VECTOR_TABLE_ADDR; unsigned int i; // Copy the interrupt vector table from Flash to RAM for (i = 0; i < 64; i++) { // 48 interrupt vectors in table (0xFF80 to 0xFFFF) ramVectors[i] = flashVectors[i]; } // Override a specific interrupt vector (e.g., Timer0_A0) ramVectors[(TIMER0_A0_VECTOR - FLASH_VECTOR_TABLE_ADDR) / 2] = (unsigned int)TIMER0_A0_ISR; } #pragma vector=TIMER0_A0_VECTOR __interrupt void TIMER0_A0_ISR (void) { static UINT8 flag = 0 ; TA0CCR0 += 16000 ; PORT2_OUT ^= MCU_PUMP ; }
Thank you,
Ankush
Hi,
You will need to set the interrupt vector in the application code. Please refer to this app note for 'Use RAM-based interrupt vector instead of FRAM-based interrupt vector. And you can also download the example code in the note.
https://www.ti.com/lit/an/slaa968/slaa968.pdf
Best regards,
Cash Hao
Just off the top of my head, this code copies the boot loader vectors to the start of RAM. Useless.
**Attention** This is a public forum