LPC1788 + FreeRtos or RTX + bootlader + Ethernet

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1788 + FreeRtos or RTX + bootlader + Ethernet

567 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dfcbkbq on Wed Nov 06 23:10:18 MST 2013
Hi all,

I have try to develop an ethernet bootloader via tftp. First program (bootloader is placed in 0x0000-0xFFFF adress area) gets bin file from tftp-server and flashes it to from 0x10000 to the end of IROM. After all it jumps using this:
__asm void boot_jump( uint32_t address )
{
  LDR SP, [R0]            ;Load new stack pointer address
  LDR PC, [R0, #4]      ;Load new program counter address
}

/**
 * @brief Jump to second program
 *
 * @param address
 */
void jumpToProgram (uint32_t address)
{
        SCB->VTOR = address & 0x3FFFFF80;
        boot_jump(address);
}

//some code here
...
        // jumping to second program from bootloader
        else if(memcmp("jump\r", str, strlen("jump\r")) ==0 )
        {
            vTaskEndScheduler();
            jumpToProgram(0x10000);
        }
...

Second program is shifted to 0x10000 by compiler (IROM1 start parametr is 0x10000). It works if I don't use any RTOS in second program. If I do, then program crashes at starting sheduler (vTaskStartScheduler() in FreeRtos or os_sys_init() in RTX). Furthermore I figured out that if I exclude frome bootloader file EMAC_LPC177x_8x.c the second program starts working (sheduler starts) after jumping in it from bootloader. What is wrong?
Regards Vasilij
Labels (1)
0 Kudos
3 Replies

331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dfcbkbq on Thu Nov 07 01:11:12 MST 2013
John Sinclair

You was right! Thank you! It is the Vector Table mismatch! When you advice to me to edit SystemInit, I saw that VTOR initialize in it too!
void SystemInit (void)
{
//code code
...
#ifdef  __RAM_MODE__
  SCB->VTOR  = 0x10000000 & 0x3FFFFF80;                  /**< here it is! */
#else
  SCB->VTOR  = 0x00000000 & 0x3FFFFF80;
#endif
}
0 Kudos

331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dfcbkbq on Thu Nov 07 00:52:06 MST 2013
John Sinclair, thank you for your reply!

I think your way to remap vector is great! I am going to use it. But I didn't exacly get what __Vectors is. I found it in startup_LPC177x_8x.s. I suppose it just pointer. But when I try to compile that:
SCB->VTOR = (uint32_t) __Vectors;

I get that: drv\src\system_LPC177x_8x.c(466): error:  #20: identifier "__Vectors" is undefined.
Haw should I declare it? extern uint32_t * __Vectors?

I tryed this:
extern uint32_t * __Vectors;
void SystemInit (void)
{
//init code
...
SCB->VTOR = (uint32_t) __Vectors;
}

In this case after statring sheduler in second program starts to work  first program (bootloader). I suppose it just restarting (can't to debug this). What am I doing wrong?
0 Kudos

331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by John Sinclair on Thu Nov 07 00:29:23 MST 2013
Hi Vasilij,

first i recommended to reset the Link Register before you load the stack pointer (so is written in the LPC User Manual chapter 39.3.1.3.3 Link Register). So you have the same condition like an real reset :

void jumpToProgram (uint32_t address)
{
   MOV LR, #0xFFFFFFFF  ;Reset Link Register
   LDR SP, [R0];Load new stack pointer address
   LDR PC, [R0, #4];Load new program counter address
}


But your problem I think is that the Vector Table mismatch. I found in some code examples to remap the Vector Table in the Bootloader. I think it is a bad idea!
Because:
In the user-program (second program) you have to ensure that the vector table is always on the same place.

I think better is to set the Vector in the user-program in the SystemInit like:

extern void __Vectors(void);

void SystemInit (void)
{
...
SCB->VTOR = (uint32_t) __Vectors;
...
}

0 Kudos