views:

4141

answers:

23

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?

Thanks.

+1  A: 

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).

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.

Daemin
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
+10  A: 

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., http://www.embeddedarm.com/products/board-detail.php?product=KIT-ARM#) (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 is a good start). Practice writing clean, maintainable, small code!

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

dwj
+3  A: 

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.

OSDev.org 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).

Ben Collins
+26  A: 

Here are some tips to get started in embedded systems.

  1. Get a micro-controller. Try starting with a demonstration board. ( 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
  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
Justin Tanner
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
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
@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: http://www.bsdhome.com/avrdude/ If one wants plug and play - http://www.nerdkits.com/ for ~$100 has all the ingredients to start with.
Andrew Y
+1  A: 

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

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

David Sykes
+4  A: 

Try an Arduino.

Registered User
+1  A: 
JeffV
embedded Linux is a good advice.
Johan
+1  A: 

I would reccomend starting out with devkitPro 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 (for GBA and NDS), and Wiibrew.

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

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 for the GBA/NDS and VisualBoy Advance for GBA, both of which have some debug capabilities.

Cristián Romo
+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
A: 

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 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 to get a GCC toolchain running under Linux for this board. I also found this article to be an excellent, more detailed technical description of the ARM chip.

Adam Pierce
+2  A: 

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

Have fun!

yogeesh
A: 

http://www.gnuarm.com/ or http://www.gnuarm.org/

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

Join their mailing list and ask some the community some questions.

Iulian Şerbănoiu
+1  A: 

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  A: 

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 and Farnell.

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.

MrZebra
+2  A: 

(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. 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.

MrZebra
A: 

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).

A: 

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.

Vaibhav Garg
+1  A: 

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!

Leon Sodhi
+3  A: 

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!

gthuffman
+2  A: 
  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, AVR:s are very popular right now since they have a really go tool support and a live community 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) 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.

  • NGW100 - You have 2 network interfaces and access to all gpio (and more)
  • LinuxStamp - A real minimalistic LinuxCard.
  • BeagleBoard - A little monster
  • GumStick - Another nice little card
Johan
+8  A: 

I'm a fan of the AVR butterfly and the Arduino. 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 - Really good hobbyist retailer, with excellent forums and tutorials.
  • AVR Freaks - The main online community for AVR related hardware.
  • Also look around for robotics clubs that may be in your area.
MrEvil
A: 

Hello Everyone,

I have a few questions along the same lines. I have a EE background with fpga design expereince and writing low-level C/C++ firmware code. I want to get into the embedded field more in the lines of linux RTOS. I have bought a few RTOS fundamentals books to give me theoretical knowledge. But I would like to get my hands dirty with some actual project I can work with. Can someone please tell me a of an emulator/simulator I can use on my PC to get started with embedded linux and some reference books/ sites to actually build some stuff with it as well.

Thank You, -rt

A: 

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

User
A: 

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 http://www.mikroe.com/eng/categories/view/6/pic-development-tools/

O Engenheiro