HOWTO: Migrate project created in S32DS Power v1.x into v1.2+

Document created by stanish Employee on Sep 26, 2017Last modified by stanish Employee on Oct 11, 2017
Version 7Show Document
  • View in full screen mode

Bare-metal project migration from an older version of S32DS into a newer one is typically pretty straightforward.

Despite of that the migration into S32DS Power v1.2+ requires more attention due the fact it includes a new version of GCC compiler + GCC binutils (see the GCC release notes - here). This version of GCC is now fully EABI VLE compliant  (in contrast to previous versions of S32DS Power  v1.0 and v1.1) and it has several consequences for the project migration

  • object code/libraries are not backward compatible - if you have an object code/library built by a previous version of S32DS Power v1.x you have to rebuild it in new S32DS v1.2+ compiler.
  • default compiler setup has changed - bitfield access is not volatile anymore. This may have a impact on a peripheral registers access via standard header file bitfield structures. Such access may require a specific load/store instruction e.g. "stw" but if compiler is allowed to optimize the access (e.g. use "stb" instead of "stw") an exception may occur. Therefore it is recommended to add  -fstrict-volatile-bitfields  flag into your project GCC compiler settings:


  • linker script file (*.ld) requires some additional linker sections - Linker script file in S32DS Power v1.2+ must contain the sections below:

•  KEEP for .init and .fini sections

.ctors and .dtors sections

.preinit array .init array and .fini array sections


If the linker script file is not updated and the linker warnings are ignored you may experience an exception at the runtime - typically when __init routine is executed. Missing .init section causes that an invalid instructions is fetched and causes the core IVOR exception.



There is an easy way how to automatically fix the linker script file issue directly in IDE.

If you import and build an older project in S32DS Power v1.2 the linker issues these linker script related warnings:


Right click on the warning and select Quick Fix:


Select "Add missed section in linker script"  + "Select All" and press "Finish".

Repeat these steps until all the linker script warnings disappears.



If you don't use IDE project you have to add the sections below into your linker script manually:

.text_vle : 
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(16);
} > m_text /* that will force pick VLE .text sections */

.ctors :
__CTOR_LIST__ = .;
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */

KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */

KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__CTOR_END__ = .;
} > m_text

.dtors :
__DTOR_LIST__ = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__DTOR_END__ = .;
} > m_text

.preinit_array :
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > m_text

.init_array :
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} > m_text

.fini_array :
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} > m_text


This may help you to avoid time consuming debugging to figure out the root cause of the core exception. 

1 person found this helpful