Embedded Software Fundamentals How does code get converted into ones and zeroes? Kizito NKURIKIYEYEZU, Ph.D. Reading material Read the following resources available on the course platforms 1 Chapter 1 of White, E. (2011). Making Embedded Systems: Design Patterns for Great Software. " O’Reilly Media, Inc.". 2 Chapter 3 of Bertolotti, I. C., & Hu, T. (2017). Embedded Software Development. Amsterdam University Press. Kizito NKURIKIYEYEZU, Ph.D. Embedded Software Fundamentals September 26, 2021 1 / 22 Kizito NKURIKIYEYEZU, Ph.D. Embedded Software Fundamentals September 26, 2021 2 / 22 Components of embedded software development Host Machine Development Environments Compiler Toolchain Debuggers Development Kits Version Control FIG 1. Components of an embedded development Kizito NKURIKIYEYEZU, Ph.D. Embedded Software Fundamentals September 26, 2021 3 / 22
7
Embed
Embedded Software Fundamentals - How does code get ...
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Embedded SoftwareFundamentals
How does code get converted into ones and zeroes?
Kizito NKURIKIYEYEZU,Ph.D.
Reading materialRead the following resources available on the course platforms
1 Chapter 1 of White, E. (2011). Making Embedded Systems:Design Patterns for Great Software. " O’Reilly Media, Inc.".
2 Chapter 3 of Bertolotti, I. C., & Hu, T. (2017). Embedded SoftwareDevelopment. Amsterdam University Press.
The software is organized inlayersEach layer assumes specificfunctionalityModules are described inC-files (.c)Definitions are described inheader files (.h)Functions interact with othermodulesEventually interact withHardware
Availability of compilers for almostany MCUSmall executableDeterministic resource use (e.g.,no dynamic memory allocation)Efficient Memory ManagementTiming-centric operationsDirection Hardware/IO ControlOptimized executionNote: Modern C++ is as efficientas C and I believe it will slowlyreplace C in the future. For detailssee Kormanyos, C. (2018).Real-time C++: efficientobject-oriented and templatemicrocontroller programming
FIG 4. C can be used even onvery small micro-controllersThe ATtiny20-UUR is an AVRmicro-controller that is smallerthan a grain of rice. It is an8-Bit IC that runs at 12MHz2KB (1K x 16) FLASH and12-WLCSP (1.56x1.4)
FIG 5. Embedded System Development PlatformThe host machine contains the build environment for an embedded system. Itcontains a cross compiler and a cross debugger. The debug allowscommunication between the target processor through a special processorinterface, the JTAG
FIG 8. Detailed embedded C compilation processThe C preprocessor transform the program before actual compilation. Thecompiler translate the source code into opcode (object files) for the targetprocessor. The linker combine these object files and resolve all of theunresolved symbols. The locator assign physical memory addresses to each ofthe code and data and produce an output file containing a binary memoryimage that can be loaded into the target ROM.
FIG 9. The role of a preprocessorThe C preprocessor is the macro preprocessor for the C compiler. Thepreprocessor provides the ability for the inclusion of header files, macroexpansions, conditional compilation, and line control.
FIG 10. The role of a linkerThe linker combines all of objects files into a single executable object codeuses symbols to reference other functions/variables
FIG 11. Linear detailed embedded C compilation processThe compiler translate the source code into opcode (object files) for the targetprocessor. The linker combine these object files and resolve all of theunresolved symbols. The locator assign physical memory addresses to each ofthe code and data and produce an output file containing a binary memoryimage that can be loaded into the target ROM.
4 Linker: Finally, the linker links the object code with the librarycode to produce an executable and linkable format (.elf) file"blink.elf".
avr-gcc blink.o -o blink.elfThis generates an .elf file isn’t directly executable by theMCU. Thus, one needs to extract the machine code from it inthe Intel Hex format
Building can be tediousMany GCC flagsMany independentcommandsMany build targetsMany supportedarchitecturesMany source files
Building manually cancause consistency issueswaste development time
Real world software iscomplex. For example, theLinux kernel contains:
More than 23,000 .c filesMore than 18,000 headerfileMore than 1,400assembly filesHow would you compilerthis manually?
In most cases, one can usean Integrated developmentenvironment (IDE) toautomate this process.
Why use an automatic build system?Build Management Software (or Build Automation) provides asimple and consistent method for producing a target executable