Your SlideShare is downloading. ×
0
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Compilers programmingembedded
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Compilers programmingembedded

569

Published on

kjj

kjj

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
569
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
38
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Compilers, assemblers, linkers, loaders, and programming issues For embedded Systems Chris Gregg January 29, 2009
  • 2. is programming for an embedded system different? <ul><li>Speed </li></ul><ul><li>Size </li></ul><ul><li>Correctness </li></ul><ul><li>Portability </li></ul><ul><li>Real-Time or not </li></ul><ul><li>Other Hardware Considerations </li></ul>
  • 3. How does one actually program an embedded system? <ul><li>Has this changed over the years? Has there been significant progress? </li></ul><ul><ul><li>How does Ford program their Fuel Injection System computer? </li></ul></ul><ul><ul><li>How does GE program their Microwave Ovens (and was this different 30 years ago?) </li></ul></ul><ul><ul><li>How does Nikon program their digital SLR cameras? </li></ul></ul><ul><ul><li>How does Apple/RIM/Microsoft program their iPhone/Blackberry/SmartPhone? </li></ul></ul><ul><ul><li>How does a hobbyist program a Pic microprocessor? </li></ul></ul><ul><ul><li>How does NASA program (and reprogram ) the Mars Rover? </li></ul></ul><ul><ul><li>How did James Gosling at Sun want his set-top boxes programmed? </li></ul></ul><ul><ul><li>(How was the original 128K Macintosh programmed?) </li></ul></ul>
  • 4. Programming Languages Machine Code Assembly Code Higher Level Languages Fixed Rom, Ram, Firmware Compiled C , nesC, C++, Ada, Forth, etc. Interpreted (?) Perl, Python, Javascript Markup HTML, XML Java All Eventually End up as Machine Code
  • 5. So you’ve chosen C. Let’s Go! <ul><li>What does a programmer need to know about programming for an embedded system? </li></ul><ul><li>She’d better know about the hardware. </li></ul><ul><ul><li>Purpose </li></ul></ul><ul><ul><li>How data flows (to include getting the program onto the system, I/O), how to interface with sensors, actuators, etc. </li></ul></ul><ul><ul><li>Whether there is an operating system, and how it runs programs </li></ul></ul><ul><ul><li>Limitations: memory, speed, upgradability (firmware?) </li></ul></ul><ul><ul><li>How are hardware errors handled? (think Mars Rover) </li></ul></ul><ul><ul><li>Plan on debugging hardware issues… </li></ul></ul>(Not so fast.)
  • 6. So you’ve chosen C. Let’s Go! <ul><li>What does a programmer need to know about programming for an embedded system? </li></ul><ul><li>She’d better know about the software tools related to programming for the specific hardware. </li></ul><ul><ul><li>Is there a compiler/linker/assembler? (hopefully!) </li></ul></ul><ul><ul><li>How is the memory addressed, what bit-level knowledge of the hardware is necessary, how does one access pins, etc.? </li></ul></ul><ul><ul><li>How will debugging be managed? </li></ul></ul><ul><ul><li>How will testing be done? </li></ul></ul><ul><ul><li>What licensing needs to be organized (this can be tricky!) </li></ul></ul><ul><ul><li>Does the software need to be portable? (using C is probably going to help you—see the second point above). </li></ul></ul>(Not so fast.)
  • 7. The Embedded Software Development Process Barr, M. &amp; Massa, A. Oram, A. (ed.) Programming Embedded Systems in C and C++, 2nd Edition. O&apos;Reilly &amp; Associates, Inc., 2006 , p.55
  • 8. The Tools <ul><li>Compiler: Translates human readable code into assembly language or opcodes for a particular processor (or possibly into machine-independent opcodes a la Java). Produces an object file. </li></ul><ul><li>Assembler: Translates assembly language into opcodes (it is really a compiler, too). Also produces an object file. </li></ul><ul><li>Linker: Organizes the object files, necessary libraries, and other data and produces a relocatable file. </li></ul><ul><li>Locator: Takes the relocatable file and information about the memory of the system and produces an executable. </li></ul><ul><li>(By the way: gcc takes care of all of these functions at once) </li></ul>
  • 9. The Tools: Embedded System Specifics <ul><li>All of the tools run on the host computer, not the embedded computer. </li></ul><ul><li>Compiler: Has to know about the specific hardware (except in very trivial cases). Should be able to optimize for size. </li></ul><ul><li>Assembler: Produces “startup code”; not inserted automatically as in general purpose computers (i.e., the programmer needs to compile it independently). </li></ul><ul><li>Linker: Needs the correct libraries (open source c libraries, such as newlib , are available). </li></ul><ul><li>Locator: Needs programmer input for information about memory. </li></ul>Bottom Line: There can be a lot of extra work for the programmer, although certain systems (e.g. Pic programming) tools can automate most of it.
  • 10. Moving the program onto the embedded system <ul><li>Remember, the program is written (and possibly run in an emulator) on a host computer, but it still needs to get onto the embedded system. </li></ul><ul><li>Methods: </li></ul><ul><ul><li>Build/burn the program into the hardware (firmware or other flash memory) </li></ul></ul><ul><ul><li>Bootloader: a bootloader resides on the embedded system and facilitates loading programs onto the system. </li></ul></ul><ul><ul><li>Debug Monitor: The debug monitor is a more robust program on an embedded system that helps with debugging and other chores, and can include a bootloader as well. </li></ul></ul>
  • 11. Debugging <ul><li>Debugging embedded systems can be facilitated with a Debug Monitor, or through a remote debugger on the host computer. A serial link is normally set up, and the debugger acts more or less like a general purpose debugger. </li></ul><ul><li>Emulators can be used to test the system without utilizing the actual hardware (but this has many caveats, and nothing beats testing on the real system). </li></ul><ul><li>Software Simulators allow the programmer to debug completely on the host system, which can be quicker and can allow faster code turnaround. </li></ul><ul><li>When it comes down to it, an oscilloscope and a multimeter can be your best friend for debugging. </li></ul>
  • 12. Final Thoughts <ul><li>Programming for embedded systems has come a long way since the days of toggle switches, but it still involves greater programmer involvement in the hardware aspect of the system. </li></ul><ul><li>There are many software tools built for embedded systems, and many embedded system hardware designers include debugging tools with the hardware. </li></ul><ul><li>You had probably learn C (and a fair amount of assembly) to program embedded systems. </li></ul>
  • 13. Final Thoughts <ul><li>Is this a necessary topic for an Embedded Systems class? </li></ul><ul><li>Yes </li></ul><ul><ul><li>You’ve got to get your program onto the system some how, and flipping toggle switches doesn’t put food on the table any more. </li></ul></ul><ul><ul><li>Hardware only does what you tell it to, via software. </li></ul></ul><ul><ul><li>Discussion of the tradeoffs necessary to program an embedded system versus a GP system is a necessity. </li></ul></ul>
  • 14. 6 Questions <ul><li>Discuss the steps needed to get a program from source code to executable in an embedded system, and the differences between similar steps on a general purpose system. </li></ul><ul><li>What trade-offs are necessary when thinking about how you are going to program for an embedded system? </li></ul><ul><li>Why is C generally considered a better language to program in for embedded systems than, say, Java or Perl? </li></ul>
  • 15. 6 Questions <ul><li>Name three different ways you might debug the code for your embedded system. </li></ul><ul><li>Why is it imperative that an embedded system programmer know the details of the hardware that she is programming for? Compare this to someone writing a Java applet for a web site. </li></ul><ul><li>Talk about the role firmware plays in developing software for an embedded system. </li></ul>
  • 16. Bibliography <ul><li>Barr, M. &amp; Massa, A. Oram, A. (ed.) Programming Embedded Systems in C and C++, 2nd Edition. O&apos;Reilly &amp; Associates, Inc., 2006 </li></ul><ul><li>Wolfe, M. How compilers and tools differ for embedded systems. 2005 . http://www.pgroup.com/lit/pgi_article_cases.pdf </li></ul><ul><li>Gay, D.; Levis, P.; von Behren, R.; Welsh, M.; Brewer, E. &amp; Culler, D. The nesC language: A holistic approach to networked embedded systems SIGPLAN Not., ACM, 2003 , 38 , 1-11 </li></ul><ul><li>Williams, B.; Ingham, M.; Chung, S. &amp; Elliott, P. Model-based programming of intelligent embedded systems and robotic space explorers Proceedings of the IEEE, 2003 , 91 , 212-237 </li></ul>

×