EmbeddedRelated.com
Forums
The current bootloader that I am working on for MSP430F2618 works fine with memory size of 64K and instruction set of MSP430X. Changing the memory size to 1MB does not let the function pointer to jump to the required interrupt vector. The interrupt vector for the bootloader is defined under crt0.asm as follows:

; Jump routines to pass on interrupts from Loader to Loadee
      .code
#define LOADEE_INT_VEC 0xE9C0
jumpvec0:
        mov LOADEE_INT_VEC+0, pc
jumpvec1:
        mov LOADEE_INT_VEC+2, pc
jumpvec2:
        mov LOADEE_INT_VEC+4, pc
jumpvec3:
        mov LOADEE_INT_VEC+6, pc
jumpvec4:
        mov LOADEE_INT_VEC+8, pc
jumpvec5:
        mov LOADEE_INT_VEC+10, pc
jumpvec6:
        mov LOADEE_INT_VEC+12, pc
jumpvec7:
        mov LOADEE_INT_VEC+14, pc
jumpvec8:
        mov LOADEE_INT_VEC+16, pc
jumpvec9:
        mov LOADEE_INT_VEC+18, pc
jumpvec10:
        mov LOADEE_INT_VEC+20, pc
jumpvec11:
        mov LOADEE_INT_VEC+22, pc
jumpvec12:
        mov LOADEE_INT_VEC+24, pc
jumpvec13:
        mov LOADEE_INT_VEC+26, pc
jumpvec14:
        mov LOADEE_INT_VEC+28, pc
jumpvec15:
        mov LOADEE_INT_VEC+30, pc
jumpvec16:
        mov LOADEE_INT_VEC+32, pc
jumpvec17:
        mov LOADEE_INT_VEC+34, pc
jumpvec18:
        mov LOADEE_INT_VEC+36, pc
jumpvec19:
        mov LOADEE_INT_VEC+38, pc
jumpvec20:
        mov LOADEE_INT_VEC+40, pc
jumpvec21:
        mov LOADEE_INT_VEC+42, pc
jumpvec22:
        mov LOADEE_INT_VEC+44, pc
jumpvec23:
        mov LOADEE_INT_VEC+46, pc
jumpvec24:
        mov LOADEE_INT_VEC+48, pc
jumpvec25:
        mov LOADEE_INT_VEC+50, pc
jumpvec26:
        mov LOADEE_INT_VEC+52, pc
jumpvec27:
        mov LOADEE_INT_VEC+54, pc
jumpvec28:
        mov LOADEE_INT_VEC+56, pc
jumpvec29:
        mov LOADEE_INT_VEC+58, pc
jumpvec30:
        mov LOADEE_INT_VEC+60, pc


#ifndef __NOVECTORS
; Reset vector
        .vectors
        .keep

        dw      jumpvec0
        dw      jumpvec1
        dw      jumpvec2
        dw      jumpvec3
        dw      jumpvec4
        dw      jumpvec5
        dw      jumpvec6
        dw      jumpvec7
        dw      jumpvec8
        dw      jumpvec9
        dw      jumpvec10
        dw      jumpvec11
        dw      jumpvec12
        dw      jumpvec13
        dw      jumpvec14 
        dw      jumpvec15
        dw      jumpvec16
        dw      jumpvec17
        dw      jumpvec18
        dw      jumpvec19
        dw      jumpvec20
        dw      jumpvec21
        dw      jumpvec22
        dw      jumpvec23
        dw      jumpvec24 
        dw      jumpvec25
        dw      jumpvec26
        dw      jumpvec27
        dw      jumpvec28
        dw      jumpvec29
        dw      jumpvec30
        dw      __reset
#endif

//#ifndef __NOVECTORS
//; Reset vector
//        .vectors
//        .keep
//        org     RESET_VECTOR
//        dw      __reset
//#endif
The code for jumping from Bootloader to program is as follows:

#define BOOTLOADER_VECTOR 0xE9FE
typedef void (*fnptr)(void);

unsigned int addr = *(unsigned int *)BOOTLOADER_VECTOR;
fnptr jaf = (fnptr)addr;// Condition checking
(*jaf)();


I tried defining 'addr' as unsigned long and didn't make any difference. This program was written in CrossStudio for MSP430. Any help on this would be much approciated.
[ - ]
Reply by Bob11February 12, 2021

Make sure the linker is putting the .vector section where it's supposed to be for the new memory size. Many embedded CPUs put the reset vector at the top of memory, a location which naturally changes when memory size changes. If necessary, have the compiler output the assembly code for the bootloader and walk through it to see if the addresses and data sizes appear correct.

[ - ]
Reply by aruntkkumarFebruary 12, 2021

It seems when I change the memory size to 64K, the INTVEC defined under .hzx is shown as below:

CODE SECTION INTVEC [LOAD=YES]

          dw      jumpvec0

            82fc              DW jumpvec0

          dw      jumpvec1

            86fc              DW jumpvec1

          dw      jumpvec2

            8afc              DW jumpvec2

          dw      jumpvec3

            8efc              DW jumpvec3

          dw      jumpvec4

            92fc              DW jumpvec4

          dw      jumpvec5

            96fc              DW jumpvec5

          dw      jumpvec6

            9afc              DW jumpvec6

          dw      jumpvec7

            9efc              DW jumpvec7

          dw      jumpvec8

            a2fc              DW jumpvec8

          dw      jumpvec9

            a6fc              DW jumpvec9

          dw      jumpvec10

            aafc              DW jumpvec10

          dw      jumpvec11

            aefc              DW jumpvec11

          dw      jumpvec12

            b2fc              DW jumpvec12

          dw      jumpvec13

            b6fc              DW jumpvec13

          dw      jumpvec14  

            bafc              DW jumpvec14

          dw      jumpvec15

            befc              DW jumpvec15

          dw      jumpvec16

            c2fc              DW jumpvec16

          dw      jumpvec17

            c6fc              DW jumpvec17

          dw      jumpvec18

            cafc              DW jumpvec18

          dw      jumpvec19 

            cefc              DW jumpvec19

          dw      jumpvec20

            d2fc              DW jumpvec20

          dw      jumpvec21

            d6fc              DW jumpvec21

          dw      jumpvec22

            dafc              DW jumpvec22

          dw      jumpvec23

            defc              DW jumpvec23

          dw      jumpvec24  

            e2fc              DW jumpvec24

          dw      jumpvec25

            e6fc              DW jumpvec25

          dw      jumpvec26

            eafc              DW jumpvec26

          dw      jumpvec27

            eefc              DW jumpvec27

          dw      jumpvec28

            f2fc              DW jumpvec28

          dw      jumpvec29 

            f6fc              DW jumpvec29

          dw      jumpvec30

            fafc              DW jumpvec30

          dw      __reset

            00ff              DW __reset

However, changing the meory size to 1M produces the INTVEC as shown below:

CODE SECTION INTVEC [LOAD=YES]

          dw      jumpvec0

            c8fc              DW jumpvec0

          dw      jumpvec1

            ccfc              DW jumpvec1

          dw      jumpvec2

            d0fc              DW jumpvec2

          dw      jumpvec3

            d4fc              DW jumpvec3

          dw      jumpvec4

            d8fc              DW jumpvec4

          dw      jumpvec5

            dcfc              DW jumpvec5

          dw      jumpvec6

            e0fc              DW jumpvec6

          dw      jumpvec7

            e4fc              DW jumpvec7

          dw      jumpvec8

            e8fc              DW jumpvec8

          dw      jumpvec9

            ecfc              DW jumpvec9

          dw      jumpvec10

            f0fc              DW jumpvec10

          dw      jumpvec11

            f4fc              DW jumpvec11

          dw      jumpvec12

            f8fc              DW jumpvec12

          dw      jumpvec13

            fcfc              DW jumpvec13

          dw      jumpvec14  

            00fd              DW jumpvec14

          dw      jumpvec15

            04fd              DW jumpvec15

          dw      jumpvec16

            08fd              DW jumpvec16

          dw      jumpvec17

            0cfd              DW jumpvec17

          dw      jumpvec18

            10fd              DW jumpvec18

          dw      jumpvec19 

            14fd              DW jumpvec19

          dw      jumpvec20

            18fd              DW jumpvec20

          dw      jumpvec21

            1cfd              DW jumpvec21

          dw      jumpvec22

            20fd              DW jumpvec22

          dw      jumpvec23

            24fd              DW jumpvec23

          dw      jumpvec24  

            28fd              DW jumpvec24

          dw      jumpvec25

            2cfd              DW jumpvec25

          dw      jumpvec26

            30fd              DW jumpvec26

          dw      jumpvec27

            34fd              DW jumpvec27

          dw      jumpvec28

            38fd              DW jumpvec28

          dw      jumpvec29 

            3cfd              DW jumpvec29

          dw      jumpvec30

            40fd              DW jumpvec30

          dw      __reset

            00ff              DW __reset

Clearly, the memory location for jumpvec14 onwards was in upper mem location (above 64K), but getting truncated to 16 bit address. I tried changing dw (define word) to dl (32 bit), the address shown is as follows (with the warning, section 'INTVEC' overflows group range by 64 bytes):

          dl      jumpvec0

            c8fc0000          DL jumpvec0

          dl      jumpvec1

            ccfc0000          DL jumpvec1

          dl      jumpvec2

            d0fc0000          DL jumpvec2

          dl      jumpvec3

            d4fc0000          DL jumpvec3

          dl      jumpvec4

            d8fc0000          DL jumpvec4

          dl      jumpvec5

            dcfc0000          DL jumpvec5

          dl      jumpvec6

            e0fc0000          DL jumpvec6

          dl      jumpvec7

            e4fc0000          DL jumpvec7

          dl      jumpvec8

            e8fc0000          DL jumpvec8

          dl      jumpvec9

            ecfc0000          DL jumpvec9

          dl      jumpvec10

            f0fc0000          DL jumpvec10

          dl      jumpvec11

            f4fc0000          DL jumpvec11

          dl      jumpvec12

            f8fc0000          DL jumpvec12

          dl      jumpvec13

            fcfc0000          DL jumpvec13

          dl      jumpvec14  

            00fd0000          DL jumpvec14

          dl      jumpvec15

            04fd0000          DL jumpvec15

          dl      jumpvec16

            08fd0000          DL jumpvec16

          dl      jumpvec17

            0cfd0000          DL jumpvec17

          dl      jumpvec18

            10fd0000          DL jumpvec18

          dl      jumpvec19 

            14fd0000          DL jumpvec19

          dl      jumpvec20

            18fd0000          DL jumpvec20

          dl      jumpvec21

            1cfd0000          DL jumpvec21

          dl      jumpvec22

            20fd0000          DL jumpvec22

          dl      jumpvec23

            24fd0000          DL jumpvec23

          dl      jumpvec24  

            28fd0000          DL jumpvec24

          dl      jumpvec25

            2cfd0000          DL jumpvec25

          dl      jumpvec26

            30fd0000          DL jumpvec26

          dl      jumpvec27

            34fd0000          DL jumpvec27

          dl      jumpvec28

            38fd0000          DL jumpvec28

          dl      jumpvec29 

            3cfd0000          DL jumpvec29

          dl      jumpvec30

            40fd0000          DL jumpvec30

          dl      __reset

            00ff0000          DL __reset

This did not provide proper mem location. I tried reducing the jumpvec to 13, didn't resolve it either. Is there a way to resolve this issue or if I could initialise the INTVEC inside any of the source files (*.c) rather than in the system files (crt0.asm)?

[ - ]
Reply by Bob11February 12, 2021

Looks to me like your addresses are in little-endian, with jumpvec0 at either 0xfc82 or 0xfcc8 depending on memory size. The __reset vector seems to be placed at 0xff00 regardless. Is the INTVEC section itself going where you expect it to be? I don't see addresses in the assembly list. Perhaps others on this list can be of more help, as I've never used the MSP430 family.

[ - ]
Reply by aruntkkumarFebruary 12, 2021

MSP430 is little endian. The INTVEC section is going to the correct address FFC0-FFFF (64 bytes). Is there a way if the memory locations of the statements DW jumpvecX be kept the same as 64K. i.e. not to change from 82fc(64K) to c8fc(1M)? Or even define them inside main.c?

[ - ]
Reply by Bob11February 12, 2021

That has something to do with where the linker/loader is putting the INTVEC section. I'm not familiar with your development environment, however, so I can't tell you exactly where to look.