Close

toolchain difficulties

A project log for operation: Learn The MIPS (PIC32MX1xx/2xx/370)

Having been exclusive to a certain uC-line for over a decade, it's time to learn something new (and port commonCode!)... Enter MIPS

eric-hertzEric Hertz 07/01/2015 at 05:416 Comments

I dunno what's wrong with my search-fu, 'cause the signs all point to that *people are doing it*... but all I can seem to find is really low-level weird ways of doing it.

There's more to a toolchain than just the compiler; compiled code can run in many forms... "bare-metal" or as an application atop an OS... Once it's compiled, it's gotta be "linked" appropriately, which in a bare-metal situation means the linker needs to know *where* to put the compiled machine-language on the machine. Interrupts in certain locations, initial boot stuff at the beginning, whatnot. Then there's these newfangled chips with their newfangled abilities to run code from the RAM (WHAT?!)... but that code has to be *stored* in the FLASH, then *relocated* into RAM before it's executed... blah blah blah.

The gist of it is that: Yeah, the Microchip IDE handles all that, specifically for their chips. Of course. And alternatively, yeah, there's a MIPS cross-compiler for gcc, and many other such tools... but basically, it seems, most of the nitty-gritty described above is... beyond my search-fu.

So, it would seem, the way it's done is one of two paths:

A) write your own linker-scripts, header files, etc... for each different chip you work with... or if you're lucky you'll find someone who's done-so already. Then, use mips-gcc... e.g. http://wise-ware.org/wiki/index.php?n=Pic32.Gcc4Pic which is well-written, but a lot of work and a bit incomplete. Or...

B) download and install Microchip's IDE, and get its linker-scripts, header-files, etc. Then plausibly apply them to a more generic build-chain. e.g. http://www.paintyourdragon.com/uc/osxpic32/

Either way seems utterly ridiculous. And neither makes a bit of sense as the way people do it considering how much effort apparently has already gone into supporting these devices at the lower-levels (JTAG/flash-programming via openOCD, etc.).

So, apparently, I just don't know what to search for, right?

Well, as it stands, I'm half-assing option B: I'm downloading MPLAB XC32 from Microchip... there's a Linux version, so who knows. On the plus-side, no need for writing linker-scripts, etc. On the minus-side, it's a bit crippled unless you're willing to pay for a license (I'm not). And it kinda takes away from this being a totally open-source method. But... maybe I'll actually be able to run some code on my chip soon, which'd be a nice improvement over having to dig out the instruction-set reference and create op-codes, uploaded one-by-one by hand ;) (yeah, I didn't get beyond 0x00000000 NOP).

http://www.microchip.com/pagehandler/en-us/devtools/mplabxc/home.html

That's, basically, the equivalent of a regular "tool-chain" except distributed and slightly crippled by Microchip. Allegedly it's got xc32-gcc which is allegedly open-source, as well as the linker-scripts, headers, etc. which are explicitly NOT OPEN SOURCE. This is different from the IDE, it's the toolchain the IDE uses. Again, I'm not too fond of IDEs, in general, so this'll probably be a happy-medium for now. Still, it's 60+MB, which means I've had plenty of time to write this, look at various other links, download documentation, and am still at less than 2/3rds downloaded.

And, again, even if it's not open-source, at least the entry-requirements are free. That's a plus.

Discussions

Eric Hertz wrote 07/01/2015 at 08:05 point

IT BLINKS!

  Are you sure? yes | no

AVR wrote 07/01/2015 at 06:28 point

my friend's DyIO project uses the PIC32 and he managed to build a toolchain on linux he might be able to help you out

https://hackaday.io/project/3185-dyio-dynamic-input-output-controller

  Are you sure? yes | no

Eric Hertz wrote 07/01/2015 at 07:08 point

Hey! Thank you for that!

  Are you sure? yes | no

Eric Hertz wrote 07/02/2015 at 08:17 point

Might be looking into the open-source path again sooner than I planned; I'll be sure to harass your buddy when I do ;)

  Are you sure? yes | no

Eric Hertz wrote 07/01/2015 at 05:58 point

FINALLY downloaded... and it doesn't run.

  Are you sure? yes | no

Eric Hertz wrote 07/01/2015 at 06:02 point

Must change the executable-flag to +x... and run sudo

Notes to self: /opt/microchip/xc32/v1.40/

  Are you sure? yes | no