This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Compiler error when migrating to SES 3 and SDK14

Hello, I'm practicing this blog; Segger Embedded Studio - A Cross Platform IDE

on the following environment.

  • 64-bit Windows 10 desktop

  • SEGGER J-Link 6.16h

  • 64-bit SEGGER Embedded Studio (SES) 3.26

  • PCA10040 v1.1.1

  • nRF5_SDK_14.0.0_3bcc1f7

  • imported Keil MDK 5 project using ble_app_cts_c example

The blog showed several steps.

  • Importing a Keil uVision project

  • Nuances

  • Adding nRF5 MDK Files

  • Peer Manager/Flash Data Storage

  • Building

and more. I have used ble_app_cts_c example instead of the beacon example.

SESOpt

I have tried until Peer Manager/Flash Data Storage.

Also, I have configured the compiler further like this.

Option0

I chose GNU11.

However, compared to Keil MDK 5 that it was compiled and build successfully, I observed two compiler errors.

- When configured to GCC; variably modified '_do_assert' at file scope

Compile Error 0

// In app_util.h
/**@brief Macro for doing static (i.e. compile time) assertion.
*
* @note If the EXPR isn't resolvable, then the error message won't be shown.
* @note The output of STATIC_ASSERT will be different across different compilers.
*
* @param[in] EXPR Constant expression to be verified.
* @hideinitializer
*/
#define STATIC_ASSERT(EXPR) \
    extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]

- When configured to Clang; unknown register name 'vfpcc' in asm

Clang Config

Compile Error 1

#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) /* in cmsis_gcc.h*/
  /* Empty asm statement works as a scheduling barrier */
  __ASM volatile ("");
  __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
  __ASM volatile ("");
#endif

Surprisingly, looks like I'm the only person who had this type of trouble while migrating to SES. :(

  • Are there extra configurations needed to solve these compile errors?

  • Additionally, is it impossible to use Clang?

  • Lastly, I use STM32 boards with SES. The blog tells me to modify the thumb_crt0.s file.

I haven't used that file when I was working with STM32 boards.

Then this modification won't affect other projects, right?

/*************************************************************************************/

Edited: 7, Sept. 2017

<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
  <MemorySegment name="$(FLASH_NAME:FLASH)">
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
    <ProgramSection alignment="4" load="Yes" name=".init" />
    <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
    <ProgramSection alignment="4" load="Yes" name=".text" />
    <ProgramSection alignment="4" load="Yes" name=".dtors" />
    <ProgramSection alignment="4" load="Yes" name=".ctors" />
    <ProgramSection alignment="4" load="Yes" name=".rodata" />
    <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
    <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
    <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
    <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
    <ProgramSection alignment="4" keep="Yes" load="Yes" runin=".fs_data_run" name=".fs_data" />
  </MemorySegment>
  <MemorySegment name="$(RAM_NAME:RAM);SRAM">
    <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
    <ProgramSection alignment="4" load="No" name=".fast_run" />
    <ProgramSection alignment="4" load="No" name=".data_run" />
    <ProgramSection alignment="4" load="No" name=".tdata_run" />
    <ProgramSection alignment="4" load="No" keep="Yes" name=".fs_data_run" address_symbol="__start_fs_data" end_symbol="__stop_fs_data" />
    <ProgramSection alignment="4" load="No" name=".bss" />
    <ProgramSection alignment="4" load="No" name=".tbss" />
    <ProgramSection alignment="4" load="No" name=".non_init" />
    <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
    <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
    <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
  </MemorySegment>
  <MemorySegment name="$(FLASH2_NAME:FLASH2)">
    <ProgramSection alignment="4" load="Yes" name=".text2" />
    <ProgramSection alignment="4" load="Yes" name=".rodata2" />
    <ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
  </MemorySegment>
  <MemorySegment name="$(RAM2_NAME:RAM2)">
    <ProgramSection alignment="4" load="No" name=".data2_run" />
    <ProgramSection alignment="4" load="No" name=".bss2" />
  </MemorySegment>
</Root>

This is the content of the flash_placement.xml file.

I think I have to edit the flash_placement.xml due to the following error message;

ERR

elf section `.log_dynamic_data' will not fit in region `UNPLACED_SECTIONS'
undefined reference to __stop_log_const_data
undefined reference to __start_log_const_data
undefined reference to __start_log_dynamic_data

I think these fields should be written in the XML file. However, I don't know how and what specifications are needed.

Did you add something in the XML file, @Joakim?

Or do I need to remove a preprocessor?

-Best Regards

  • Hi MANGO! I do get the same error as you do, and I will get back to you as soon as I have a solution.

  • Hi, Joakim. What a surprise! Take your time, please.

  • Hi MANGO!

    Sorry for the delayed response. I can confirm that we see the same error as you do, and we are working on a fix for it.

    In the meanwhile you can try to change the following in app_util.h:

    #define STATIC_ASSERT(EXPR) \
        extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    

    to:

    #define STATIC_ASSERT(EXPR) \
        // extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    

    This should should remove the error you are seeing, and can be used as temporary fix. It's not recommended to do so, but for testing purposes it should be fine.


    EDIT: 06.09.17

    You can disregard the above. Regarding the variably modified '_do_assert' at file scope error when using GCC as compiler:
    In the file app_util.h, add this workaround at aprox. line 90:

    #if defined(__SES_ARM) && defined(__GNUC__)
    #undef offsetof 
    #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
    #endif
    

    Your code should look something like this:

    enum
    {
        UNIT_0_625_MS = 625,        /**< Number of microseconds in 0.625 milliseconds. */
        UNIT_1_25_MS  = 1250,       /**< Number of microseconds in 1.25 milliseconds. */
        UNIT_10_MS    = 10000       /**< Number of microseconds in 10 milliseconds. */
    };
    
    #if defined(__SES_ARM) && defined(__GNUC__)
    #undef offsetof 
    #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
    #endif
    
    /**@brief Implementation specific macro for delayed macro expansion used in string concatenation
    *
    * @param[in]   lhs   Left hand side in concatenation
    * @param[in]   rhs   Right hand side in concatenation
    */
    #define STRING_CONCATENATE_IMPL(lhs, rhs) lhs ## rhs
    

    When following the blog-post on DevZone and applying this workaround, you should be able to make SES work with SDK 14.

    flash_placement.xml

    Best regards,
    Joakim.

  • Hi, Joakim.

    • The above error was thrown from GCC. Did you check the error from Clang and a solution for it?

    • Also, can you help me with my original question which was related to thumb_crt0.s?

    • Lastly, this was found from nRF5_SDK_14.0.0_3bcc1f7. When releasing SDK 14.1, can the dev-team provide a fix to solve the above error?

    My team is trying to migrate to SES from Keil MDK 5.

    Since Keil doesn't throw compiler errors when using the current SDK, I think we can wait until the update.

    -Best Regards

  • Hi MANGO.

    • I've been looking into your questions and it seems we are not supporting Clang out-of-the-box. My settings when using SES is; (gcc, gnu99, gnu++98)

    • Regarding the thumb_crt0.s, it should not affect other projects when modifying the file.

    • I can not promise anything for future releases, because I don't know. The problems has been reported internally and I will bring you up to speed as soon as I know anything.
      Best regards,
      Joakim.

Related