I want to know if it is possible to program a STM32 microcontroller using Objective-C. Are there any IDE's with tools to compile directly from Objective-C to machine code?
Thanks in advance!
STM32 is ARM. GCC can compile Objective-C to ARM machine code. The real question is whether or not that's useful in the absence of an Objective-C runtime and Foundation frameworks. From this wiki page it looks like there has been some effort to get GNUStep building for various ARM targets. Perhaps that'd be a good place to start.
Related
I would like to start learning Objective-C for future iOS development. I understand that there are many large hurdles in getting an iPhone app to work on a PC but I'm trying to avoid all of that and just get familiar with the Objective-C language itself without all of the added mobile features.
Is there a way to compile Objective-C programs on a PC to learn just the language without any extra iOS features?
Yes, definitely. Have a look at GNUstep - it's a framework that contains the Objective-C runtime library and most of the Foundation classes. You can learn the language very well by using this package with GCC (gobjc) and MinGW on Linux or Windows.
We have a codebase for a sync library written in Objective-C. In general it's only using stuff from the Foundation framework (NSArray's, NSDictionary's, NSURLConnection's etc.).
We also use some Cocoa-specific functionality in this codebase: KVO and delegation.
Is it possible to compile this codebase to other platforms, similar to how it's possible to compile C/C++ code to multiple platforms? How should I go about doing this? What tools would I need?
edit: The platforms we're mostly interested in (if possible of course): Windows, Android, BlackBerry, Windows Phone 7
Thanks in advance.
Here is a delightful article from cocoawithlove - Options for porting Objective-C/Cocoa apps to Windows. It atleast answers how to port ObjectiveC to windows.
I have been experimenting with Objective-C using GCC + GNUstep on an Ubuntu system.
Now regarding the LLVM Clang compiler, what kind of *step library does it offer? Does it use the GNUstep on the Apple Cocoa? I am mostly interested in the base library - collections, streams, etc. The website doesn't give much information.
Like MKroehnert and puzzle said, neither LLVM Clang nor GCC actually come with a set of frameworks. GCC comes with only a small runtime that doesn't provide NSArray, NSString, not even NSObject.
Frameworks are provided by, for example:
GNUstep
Cocotron
Cocoa
ObjFW
ObjFW is the lightest of them all, but on any UNIX, I'd recommend you go the GNUstep route.
LLVM Clang is a compiler. It is completely independent from the Cocoa / Cocoa Touch frameworks on OS X / iOS, or any other frameworks or platform, for that matter.
Like puzzle said in his answer clang is a compiler like gcc.
On linux you can also use clang instead of gcc together with the GNUstep libraries (which provide the NS* classes you were asking about).
For more information see GNUstep Objc2 FAQ or this blogpost for example.
Like others said, LLVM Clang is just a compiler. But you can have all the modern features of Objective-C 2.0 on Ubuntu using Clang, the modern GNUstep Objective-C 2.0 runtime and GNUstep itself. Have a look here for a how to:
http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux
That page is maintained by the GNUstep developers and contains bash scripts to compile and install everything needed for Objective-C 2.0 from scratch for different versions of Ubuntu-Linux using Clang and the GNUstep Objective-C runtime, which can be found here: https://github.com/gnustep/libobjc2 . It would be moot to copy those lengthy scripts to Stackoverflow since they would get out of date sooner or later. So follow that link to get everything from first hand.
I am a newbie to embedded developement, as figure shown. I have a small ARM board, AT91SAM7-EX256. I have also a JTAG programmer dongle, too. I am using Linux (Ubuntu x86_32) on my notebook and desktop machine. I'm using CodeSourcery Lite for cross-compiling to ARM-Linux.
Am I right that I can't use this Linux-target cross-compiler to make binary or hex files for the small ARM board (it comes without any operating system)? Should I use the version called ARM EABI instead?
As I see, it's a "generic" ARM compiler. I've read some docs, and there're lot of options to specify the processor type and instruction set (thumb, etc.), there will be no problem with it. But how can I tell the compiler, how should the image (bin/hex) looks like for the specific board (startup, code/data blocks etc.)? (In assemblers, there're the org and load directives for it.)
What software do I need to capture some debug messages from the board on my PC? I don't want to on-board debugging, I just need some detailed run-time signal, more than just blinking leds.
I have an option to use MS-Windows, I can get a dedicated machine for it. Do you recommend it, is it much easier?
Can I use inline assembly somehow in my C code? I dunno anything about that. Can I use C++ or just C?
I have also a question, which don't need to answer: are there really 4096 kind of GNU compilers and cross-compilers (from Linux_x86_32 -> Linux_x86_32, Linux_x86_32 -> Linux_ARM, OSX -> Linux_ARM, PPC_Linux -> OSX) and 16 different GNU compiler sources (as many target platforms/processors exists) around? The signs says "yes", but I can't believe it. Correct me, and show me the GNU compiler which can produce object file for any platform/processor, and the universal linker which can produce executable for any platform.
While Windows is not a "better" platform do this kind of embedded development on, it may be easier to start with since you can get a pre-built environment to work with. For example, Yagarto (which I would recommend).
Setting up an embedded development environment on Linux can require a considerable amount of knowledge, but it's not impossible.
To answer your questions:
Your Linux cross-compiler comes with libraries to build executables for a Linux environment. You have hinted that you want to build a bare-metal executable for this board. While you can do this with your compiler, it will just confuse things. I recommend building a baremetal cross-compiler. Since you're building your own baremetal executable (and thus you are the operating system, the ABI doesn't matter since you're generating all of the code and not interoperating with other previously built code.
There are several versions of the ARM instruction set (and Thumb). You need to generate code for your particular processor. If you generate the code for a newer version of the instruction set, you will likely generate code which generates a reserved instruction exception. Most prebuilt gcc cross-compiler toolchains for ARM are "multilib" and will build for a variety of architectures in both ARM and Thumb.
Not sure exactly what you're looking for here. This is a bare metal platform. You can use the debugger channel to send messages if you're debugging on target, or you'll need to build your own communication channel into the firmware you write (i.e. uart support).
See above.
Yes. See here for details on gcc's extended inline assembly syntax. You can do this in C++ and C. You can also simply link pure assembly files.
There is no universal gcc compiler / linker. You need a uniquely built compiler for each host / target combination you use.
Finally, please take a look at Atmel's documentation. They have a wealth of information on developing for this target as well as a board package with the needed linker directives and example programs. Note of course the package is for Atmel's own eval board, but it will get you started.
http://sam7stuff.blogspot.com/
I use either of the codesourcery lite versions. But I have no use for the gcc library nor a C library, I just need a compiler.
In the gcc 3 days newlib was great, modify two files worth of system support (simple open, close, read, putc type stuff) and you could compile just about anything, but with gcc 4.x you cannot even go back and cross compile gcc 3.x, you have to install an old linux distro in a virtual machine.
To get the gcc library yes you probably want to use the eabi version not the version with linux gnueabi in the file names.
You might also consider llvm (if you dont need a C library, and you will still need binutils), hmm, I wonder if newlib compiles with llvm.
I prefer to avoid getting trapped in sandboxes, learn the tools and how to manipulate the linker, etc to build your binaries.
I would like to learn objective-c, but don't have a Mac.
How would I compile obj-c on Windows or Linux?
I would prefer Windows, but Linux would be OK.
GCC has an objective-C compiler. You may also want to investigate the GNUStep tools, which provide a clone of the OpenStep APIs (Which Cocoa is based on.)
You can use gcc to compile objective c as suggested by the previous answers. But one thing is if you are planning this for iPhone development then mac is a must as the framework, simulator etc. are not available in other platforms.
http://gnustep.org/ -- no experience using it, but it might be worth a shot.
If you just want to experiment, there's an Objective-C compiler for .NET (Windows) here: http://www.qckapp.com/index.html?p=ObjC