SlideShare a Scribd company logo
Device Tree Overlay
Implementation
on AOSP 9.0
WIG CHENG IN COSCUP 2020
2020/8/1
Me
Name: Wig
Work: Technexion
#> Embedded Linux
#> Industrial Android BSP
#> Robotic OS
Github: @wigcheng
Contents
• Introduce Device Tree Overlay
• AOSP 9.0 new feature: DTBO
• Implement DTBO on AOSP 9.0
•Big issue
•Make a DTBO image including DTB and DTBO
•U-boot Tweaking
• Future work
• Android 10 and 11
• Conclusion
Introduce Device Tree Overlay
Why Device Tree Overlay?
NFC HAT
VOICE HAT
RS485 HAT
CAN BUS HAT
LED HAT
a.dtb
DTB: Device Tree BlobDTS: Device Tree Source DTBO: Device Tree Blob for Overlay
a-nfc.dtbTraditional Solution
a-voicehat.dtb
a-rs485.dtb
a-can.dtb
a-led.dtb
Multiple inch LCD
a-5inch-lcd.dtb
a-10inch-lcd.dtb
...
a-60inch-lcd.dtb
U-boot
Kernel Image
a-nfc.dtb
a-voicehat.dtb
a-rs485.dtb
a-60inch-lcd.dtb
...
Why Device Tree Overlay? (cont.)
NFC HAT
VOICE HAT
RS485 HAT
CAN BUS HAT
LED HAT
a.dtb
nfc.dtboOverlay Solution
voicehat.dtbo
rs485.dtbo
can.dtbo
led.dtbo
Multiple inch LCD
5inch-lcd.dtbo
10inch-lcd.dtbo
...
60inch-lcd.dtbo
U-boot
Kernel Image
a.dtb
nfc.dtbo
voicehat.dtbo
60inch-lcd.dtbo
...
Linux example (in u-boot)
~# fdt addr ${fdt_addr}
~# fdt resize ${fdt_buffer}
~# setexpr fdtovaddr ${fdt_addr} + 0xF0000;
~# fatload mmc ${mmcdev}:${mmcpart} ${fdtovaddr} xxx.dtbo
~# fdt apply ${fdtovaddr}
U-boot
Kernel Image
a.dtb
nfc.dtbo
voicehat.dtbo
60inch-lcd.dtbo
...
Rootfs
FAT partition
AOSP 9.0 new feature: DTBO
AOSP 9.0 partitions
bootloader
boot
dtbo
vbmeta
system
vendor
recovery
presister
user data
Non-AB system
bootloader
user data
system
boot vendor
AB system
dtbo
vbmeta
presister
Source: https://source.android.com/devices/architec ture/dto/partitions
DTBO Overview
o Special Image format such as boot.img
o Depend on dt_table structure
o Depend on boot image header version
Pie
Pie Non AB
DTBO Overview (cont.d)
Structure prototype in U-boot:
1. Boot Image header: <source>/include/android_image.h
2. DT table: <source>/include/dt_table.h
Implement DTBO on AOSP 9.0
Big issue
ANDROID OPEN SOURCE BSP
Case: PICO-IMX8MM
• CPU: NXP ARM Cortex-A53 IMX8M-Mini 4-core 1.2GHz
• DRAM: 4GB
• OS: Android 9.0.0
• Complexity issue: NXP does not support multiple dtb in DTBO
[** L**] The dtbo image will be loaded from eMMC to dram in the process
of AVB verify, after verify pass the correct dtb will then be loaded to the
right address. We have only one dtb so the load process is quite simple,
you can check do_boota() in “drivers/usb/gadget/f_fastboot.c” for more
details. You don’t see the custom dtb because only the first dtb in the
dtbo will be loaded by default, what you have to do is load the second
(custom dtb) yourself.
I'm not very familiar with the dtbo.img loading process or format, I merely
helped Linaro get the headers from AOSP to U-Boot. In your case I would ask
Sam ( s***n.p******o@linaro.org ) about it. This dtbo.img is relatively new
and a bit of a niche so googling might not help.
Regards,
d****
Raspberry PI case
Classic AOSP A/B system case
bootloader boot_a
dtbo_a
vbmeta_a
system_a
vendor_a
Normal reboot
Fastboot mode
Upgrade mode
Raspberry PI case
bootloader boot_a
dtbo_a
vmeta_a
system
vendor
FAT partition
zImage bootargs dtb,dtbos uramdisk
Raspberry Open source project (Reference: android-rpi repo)
Is it useable?
Make a DTBO image
Path: <source>/device/fsl/imx8m/pico_imx8mm/AndroidBoard.mk
LOCAL_PATH := $(call my-dir)
include device/fsl/common/build/kernel.mk
include device/fsl/common/build/uboot.mk
include device/fsl/common/build/dtbo.mk
...
include $(LOCAL_PATH)/AndroidTee.mk
include $(FSL_PROPRIETARY_PATH)/fsl-proprietary/media-profile/media-profile.mk
include $(FSL_PROPRIETARY_PATH)/fsl-proprietary/sensor/fsl-sensor.mk
Make a DTBO image (cont.d)
Path: <source>/device/fsl/common/build/dtbo.mk
TARGET_BOARD_DTS_CONFIG := imx8mm:imx8mm-pico-pi-ili9881c.dtb dtbo-imx8mm.img
Make a DTBO image (cont.d)
/host/linux-x86/bin/mkdtimg create dtbo.img
target/product/pico_imx8mm/obj/KERNEL_OBJ/arch/arm64/boot/dts/freescale/imx8mm-pico-pi.dtb
target/product/pico_imx8mm/obj/KERNEL_OBJ/arch/arm64/boot/dts/freescale/overlays/imx8mm-pico-pi-nfc.dtbo
Device Tree Overlay implementation on AOSP 9.0
Make a DTBO image (cont.d)
TARGET_BOARD_DTS_CONFIG := imx8mm:imx8mm-pico-pi-ili9881c.dtb
TARGET_BOARD_DTBO_CONFIG := imx8mm:imx8mm-pico-pi-mipi_5-overlay.dts.dtbo
dtbo-imx8mm.img
dtbo.img
Get A/B slot
boot.img
Load kernel addr
Load boot header
U-boot Tweaking (before)
Path: <source>/vendor/nxp-opensource/uboot-imx/drivers/usb/gadget/f_fastboot.c
Start boota
AVB verification
Checking
AB/ NonAB
Load ramdisk addr
Second addr
Load table
Load entry[0] boot
kernel
U-boot V2018.03
dtbo.img
Get A/B slot
boot.img
Load kernel addr
Load boot header
U-boot Tweaking (after)
Path: <source>/vendor/nxp-opensource/uboot-imx/drivers/usb/gadget/f_fastboot.c
Start boota
AVB verification
Checking
AB/ NonAB
Load ramdisk addr
Second addr
Load table
Load entry[0] (dtb)
boot
kernel
Load entry[n] (dtbo)
merge entry[n]
Update second addr
U-boot V2018.03
Merge API: CONFIG_OF_LIBFDT_OVERLAY=y
Patch link
[** L**]
Nice to hear it works out! We are glad to see the patches if you can share
it with us.
Future Work
What about boot image V2
• For Android 10
• Add "DTB" field
• Keep DTB files in Boot Image
(concatenated or in DTBO image format)
• All DTBO files must be stored in ‘dtbo’
partition
End?? No, V3 format coming
• For Android 11
• Needed for GKI (Generic Kernel Image)
• Other new features and partition layouts...
Other vendors....
V1 V2 V3
NXP IMX8
Android 10
✔
TI Beagle Board
Android 10
✔
Rockchip RK3399
Android 10
✔
MTK Android 11 ✔
Summary
• DTBO discussion
Pros
• Overcome complexity issue for runtime level
• Match AOSP security architecture
• Easy to make a DTBO image
Cons
• The version of Boot image header changes are being made too fast
• Google said it's universal for all vendors, but the truth is different implement
methods for each vendors
Thank you for your listen!
Reference
• Google DTBO overview
• Linaro Connect resource:
SAN19-217 - New Android requirements for bootloaders
• Linux example: load device tree overlay on u-boot

More Related Content

PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
PDF
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
ODP
Q4.11: Porting Android to new Platforms
PPTX
Linux PCI device driver
PDF
Booting Android: bootloaders, fastboot and boot images
PDF
Kdump and the kernel crash dump analysis
PDF
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
PDF
Linux Internals - Part II
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Q4.11: Porting Android to new Platforms
Linux PCI device driver
Booting Android: bootloaders, fastboot and boot images
Kdump and the kernel crash dump analysis
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Linux Internals - Part II

What's hot (20)

PPTX
Linux Kernel MMC Storage driver Overview
PDF
Embedded Linux from Scratch to Yocto
PDF
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
PDF
Linux Kernel - Virtual File System
PPT
Linux Crash Dump Capture and Analysis
PPTX
Linux Device Driver’s
PDF
Kernel Recipes 2015 - Kernel dump analysis
PDF
Arm device tree and linux device drivers
PDF
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
Embedded Android : System Development - Part II (HAL)
PDF
Android Treble: Blessing or Trouble?
PPT
Learning AOSP - Android Booting Process
PDF
Device Tree for Dummies (ELC 2014)
PDF
Embedded Linux BSP Training (Intro)
PDF
Building aosp
PDF
Kernel_Crash_Dump_Analysis
PDF
Embedded Android : System Development - Part I
PDF
Red Hat OpenStack 17 저자직강+스터디그룹_3주차
PPTX
BIND DNS Configuration Red Hat 5
Linux Kernel MMC Storage driver Overview
Embedded Linux from Scratch to Yocto
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
Linux Kernel - Virtual File System
Linux Crash Dump Capture and Analysis
Linux Device Driver’s
Kernel Recipes 2015 - Kernel dump analysis
Arm device tree and linux device drivers
Kernel Recipes 2017 - An introduction to the Linux DRM subsystem - Maxime Ripard
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (HAL)
Android Treble: Blessing or Trouble?
Learning AOSP - Android Booting Process
Device Tree for Dummies (ELC 2014)
Embedded Linux BSP Training (Intro)
Building aosp
Kernel_Crash_Dump_Analysis
Embedded Android : System Development - Part I
Red Hat OpenStack 17 저자직강+스터디그룹_3주차
BIND DNS Configuration Red Hat 5
Ad

Similar to Device Tree Overlay implementation on AOSP 9.0 (20)

PDF
Kubernetes on Bare Metal at the Kitchener-Waterloo Kubernetes and Cloud Nativ...
PPTX
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
PDF
Check the version with fixes. Link in description
PDF
Docker 활용법: dumpdocker
PPTX
ChromePad - Chromium OS ThinkPad X220
PDF
BeagleBone Black: Platform Bring-Up with Upstream Components
PPTX
ChromePad - Chromium OS for ThinkPad
PDF
Docker as an every day work tool
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
PDF
A million ways to provision embedded linux devices
TXT
OPTEE on QEMU - Build Tutorial
PPTX
Effective images remix
PPTX
Starting Raspberry Pi
PDF
Ci For The Web 2.0 Guy Or Gal
PDF
Next Stop, Android
PPTX
C# Production Debugging Made Easy
PDF
Compiling and using u boot for beagle bone
PPTX
Introduction to Docker
PDF
Hardwear.io 2018 BLE Security Essentials workshop
PPTX
k8s practice 2023.pptx
Kubernetes on Bare Metal at the Kitchener-Waterloo Kubernetes and Cloud Nativ...
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Check the version with fixes. Link in description
Docker 활용법: dumpdocker
ChromePad - Chromium OS ThinkPad X220
BeagleBone Black: Platform Bring-Up with Upstream Components
ChromePad - Chromium OS for ThinkPad
Docker as an every day work tool
Let's trace Linux Lernel with KGDB @ COSCUP 2021
A million ways to provision embedded linux devices
OPTEE on QEMU - Build Tutorial
Effective images remix
Starting Raspberry Pi
Ci For The Web 2.0 Guy Or Gal
Next Stop, Android
C# Production Debugging Made Easy
Compiling and using u boot for beagle bone
Introduction to Docker
Hardwear.io 2018 BLE Security Essentials workshop
k8s practice 2023.pptx
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
KodekX | Application Modernization Development
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
KodekX | Application Modernization Development
The AUB Centre for AI in Media Proposal.docx
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Understanding_Digital_Forensics_Presentation.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
Digital-Transformation-Roadmap-for-Companies.pptx

Device Tree Overlay implementation on AOSP 9.0

  • 1. Device Tree Overlay Implementation on AOSP 9.0 WIG CHENG IN COSCUP 2020 2020/8/1
  • 2. Me Name: Wig Work: Technexion #> Embedded Linux #> Industrial Android BSP #> Robotic OS Github: @wigcheng
  • 3. Contents • Introduce Device Tree Overlay • AOSP 9.0 new feature: DTBO • Implement DTBO on AOSP 9.0 •Big issue •Make a DTBO image including DTB and DTBO •U-boot Tweaking • Future work • Android 10 and 11 • Conclusion
  • 5. Why Device Tree Overlay? NFC HAT VOICE HAT RS485 HAT CAN BUS HAT LED HAT a.dtb DTB: Device Tree BlobDTS: Device Tree Source DTBO: Device Tree Blob for Overlay a-nfc.dtbTraditional Solution a-voicehat.dtb a-rs485.dtb a-can.dtb a-led.dtb Multiple inch LCD a-5inch-lcd.dtb a-10inch-lcd.dtb ... a-60inch-lcd.dtb U-boot Kernel Image a-nfc.dtb a-voicehat.dtb a-rs485.dtb a-60inch-lcd.dtb ...
  • 6. Why Device Tree Overlay? (cont.) NFC HAT VOICE HAT RS485 HAT CAN BUS HAT LED HAT a.dtb nfc.dtboOverlay Solution voicehat.dtbo rs485.dtbo can.dtbo led.dtbo Multiple inch LCD 5inch-lcd.dtbo 10inch-lcd.dtbo ... 60inch-lcd.dtbo U-boot Kernel Image a.dtb nfc.dtbo voicehat.dtbo 60inch-lcd.dtbo ...
  • 7. Linux example (in u-boot) ~# fdt addr ${fdt_addr} ~# fdt resize ${fdt_buffer} ~# setexpr fdtovaddr ${fdt_addr} + 0xF0000; ~# fatload mmc ${mmcdev}:${mmcpart} ${fdtovaddr} xxx.dtbo ~# fdt apply ${fdtovaddr} U-boot Kernel Image a.dtb nfc.dtbo voicehat.dtbo 60inch-lcd.dtbo ... Rootfs FAT partition
  • 8. AOSP 9.0 new feature: DTBO
  • 9. AOSP 9.0 partitions bootloader boot dtbo vbmeta system vendor recovery presister user data Non-AB system bootloader user data system boot vendor AB system dtbo vbmeta presister
  • 10. Source: https://source.android.com/devices/architec ture/dto/partitions DTBO Overview o Special Image format such as boot.img o Depend on dt_table structure o Depend on boot image header version Pie Pie Non AB
  • 11. DTBO Overview (cont.d) Structure prototype in U-boot: 1. Boot Image header: <source>/include/android_image.h 2. DT table: <source>/include/dt_table.h
  • 12. Implement DTBO on AOSP 9.0
  • 14. Case: PICO-IMX8MM • CPU: NXP ARM Cortex-A53 IMX8M-Mini 4-core 1.2GHz • DRAM: 4GB • OS: Android 9.0.0 • Complexity issue: NXP does not support multiple dtb in DTBO
  • 15. [** L**] The dtbo image will be loaded from eMMC to dram in the process of AVB verify, after verify pass the correct dtb will then be loaded to the right address. We have only one dtb so the load process is quite simple, you can check do_boota() in “drivers/usb/gadget/f_fastboot.c” for more details. You don’t see the custom dtb because only the first dtb in the dtbo will be loaded by default, what you have to do is load the second (custom dtb) yourself.
  • 16. I'm not very familiar with the dtbo.img loading process or format, I merely helped Linaro get the headers from AOSP to U-Boot. In your case I would ask Sam ( s***n.p******o@linaro.org ) about it. This dtbo.img is relatively new and a bit of a niche so googling might not help. Regards, d****
  • 17. Raspberry PI case Classic AOSP A/B system case bootloader boot_a dtbo_a vbmeta_a system_a vendor_a Normal reboot Fastboot mode Upgrade mode
  • 18. Raspberry PI case bootloader boot_a dtbo_a vmeta_a system vendor FAT partition zImage bootargs dtb,dtbos uramdisk Raspberry Open source project (Reference: android-rpi repo)
  • 20. Make a DTBO image Path: <source>/device/fsl/imx8m/pico_imx8mm/AndroidBoard.mk LOCAL_PATH := $(call my-dir) include device/fsl/common/build/kernel.mk include device/fsl/common/build/uboot.mk include device/fsl/common/build/dtbo.mk ... include $(LOCAL_PATH)/AndroidTee.mk include $(FSL_PROPRIETARY_PATH)/fsl-proprietary/media-profile/media-profile.mk include $(FSL_PROPRIETARY_PATH)/fsl-proprietary/sensor/fsl-sensor.mk
  • 21. Make a DTBO image (cont.d) Path: <source>/device/fsl/common/build/dtbo.mk TARGET_BOARD_DTS_CONFIG := imx8mm:imx8mm-pico-pi-ili9881c.dtb dtbo-imx8mm.img
  • 22. Make a DTBO image (cont.d) /host/linux-x86/bin/mkdtimg create dtbo.img target/product/pico_imx8mm/obj/KERNEL_OBJ/arch/arm64/boot/dts/freescale/imx8mm-pico-pi.dtb target/product/pico_imx8mm/obj/KERNEL_OBJ/arch/arm64/boot/dts/freescale/overlays/imx8mm-pico-pi-nfc.dtbo
  • 24. Make a DTBO image (cont.d) TARGET_BOARD_DTS_CONFIG := imx8mm:imx8mm-pico-pi-ili9881c.dtb TARGET_BOARD_DTBO_CONFIG := imx8mm:imx8mm-pico-pi-mipi_5-overlay.dts.dtbo dtbo-imx8mm.img
  • 25. dtbo.img Get A/B slot boot.img Load kernel addr Load boot header U-boot Tweaking (before) Path: <source>/vendor/nxp-opensource/uboot-imx/drivers/usb/gadget/f_fastboot.c Start boota AVB verification Checking AB/ NonAB Load ramdisk addr Second addr Load table Load entry[0] boot kernel U-boot V2018.03
  • 26. dtbo.img Get A/B slot boot.img Load kernel addr Load boot header U-boot Tweaking (after) Path: <source>/vendor/nxp-opensource/uboot-imx/drivers/usb/gadget/f_fastboot.c Start boota AVB verification Checking AB/ NonAB Load ramdisk addr Second addr Load table Load entry[0] (dtb) boot kernel Load entry[n] (dtbo) merge entry[n] Update second addr U-boot V2018.03 Merge API: CONFIG_OF_LIBFDT_OVERLAY=y
  • 28. [** L**] Nice to hear it works out! We are glad to see the patches if you can share it with us.
  • 30. What about boot image V2 • For Android 10 • Add "DTB" field • Keep DTB files in Boot Image (concatenated or in DTBO image format) • All DTBO files must be stored in ‘dtbo’ partition
  • 31. End?? No, V3 format coming • For Android 11 • Needed for GKI (Generic Kernel Image) • Other new features and partition layouts...
  • 32. Other vendors.... V1 V2 V3 NXP IMX8 Android 10 ✔ TI Beagle Board Android 10 ✔ Rockchip RK3399 Android 10 ✔ MTK Android 11 ✔
  • 33. Summary • DTBO discussion Pros • Overcome complexity issue for runtime level • Match AOSP security architecture • Easy to make a DTBO image Cons • The version of Boot image header changes are being made too fast • Google said it's universal for all vendors, but the truth is different implement methods for each vendors
  • 34. Thank you for your listen!
  • 35. Reference • Google DTBO overview • Linaro Connect resource: SAN19-217 - New Android requirements for bootloaders • Linux example: load device tree overlay on u-boot