# Recommendations for microcontroller programming under Linux [closed]

Can somebody make me a recommendation of some stable development environment (platform + programmer device + sw/ide) for beginning programming microcontrollers under linux (not arduino)?

I find it difficult to pick all this components, and I'm afraid I'll have to resort to windows. Thanks!

Update: Thanks for your answers! I'll give Microchip and Netbeans based MPLAB a try. Nothing against Atmel, but I think the former will be easy to setup for me;-)

## closed as off-topic by duskwuff, old_timer, Daniel Grillo, Voltage Spike, Sparky256Jul 19 '16 at 18:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

• Sadly, I have to admit I use Microchip's MPLAB under Virtualbox in Windows XP when programming on Ubuntu. It works. I'll be switching to MPLAB X soon. – Thomas O Oct 4 '11 at 7:00
• My development system described here: electronics.stackexchange.com/questions/10580/… – markrages Oct 4 '11 at 15:54

Microchip has a new MPLAB X using the NetBeans platform that installs under Linux, either 32-bit or 64-bit. It is still under beta release, but has been out for awhile now, and has support through their forums.

You can develop for any of the Microchip MCU lines, PIC10/12/16/18 (all 8-bit), PIC24 (16-bit), or PIC32 (32-bit). I would recommend starting with at least the PIC18 line -- the smaller ones are best programmed with assembler, and it's much easier to start with C.

You can get "lite" versions of the compilers for free (the main limitation is that some optimizations expire after 60 days, but there is no code limit like some development systems).

Microchip has a combined development board/programmer -- MPLAB Starter Kit for PIC18F MCU that costs $60. It includes USB communication, a capacitive touch pad, potentiometer, acceleration sensor, MicroSD memory card, and an OLED display. • Thanks! Also heard of MPLABX, but thought it was still not usable. Why do you think its better to start with PIC18 instead of 16 line? – grieih Oct 4 '11 at 20:01 • The PIC18 is an improved version of the PIC16. In particular it has a real data stack with a frame pointer, so that the instruction set is much more friendly to C compilers. I just finished doing a PIC16 project (the processor was picked by my client before I came on board), and I ended up writing the entire application in assembler. – tcrosley Oct 4 '11 at 21:57 • From what I see listed on Mouser/Digikey the PIC16/18 series are all 8-bit MCUs and PIC24 is where the 16-bit parts start. – Captainj2001 Jul 18 '16 at 22:49 • @Captainj2001 thanks for the correction. In my previous comment, I had said the PIC18 is an improved version of the PIC16 (which is also 8-bit), but I see in my answer I refer to it as 16-bit. I'll correct that. – tcrosley Jul 18 '16 at 23:48 I've had good success with Atmel AVRs using: • the GCC C compiler with AVR libraries (packaged in APT for Debian based distros) • avrdude for flashing devices (using a cheap Atmel AVRISP mkII programmer) • AVR Eclipse plugin for an IDE Googling will find some guides on setting it all up under a recent Ubuntu install. It's a lot easier than it used to be, it's now pretty much just installing packages from the repos. • Thanks for your answer. Are those AVRISP programmers enough to start getting in touch with AVR micros or is more hw needed? – grieih Oct 4 '11 at 19:56 • The AVRISP micros and a simple breadboard power supply are all you need to get an LED blinking. For$50, though, the AVR Dragon is worth every penny. – Zuph Oct 13 '11 at 17:03
• Sorry @grieih, I missed your comment. As Zuph says, it's simple on the hardware side, just the programmer and power supply needed. Here's a good reference on the few pins you need to hook up for programming: evilmadscientist.com/article.php/avrtargetboards – Al Bennett Oct 18 '11 at 9:10

If you wish to work in C, you can check out either SDCC or the list of supported GCC cross-compilers. There is a long list. If you wish to work in assembly, most of the 8-bit micros have well supported Linux tools e.g. gputils.

As for programming devices, most of the newer micros these days come with built-in boot-loaders that no longer require purchasing any expensive programming device. Otherwise, you can always build one yourself. For the PIC, there's the PICKIT2, which comes with schematics.

As for the IDE, you can just use emacs or eclipse in general.

• SDCC would be awesome, but sadly, it supports only some devices. Great, if your device is in it's list; not so great when you migrate to a chip with slightly more RAM and suddenly have no support for it. Can even try this on Windows with gputils, and even in MPLABx with the SDCC toolchain, however that is "experimental" at best. – rdtsc Jul 19 '16 at 14:59

You should be able to get a development environment set up for the TI/Stellaris ARM Cortex M3 parts using arm-eabi-gcc to compile code and OpenOCD for flashing and debugging on the target board. I have done it all on Mac OS X so I can't give you a straight how-to but I did a couple quick Google searches and it looks like there are plenty of setup guides out there. Honestly it's kind of a pain and you'll probably have to do some fiddling to get everything working even if you get a great setup guide, but once everything is configured the workflow is pretty good. You should also be able to use Eclipse as an IDE and configure it to load your binaries onto the board automatically if you are so inclined. The Stellaris line are great parts too.

• – Toby Jaffey Oct 4 '11 at 8:02
• It is possible, but not nearly as easy as setting up an environment for AVR. I know because I'm just doing it for an LPC17xx ARM Cortex M3. – starblue Oct 4 '11 at 10:30
• There's a straight how-to for Mac OS X which I've used here for the Stellaris parts. – Kevin Vermeer Oct 4 '11 at 10:51
• @starblue - The OP said "not Arduino" so I figured AVR was out. Maybe he's cool with plain AVR but AVR is weak compared to ARM Cortex parts. Of course it depends on your application and an M3 would be overkill in a super-simple mass-produced device, but for a hobbyist setting out to learn micros you get a lot of power and features with an ARM part. The advantages of AVR as Arduino are the tools, community and accessories, so if you don't want the whole Arduino package, might as well pass on AVR. – Suboptimus Oct 4 '11 at 18:10

The Eclipse IDE is Java based, so works fine under Linux. There is a plugin for the IDE available that supports C/C++ development for AVR microcontrollers and also allows you to upload compiled code to the device via a variety of programmers.

I have a number of linux based embedded microcontroller examples at github https://github.com/dwelch67. Note the ide is your favorite text editor and a command line where you type make.

Note the free tools for microchip (pic32) (not the ones FROM microchip) have optimization, 16 bit instruction set support, etc. And you get to see what is going on (cause you are doing it yourself). These of course being the mainline gcc and llvm (not the ones from microchip).

The mbed or stellaris are probably more along the lines of what you want. Or arduino like go with the maple perhaps. I hate to say maybe the fez panda. The msp430 launchpad is $4.30, at that price might as well buy a couple to save for a rainy day. The stm32 value line discovery is around$10, same deal get one save it for a rainy day.

If you let the libraries and environment do all the work for you then its no different than just writing applications on your desktop computer, a bit of a waste of time going embedded, just write desktop apps. If you go with embedded you should roll up your sleeves and get your hands dirty...something to think about...Otherwise just buy the arduino and get it over with. Atmel is hard to touch for customer satisfaction, not sure why but it is what it is. The avr instruction set is not great, nowhere near as bad as the PIC (not counting the PIC32) but not as good as the msp430 or ARM instruction sets. I have used the arduino ide on linux, likely wont need to reboot to windows. There isnt anything as easy as the arduino except maybe the BASIC based stamps like parallax and some others.

As with linux/unix development in general, dont focus on looking for an IDE. Focus on the compiler, gcc or llvm, then your favorite editor and thats it, start coding. Apply that to a microcontroller and look at the targets the compilers support. ARM and MIPS are a natural fit, you wont have any problems getting the tools up and running, any time you are taking a patched gcc versions and trying to make that work on your up to date Linux box you are going to struggle from time to time, avr, msp, and pic fall into that category. Same goes for sdcc, it is hit or miss, and anyway you have to ask yourself: C on the 8051? Not as bad as C on the PIC but close. If you are really looking for a polished, supported, up to date, stable IDE, etc, you have to go to windows. Keil, IAR, Code Red, etc. The demand just isnt there, linux/unix developers historically spend their time arguing vi vs emacs as those are the dominant ides for lack of a better term. throw in gdb if you get desperate.

• This is the problem with Linux, the only option is GCC. And there will only be reliable, maintained GCC ports for the most hyped, mainstream MCUs. – Lundin Oct 14 '11 at 11:23
• llvm is catching and passing gcc, and is by default a cross compiler. It may someday be a boat anchor, also, but for now it is not. The msp430 port took less than 24 hours so they say. – old_timer Oct 14 '11 at 11:44
• Thanks for your answer, @dwelch! My principal concern here is finding a suitable programmer board supporting linux developments, but I thought an IDE could free me from putting all the necessary software pieces together, at least at the begining. – grieih Oct 14 '11 at 15:56

Programming PIC Microcontrollers in Linux is prety easy. I have a Pickit2 Clone, MPLAB X IDE, And QPickit which uses pk2cmd as backend. I have programmed dsPIC33 without problems with this programmer. To program your device:

1. Build your project on MPLAB X. In the output window, the .hex file path will be shown. For example: /home/user/MPlabx_projects/Test/dis/default/production/test.hex
2. Copy that route and use pk2cmd -p -f /home/user/MPlabx_projects/Test/dis/default/production/test.hex -m -r
3. Your device will be detected automatically, then programmed and the MCLR will be released to start operation.

Remember to choose the correct voltage in your pickit. For dsPIC33 is 3.3V generally. You can choose it from your pickit2 clone, selecting the correct jumper. Also, you can power your MCU from a independent power supply of 3.3V, and use the default settings on pk2cmd.

If you want, you can use QPickit. Is a QT based application to program pic microcontrollers with a very simple and useful interface. I will load the program sources in the next days.