chipKIT® Development Platform

Inspired by Arduino™

[Experimental] chipKIT compiler using Newlib Standard C lib

Created Fri, 21 Oct 2011 05:03:47 +0000 by jasonk


Fri, 21 Oct 2011 05:03:47 +0000

We now have experimental builds of the compiler using the open-source Newlib Standard C and Math lib. We're hoping that the growing chipKIT community will help us test this Newlib build with the chipKIT core files and libraries.

You can download these builds here: (I recommend making a backup copy of your existing compiler.) Extract the pic32-tools directory from the zip over your existing directory located in hardware/pic32/compiler.

For those of you interested in the source code, the Newlib source-code repository is here:

Once we get the issues ironed out (and [color=#BF0000]I do expect that there will be conflicts between the chipKIT core files/libraries and Newlib[/color]), I will fork these repositories over to the chipKIT32 team account and we can make it the default compiler for chipKIT.

When posting to this forum or entering an issue in the github tracker, please be sure to mention that you are using the experimental compiler with Newlib. I'm also interested to hear about how this change affects your sketch code size and performance. Do we also need to provide the proprietary library as an alternative or is Newlib everything we need?

The community has been asking for this for a while. I've finally gotten off of my lazy butt to get this done, and we are that much closer to having a full open-source compiler toolchain.


Sun, 23 Oct 2011 00:32:34 +0000

Way to go Jason!

I'm excited to check this out, and start working on integration with the mpide.



Sun, 06 Nov 2011 20:50:30 +0000

That's surprising... good move!



Sun, 18 Dec 2011 01:04:54 +0000

Hi everyone,

Please let us know if you've tried this build of the compiler. We are hoping to switch to a Newlib build of the compiler for the official mpide build by February 2012, but we want to get more feedback before we make it official. It would be a big step towards having a completely open-source solution.

Specifically, we'd like to know if you've had success with the Standard C library functions such as sprintf and malloc. Also, if you have sketches that use floating-point arithmetic please try them with this compiler.

Thanks everyone!


Tue, 03 Jan 2012 14:11:33 +0000

All I can say, is that retrobsd for Chipkit Max32 project use it as the main compiler tool. See here. The svn builds are compiling fine.



Tue, 03 Jan 2012 23:11:08 +0000

I'll do a test build at the end of the week using the newlib based compiler.



Tue, 24 Jan 2012 01:19:51 +0000

I encountered two errors... the first was when using the Ethernet shield, namely (1) the redefinition of ultoa() and then (2): undefined references to kill and getpid, please see below:

/Applications/ In function _kill_r': /Users/kjason/github-jasonkajita/mac-build/newlib/pic32mx/newlib/libc/reent/../../../../../../pic32-newlib/newlib/libc/reent/signalr.c:61: undefined reference to kill' /Applications/ In function _getpid_r': /Users/kjason/github-jasonkajita/mac-build/newlib/pic32mx/newlib/libc/reent/../../../../../../pic32-newlib/newlib/libc/reent/signalr.c:96: undefined reference to getpid' collect2: ld returned 1 exit status

I SOOOO want a working malloc too!

Thanks for all your work.


Tue, 24 Jan 2012 05:05:20 +0000

Thanks for the report. I'll look into it. Are you having a problem with malloc also?


Wed, 25 Jan 2012 11:35:11 +0000

My problems with malloc are with the previous compiler toolchain (c32?), which I was hoping newlib would solve.

Thanks again! -Scott


Thu, 26 Jan 2012 05:01:38 +0000


Is the sketch that is causing the _kill_r one of the Network Shield examples? I'm not sure where the call to signal is coming from.

Thanks, Jason


Sat, 28 Jan 2012 22:35:51 +0000

(after a bunch of hair pulling... and it's not like I can really spare the hair, I chased it down to NEW)

The following will cause the link error:

class foo {
    int a;
    int b;


void setup(){ 
     foo myfoo;	// OK
     foo *kablooey = new foo();	// GENERATES LINK ERROR

void loop(){

Will generate the error:

/Applications/ In function `_kill_r':
/Users/kjason/github-jasonkajita/mac-build/newlib/pic32mx/newlib/libc/reent/../../../../../../pic32-newlib/newlib/libc/reent/signalr.c:61: undefined reference to `kill'
/Applications/ In function `_getpid_r':
/Users/kjason/github-jasonkajita/mac-build/newlib/pic32mx/newlib/libc/reent/../../../../../../pic32-newlib/newlib/libc/reent/signalr.c:96: undefined reference to `getpid'
collect2: ld returned 1 exit status

And to answer your previous question, I'm porting ArdOSC which does a little more malloc'ing, etc than I'd do if i was writing it from scratch! The network shield examples compile OK.


I think what's happening is that operator new() will throw an exception if it can't allocate memory and the exception handling is referring to kill()

Wed, 28 Mar 2012 12:05:36 +0000

This simple program crashes.

The "printf" and others functions are not handling the formating of floats.

void setup() { Serial.begin(115200); }

void loop() { char b[100]; double d = 2.7;

sprintf( b, "%f", d ); Serial.println( b ); }