Porting KL25Z from gcc-arm-embedded to codesourcery failed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Porting KL25Z from gcc-arm-embedded to codesourcery failed

1,436 Views
kai_liu
Senior Contributor I

The original project comes from Andrew Payne. The code is built under gcc-arm-embedded under Linux. Now I am trying to port it to Codesourcery arm-none-eabi-gcc under Windows, because this toolchain is used by Arduino/Maple in open source projects.

 

After checking differences between two gccs, I made some changes on makefile and mkl25z4.ld, for CFLAGS.

 

During porting project between two toolchains, I got following errors during linking:

 

D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -Wa,- adhlns=demo.lst -fmessage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -Os -I . -c demo.c D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -Wa,- adhlns=demo.lst -fmessage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -Os -I . -T mkl25z4.ld -o demo.out demo.o libbare.a libbare.a(_startup.o): In function `_reset_init': E:\labs_codesourcery_gcc_cortex_m\bare-metal-arm-master/_startup.c:307: undefined reference to `__cs3_start_c' d:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/armv 6-m\libc.a(lib_a-abort.o): In function `abort': abort.c:(.text+0xa): undefined reference to `_exit' d:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/armv 6-m\libc.a(lib_a-signalr.o): In function `_getpid_r': signalr.c:(.text+0x2): undefined reference to `_getpid' d:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/lib/armv 6-m\libc.a(lib_a-lseekr.o): In function `_lseek_r': lseekr.c:(.text+0x10): undefined reference to `_lseek' collect2: ld returned 1 exit status make: *** [demo.out] Error 1 rm demo.o

 

I believe gcc-arm-embedded and codesourcery have different approaches on startup code, interrupt and exit. For example, _start() calls main() in gcc-arm-embedded, while codesourcery uses __cs3_start_c() to call main(). But it complaints as undefined reference! And indeed this symbol is not included in any *.a file.

 

Does anyone have a complete Kinetis project for Codesourcery? Thanks in advance.

Original Attachment has been moved to: bare-metal-arm-master.zip

2 Replies

513 Views
kai_liu
Senior Contributor I

Well, it takes quite a long time to evaluate corresponding makefile/linker script.since invoking different gcc toolchains for ARM cortex-M0 are different in many ways, including:

  • -mcpu (values, some uses cortex-m0, some uses cortex-m0plus)
  • newlib in CS, nano-newlib in gcc-arm-embedded)
  • c++ handling and overhead
  • interrupt and startup code
  • more

I have tried:

  • gcc-arm-embedded (Linux)
  • gcc-arm-embedded (Windows)
  • Codesourcery 2010q1 (Windows for Arduino and Maple)
  • Codesoucery 2013 (Windows)
  • Yagarto
  • WinARM

Finally I found demos from CooCox (Eclipse based) is quite useful, it will generate code automatically. Then I check its building process and update my makefile/linker script.

You can download the attachment.

PS, the code has not verified yet (an empty main.c) . I just make sure there are no building errors/warnings from gcc.

I will update my post as soon as verification the code.

Current status:

Codesoucery G++ Lite 2010q1

make / cs-make

F:\labs_codesourcery_gcc_cortex_m\KL25Z-Demo>make all
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c startup_coide.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c syscalls.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xadc.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xcore.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xdebug.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xgpio.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xsysctl.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c xuart.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-ar -rv libbare.a startup_coide.o syscalls.o xadc.o
xcore.o xdebug.o xgpio.o xsysctl.o xuart.o
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-ar: creating libbare.a
a - startup_coide.o
a - syscalls.o
a - xadc.o
a - xcore.o
a - xdebug.o
a - xgpio.o
a - xsysctl.o
a - xuart.o
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -c main.c
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-gcc -ffunction-sections -fdata-sections -Wall -fmes
sage-length=0 -mcpu=cortex-m0 -mthumb -mfloat-abi=soft -g3 -gdwarf-2 -O0 -I . -nostartfiles -Wl,-Map=KL25Z-Demo.map -O0
-Wl,--gc-sections -L. -Wl,-Tlink.ld -g -o KL25Z-Demo.elf main.o startup_coide.o syscalls.o xadc.o xcore.o xdebug.o xgpio
.o xsysctl.o xuart.o
D:/maple-ide-0.0.12-windowsxp32/hardware/tools/arm/bin/arm-none-eabi-size KL25Z-Demo.elf
   text    data     bss     dec     hex filename
   1740       0    1104    2844     b1c KL25Z-Demo.elf
rm main.o

Teensy demostrates that K20 can be used in Arduino IDE, if this demo goes well. (Teensy works great, but standalone project IDE seems better) I will design a simple IDE with Python/wxPython, (I preferred Python than Java) with wiring C++ API.

Looking for your comments. I don't have enough motivation if it is not attractive to you guys.

513 Views
Monica
Senior Contributor III

Hello Kai,

THANKS a lot for sharing! This will help other Community members to increase their skills and build up interesting proposals like the one you came up with.

Looking forward to see you and your hard work around.

Best regards,

Monica.

0 Kudos