Search code examples
armkeilrtosucos

Why Keil Uvision 5 Does Not Support ARM Compiler Specific __isb() Function


I'm using Keil MDK-ARM Professional Version 5.38.0.0 which is set to ARM compiler version 6.19, and I trying to setup an uC/OS-iii project, everything goes fine until the last part where in the os_cpu.h file is a macro-type function that call __isb() function:

#define  OS_TASK_SW_SYNC()          __isb(0xF)

and the OS_TASK_SW_SYNC() function also called inside the os_core.c, now the problem is the compiler raised the following error and linking stage will be terminated:

.\Objects\main.axf: Error: L6218E: Undefined symbol __isb (referred from os_core.o).

any help to overcome this issue?

Here is the complete build output:

Rebuild started: Project: main
*** Using Compiler 'V6.19', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'
Rebuild target 'STM32F103'
compiling main.c...
compiling os_core.c...
compiling os_var.c...
compiling os_cfg_app.c...
compiling os_dbg.c...
compiling os_flag.c...
compiling os_mem.c...
compiling os_msg.c...
compiling os_mutex.c...
compiling os_prio.c...
compiling os_q.c...
compiling os_sem.c...
compiling os_stat.c...
compiling os_task.c...
compiling os_tick.c...
compiling os_time.c...
compiling os_tmr.c...
compiling os_app_hooks.c...
compiling os_cpu_c.c...
assembling os_cpu_a.asm...
assembling cpu_a.asm...
compiling cpu_core.c...
compiling cpu_c.c...
compiling lib_ascii.c...
compiling lib_math.c...
compiling lib_mem.c...
compiling lib_str.c...
assembling startup_stm32f10x_md.s...
compiling system_stm32f10x.c...
linking...
.\Objects\main.axf: Error: L6218E: Undefined symbol __isb (referred from os_core.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 1 error messages.
".\Objects\main.axf" - 1 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:05

Solution

  • ARM Compiler v6 is LLVM/clang based and is not 100% compatible with all features of ARM's earlier proprietary compiler technology (ARMCC), or in some cases - such as this - just has different symbol names for the same thing.

    One solution is to switch to ARMCC v5 (included in the MDK-ARM suite as an option). However that is largely unnecessary, even if you do not wish to modify the third-party code there is compatibility support, as described in the ARM Compiler Migration and Compatibility Guide.

    In this case for example __isb() is defined as a macro in arm_acle.h. You can include that globally by using a forced include (--include=arm_acle.h).

    If you consider that too heavyweight, you could simply define the macro on the command line to avoid having to modify the code or force an include which may define other macros you don't want:

    -D"__isb(i)=__builtin_arm_isb(i)"
    

    The migration guide covers a number of other issues you are likely to encounter too. I suggest that you might want to add:

    --include=arm_acle.h --include=arm_compat.h
    

    to preempt most similar issues.