TMS570: more testing including combination with HalCoGen files for direct RTEMS startup and VFP

Pavel Pisa pisa at cmp.felk.cvut.cz
Sat Nov 28 10:24:59 UTC 2015


Hello all,

I have spent some time to investigate why running RTEMS from external
SDRAM memory with enabled VFP fails but have not found a cause.
May it be that it is instability, bus timeout due to slow accesses
or problem with POM. But I still hope that it is problem on our side.

I have increased stacks sizes to be sure that it is not a problem cause.
VFP build stores little more registers on stack so I have that suspect.
I try to check actual interrupt stack usage by checking memory content
and if the stacks are tight I send patch. Changes used to increase stack
are at the end of this e-mail.

I have than switched to tms570ls3137_hdk_intram link variant testing.
This seems to be OK with VFP and POM (stack still increased).
But because of space constrains only minimal tests fit into memory.

I have updated our HW setup dummy application to new HalCoGen version
and tested it in Ti CSS build

https://github.com/hornmich/tms570ls3137-hdk-sdram/tree/master/SDRAM_SCI_configuration

Then I have generated output for GCC toolchain and combined and tested
it part by part in tms570ls3137_hdk_intram link variant. Only test if
internal SRAM has been left disabled at the end. I have used OMK
test application which replaced minimal bsp_start_hook_0() and bsp_start_hook_1()
provided by TMS570 RTEMS BSP by varinat with included HalCoGen code which
uses complete set of other HalCoGen files and functions.

Then I have forced link of resulting binary against linkcmds.tms570ls3137_hdk
and used our build of OpenOCD with TMS570 workarounds and F021 support
to Flash result to address 0. Code runs without any problem, RTEMS monitor
and test task run with printf run as expected. I have decided to analyze
if POM overlay is skipped is application starts from address 0x00000000
but condition to skip POM overlay has been optimized out for -O2 build
variant. But POM overlays area from byte 64 to 128 which is not used
during RTEMS run after startup so the POM mapping has no influence there.
It could make problem with reset processing.

I have fight for while with GCC optimization to force it recognize
that linker provided symbol is set to 0. The problem is that new
C standard directly specifies that address of any legal global object
declared in C cannot be equivalent to 0 (NULL). (optimizes checks
for global variabless adress to be zero out). When object/symbol
is placed at address 0 then behavior is undeffined. I have been avare
of this standard change but hoped that RTEMS

  tms570/rtem~hared/include/linker-symbols.h

combined with cast to (uintptr_t) whould be enough.
It is not.

  #define LINKER_SYMBOL(sym) extern char sym [];

Symbol address is delivered as address of start of array
and GCC utilizes full freedom given by standard.
So comparison of any symbol provided by this header
to zero/non zero can be optimized out.

I have come with next workaround to ensure that GCC
cannot predict that compared value is equivalent
to address of static/global object.

-  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
+  asm volatile ("\n": "=r" (need_remap_int): "r" (need_remap_ptr));
+  if ( need_remap_int != 0 ) {

Code generated with this change is correct and really
switches POM off for application located at start
of memory map. I prepare patch for this and run more tests.

Observed problem can affect much more BSPs and places
in RTEMS. Usage of all linker symbols in RTEMS should
be checked.

I have not observed any problems is this flash builds.
Intram builds are only limited by size (insufficient
resources reported) but else seems to be stable too.

We are able to provide HalCoGen, RTEMS mix now.
Licensing seems to be OK (big thanks to Ti for the
change which we debated with them two years ago).

If there are resources we are able to start work
on decent startup which could use sets of pins
per peripheral configurable/selectable per board
which allows to have single code base for more
boards. Other option is to have/include whole set
of generated HalCoGen files for each board.

The complete patch to prevent unintended GCC optimization

diff --git a/c/src/lib/libbsp/arm/tms570/startup/bspstart.c b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
index b7e2b62..2aa43f5 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/tms570/startup/bspstart.c
@@ -32,6 +32,9 @@
 
 void bsp_start( void )
 {
+  void *need_remap_ptr = bsp_start_vector_table_begin;
+  unsigned int need_remap_int;
+
   #if BYTE_ORDER == BIG_ENDIAN
     /*
      * If CPU is big endian (TMS570 family variant)
@@ -67,7 +70,8 @@ void bsp_start( void )
    * So use of POM to replace jumps to vectors target
    * addresses seems to be the best option.
    */
-  if ( (uintptr_t)bsp_start_vector_table_begin != 0 ) {
+  asm volatile ("\n": "=r" (need_remap_int): "r" (need_remap_ptr));
+  if ( need_remap_int != 0 ) {
     tms570_pom_remap();
   }
 


Patches to increase stacks sizes to be on safe side

diff --git a/c/src/lib/libbsp/arm/tms570/configure.ac b/c/src/lib/libbsp/arm/tms570/configure.ac
index e06d4e4..075c8cb 100644
--- a/c/src/lib/libbsp/arm/tms570/configure.ac
+++ b/c/src/lib/libbsp/arm/tms570/configure.ac
@@ -32,7 +32,7 @@ RTEMS_BSPOPTS_HELP([CONSOLE_USE_INTERRUPTS],
 RTEMS_BSPOPTS_SET([ARM_TMS570LS3137],[*],[0])
 RTEMS_BSPOPTS_HELP([ARM_TMS570LS3137],[target used for identify TMS570LS3137 board])
 
-RTEMS_BSPOPTS_SET([BSP_MINIMUM_TASK_STACK_SIZE],[*],[1024])
+RTEMS_BSPOPTS_SET([BSP_MINIMUM_TASK_STACK_SIZE],[*],[2048])
 RTEMS_BSPOPTS_HELP([BSP_MINIMUM_TASK_STACK_SIZE],[Suggested minimum task stack
 			size in bytes])
 
diff --git a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk 
b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk
index a32562f..61828b1 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk
+++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk
@@ -24,7 +24,9 @@ REGION_ALIAS ("REGION_STACK", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE_LOAD", RAM_INT);
 
-bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
+bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
+bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
+bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 2048;
 bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
 
 bsp_int_vec_overlay_start = ORIGIN(RAM_INT_VEC);
diff --git a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram 
b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram
index 7cb683d..5f0d232 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram
+++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_intram
@@ -24,7 +24,9 @@ REGION_ALIAS ("REGION_STACK", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE_LOAD", RAM_INT);
 
-bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
+bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
+bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
+bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 2048;
 bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
 
 bsp_int_vec_overlay_start = ORIGIN(RAM_INT_VEC);
diff --git a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram 
b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram
index 0117410..f3eb67f 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram
+++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_sdram
@@ -24,7 +24,9 @@ REGION_ALIAS ("REGION_STACK", RAM_EXT);
 REGION_ALIAS ("REGION_NOCACHE", RAM_EXT);
 REGION_ALIAS ("REGION_NOCACHE_LOAD", RAM_EXT);
 
-bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
+bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
+bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
+bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 2048;
 bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
 
 bsp_int_vec_overlay_start = ORIGIN(RAM_INT_VEC);
diff --git a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_with_loader 
b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_with_loader
index 940f303..c02f0f9 100644
--- a/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_with_loader
+++ b/c/src/lib/libbsp/arm/tms570/startup/linkcmds.tms570ls3137_hdk_with_loader
@@ -25,7 +25,9 @@ REGION_ALIAS ("REGION_STACK", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE", RAM_INT);
 REGION_ALIAS ("REGION_NOCACHE_LOAD", RAM_INT);
 
-bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
+bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
+bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
+bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 2048;
 bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
 
 bsp_int_vec_overlay_start = ORIGIN(RAM_INT_VEC);


More information about the devel mailing list