aboutsummaryrefslogtreecommitdiff
path: root/en/devices/architecture/dto/optimize.html
diff options
context:
space:
mode:
authorAndroid Partner Docs <noreply@android.com>2018-08-08 13:50:33 -0700
committerClay Murphy <claym@google.com>2018-08-08 14:05:32 -0700
commitea448b829ef3c5eefcadcd50fdf74c873eeadd86 (patch)
tree34c2647a8d8c2dffdbcdac2c5ba11d41d1426da8 /en/devices/architecture/dto/optimize.html
parent19a77ba572d415186ce503e4bf8be87fe45d08eb (diff)
downloadsource.android.com-ea448b829ef3c5eefcadcd50fdf74c873eeadd86.tar.gz
Docs: Changes to source.android.com
- 207940242 One more fix: add header for Television Requirements. by Gina Dimino <gdimino@google.com> - 207936055 Update health README link. by Android Partner Docs <noreply@android.com> - 207929938 Errata run for Android 9 CDD. by Gina Dimino <gdimino@google.com> - 207897850 Fix typos in Develop and Configure index pages by Kenneth Lau <kennethlau@google.com> - 207813977 Devsite localized content from translation request 958913. by Android Partner Docs <noreply@android.com> - 207813949 Devsite localized content from translation request 953118. by Android Partner Docs <noreply@android.com> - 207813941 Devsite localized content from translation request 961934. by Android Partner Docs <noreply@android.com> - 207813934 Devsite localized content from translation request 552632. by Android Partner Docs <noreply@android.com> - 207813463 Update line numbers in links by Kenneth Lau <kennethlau@google.com> - 207796341 Fixing the URL for the CDD link in versions file. by Gina Dimino <gdimino@google.com> - 207779392 Fix incorrect link by Kenneth Lau <kennethlau@google.com> - 207777680 Update build numbers for 2018/08 releases by Android Partner Docs <noreply@android.com> - 207775888 Update links to AOSP by Kenneth Lau <kennethlau@google.com> - 207769948 Update links to AOSP by Kenneth Lau <kennethlau@google.com> - 207763826 Clarify system for HIDL passthrough loading. by Android Partner Docs <noreply@android.com> - 207733156 Fixing malformed links in html for kernel patches, adding... by Heidi von Markham <hvm@google.com> - 207650104 Remove link by Heidi von Markham <hvm@google.com> - 207640627 Tags for Android P. by Android Partner Docs <noreply@android.com> - 207626815 Making link absolute by Clay Murphy <claym@google.com> - 207611166 Add Background Restrictions into Release Notes. by Christina Nguyen <cqn@google.com> - 207606267 Fixing unclosed tag, reformatting for clarity by Heidi von Markham <hvm@google.com> - 207604244 Fix malformed link by Clay Murphy <claym@google.com> - 207598416 adding subscript by Heidi von Markham <hvm@google.com> - 207595049 Fix link in section 3.5.1. by Gina Dimino <gdimino@google.com> - 207590813 Fix broken link due to file path change by Christina Nguyen <cqn@google.com> - 207588930 Update Power nav to include changes to mgmt page (broken ... by Christina Nguyen <cqn@google.com> - 207588102 Separate out the Power Management article into "Applicati... by Christina Nguyen <cqn@google.com> - 207583000 Fix broken links in HAL interface section by Kenneth Lau <kennethlau@google.com> - 207582699 Put index files in place as redirects are not taking hold by Clay Murphy <claym@google.com> - 207575443 P release notes: fix bad links, remove "P release" by Mark Hecomovich <mheco@google.com> - 207574657 Fix link typo from release notes to Carrier ID page by Christina Nguyen <cqn@google.com> - 207559561 Integrate SAC next branch into mainline for Android P/9 p... by Mark Hecomovich <mheco@google.com> - 207559252 Publish links to July localized versions within Japanese ... by Clay Murphy <claym@google.com> - 207122872 Devsite localized content from translation request 958912. by Android Partner Docs <noreply@android.com> - 207122854 Devsite localized content from translation request 961384. by Android Partner Docs <noreply@android.com> - 207007888 Add blurb about the SystemUpdateSampler app on SAC so use... by Christina Nguyen <cqn@google.com> - 206862073 Update Camera HAL testing page by Kenneth Lau <kennethlau@google.com> - 206805870 Devsite localized content from translation request 960240. by Android Partner Docs <noreply@android.com> - 206805861 Devsite localized content from translation request 954945. by Android Partner Docs <noreply@android.com> PiperOrigin-RevId: 207940242 Change-Id: I3dee204c744e2e6062ac56810b88aefabf84636a
Diffstat (limited to 'en/devices/architecture/dto/optimize.html')
-rw-r--r--en/devices/architecture/dto/optimize.html261
1 files changed, 171 insertions, 90 deletions
diff --git a/en/devices/architecture/dto/optimize.html b/en/devices/architecture/dto/optimize.html
index 7502d7ad..7624cc14 100644
--- a/en/devices/architecture/dto/optimize.html
+++ b/en/devices/architecture/dto/optimize.html
@@ -5,6 +5,7 @@
<meta name="book_path" value="/_book.yaml" />
</head>
<body>
+ {% include "_versions.html" %}
<!--
Copyright 2017 The Android Open Source Project
@@ -21,14 +22,21 @@
limitations under the License.
-->
-<p>This page details optimizations you can make to your DTO implementation,
-describes restrictions against overlaying the root node, and provides sample
-implementation instructions and code.</p>
+<p>
+ This page discusses optimizations you can make to your DTO implementation,
+ describes restrictions against overlaying the root node, and details how to
+ configure compressed overlays in the DTBO image. It also provides sample
+ implementation instructions and code.
+</p>
<h2 id=kernel>Kernel command line</h2>
-<p>The original kernel command line in device tree is located in the
-<code>chosen/bootargs</code> node. The bootloader must concatenate this location
-with other sources of kernel command line:</p>
+
+<p>
+ The original kernel command line in device tree is located in the
+ <code>chosen/bootargs</code> node. The bootloader must concatenate this
+ location with other sources of kernel command line:
+</p>
+
<pre class="prettyprint">
/dts-v1/;
@@ -39,11 +47,13 @@ with other sources of kernel command line:</p>
};
</pre>
-<p>DTO <strong>cannot</strong> concatenate values from main DT and overlay DT.
-We recommend putting the kernel command line of the main DT in
-<code>chosen/bootargs</code> and the kernel command line of the overlay DT in
-<code>chosen/bootargs_ext</code>. Bootloader can then concatenate these
-locations and pass the result to the kernel.</p>
+<p>
+ DTO <strong>cannot</strong> concatenate values from main DT and overlay DT, so
+ you must put the kernel command line of the main DT in
+ <code>chosen/bootargs</code> and the kernel command line of the overlay DT in
+ <code>chosen/bootargs_ext</code>. Bootloader can then concatenate these
+ locations and pass the result to the kernel.
+</p>
<table>
<tr>
@@ -77,47 +87,70 @@ locations and pass the result to the kernel.</p>
</table>
<h2 id=libufdt>libufdt</h2>
-<p>While the latest
-<code><a href="https://github.com/dgibson/dtc/tree/master/libfdt" class="external">libfdt</code></a>
-supports DTO, we recommend using <code>libufdt</code> to implement DTO (source
-at
-<code><a href="https://android.googlesource.com/platform/system/libufdt/+/refs/heads/master" class="external">platform/system/libufdt</code></a>
-in AOSP). <code>libufdt</code> builds a real tree structure (un-flattened device
-tree, or <em>ufdt</em>) from the flattened device tree (FDT), so it can improve
-the merging of two <code>.dtb</code> files from O(N2) to O(N), where N is the
-number of nodes in the tree.</p>
+
+<p>
+ While the latest
+ <code><a href="https://github.com/dgibson/dtc/tree/master/libfdt" class="external">libfdt</code></a>
+ supports DTO, is it recommended to use <code>libufdt</code> to implement DTO
+ (AOSP source at
+ <code><a href="https://android.googlesource.com/platform/system/libufdt/+/refs/heads/master" class="external">platform/system/libufdt</code></a>).
+ <code>libufdt</code> builds a real tree structure (un-flattened device tree,
+ or <em>ufdt</em>) from the flattened device tree (FDT), so it can improve the
+ merging of two <code>.dtb</code> files from O(N2) to O(N), where N is the
+ number of nodes in the tree.
+</p>
<h3 id=performance>Performance testing</h3>
-<p>In Google's internal testing, using <code>libufdt</code> on 2405
-<code>.dtb</code> and 283 <code>.dtbo</code> DT nodes results in file sizes of
-70,618 and 8,566 bytes after compilation. Compared with a
-<a href="http://fxr.watson.org/fxr/source/boot/fdt/" class="external">DTO
-implementation</a> ported from FreeBSD (124ms runtime), <code>libufdt</code>
-DTO runtime is 10ms.</p>
-
-<p>In performance testing for Pixel devices, we compared <code>libufdt</code>
-and <code>libfdt</code>. The number of base nodes effect is similar, but
-includes the following differences:</p>
+
+<p>
+ In Google's internal testing, using <code>libufdt</code> on 2405
+ <code>.dtb</code> and 283 <code>.dtbo</code> DT nodes results in file sizes of
+ 70,618 and 8,566 bytes after compilation. Compared with a
+ <a href="http://fxr.watson.org/fxr/source/boot/fdt/" class="external">DTO
+ implementation</a> ported from FreeBSD (124 ms runtime), <code>libufdt</code>
+ DTO runtime is 10 ms.
+</p>
+
+<p>
+ Performance testing for Pixel devices compared <code>libufdt</code> and
+ <code>libfdt</code>. The number of base nodes effect is similar, but includes
+ the following differences:
+</p>
+
<ul>
-<li>500 overlay (append or override) operations have 6~8x time difference</li>
-<li>1000 overlay (append or override) operations have 8~10x time difference</li>
+ <li>500 overlay (append or override) operations have 6x to 8x time
+ difference</li>
+ <li>1000 overlay (append or override) operations have 8x to 10x time
+ difference</li>
</ul>
-<p>Example with appending count set to X:</p>
+<p>
+ Example with appending count set to X:
+</p>
+
<p><img src="../images/treble_dto_appending.png"></p>
-<figcaption><strong>Figure 1.</strong> Appending count is X.</figcaption>
+<figcaption><strong>Figure 1.</strong> Appending count is X</figcaption>
+
+<p>
+ Example with overriding count set to X:
+</p>
-<p>Example with overriding count set to X:</p>
<p><img src="../images/treble_dto_overriding.png"></p>
-<figcaption><strong>Figure 2.</strong> Overriding count is X.</figcaption>
+<figcaption><strong>Figure 2.</strong> Overriding count is X</figcaption>
-<p><code>libufdt</code> is developed with some <code>libfdt</code> APIs and data
-structures. When using <code>libufdt</code>, you must include and link
-<code>libfdt</code> (however in your code you can use <code>libfdt</code> API to
-operate DTB or DTBO).</p>
+<p>
+ <code>libufdt</code> is developed with some <code>libfdt</code> APIs and data
+ structures. When using <code>libufdt</code>, you must include and link
+ <code>libfdt</code> (however, in your code you can use the <code>libfdt</code>
+ API to operate DTB or DTBO).
+</p>
<h3 id=api>libufdt DTO API</h3>
-<p>The main API to DTO in <code>libufdt</code> is as follows:</p>
+
+<p>
+ The main API to DTO in <code>libufdt</code> is as follows:
+</p>
+
<pre class="prettyprint">
struct fdt_header *ufdt_apply_overlay(
struct fdt_header *main_fdt_header,
@@ -126,30 +159,39 @@ struct fdt_header *ufdt_apply_overlay(
size_t overlay_size);
</pre>
-<p>The parameter <code>main_fdt_header</code> is the main DT and
-<code>overlay_fdt</code> is the buffer containing the contents of a
-<code>.dtbo</code> file. The return value is a new buffer containing the merged
-DT (or <code>null</code> in case of error). The merged DT is formated in FDT,
-which you can pass to the kernel when starting the kernel.</p>
-
-<p>The new buffer from the return value is created by <code>dto_malloc()</code>,
-which you should implement when porting <code>libufdt</code> into bootloader.
-For reference implementations, refer to
-<code>sysdeps/libufdt_sysdeps_*.c</code>.</p>
+<p>
+ The parameter <code>main_fdt_header</code> is the main DT and
+ <code>overlay_fdt</code> is the buffer containing the contents of a
+ <code>.dtbo</code> file. The return value is a new buffer containing the
+ merged DT (or <code>null</code> in case of error). The merged DT is formated
+ in FDT, which you can pass to the kernel when starting the kernel.
+</p>
+
+<p>
+ The new buffer from the return value is created by <code>dto_malloc()</code>,
+ which you should implement when porting <code>libufdt</code> into bootloader.
+ For reference implementations, refer to
+ <code>sysdeps/libufdt_sysdeps_*.c</code>.
+</p>
<h2 id=root>Root node restrictions</h2>
-<p>You cannot overlay a new node or property into the root node of main DT
-because overlay operations rely on labels. Because the main DT must define a
-label and the overlay DT assigns the nodes to be overlaid with labels, we
-cannot give a label for the root node (and therefore cannot overlay the root
-node).</p>
-
-<p>SoC vendors must define the overlaying ability of main DT; ODM/OEMs can only
-append or override nodes with labels defined by the SoC vendor. As a workaround,
-you can define a <strong><code>odm</code></strong> node under the root node in
-base DT, enabling all ODM nodes in overlay DT to add new nodes. Alternatively,
-you could put all SoC-related nodes in the base DT into a
-<strong><code>soc</code></strong> node under root node as described below:</p>
+
+<p>
+ You cannot overlay a new node or property into the root node of main DT
+ because overlay operations rely on labels. Because the main DT must define a
+ label and the overlay DT assigns the nodes to be overlaid with labels, you
+ cannot give a label for the root node (and therefore cannot overlay the root
+ node).
+</p>
+
+<p>
+ SoC vendors must define the overlaying ability of main DT; ODM/OEMs can only
+ append or override nodes with labels defined by the SoC vendor. As a
+ workaround, you can define an <strong><code>odm</code></strong> node under the
+ root node in base DT, enabling all ODM nodes in overlay DT to add new nodes.
+ Alternatively, you could put all SoC-related nodes in the base DT into an
+ <strong><code>soc</code></strong> node under root node as described below:
+</p>
<table>
<tr>
@@ -209,64 +251,103 @@ you could put all SoC-related nodes in the base DT into a
</tr>
</table>
+<h2 id="compressed-overlays">Using compressed overlays</h2>
+
+<p>
+ Android {{ androidPVersionNumber }} adds support for using compressed overlays
+ in the DTBO image when using version 1 of the device tree table header.
+ When using DTBO header v1, the four least significant bits of the flags field
+ in <em>dt_table_entry</em> indicate the compression format of the DT entry.
+</p>
+
+<pre class="prettyprint">struct dt_table_entry_v1 {
+ uint32_t dt_size;
+ uint32_t dt_offset; /* offset from head of dt_table_header */
+ uint32_t id; /* optional, must be zero if unused */
+ uint32_t rev; /* optional, must be zero if unused */
+ uint32_t flags; /* For version 1 of dt_table_header, the 4 least significant bits
+ of 'flags' will be used to indicate the compression
+ format of the DT entry as per the enum 'dt_compression_info' */
+ uint32_t custom[3]; /* optional, must be zero if unused */
+};
+</pre>
+
+<p>
+ Currently, <code>zlib</code> and <code>gzip</code> compressions are supported.
+</p>
+
+<pre class="prettyprint">enum dt_compression_info {
+ NO_COMPRESSION,
+ ZLIB_COMPRESSION,
+ GZIP_COMPRESSION
+};
+</pre>
+
+<p>
+ Android {{ androidPVersionNumber }} adds support for testing compressed
+ overlays to the <code>VtsFirmwareDtboVerification</code> test to help you
+ verify the correctness of overlay application.
+</p>
+
<h2 id=sample>Sample DTO implementation</h2>
-<p>The following instructions walk you through a sample implementation of DTO
-with <code>libufdt</code> (sample code below).</p>
+
+<p>
+ The following instructions walk you through a sample implementation of DTO
+ with <code>libufdt</code> (sample code below).
+</p>
<h3 id=sample-instructions>Sample DTO instructions</h3>
<ol>
-<li>Include libraries. To use <code>libufdt</code>, include <code>libfdt</code>
-for data structures and APIs:
+ <li>Include libraries. To use <code>libufdt</code>, include
+ <code>libfdt</code> for data structures and APIs:
<pre class="prettyprint">
#include &lt;libfdt.h&gt;
#include &lt;ufdt_overlay.h&gt;
</pre>
-</li>
-
-<li>Load main DT and overlay DT. Load <code>.dtb</code> and <code>.dtbo</code>
-from storage into memory (exact steps depend on your design). At this point, you
-should have the buffer and size of <code>.dtb</code>/<code>.dtbo</code>:
+ </li>
+ <li>Load main DT and overlay DT. Load <code>.dtb</code> and <code>.dtbo</code>
+ from storage into memory (exact steps depend on your design). At this point,
+ you should have the buffer and size of <code>.dtb</code>/<code>.dtbo</code>:
<pre class="prettyprint">
main_size = my_load_main_dtb(main_buf, main_buf_size)
</pre>
<pre class="prettyprint">
overlay_size = my_load_overlay_dtb(overlay_buf, overlay_buf_size);
</pre>
-</li>
-
-<li>Overlay the DTs:
-<ol>
-
-<li>Use <code>ufdt_install_blob()</code> to get the FDT header for main DT:
+ </li>
+ <li>Overlay the DTs:
+ <ol>
+ <li>Use <code>ufdt_install_blob()</code> to get the FDT header for main DT:
<pre class="prettyprint">
main_fdt_header = ufdt_install_blob(main_buf, main_size);
main_fdt_size = main_size;
</pre>
-</li>
-<li>Call <code>ufdt_apply_overlay()</code> to DTO to get a merged DT in FDT
-format:
+ </li>
+ <li>Call <code>ufdt_apply_overlay()</code> to DTO to get a merged DT in FDT
+ format:
<pre class="prettyprint">
merged_fdt = ufdt_apply_overlay(main_fdt_header, main_fdt_size,
overlay_buf, overlay_size);
</pre>
-</li>
-
-<li>To get the size of <code>merged_fdt</code>, use <code>dtc_totalsize()</code>:
+ </li>
+ <li>Use <code>merged_fdt</code> to get the size of
+ <code>dtc_totalsize()</code>:
<pre class="prettyprint">
merged_fdt_size = dtc_totalsize(merged_fdt);
</pre>
-</li>
-
-<li>Pass merged DT to start kernel. When you start the kernel, pass merged DT to
-kernel:
+ </li>
+ <li>Pass the merged DT to start the kernel:
<pre class="prettyprint">
my_kernel_entry(0, machine_type, merged_fdt);
</pre>
-</li>
-</ol></li></ol>
+ </li>
+ </ol>
+ </li>
+</ol>
<h3 id=sample-code>Sample DTO code</h3>
+
<pre class="prettyprint">
#include &lt;libfdt.h&gt;
#include &lt;ufdt_overlay.h&gt;