tag:blogger.com,1999:blog-13924388893848102352024-03-05T11:27:34.448-08:00Thierry's BlogAnonymoushttp://www.blogger.com/profile/05988697220338815747noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1392438889384810235.post-14242150178203809992016-12-05T01:50:00.000-08:002017-10-12T02:57:21.608-07:00Booting a Pixel C tablet with a custom kernelThe <a href="https://store.google.com/product/pixel_c" rel="nofollow" target="_blank">Google Pixel C</a> is a tablet running an Android userpsace on top of a ChromeOS kernel.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/zGcPdpiRQuIsr_Ti3rx9eW44ESf3RdfVJJXW_LrURL8F1RXAk3EGJheyT6yB_CB9NcE=w1016" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://1.bp.blogspot.com/zGcPdpiRQuIsr_Ti3rx9eW44ESf3RdfVJJXW_LrURL8F1RXAk3EGJheyT6yB_CB9NcE=w1016" width="320" /></a></div>
It is pretty straightforward to build your own AOSP for the Google Pixel C tablet and make it boot by following the steps from the <a href="https://source.android.com/source/requirements.html" rel="nofollow" target="_blank">Android Source web site</a>.<br />
You'll need to <a href="https://developers.google.com/android/drivers" rel="nofollow" target="_blank">Download</a> the Pixel C specific drivers (Pixel C binaries for Android 7.0.0), select one of the aosp_dragon-* lunch targets, build it, flash it, and it should run.<br />
<br />
Of course, the AOSP provides a binary version of the Pixel C kernel image (device/google/dragon-kernel/Image.fit) used in the boot image you just built.<br />
<br />
But if you want to build your own kernel, here are a few tips I had to experiment myself in order to test a few kernel patches on the Pixel C.<br />
<br />
For the sake of this post, we'll use the official Android kernel tree for NVIDIA Tegra SoC familly that you can <span style="font-family: "courier new" , "courier" , monospace;">git clone</span> here:<span style="font-family: "courier new" , "courier" , monospace;"> </span><br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ git clone -b android-tegra-dragon-3.18-nougat https://android.googlesource.com/kernel/tegra</span></span></blockquote>
The easiest way is to build your kernel while your environment is setup for the AOSP build. You'll have the aarch64 compilers and binutils in your path.<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ source ./build/envsetup.sh</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ lunch aosp_dragon-userdebug</span> </blockquote>
Then go to the kernel root folder and export the cross compilation build variables:<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ export ARCH=arm64</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ export CROSS_COMPILE=aarch64-linux-androidkernel-</span></blockquote>
Create the kernel config file:<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ <span style="font-family: "courier new" , "courier" , monospace;">make </span>dragon_defconfig</span></blockquote>
And Build your kernel image:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ make -j<span style="font-family: "courier new" , "courier" , monospace;">X</span></span></span></blockquote>
The uncompressed kernel image is located here: <span style="font-family: "courier new" , "courier" , monospace;">arch/arm64/boot/Image</span><br />
This is the image we will use to create the Image.fit file used by the AOSP build. FIT stands for Flattened Image Tree and contains one or more kernel images along with various DTBs (Device Tree Blob). You'll need <span style="font-family: "courier new" , "courier" , monospace;">mkimage</span> from the u-boot-tools package to create the FIT file from an ITS file (Image Tree Source).<br />
<br />
The Pixel C bootloader seems to want lz4 compressed images only so we will have to make it:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ lz4c ./arch/arm64/boot/Image Image.lz4</span></span></blockquote>
Now it's time to create the FIT image that will contain the freshly compiled kernel Image and the device tree blob for the Pixel C. The dts files are compiled by the kernel build system and stored in the same folder. The dtb for the Pixel C is <span style="font-family: "courier new" , "courier" , monospace;">arch/arm64/boot/dts/tegra/tegra210-smaug-p1.dtb</span>.<br />
<br />
Create the its file (Let's call it Image.its). As it is intended to boot on the Pixel C only, it will contain the image and one ftd entry.<br />
<span style="font-size: x-small;"></span>
<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">/*</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> * Simple U-Boot uImage source file containing a</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> * single kernel and FDT blob</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> */</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span>
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">/dts-v1/;</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span>
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">/ {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> description = "Simple image with single Linux kernel and FDT blob";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> #address-cells = <1>;</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span>
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> images {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> kernel@1 {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> description = "<span style="font-family: "courier new" , "courier" , monospace;">Tegra Dragon</span> Linux kernel";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> data = /incbin/("./Image.lz4");</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> type = "kernel_noload";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> arch = "arm64";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> os = "android";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> compression = "lz4";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> fdt@1 {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> description = "Flattened Device Tree blob";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> data = /incbin/("./</span></span><span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "courier new" , "courier" , monospace;">arch/arm64/boot/dts/tegra</span>/tegra210-smaug-p1.dtb");</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> type = "flat_dt";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> arch = "arm64";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> compression = "none";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> hash@1 {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> algo = "sha1";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> configurations {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> default = "conf@1";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> conf@1 {</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> description = "Boot Linux kernel with FDT blob";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> kernel = "kernel@1";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> fdt = "fdt@1";</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"> };</span></span><br />
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">};</span></span></blockquote>
<br />
Build the FIT image:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ mkimage -f Image.its Image.fit</span></span></blockquote>
Now copy <span style="font-family: "courier new" , "courier" , monospace;">Image.fit</span> to <span style="font-family: "courier new" , "courier" , monospace;">AOSP_ROOT/device/google/dragon-kernel</span> and rebuild the bootimage from the AOSP root:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ make bootimage</span></span></blockquote>
Reboot the Pixel C in fastboot mode and flash the boot image:<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;">$ fastboot flash boot</span></span></blockquote>
That's it! Reboot your device and voilĂ !Anonymoushttp://www.blogger.com/profile/05988697220338815747noreply@blogger.com0tag:blogger.com,1999:blog-1392438889384810235.post-30508907344088794822016-09-07T01:41:00.001-07:002016-09-07T01:41:59.608-07:00NFC improvements in Linux 4.8<div class="" id="magicdomid2" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">Almost
4 years ago, I started to work on the <a href="https://01.org/linux-nfc" target="_blank">linux-nfc project</a>. I first
worked on the implementation of a virtual device driver named nfcsim that was intended to simulate 2 NFC devices on the same host and make them
talk to each other through the </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-tltt4jz65zqu4qhz80zz87zd2">Logical Link
Control Protocol (LLCP)</span>, also known as </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"></span>P2P mode</span>.</span></div>
<div class="" id="magicdomid2" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><br /></span></div>
<div class="" id="magicdomid3" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">My next project was the implementation of the NFC Digital Protocol stack.
The Digital Protocol layer is usually embedded into the chipsets
firmware but this is not the case for all of them. For example, the <a href="https://www.sony.net/Products/felica/business/products/RC-S380.html" target="_blank">Sony RC-S380</a> USB dongle does not have it and I wrote its driver as well, based on the Digital layer.</span></div>
<div class="" id="magicdomid3" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">With this work I was in the top 20 developers (by changed </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-tltt4jz65zqu4qhz80zz87zd2">lines)</span> for the <a href="http://lwn.net/Articles/579081/" target="_blank">Linux 3.13 release</a>.</span></div>
<div class="" id="magicdomid4" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><br /></span></div>
<div class="" id="magicdomid4" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">Here is an overall picture of the Linux NFC stack showing where the Digital Protocol layer fits in.</span></div>
<div class="" id="magicdomid4" style="text-align: justify;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd5wF5PedFCkjjGSDChM4UQfL4vC1DpWGlKd-OMrcCY7JJbVV5qOxeOfg-7ALKxiJYClIEVC_MTYEc052Db-wJycaNlaRxdsYrOncbmjCZaYHw_Fbu4B3znziioT8YucemHwch05XAyw-_/s1600/NFC_Linux_Stack_Architecture.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="330" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd5wF5PedFCkjjGSDChM4UQfL4vC1DpWGlKd-OMrcCY7JJbVV5qOxeOfg-7ALKxiJYClIEVC_MTYEc052Db-wJycaNlaRxdsYrOncbmjCZaYHw_Fbu4B3znziioT8YucemHwch05XAyw-_/s400/NFC_Linux_Stack_Architecture.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Linux NFC Stack</td></tr>
</tbody></table>
<div class="" id="magicdomid4" style="text-align: justify;">
</div>
<div class="" id="magicdomid4" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">Unfortunately, </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-bz84zz66zz122zw1z68zz70zz73zz89zz85zz78z7z122zz78zz67z">about 2 years ago I had to stop working on the linux-nfc project because of new priorities set by my former employer</span><span class="author-a-bz84zz66zz122zw1z68zz70zz73zz89zz85zz78z7z122zz78zz67z s"></span> and switch to
Android platform development.</span></div>
<div class="" id="magicdomid5" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">I had to "abandon-in-place" this work and did not have any spare time to continue, so there was still some missing features and stability issues.</span></div>
<div class="" id="magicdomid6" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><br /></span></div>
<div class="" id="magicdomid6" style="text-align: justify;">
<div class="" id="magicdomid16" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">In
the meantime, other developers have contributed to the Digital layer,
adding support for some of the missing features in the NFC-DEP protocol
such as packets chaining.</span></div>
<div class="" id="magicdomid17" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">Also, TI and STM have added drivers for their own chipsets based on the Digital Protocol layer.</span><br />
<br />
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">But now thanks
to my new employer, <a href="https://www.collabora.com/" target="_blank">Collabora</a>, I'm now back to business and I've been
offered the opportunity to keep on working the linux-nfc project.</span></div>
</div>
<div class="" id="magicdomid18" style="text-align: justify;">
<br /></div>
<div class="" id="magicdomid19" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-bz84zz66zz122zw1z68zz70zz73zz89zz85zz78z7z122zz78zz67z">However even with the progress made by other developers in the past years </span>there was still a lot of kernel panics and memory leaks around the Digital
layer and RC-S380 driver implementation</span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"><span class="author-a-bz84zz66zz122zw1z68zz70zz73zz89zz85zz78z7z122zz78zz67z">s</span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2">. M</span><span class="author-a-bz84zz66zz122zw1z68zz70zz73zz89zz85zz78z7z122zz78zz67z">y main focus in the last 3 months was fixing these issues to provide a
better stability both to Digital layer and RC-S380 implementations</span>.</span></div>
<div class="" id="magicdomid20" style="text-align: justify;">
<br /></div>
<div class="" id="magicdomid21" style="text-align: justify;">
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">The upcoming Linux 4.8 release contains 26 patches for the </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2 b"><b>Digital Protocol</b></span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"> layer, the </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2 b"><b>port100</b></span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"> driver (port100 is the NFC chip inside the RC-S380), and the </span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2 b"><b>nfcsim</b></span><span class="author-a-tltt4jz65zqu4qhz80zz87zd2"> driver.</span><br />
<br />
<span class="author-a-tltt4jz65zqu4qhz80zz87zd2">I'll talk about all of these components in more details in next posts but what I can say is that now they are rock solid!</span></div>
<div style="text-align: justify;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/05988697220338815747noreply@blogger.com0tag:blogger.com,1999:blog-1392438889384810235.post-48065117090628997072016-07-25T02:23:00.001-07:002016-07-25T02:36:15.172-07:00First post<span style="font-family: "verdana" , sans-serif;">Now that I'm a proud <a href="https://www.collabora.com/">Collaboran</a> it's time for me to <span style="font-family: "verdana" , sans-serif;">start</span> my blog.</span><span style="font-family: "verdana" , sans-serif;"> </span><br />
<br />
<span style="font-family: "verdana" , sans-serif;">Here I'll talk about Linux kernel development, mainly about NFC at first.</span><br />
<br />
<span style="font-family: "verdana" , sans-serif;">Some more interesting posts should land here soon.</span>..Anonymoushttp://www.blogger.com/profile/05988697220338815747noreply@blogger.com