This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Place code in different address offset and execution question.

Other Parts Discussed in Thread: EK-TM4C1294XL

Hi all:

I am using ek-TM4C1294xl boards and program in TI-rtos/NDK environment. Now I try to place two programs and one monitor program in the flash like below post.

e2e.ti.com/.../317657

I hope monitor program can decide (maybe check from eeprom value) which program (old or new version programs) need to run.

Now I test one program and one monitor program in the flash at first. The step are:

1. Download uartecho_TivaTM4c1294NCPDT program in the flash program address 0x30000
2. Download monitor program in the flash program address 0x0. Monitor program likes below:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_gpio.h"
#include "inc/hw_flash.h"
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_ssi.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"

int main(void) {
HWREG(NVIC_VTABLE) = 0x00030000;
__asm(" ldr r1, [r0]\n"
" mov sp, r1");

__asm(" ldr r0, [r0, #4]\n"
" bx r0\n");
}

But after these steps and reset the board. I can't control uart function. Maybe some errors happen. Could some body give me suggestions?

Sincerely,
Joey

  • Hello Joey

    Did you check if the program at location 0x30000 was still present? Or did the download of the monitor program overwrite the same. Also what is the content of r0 register?

    Regards
    Amit
  • Hi Amit:

    Thanks for your response.
    I've checked offset 0x30000 and 0x0 program via LM Flash Programmer -> Flash Utilities -> Verify Flash Contents,
    and it feedback me "Verify Complete - Passed". I think program is still exist.

    But about r0 register, actually I don't know what's meaning~
    I just reference the e2e post. (And final it seems can work)
    e2e.ti.com/.../317657

    Can you give some reference about r0 register, or some suggestions if I want to place code in different address offset, and decide which progrm can be executed?
  • Hello Joey

    R0 is a CPU register. You have to make sure that R0 contains the application address of 0x30000 when the Application ASM is called. And before the call you have to disable all interrupts as well.

    Regards
    Amit
  • Hello Amit:

    Thanks for you response.

    I check some e2e posts and fix the hints you suggest, Now my program like below:

    int main(void) {
    	HWREG(NVIC_DIS0) = 0xffffffff;
    	HWREG(NVIC_DIS1) = 0xffffffff;
    	HWREG(NVIC_DIS2) = 0xffffffff;
    	HWREG(NVIC_DIS3) = 0xffffffff;
    	HWREG(NVIC_DIS4) = 0xffffffff;
    
    	HWREG(NVIC_VTABLE) = 0x00030000;
    
    	__asm(" mov r5, #0x30\n"
    	"  mov r0, r5, lsl#24\n"
    	" ldr r1, [r0]\n"
    	" mov sp, r1\n");
    
    	__asm(" ldr r0, [r0, #4]\n"
    	" bx r0\n");
    }
    

    But it still can't running uart program in flash offset 0x30000.
    Can you give me some suggestion?

    (I use ti-rtos & ndk when I start to writing TI program, so I don't have concept about assembly code,
    Hope anyone give me more suggests, Thank you very much.)

  • Hello Joey,

    Just before the bx r0 is called did you check the contents of the sp and r0 in the CPU register view. What does it contain and does it match the content at 0x30000 and 0x30004 respectively?

    Regards
    Amit