Stack OverflowHow do I get started in embedded programming?
[+96] [23] mmattax
[2008-09-05 04:54:30]
[ c++ c embedded ]

I would like to get started in embedded systems programming but don't know where to start...I have a very solid knowledge of C and C++ and would preferably like to use these languages with the GNU compilers. I have a degree in CS so I have a solid foundation...

I have no clue about what hardware and other resources that I will need...If you work or are knowledgeable in this area, how did you get started and what are some good resource for a beginner?


(9) Apparently, not by asking for help on any Stack Exchange site. - Chris K
[+50] [2008-09-05 06:30:25] Justin Tanner

Here are some tips to get started in embedded systems.

  1. Get a micro-controller. Try starting with a demonstration board [1]. ( they are cheap now )
  2. Dive right into programming and exploring the board ( turn on LEDs, play with timers )
  3. Subscribe to Hack a Day [2]
  4. Try a more ambitious project, involving external components ( accelerometers, DC motors, etc).
  5. Publish your project online ( maybe get it featured on Hack a Day )
  6. Take a class in embedded systems or real time operating systems


What Development Board to Use [3]


(4) That's a pretty good list, however personally I'd add "get a hardware simulator/emulator for your target platform" as item #0 - this can be easily used to get started fairly quickly and usually doesn't require any significant investments, but can be tremendously helpful - none
(7) most platforms (atmel few others) have that build into their APIs, but part of the fun of embedded systems over regular programming, is that you can manipulate the real world. I really thinking turning on lights on a demo board is the best way to start. - Justin Tanner
(1) @Justin: +1 for Atmel controllers. They are a lot of fun and easy to start with. And as for the cost - it would involve a couple of bucks for the microcontroller itself, and a some time to build the simplest programmer as shown here: If one wants plug and play - for ~$100 has all the ingredients to start with. - Andrew Y
[+18] [2008-09-05 05:30:27] dwj

I got started right out of college by joining a company that did embedded development. All my previous experience was PC-based but I knew C and what happens on a low level inside the machine.

Here are a couple of options for getting in:

  • Do you work at a company that has embedded work going on? Can you transfer into the group?

  • Look for companies in your area hiring junior embedded software engineers. Many want some embedded experience but don't let that stop you from trying to get in the door. Knowledge of how code really runs (when is the stack used? the heap? what do pointers really do?) is more important.

  • Pick up a development kit and try some home brew projects (e.g., (now you are talking $)

Brush up on your knowledge of how stacks, heaps, pointers, memory allocation (or lack thereof) all work. Read up on real-time OSes ( uC/OS-II [1] is a good start). Practice writing clean, maintainable, small code!

Jack Ganssle has a review [2] of a new book, John Davies' "MSP430 Microcontroller Basics," that he gives high props to for beginning and experienced embedded developers.


[+16] [2009-03-18 05:42:46] MrEvil

I'm a fan of the AVR butterfly [1] and the Arduino [2]. Both are very cheap, < $30 USD so if you burn out your board it's no big deal. Both have lots of sample programs and examples of how to interface with common hardware. Arduino also has a very large open source hardware community that produces add-on shields, schematics, tutorials etc... Once you've got your sea legs the Arduino boot loader can be overwritten using any AVR ICSP programmer allowing you to use the GCC AVR toolchain directly.

Because of your experience you may be tempted to jump directly to one of the more advanced boards but I would advise against it. Programming for embedded systems is a whole new beast with limited debugging options and on hardware that you've patched together using jumper wire and hot glue. By starting with a known, well documented environment like the Arduino you can eliminate many variables making it easier to solve problems that would otherwise frustrate a beginner.

Also, I forgot to mention some helpful resources:

  • Sparkfun [3] - Really good hobbyist retailer, with excellent forums and tutorials.
  • AVR Freaks [4] - The main online community for AVR related hardware.
  • Also look around for robotics clubs that may be in your area.

[+13] [2008-10-16 00:00:34] gthuffman

I have some suggestions:

1) Learn microprocessor basics such as memory systems, how peripheral devices are accessed, and the difference between memory latency and RTOS "TICK" times.

2) Know what happens when an interrupt is serviced. In case you didn't catch that, know what happens when an interrupt is serviced.

3) You might not like this next suggestion, but learn assembly language for any processor. Once you understand assembly language, C and C++ will make a lot more sense in how the compilers create code.

4) Be ready to hold a scope probe. I had a very good mentor that made the comment, "you cannot program without a scope." This comment stills serves me more than 12 years after I heard it.

5) And above all, be ready to debug and or troubleshoot really different kinds of problems than you would encounter with non-embedded programs. Embedded systems are one of the most difficult to get "right", but the rewards are great!

Good luck in your adventure!

[+10] [2008-09-05 05:59:19] Ben Collins

I got my start by writing a PC-based operating system from scratch. It was a fabulous way to get used to writing applications on-the-metal (which is essentially what 'embedded programming' is, even if you're using a RTOS like VxWorks or whatever).

You don't need to buy anything - just download Bochs, which is a truly excellent x86 emulator. QEMU is good too, but I found bochs easier to start with. [1] is a great place to start. The forums there are very helpful and friendly (because it's a niche and hasn't been invaded by the moronic masses (mostly).


[+9] [2008-09-05 06:52:42] Registered User

Try an Arduino [1].


[+7] [2009-01-09 21:02:37] Johan
  1. The first thing is to think embedded: Since it is not uncommon in the embedded world to run stuff for years and years in with MCU that only has a few kB of RAM you need to make sure your programs are perfect. You need to make sure you don't have any memory leaks or anything like that, and wipe your mind from the idea that a reboot is ok.

  2. Get a dev-card and get to work. Get some hardware and do something fun [1], AVR:s are very popular right now since they have a really go tool support and a live community [2] to ask for help. Or maybe do some embedded Linux stuff, there are some really cheap and funny Linux cards right now, and a lot off them are really nice to work with.

  3. Find a embedded company and brag about what you just did in point 2. And if you impress them, I bet you get a work offer :-)

Update: I forgot to mention one little thing, both in the AVR and linux case you use the gcc compiler. The AVR does actually have a quite good gcc port ( winavr [3]) not many 8-bit mcu has that, and that port is sponsored by Atmel.

Update: Hardware, the linux case is also fun. There is a lot of cheap cards around.


[+5] [2008-09-21 07:49:29] yogeesh

Michael Barr's Programming Embedded Systems: With C and GNU Development Tools [1] is the place to start. Also, browse through Embedded systems guru Jack Ganssle's articles in his website [2] and subscribe to his Muse.

Have fun!


[+4] [2008-09-06 17:06:02] JeffV

If you have good knowledge in Linux, you can into the industry by learning more about embedded Linux.

There will be more and more demand for this embedded systems with an RTOS (such as embedded linux) as more capable chips get cheaper and the industry strives to make use of them. You can migrate your career closer and closer to embedded systems that way.

Eventually, you will get on a project with a microcontroller with a total of 8 pins, 32 registers, 1k ram and 16k flash. Yee haa! ;-)

Also, you can get experience with digital circuits with hobby projects like robot kits. Make Magazine [1] has a ton of cool projects like this.


(1) embedded Linux is a good advice. - Johan
[+4] [2008-09-22 11:06:18] MrZebra

PIC Microcontrollers from Microchip are a great way to get into embedded programming, because the hardware is so simple. All you need in terms of circuitry is a ceramic resonator, a capacitor for the power supply, and a resistor for the reset. These are all very cheap.

Get the 3-pin kind of ceramic resonator - 2 pins go directly to the PIC, the centre pin goes to ground. Put an electrolytic capacitor of about 0.1 or 1uF between +5v and ground, and a 10k resistor between the MCLR pin (normally pin 1) and +5v. That's all the hardware you need! You really can't get much simpler. DON'T think you can skip the capacitor though, even if you're just turning a single LED on and off. Your CPU will reboot at random times and you'll have nightmares trying to figure out why.

You then connect it to your PIC programmer (there are different kinds available, from cheap Chinese knock-offs to expensive in-circuit emulators), flash the chip, and you're done. Chips are cheap, and the flash kinds can be reprogrammed many times. (Be sure to get the FLASH ones, not the one-time-programmable (OTP) ones! The flash ones have a part number like xxFxxxx, whereas the OTP ones are xxCxxxx.)

All these components are cheap and easily available from mail-order suppliers. In the UK, I recommend Rapid Electronics [1] and Farnell [2].

There is loads of documentation and samples for PICs available directly from Microchip's website. They also give away a free IDE, assembler, and a trial C compiler.

The microcontrollers have lots of on-board peripherals, including analog->digital converters, RS-232, timers, interrupts, I2C, CAN, and even USB. More than enough to get you started in the world of embedded programming.


[+4] [2008-10-15 23:44:53] Leon Sodhi

As you've probably gathered from reading the other posts, hardware knowledge is quite important in developing code for embedded systems. Like you, I also have a CS degree but found it quite challenging working in an embedded systems environment and trying to communicate with people that come from an almost entirely hardware orientated background.

My first recommendation would thus be to read up on the basics of hardware or possibly even get some formal electronics training. Depending on the embedded environment you're looking at going into, learning some VHDL might also be helpful, I was at one point given some code and told to write the software having never really seen VHDL before!

From a software perspective I would also have to completely agree with Ben Collins, writing a small and simple OS for your PC is an excellent (and free) way to get used to writing code on the bare metal. I would certainly have been lost without that knowledge.

Good luck!

[+3] [2008-09-22 11:15:06] MrZebra

(Posting this as a separate reply, because it's quite different)

A more complex but powerful alternative to the PIC is an ARM based processor. This will give you more horsepower to play with, but is more difficult from an electronics point of view. These only come in large surface mount packages, so you won't want to build the circuit yourself.

A good one is the MAKE controller from Making Things [1]. It has a powerful ARM CPU, and very simple to use board with screw terminals for digital I/O, analogue inputs, and servo drive. Best of all, it has very good software support. It comes complete with a full GCC tool chain, lightweight RTOS, and custom driver library for all the CPU's special features. I have one of these, and within an hour of opening the box I had it controlling servos. It also has built-in Ethernet support, which allowed me to write a simple HTTP server for it very quickly.

It's just over $100, which is a pretty reasonable price for a well-made piece of kit. Disadvantages are that it's not as flexible from a hardware point of view as designing your own circuit. However, designing a circuit for a 64-pin plus surface mount IC is not something to be taken lightly. You don't need any special hardware to program it, it plugs directly into the USB.


[+2] [2008-09-05 05:22:22] Daemin

Depends on what processor and device type you want to target. I.e. mobile/hand held, or small microcontrollers?

If you want to go for the microcontrollers then you could try developing with the MSP430 - I've found that to be a reasonable chip and nice to program with (even assembly). For that try the small usb based development kit (eZ430) [1].

For mobile phones you could either go the Windows CE route, or try your hand at using Linux. Though in this day and age "embedded" programming for small devices and mobile phones is similar to desktop application development that was several years ago (1995 to 2000 or there abouts),

You can get processor development starter kits from many companies on the net. Just pick a processor (ARM, MIPS, etc) and buy a development starter kit, though they can be somewhat pricey.


The eZ430 is very nice and an inexpensive way to get started. TI provides C compiler and IDE and the eZ430 doubles as a programmer and in circuit debugger. Can't beat it for the price. - Louis Davis
[+2] [2008-09-05 06:51:22] David Sykes

For real cheap kit you can use to experiment at home you could try Pic chips using the PICKit Flash Starter Kit [1] Pic chips are very cheap, easy to get into. There is a free C compiler [2] for it.

If you want to talk to a pc the Vellemen USB experimenter [3] board works quite well for low bandwidth data.


[+2] [2008-09-07 20:49:43] Cristián Romo

I would reccomend starting out with devkitPro [1] which is GCC based and has toolchains for the Nintendo DS, GameBoy Advance, Wii, GameCube, and PlayStation Portable. There are communities where you can ask questions for the different platforms. The ones that I know of are GBADev [2] (for GBA and NDS), and Wiibrew [3].

As far as resources, Wiibrew holds a fair amount of documentation for Wii, while the major resources for GBA/NDS are TONC [4] and GBATek [5].

You don't need an actual system to do development for a few of the systems, since there are good emulators such as no$gba [6] for the GBA/NDS and VisualBoy Advance [7] for GBA, both of which have some debug capabilities.


+1 for GameBoy Advance. It's a wonderfully satisfying way to get started in embedded programming, and the homebrew toolchain (VisualBoyAdvance + gcc, including wonderful things like gdb frontends and gprof) beats anything I've worked with professionally since. - leander
[+2] [2008-09-21 09:09:37] Khouri

My school had the opportunity to specialize in Technical Informatics (as they called it) for the last 2 years of the program. I got classes on RTOSs, soldering and (some) welding, programming for microcontrollers and the nitty-gritty details of processors. The "normal" CS students got classes on design patterns, advanced OO, genetic algorithms and such. This was a great intro, but it's a very wide field.

My final internship was on porting a protocol stack to an OS-less, embeddded platform. I learned a LOT in those 4 months. You read about things like caches, MMUs and low-level protocols, but it's not until you´ve tried to get them working (or stop them from breaking your code), that you really get a feel for them.

The best way to start is to read up on the area of embedded software that you're interested in and just build something. The MSP430 has a very nice USB-based demo board, AVR microcontrollers are very popular for small projects, but there is a ton of stuff out there. There are a lot of websites dedicated to home-brew weather stations, robots, lighting set-ups and modifying existing products (like the RoboSapien). Try to build a small device from the descriptions on these websites and start from there.

You could also apply for a job in the embedded applications field and once you have some experience, expand your job into fields like drivers and boot code. Note: for the products we build, we usually write the Board Support Package and the customer writes the application software, YMMV.

[+2] [2008-10-15 14:30:41] Vaibhav Garg

A point that I would like to add that unlike programmers on the desktop, the resources in an embedded system are relatively less. You must keep an eye on the ram/ code footprint of any application you write as a mental training before a foray into embedded.

[+2] [2011-07-14 16:53:23] Jonathan Cline IEEE

It is much easier now than in years past--really. Development previously required expensive hardware tools (JTAG unit, emulator, flash programmer, serial-to-custom-hardware dongles to communicate to the board, power supplies, etc). Then obtaining the software tools was very expensive (not free) possibly without availability of any C compiler.

As of now there are several small boards which include firmware bootloaders, they can self-program the flash memory of the chips, and connect directly with USB (not using USB-to-serial dongle, but straight USB to the chip), plus free software development tools provided directly by the vendor.

Currently the best is Microchip with the MPLAB IDE which runs on Windows (currently new version in beta for OS/X, Linux, Windows) and has very low cost programming dongles-- though the programming dongles are optional since other small boards are available which bootload-program themselves as above. Plus MPLAB can simulate code very well (including I/O) so the embedded software can be run thru and debugged offline.

My recommendation would be the following.

  • Avoid Arduino because it has many limitations and drawbacks; briefly: higher cost, excessive need for extra modules (more $), lack of peripherals integrated into the chip, lower quality tools (open source, no simulator, non-vendor-packaged), and the idea of using C++ on an 8-bit microcontroller is overkill. This is probably flame bait however even Arduino fans admit this after getting into more advanced development.
  • Download Microchip MPLAB, download one of the 'evaluation' C compilers; eval version only disables optimization and is otherwise very usable = free -- The above comes with tons of docs and code
  • Buy a UBW board (either 8-bit PIC or 32-bit PIC version) - which allows USB downloading of .hex files to self-program the code & data; less than $40
  • Use a spare USB device cable (also functions as the power supply) = free
  • Buy a handful of LED's and resistors, to hook up to various pins on the board, as simple way to monitor I/O
  • Assemble or compile some example code straight from Microchip application notes, modify the code as desired.


That's the low level embedded part.

The high level C/linux part would be the following.

  • Buy one of the open source wifi routers. For example, DD-WRT or open-wrt routers. Frequently found on ebay.
  • Download the source code for the GNU/linux open source router.
  • Set up a GNU/linux development machine.
  • Build the router source code from scratch, download it to the router via the web browser interface, add software modules or modify as desired.
  • With the UBW embedded board hacking as above, then the UBW can be connected to the wifi router, and with some custom software on both sides, it's now a complete embedded system capable of controlling real time signals.

"In the past" there was Forth... and in the right hands simplified everything. (The link is to Frank Sargent's famous 3-instruction Forth.) - Assad Ebrahim
[+1] [2008-09-10 03:23:52] Adam Pierce

Depends on your skill level and what you want to achieve. If you want something a little more beefy than the PICs and AVRs, I've recently been using the SAM7-P256 development kit from Olimex [1] which is based on the ARM7 32 bit processor. It was cheap and GNU tools are available for it. You can cross-compile under Windows or Linux. I wrote a step-by-step on my blog [2] to get a GCC toolchain running under Linux for this board. I also found this article [3] to be an excellent, more detailed technical description of the ARM chip.


[+1] [2008-09-21 08:09:11] INS or

There are many GCC based toolchains that create good code (I personally have used gnuarm 4.2.2 [1])

Join their mailing list and ask some the community [2] some questions.


[+1] [2008-10-03 16:29:34] user24900

The field of embedded software is actually quite broad, so it depends on where you want to focus. Is it more bare metal programming with 8 bit processors? Something with a lot of I/O, peripherals, and maybe an RTOS? Or are you referring to higher end stuff with something like Windows CE / embedded Linux?

Personally, my degree is in EE and I had some programming background before I got a job w/ embedded stuff (all of the above, except for the embedded Linux / WinCE stuff).

[+1] [2010-05-26 10:55:58] Daniel Grillo

I think that you have to learn assembly first. 8 bits pic microcontrollers are the best choice.

There are many kits that you can buy. Chose one like these

[0] [2009-07-29 21:51:54] User

Get embedded in some embedded project. There you'll see what it's like and whether you like it.