This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

static data in position independent code on arm

Hello everyone,

I'm a student from germany and am trying to implement position independency (ram and rom) on a STM32F103VF (Cortex™-M3 with MPU), programmed with Keil µVision V4 (full version). I want to write an OS that calls postinstalled Apps that are programed in other µVision projects.

The calling code int the OS looks like this:

  tOSInitFunc initFunc = (tOSInitFunc) (APP_LOCATION);
  thisSb = OS_GetSb();
  OS_SetSb( APP_SB );
  workFunc = (tOSFunc) initFunc();
  OS_SetSb( thisSb );

where

 OS_GetSb( void )

and

 OS_SetSb( u32 )

get and set the static base register r9.

 initFunc( void )

shall initialize the static data and return the adress of a worker function.

My problem is with the initialization part.

Is it possible to adapt the startup code (startup_stm32f10x_hd.s) in the way it uses position independency for initializing my static data? I don't think its that easy to just call __main in the startupfile, is it? Do I have to adapt a __scatterload-function? Is there any useful documentation about this problem (I'm searching for about 4 days now...).

I'm no pro at all and hope my question is not that stupid...

thanks for helping