AnsweredAssumed Answered

Program not reaching ResetISR, appears to be stuck in BOOTROM

Question asked by Craig Cobabe on May 29, 2019
Latest reply on Jun 25, 2019 by Craig Cobabe

I am using the imxrt1060 evk with MCUXpresso (v10.3.1 [Build 2233] [2019-02-20]) and MQX. I'm attempting to build my project with C++ using Newlib-nano.

 

Starting a debug session does not reach my code. It doesn't even reach the entry point ResetISR. When I stop the debugger, the PC is in the same region, but not exactly the same location. Examples:

pc    0x2173a6    Program Counter (r15)

pc    0x20e362    Program Counter (r15)

I checked the reference manual and this is the ROMCP.

 

FYI, this same board works with other projects, and this project does not work on other boards. So there is definitely a project specific issue that I cannot figure out.

 

Here are the steps I've taken:

  1.  I have been able to build and start debugging the SDK example "evkmimxrt1060_iled_blinky_SWO " after following a similar process to below. I added a cpp file and it built, ran as expected.
  2. Changed project nature to C++ by doing New > Other > Convert to a C/C++ Project (Adds C/C++ Project Nature)
    1. note: at this point the program makes it to ResetISR. From here to get the project to build there are a lot of changes and I don't know how to narrow down the issue.
  3. Changed all libraries (bsp,psp,etc)  used in the same fashion
  4. Ensured that all libraries and project are building with Newlib-nano libraries
  5. Clean rebuild everything
    1. Had to supply system call definitions for _exit, _kill, _getpid, _write, _close, _fstat, _isatty, _lseek, _read. They are all dummy implementations and have infinite loops for now. Does this exist already?
    2. Had to include each library several times for it to find symbols
    3. Defined the same symbols for C++ as with C. The _REDLIB_ was replaced with _NEWLIB_
  6. Linker file(s)
    1. Tried using the same linker files with the Redlib libraries replaced by Newlib libraries.
    2. Tried instead using the "Managed linker script" option.
    3. Diff'ing the generated linker files, the linker files that worked with my previous C project config and also with the evkmimxrt1060_iled_blinky_SWO didn't shed any light.
  7. Made sure that ResetISR is extern C'd. I found extern "C" in the startup code already so I assume any C/C++ linkage issues have already been resolved, plus again I got it working with an example project.
  8. I've tried on a different eval board, same result.
  9. FWIW, the boot dip switch SW7 setting is off-off-on-off (1-2-3-4).

 

Linker file sections that changed from C to C++ setups (if the entire contents are needed I can add them):

Previous C Libraries:

GROUP (
  "libcr_semihost_nf.a"
  "libcr_c.a"
  "libcr_eabihelpers.a"
)

New C++ Config:

GROUP (
  "libgcc.a"
  "libc_nano.a"
  "libstdc++_nano.a"
  "libm.a"
  "crti.o"
  "crtn.o"
  "crtbegin.o"
  "crtend.o"
  "libcr_newlib_none.a"
)

 

***** Find the added section wrapped in my comments

.text : ALIGN(4)
    {
        *(KERNEL)
       *(.text*)
       *(.rodata .rodata.* .constdata .constdata.*)
       . = ALIGN(4);

/* START OF NEW SECTION FOR C++ */
            /* C++ constructors etc */
            . = ALIGN(4);
            KEEP(*(.init))
            
            . = ALIGN(4);
            __preinit_array_start = .;
            KEEP (*(.preinit_array))
            __preinit_array_end = .;
            
            . = ALIGN(4);
            __init_array_start = .;
            KEEP (*(SORT(.init_array.*)))
            KEEP (*(.init_array))
            __init_array_end = .;
            
            KEEP(*(.fini));
            
            . = ALIGN(4);
            KEEP (*crtbegin.o(.ctors))
            KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
            KEEP (*(SORT(.ctors.*)))
            KEEP (*crtend.o(.ctors))
            
            . = ALIGN(4);
            KEEP (*crtbegin.o(.dtors))
            KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
            KEEP (*(SORT(.dtors.*)))
            KEEP (*crtend.o(.dtors))
            . = ALIGN(4);
            /* End C++ */

/* END OF NEW SECTION FOR C++ */
    } > BOARD_FLASH

Outcomes