SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
The First Practical, Hands-On Guide to Embedded System Programming for Android
Today, embedded systems programming is a more valuable discipline than ever, driven by fast-growing, new fields such as wearable technology and the Internet of Things. In this concise guide, Roger Ye teaches all the skills you’ll need to write the efficient embedded code necessary to make tomorrow’s Android devices work.
The first title in Addison-Wesley’s new Android™ Deep Dive series for intermediate and expert Android developers, Embedded Programming with Android™ draws on Roger Ye’s extensive experience with advanced projects in telecommunications and mobile devices. Step by step, he guides you through building a system with all the key components Android hardware developers must deliver to manufacturing. By the time you’re done, you’ll have the key programming, compiler, and debugging skills you’ll need for real-world projects.
First, Ye introduces the essentials of bare-metal programming: creating assembly language code that runs directly on hardware. Then, building on this knowledge, he shows how to use C to create hardware interfaces for booting a Linux kernel with the popular U-Boot bootloader. Finally, he walks you through using filesystem images to boot Android and learning to build customized ROMs to support any new Android device. Throughout, Ye provides extensive downloadable code you can run, explore, and adapt.
You will
Preface xv
Acknowledgments xxi
About the Author xxiii
Part I: Bare Metal Programming 1
Chapter 1: Introduction to Embedded System Programming 3
What Is an Embedded System? 3
Bare Metal Programming 3
Learning Embedded System Programming 5
Software Layers in an Embedded System 7
Tools and Hardware Platform 11
The Difference between Virtual Hardware and Real Hardware 11
Summary 12
Chapter 2: Inside Android Emulator 13
Overview of the Virtual Hardware 13
Configuring Android Virtual Devices 14
Hardware Interfaces 17
Serial 18
Timer 18
Summary 24
Chapter 3: Setting Up the Development Environment 25
The Host and Client Environments 25
Development Environment Setup 26
Downloading and Installing Android SDK 27
Downloading and Installing the GNU Toolchain for ARM 27
Integrated Development Environment 29
Your First ARM Program 29
Building the Binary 30
Running in the Android Emulator 32
makefile for the Example Projects 36
Summary 38
Chapter 4: Linker Script and Memory Map 39
Memory Map 39
Linker 41
Linker Script 51
Linker Script Example 53
Initializing Data in RAM 56
Summary 61
Chapter 5: Using the C Language 63
C Startup in a Bare Metal Environment 63
Calling Convention 78
Goldfish Serial Port Support 81
Summary 92
Chapter 6: Using the C Library 93
C Library Variants 93
Newlib C Library 96
Common Startup Code Sequence 97
CS3 Linker Scripts 97
Customized CS3 Startup Code for the Goldfish Platform 103
System Call Implementations 104
Running and Debugging the Library 112
Using Newlib with QEMU ARM Semihosting 116
Summary 122
Chapter 7: Exception Handling and Timer 125
Goldfish Interrupt Controller 125
The Simplest Interrupt Handler 128
Nested Interrupt Handler 140
Testing System Calls/Software Interrupts 163
Timer 164
Real-Time Clock 172
Summary 181
Chapter 8: NAND Flash Support in Goldfish 183
Android File System 183
NAND Flash Properties 185
NAND Flash Programming Interface in the Goldfish Platform 187
Memory Technology Device Support 188
MTD API 189
NAND Flash Programming Interface Test Program 206
Summary 216
Part II: U-Boot 217
Chapter 9: U-Boot Porting 219
Introducing U-Boot 219
Downloading and Compiling U-Boot 220
Debugging U-Boot with GDB 224
Porting U-Boot to the Goldfish Platform 227
Summary 246
Chapter 10: Using U-Boot to Boot the Goldfish Kernel 249
Building the Goldfish Kernel 249
Prebuilt Toolchain and Kernel Source Code 250
Running and Debugging the Kernel in the Emulator 252
Booting Android from NOR Flash 254
Booting Android from NAND Flash 270
Summary 280
Part III: Android System Integration 281
Chapter 11: Building Your Own AOSP and CyanogenMod 283
Introducing AOSP and CyanogenMod 283
Setting Up an Android Virtual Device 284
AOSP Android Emulator Build 288
CyanogenMod Android Emulator Build 297
Summary 307
Chapter 12: Customizing Android and Creating Your Own Android ROM 309
Supporting New Hardware in AOSP 309
Supporting New Hardware in CyanogenMod 332
Summary 338
Part IV: Appendixes 339
Appendix A: Building the Source Code for This Book 341
Setting Up the Build Environment 341
Setting Up a Virtual Machine 344
Organization of Source Code 344
Source Code for Part I 345
Source Code for Part II 350
Source Code for Part III 352
Appendix B: Using Repo in This Book 355
Resources for Repo 355
Syncing a New Source Tree In Minutes 355
Downloading Git Repositories Using Local Manifest 356
Index 359