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
• 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 :
{ INPUT_SECTION_FLAGS (SHF_PPC_VLE)
*(.text.startup)
*(.text)
*(.text.*)
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.
This resolved my issue.
The example code (bare metal) package downloaded from official site (https://www.nxp.com/downloads/en/board-support-packages/DEVKIT-MPC5748G-QSP.zip) should be updated according to the instructions. The code in the package can't be run in S32DS 2017 if failed to notice this.
Xuewei,
Thank you for your report!
I've contacted responsible team to fix this issue.
Regards,
Stan