App2 set address

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

App2 set address

Jump to solution
1,633 Views
CCandido
Contributor V

Hi,

What better way to sit the entry in an App2 ?.
Wanted an example, setting the function in an address or setting a constant with the address of the entry function.

startup_App init.....

switch( n_app ){

case...App2   0x8000

case..App3    0xA000

case..Appn    0x14000...

JumpToUserApplication(0x20002FF8,(uint32)APPn);

- Appn compiled separately after.

thanks,

Carlos.

0 Kudos
1 Solution
1,120 Views
CCandido
Contributor V

Hi Hui_Ma,

App2 is complete code to program diret runnig ok.

error when, case ( update App1 flasher...goto App2 ) entry_pointer (_startUp or main_task ).

I see, USB error.

example Timer_isr app1,app2 = ok.

my solution: SoftwareReset(); start direct App2 = ok.

thanks for helping me.
I invite you to help improve my freeSimpleMultiTask.

GitHub - autoprog/DelayCore: DelayCore to Multi-task 

thanks.

Carlos.

View solution in original post

0 Kudos
15 Replies
1,121 Views
CCandido
Contributor V

Hi Hui_Ma,

App2 is complete code to program diret runnig ok.

error when, case ( update App1 flasher...goto App2 ) entry_pointer (_startUp or main_task ).

I see, USB error.

example Timer_isr app1,app2 = ok.

my solution: SoftwareReset(); start direct App2 = ok.

thanks for helping me.
I invite you to help improve my freeSimpleMultiTask.

GitHub - autoprog/DelayCore: DelayCore to Multi-task 

thanks.

Carlos.

0 Kudos
1,120 Views
CCandido
Contributor V

Hi,

I finally found the solution to problem,

the entry point in app2 was via the VECTOR address table ( saved pointer address not used to isr).

ex:

(m_Func)&entry_pointer,  <---- address my pointer enter app2 runinng from ram.

procedure:

void (*ram_call)(void);

          ram_call = _MYREG->RAM_VECTOR[x];

ram_call();   call ok , USBCDC not run....ever

sulution:

not use pointer address saved in vector table to call RAM, use others forms.

thanks,

Carlos.

0 Kudos
1,120 Views
CCandido
Contributor V

Hi,

Partial solution:

_stakp = ( *(( unsigned long*)&MEMBASE + 0));
_addr = ( *(( unsigned long*)&MEMBASE +  4 ));   to  _addr = ( *(( unsigned long*)&MEMBASE + 1  ));

READ ( UINT32 ), note read byte.

goto App2 = ok

when:

Continues with error using USB App1 and App2 = error

Even closing the usb:
CDC1_Deinit();
USB1_Deinit();

thanks,

Carlos.

0 Kudos
1,120 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Carlos,

I checked the APP2 just using FlexTimer module to negate a LED with interrupt.

Could you let me know if the APP2 FlexTimer interrupt working now?


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,120 Views
CCandido
Contributor V

Hi Hui_Ma,

App2 with timer interrupt = ok.

App1 and App2 with USB_CDC  = error.

solution partial is: start app1 ( usb...flash...        SoftwareReset(void) )

init processor test:

if( ( *(( unsigned long*)&MEMBASE_32 + 0)) == 0xFFFFFFFF){ // area app2

         PE_low_level_init(); <----not init

        main_run ();
}
JumpToUserApplication( ( *(( unsigned long*)&MEMBASE_32 + 0)) ,(*(( unsigned long*)&MEMBASE_32 + 0x01 )) );

problems for my is USB not RE-Start

thanks,

Carlos

0 Kudos
1,120 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

For the USB module was initializated at APP1, while In APP2, it also need to re-initialize USB module again.

The USB stack related function also need be included in APP2 project.

And customer need to check the system core and USB clock frequency in APP2, if the clock frequency as setting expected. Customer could use PTC3 CLKOUT to check system clock.

It also need to add USB related ISR in APP2 vector table.

Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,120 Views
CCandido
Contributor V

Hi,

My arm it MK20DX256,

app starup it auxiliar, the with usb driver, CMD to my swap or goto App, not use pin signal.

Thanks

Carlos.

0 Kudos
1,120 Views
CCandido
Contributor V

Hi,

my test a moment

  ram_vector (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x000001FF   // add

__attribute__ ((section (".ram_vector"))) const   tVectorTable __vect_table_ram;  // add

copy vector table to ram in APP1 ok

for(i=0 ; i<0x1BC; i++){
*((volatile unsigned long*)&__vect_table_ram + i )= ( *((volatile unsigned long*)&__vect_table + i ));
  }


SCB_VTOR = (uint32) &__vect_table_ram;  // set vector ram.

my case, fixed App2 vector 0x8000 ( program 8400>)

int App1, read  8000 + 8004

JumpToUserApplication(8000,8004); jmp  App2, or App_on_RAM

or, jmp App1.

thanks,

Carlos.

0 Kudos
1,120 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

From above description, the APP2 uses the different vector table with APP1, right?

If so, before jump to the APP2, it need redirect the vector table of APP2 related interrupt vector location (0x8000).

After finish APP2 vector table redirection, the application code could jump from APP1 to APP2.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,120 Views
CCandido
Contributor V

hi,

new test without ( ISR ) goto App2 = ok

test program with ( ISR = ON ,usb,timer,...) goto App2 = error

with __DI()  or __EI() 

Vector direct 0x8000 Flash or 0x1FFF8000 RAM, problems reset processor.

my test  (tIsrFunc)&app2_entry           /* 0x6E  saved App_entry function here ( goto BASE + 0x6E direct functino entry  ) 

thanks,

Carlos.

0 Kudos
1,119 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

In APP1, please doesn't copy interrupt vector table to SRAM and use the vector table at Flash memory 0x00000000.

Please doesn't redirect the vector table to SRAM in APP1.

Then after after load APP2 and jump to APP2, please copy APP2 vector table to SRAM and redirect the vector table to RAM address 0x1FFF8000 by changing the SCB_VTOR register.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,120 Views
CCandido
Contributor V

Hi Hui_Ma,

See code source, other code normal error, I creat simple test = error , when use ISR in App2.

//------------------------------------------------------------

void main_run (void){   // App1
uint32 i=0,x=0,_addr, _stackp;
byte asc=0;
BL_FLASH1 = FLASH1_Init( &OpStatus); // init Flash

WAIT1_Waitms(1);
                       while( asc != 'N'){               // wait end table

UTIL1_strcpy(in_buffer,46,app2_hex[x++] );  // Copy App2 ( Hex, charged table )
asc = in_buffer[0];
if( asc != 'N' ){
convert_line_hex();  // convert hex ascii to Hex value
status_flash_busy();
i = FLASH1_Write( BL_FLASH1, my_hexline.HEX_linedata,

                               my_hexline.hex_addr,

                                 my_hexline.hex_count);            //program App2 in flash memory
WAIT1_Waitms(5);
status_flash_busy();
}

}
                     x=0;

                          for(;;){


                               if( x == 9){ // insert value 9, to goto App2


                             _stackp = ( *(( unsigned long*)&MEMBASE + 0));        /// BASE = 0x8000
              _addr = ( *(( unsigned long*)&MEMBASE + 0x6E));    // BASE + 0x6E = address direct entry pointer main_run
                              // SCB_VTOR = 0x8000; // vector in fash_0x8000
                                 reloked_vector(); // vector in ram_0x1FFF8000
                                JumpToUserApplication( _stackp , _addr );
                           x=0;
                          }

                 WAIT1_Waitms(1000);
               LED1_Neg();

                }

}

//----------------------------------------------------- see debug

Isr_error app2.png

thanks,

Carlos

0 Kudos
1,120 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

The below code doesn't copy APP2 vector table from 0x8000 to SRAM 0x1FFF8000.

When the interrupt happens in APP2, the SRAM 0x1FFF8000 without correct vector table to load related interrupt service routine.

   if( x == 9){ // insert value 9, to goto App2


                             _stackp = ( *(( unsigned long*)&MEMBASE + 0));        /// BASE = 0x8000
              _addr = ( *(( unsigned long*)&MEMBASE + 0x6E));    // BASE + 0x6E = address direct entry pointer main_run
                              // SCB_VTOR = 0x8000; // vector in fash_0x8000
                                 reloked_vector(); // vector in ram_0x1FFF8000
                                JumpToUserApplication( _stackp , _addr );


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,120 Views
CCandido
Contributor V

Hi Hui_Ma,

please open code source see code:

                               // SCB_VTOR = 0x8000; // vector in fash_0x8000
                                 reloked_vector(); // vector in ram_0x1FFF8000

//------------------------------------------------------------------

#define MEMBASE *(( unsigned long*)0x00008000)


void reloked_vector (void){ // <------ copy vector 0x8000 to 0x1FFF8000
int i;
                  for(i=0 ; i< 0x6E; i++){ 

*((volatile unsigned long*)(&__vect_table_ram) + i )= ( *(( unsigned long*)&MEMBASE + i ));
           }
                                    SCB_VTOR = (uint32)( &__vect_table_ram);
}
//-------------------------------------------------------------------

vector_reloked.png

thanks,

Carlos.

0 Kudos
1,120 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Could you let us know which chip you are using(part number)?

In general, if there with two application, there could use a pin input signal to determine which application to execute.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos