Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Help Importing Existing IAR Project to SES / GCC

Hi,

I am attempting to import an existing IAR project to SES / GCC and am having some trouble. I recently joined the project team and we are making an effort to switch from the paid IAR license that our contracting firmware group has used to a free IDE/toolchain in order to take over development.

It began as a ble_app_hrs example and dfu secure_bootloader example was later incorporated, but it has come a long way.

I am not yet familiar with IAR so I am having some trouble translating the IAR .icf linker files, macros, and preprocessor definitions to work with the Segger internal GCC toolchain. I have been looking for any guides or assistance that I can find, but there doesn't seem to be much on the subject.

I followed the Segger guide for porting projects from IAR (link) but it is not specific to Nordic or comprehensive, and I have had difficulty at the troubleshooting memory linker script section. I also referenced the Nordic guide for Importing from Keil but it seems a bit out of date. After creating a flash_placement.xml file based off the original SES examples' flash_placement.xml files, and then changing the FLASH and RAM section placement macros and Heap/Stack size in runtime memory area settings I am still unable to compile and am seeing the following errors:

Building ‘neop_hat_main_s132_with_dfu_pca10040’ from solution ‘project’ in configuration ‘nrf52832_xxaa_s132 Internal’
...
Output/nrf52832_xxaa_s132 Internal/Exe/neop_hat_main_s132_with_dfu_pca10040.elf does not exist.
Generating linker script ‘neop_hat_main_s132_with_dfu_pca10040.ld’
Linking neop_hat_main_s132_with_dfu_pca10040.elf
Output/nrf52832_xxaa_s132 Internal/Exe/neop_hat_main_s132_with_dfu_pca10040.elf section `.init' will not fit in region `UNPLACED_SECTIONS'
region `UNPLACED_SECTIONS' overflowed by 16688 bytes
cannot find entry symbol reset_handler; not setting start address
Output/neop_hat_main_s132_with_dfu_pca10040 nrf52832_xxaa_s132 Internal/Obj/ses_startup_nrf52.o: in function `_vectors':
(.vectors+0x0): undefined reference to `__stack_end__'
(.vectors+0x4): undefined reference to `Reset_Handler'
Output/neop_hat_main_s132_with_dfu_pca10040 nrf52832_xxaa_s132 Internal/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x0): undefined reference to `__start_sdh_stack_observers'
Output/neop_hat_main_s132_with_dfu_pca10040 nrf52832_xxaa_s132 Internal/Obj/nrf_sdh.o:(.rodata.sdh_stack_observers+0x4): undefined reference to `__stop_sdh_stack_observers'
Post-build command
\GIT\Neopenda\Firmware\neop_hat_main\pca10040\s132_with_dfu\iar>echo Creating folder for DFU packages if not exist... 1>.\..\..\..\tools\"\postBuildLog.txt
\GIT\Neopenda\Firmware\neop_hat_main\pca10040\s132_with_dfu\iar>if not exist ".\..\..\..\tools\"\DFU_Packages" mkdir .\..\..\..\tools\"\DFU_Packages
Build failed

So my questions are:

  1. Is there anything obvious I am doing wrong based on error output?
  2. Which startup files should I be including? I added thumb_crt0.s as the Keil importing guide instructed - is this correct? Should I also add ses_startup_nrf_common.s (it is in the ble_app_hrs example but causes more errors when I include it). Anything else?
  3. Is there any more comprehensive guide or any other useful information available on converting the IAR linker scripts correctly to corresponding GCC linker scripts and allocating memory correctly in the flash_placement.xml format?
  4. Am I going about this the right way or is there anything else I should be considering or referencing at this point in order to successfully migrate the project?

I am aware that importing existing IAR projects can be challenging. If there is anything else that can help us do so I would like to pursue it. If however, the recommendation is that this is a mess and to stay with IAR at all costs we would consider that as well.

Thanks!

Parents
  • Thanks for all the input!  your example files are particularly helpful, and your comment makes for a pretty good basic migration guide. I see some of the steps/checks that I was missing in my first attempt. I did have the same initial thought.. to take a standard project and directly compare differences in unaltered linker files, then compare with linker files from our existing IAR project and attempt the migration. Unfortunately upon going through the differences it quickly turned into a more complicated endeavor than I was hoping it would be.

    Ultimately we decided to stick with IAR for the time being as there seems to be too much risk in changing at our current stage of development. I will be coming back to this however if we have time later on when development is less active and transitioning is less risky.

Reply
  • Thanks for all the input!  your example files are particularly helpful, and your comment makes for a pretty good basic migration guide. I see some of the steps/checks that I was missing in my first attempt. I did have the same initial thought.. to take a standard project and directly compare differences in unaltered linker files, then compare with linker files from our existing IAR project and attempt the migration. Unfortunately upon going through the differences it quickly turned into a more complicated endeavor than I was hoping it would be.

    Ultimately we decided to stick with IAR for the time being as there seems to be too much risk in changing at our current stage of development. I will be coming back to this however if we have time later on when development is less active and transitioning is less risky.

Children
  • Thanks for feedback, and good luck. As an aside, one of the most tedious parts in SES is to get the include files correct, and sometimes it's easier to just include all header file paths in the project and edit them later to remove those unneeded paths. I added this script to another response recently; it generates either absolute paths or relative paths., the latter in case your project is not in the Nordic tree. Some of the obvious include directories not required can easily be removed. Windows 10 I'm afraid.

    rem: Project Header File Directory Listing Utility
    rem:
    rem: Author - Hugh
    rem:
    rem: "find" can get lost, use specific path
    SET path=C:\Windows\System32\;%path%
    rem:
    rem: Setup output file and initialise it
    set OutputFile=HeaderIncludeList.txt
    echo Project root directory                 > %OutputFile%
    echo ======================                >> %OutputFile%
    cd                                         >> %OutputFile%
    echo -                                     >> %OutputFile%
    echo Header file Include Directories       >> %OutputFile%
    echo ===============================       >> %OutputFile%
    rem: Catalogue all header file directories
    rem:  - leave out "File(s)" total size
    rem:
    dir *.h /O N /S | find "Directory"         >> %OutputFile%
    rem:
    rem: Now edit to replace " Directory of D:\blahblah" with "D:\blahblah"
    @echo off
    rem: Begin localization of environment changes:
    setlocal
    rem: optionally use relative path or absolute path; first is relative second is absolute
    rem: set "Search= Directory of D:\Projects\Nordic\NRF5-SDK-15.2.0.xpi"
    rem: set "Replace=../../../../../../"
    set "Search= Directory of "
    set "Replace="
    set "TempFile=Temp-99.txt"
    (for /f "delims=" %%i in (%OutputFile%) do (
        set "line=%%i"
        setlocal ENABLEDELAYEDEXPANSION
        set "line=!line:%Search%=%Replace%!"
        echo(!line!
        endlocal)
    )>"%TempFile%"
    rem: Update output file
    if exist %OutputFile% del %OutputFile%
    if exist %TempFile% rename %TempFile% %OutputFile%

Related