Different code sections

Hi everybody, I am trying develop the programme, in which the parts of code will be in different parts of flash memory. There should be regular programme, which should start at the begining of the flash memory, and then my own bootloader, which should be at the highest part of flash memory.

So I modified SECTIONS in linker file “lnk_msp430f2132.cmd” as: (uninteresting parts were removed)

SECTIONS
{
.boot	   : {} > FLASH (HIGH)
.text            : {} > FLASH
.reset          : {} > RESET
}

And then I want from my program to able to do something like this:

    .cdecls C,LIST, "msp430x21x2.h"

    .sect ".boot"
bootloader
    mov.w	#0, R4
    jmp  back_to_main

    .text
main
    jmp bootloader
back_to_main
    jmp   $

    .sect   ".reset"                
    .short  main	               
    .end

From the reset vector jump to main, perform commands in main, jump to bootloader, perform bootloader and then jump back_to_main. But when the programme gets to the “jmp bootloader” command, it does not jump to “bootloader”, but only to “main” :frowning:

When I look into the memory at the positions, where I want to have the bootloader sections, the commands are there, probably correctly… Only those jumps do not work…

Thank you for any advice…

Solved, it was neccesary to use BRANCH instruction instead of JMP. (JMP can not jump “far”.)