How to create a new target platform for Xcode?

What I am seeking to create is a target platform definition in Xcode for ARM Cortex-M microcontrollers. I have all the building blocks, with a third party IDE I can build working code out of it, I just need to package it into something Xcode can use.


Here are the steps I need to take, but have no idea how to:

  • Package the GCC ARM Embedded toolchain (contains GCC, binutils and GDB) obtained from developer.arm.com, as well as OpenOCD compiled from source, into a "toolchain" bundle that Xcode can use,
  • Define the Cortex-M target platform and populate the base SDK with some necessary files (CMSIS headers, etc)
  • Figure out a way to convince Xcode to load the program (flash the target chip) and debug target application using GDB and OpenOCD (maybe emulate what was going on with iOS? I think Xcode should still have GDB debug support)

Alterations to the procedure if necessary:

  • If Xcode no longer supports GDB, can LLDB make use of a GDB server connection provided by OpenOCD?
  • If Xcode requires LLVM compiler, and since Apple's copy of LLVM compiler can emit arm-none-eabi ELF files ("clang -target arm-none-eabi -mcpu=cortex-m3" for Cortex-M3, and "clang -target arm-none-eabi -mcpu=cortex-m4 -fpu=fpv4-sp-d16 -mfloat-abi=hard" for Cortex-M4F with hardware float point ABI works,) can Apple's copy of LLVM be directed to call the linker in the packaged GCC ARM Embedded toolchain?
  • If I cannot package an alternative toolchain, how to get the Apple linker to work here, especially how do linker scripts work? What target triplet maps to ARM EABI Mach-O?

Additional questions:

  • How does the "additional SDKs" in Xcode work? I might want to use this as a way to manage imported Keil packs (they contain not only device support files, but also memory, SFR and IRQ definition files that is useful for below.)
  • How does IDEKit work? Each project might need a few auto-generated files and I will want topresent a SFR view when debugging.

Hello maxtch,

Don't bother with any of that. If you need to do something that Xcode doesn't natively support, just use a Makefile. Xcode has decent support for Makefile-based projects. You can build, clean, and otherwise interact with it without much trouble. With a makefile, you can use whatever toolchain you want. But you still have Xcode as an editor and IDE. I build my websites using XML, XSLT, and Xcode.


The problem with trying to do any of this natively in Xcode is that it is really, really difficult. And by the time you finally get it running, Apple is going to release the next version of Xcode and everything you have done will no longer work.

How to create a new target platform for Xcode?
 
 
Q