<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>raspberry pi on irq5 test</title><link>https://irq5-7854a1fdb9f4.pages.dev/tag/raspberry-pi/</link><description>Recent content in raspberry pi on irq5 test</description><language>en-us</language><lastBuildDate>Sun, 22 Jul 2018 22:12:00 +0000</lastBuildDate><atom:link href="https://irq5-7854a1fdb9f4.pages.dev/tag/raspberry-pi/feed/" rel="self" type="application/rss+xml"/><item><title>Boot-time Device Tree Overlays with U-Boot</title><link>https://irq5-7854a1fdb9f4.pages.dev/2018/07/boot-time-device-tree-overlays-with-u-boot/</link><pubDate>Sun, 22 Jul 2018 22:12:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2018/07/boot-time-device-tree-overlays-with-u-boot/</guid><description>&lt;p>I bought a &lt;em>Banana Pi&lt;/em> some time ago and have been using it as my go-to ARM box.
Among the single-board computers I have,
this Allwinner A20-based platform has the fastest CPU.&lt;/p>&lt;p>Similar to the (old) Raspberry Pi, it has a 26-pin GPIO header on one side that sports the same layout.
This means that the 5V, 3V3 and I2C pins are the same as where they would be on the Raspberry Pi.&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2018/img/banana-pi-a20.jpg.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2018/img/banana-pi-a20.jpg alt width=1280 height=853>&lt;/picture>&lt;/p>&lt;h1 id=device-tree--overlays>Device Tree &amp; Overlays&lt;/h1>&lt;p>On embedded systems, the &lt;a href=https://elinux.org/Device_Tree_What_It_Is rel=noopener target=_blank class=external>Device Tree&lt;/a>
helps the kernel understand various peripherals that are connected to the board
and how to initialize them.
These hardware might be things like LDO regulators,
various controllers, GPIO, etc which are generic,
but yet needs certain configuration that should not be
hard-coded into the kernel.
To understand more about device trees I recommend you start with the Raspberry Pi
&lt;a href=https://www.raspberrypi.org/documentation/configuration/device-tree.md rel=noopener target=_blank class=external>documentation on this topic&lt;/a>.
There are more links at the end of this article.&lt;/p>&lt;p>To support &lt;a href=https://www.raspberrypi.org/blog/introducing-raspberry-pi-hats/ rel=noopener target=_blank class=external>Pi HATs&lt;/a> and other non-HAT accessories,
the Pi added a &lt;a href=https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README rel=noopener target=_blank class=external>&lt;code>dtoverlay&lt;/code> configuration parameter&lt;/a> in the &lt;code>config.txt&lt;/code> file.
This allows you to specify, at boot time,
&lt;a href=https://www.kernel.org/doc/Documentation/devicetree/overlay-notes.txt rel=noopener target=_blank class=external>&lt;em>Device Tree Overlays&lt;/em>&lt;/a>,
which modify the board&amp;rsquo;s base device tree to specify additional peripherals
like I2C devices, or to configure GPIO pins for certain purposes.
The BeagleBone also has a similar mechanism to support its add-on boards via
&lt;a href=https://elinux.org/Capemgr rel=noopener target=_blank class=external>Capemgr&lt;/a>.
These mechanisms enable non-technical users to easily modify the device tree
by simply editing a text file or running a command.
Neither of these have been adopted into mainline Linux,
so there is no provisions for doing quick overlays on other boards yet.&lt;/p>&lt;p>Fortunately for us, &lt;a href=https://bootlin.com/blog/dt-overlay-uboot-libfdt/ rel=noopener target=_blank class=external>device tree overlay support has been merged&lt;/a>
into &lt;a href=https://www.denx.de/wiki/U-Boot rel=noopener target=_blank class=external>U-Boot&lt;/a>,
and the Banana Pi uses U-Boot for booting Linux.
This means that U-Boot can perform the merging of device tree overlays with
the base device tree, and pass the entire Flattened Device Tree (FDT) structure
to the kernel during boot-up.&lt;/p>&lt;p>Before we get started, you will need the &lt;code>i2c-tools&lt;/code> and &lt;code>dtc-overlay&lt;/code> package,
and the U-Boot source code for the &lt;code>mkimage&lt;/code> tool
(you &lt;em>did&lt;/em> have to compile U-Boot for your Banana Pi right?)&lt;/p>&lt;h1 id=creating-the-overlay>Creating the Overlay&lt;/h1>&lt;p>For this example, we will be attaching an &lt;a href=http://www.ti.com/lit/ds/symlink/ina219.pdf rel=noopener target=_blank class=external>INA219 current sensor&lt;/a>
to the Banana Pi over I2C.
The kernel has drivers for this sensor in its hwmon subsystem
and provides an easy way of reading values for us.&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2018/img/ina219-breakout.jpg.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2018/img/ina219-breakout.jpg alt="INA219 current sensor breakout board" width=1280 height=853>&lt;/picture>&lt;/p>&lt;p>The default I2C address on most INA219 breakout boards is with the address lines &lt;code>A0&lt;/code> and &lt;code>A1&lt;/code> grounded, giving it an address of &lt;code>0x40&lt;/code>.
Also note that the shunt resistor is marked with &lt;code>R100&lt;/code>,
which denotes 0.1 mΩ or 100,000 µΩ.&lt;/p>&lt;p>My Banana Pi has 3 I2C buses:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl>$ i2cdetect -l
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>i2c-1 unknown mv64xxx_i2c adapter N/A
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>i2c-2 unknown sun4i_hdmi_i2c adapter N/A
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>i2c-0 unknown mv64xxx_i2c adapter N/A&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We will try scanning each of the buses, and the one with device &lt;code>0x40&lt;/code> will
&lt;em>likely&lt;/em> be the bus that is exposed via the GPIO headers.
We can do this using &lt;code>i2cdetect&lt;/code>:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl># i2cdetect -y 1
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> 0 1 2 3 4 5 6 7 8 9 a b c d e f
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>00: -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>70: -- -- -- -- -- -- -- --&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The last parameter to &lt;code>i2cdetect&lt;/code> specifies the bus number,
which is &lt;code>1&lt;/code> in this case.
We can see here that the INA219 has been correctly wired and detected,
as it shows up in the I2C bus scan.&lt;/p>&lt;p>We now need to find out which device tree node this bus corresponds to:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl>$ readlink /sys/class/i2c-adapter/i2c-1/of_node
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>../../../../../firmware/devicetree/base/soc@1c00000/i2c@1c2b400&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In order to figure out the symbolic name for this I2C bus,
we can &lt;code>grep&lt;/code> from the kernel&amp;rsquo;s live device tree,
parsed with the help of the &lt;code>dtc&lt;/code> utility:&lt;/p>&lt;div class=highlight role=region aria-label="code block" translate=no>&lt;pre tabindex=0 class=chroma>&lt;code class=language-fallback data-lang=fallback>&lt;span class=line>&lt;span class=cl># dtc -I fs /proc/device-tree | grep 1c2b400
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl>...
&lt;/span>&lt;/span>&lt;span class=line>&lt;span class=cl> i2c2 = &amp;#34;/soc@1c00000/i2c@1c2b400&amp;#34;;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2018/07/boot-time-device-tree-overlays-with-u-boot/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Raspberry Pi Zero Wireless</title><link>https://irq5-7854a1fdb9f4.pages.dev/2017/03/raspberry-pi-zero-wireless/</link><pubDate>Fri, 10 Mar 2017 01:07:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2017/03/raspberry-pi-zero-wireless/</guid><description>&lt;p>On the 5th birthday of the Raspberry Pi last week, the foundation announced a new
addition to the family &amp;ndash;
the &lt;a href=https://www.raspberrypi.org/blog/raspberry-pi-zero-w-joins-family/ rel=noopener target=_blank class=external>&lt;strong>Raspberry Pi Zero W&lt;/strong>&lt;/a>.
The W stands for Wireless.&lt;/p>&lt;p>I got my hands on one, from the fine folks at &lt;a href=https://shop.pimoroni.com/products/raspberry-pi-zero-w rel=noopener target=_blank class=external>Pimoroni&lt;/a>.
(And no they didn&amp;rsquo;t pay me to say this.)&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c2.staticflickr.com/4/3727/32924538120_07709cc863_b.jpg alt="The Pi Zero W board">&lt;/picture>&lt;/p>&lt;p>It has the same specs as the Raspberry Pi Zero, namely the 1GHz single-core CPU
and 512 MB of RAM.
It still has the two micro USB port &amp;ndash; one for power and another for OTG,
which means you can &lt;a href=https://irq5-7854a1fdb9f4.pages.dev/2016/12/raspberry-pi-zero-as-multiple-usb-gadgets/ rel=noopener>get it to behave like USB devices&lt;/a>
when plugged into a PC.
The big difference is that they have added WiFi and Bluetooth capability to this
small board by squeezing some space out from between the processor and the power circuitry.
The size of the board and the placement of connectors remain the same,
even the test points on the back.&lt;/p>&lt;p>I&amp;rsquo;m excited for anything that has processing power, HDMI connectivity and WiFi.&lt;/p>&lt;h1 id=wifi--bluetooth>WiFi + Bluetooth&lt;/h1>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/1/725/33151674662_b77d8963a9_b.jpg alt="BCM43438 wireless chipset">&lt;/picture>&lt;/p>&lt;p>The 802.11n WiFi and Bluetooth 4.1 functionality comes from the
&lt;a href=http://www.cypress.com/documentation/datasheets/bcm43438-single-chip-ieee-80211-bgn-macbasebandradio-bluetooth-41-and-fm rel=noopener target=_blank class=external>&lt;em>Broadcom BCM43438&lt;/em>&lt;/a> (now known as the Cypress CYW43438).
This is the same chipset that was used in the Pi 3.
The wireless chipset connects via SDIO, so your network traffic does not have
to contend for the USB bus bandwidth.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2017/03/raspberry-pi-zero-wireless/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Raspberry Pi Zero as Multiple USB Gadgets</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/12/raspberry-pi-zero-as-multiple-usb-gadgets/</link><pubDate>Thu, 22 Dec 2016 23:45:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/12/raspberry-pi-zero-as-multiple-usb-gadgets/</guid><description>&lt;p>In case you haven&amp;rsquo;t heard, the &lt;a href=https://www.raspberrypi.org/products/pi-zero/ rel=noopener target=_blank class=external>&lt;strong>Raspberry Pi Zero&lt;/strong>&lt;/a> is the smallest, most low-cost device in the Raspberry Pi family,
but it&amp;rsquo;s also the hardest to find.
It has two Micro-B USB ports, one for power and another functions as a dual-role
&lt;a href=https://en.wikipedia.org/wiki/USB_On-The-Go rel=noopener target=_blank class=external>USB OTG&lt;/a> port.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://c1.staticflickr.com/1/131/31623966595_aaa1696c4e_b.jpg alt="Raspberry Pi Zero, back side">&lt;/picture>&lt;/p>&lt;p>One of the more interesting uses for the Raspberry Pi Zero is to get it to behave as a USB device, just like your USB flash drive, for example.&lt;/p>&lt;p>There have been several guides written already,
such as the &lt;a href=https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget rel=noopener target=_blank class=external>Adafruit one&lt;/a>,
but most of them were based on the &lt;a href=http://www.linux-usb.org/gadget/ rel=noopener target=_blank class=external>old kernel gadget drivers&lt;/a>, like &lt;code>g_serial&lt;/code> and &lt;code>g_ether&lt;/code>.
It still works, but not as flexible and likely to be deprecated in future.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/12/raspberry-pi-zero-as-multiple-usb-gadgets/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Netbooting Your Raspberry Pi</title><link>https://irq5-7854a1fdb9f4.pages.dev/2016/08/netbooting-your-raspberry-pi/</link><pubDate>Tue, 09 Aug 2016 00:29:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2016/08/netbooting-your-raspberry-pi/</guid><description>&lt;p>A very long time ago, I set up and played around with &lt;em>diskless machines&lt;/em>.
These are basically PCs can boot up an operating system fully without hard disks.
All the operating system files come from a server on the network.
It was amazing (well, to me at least)!&lt;/p>&lt;p>Back then, Ethernet cards used to have a DIP/PLCC socket,
which allowed you to insert
an &lt;a href=http://etherboot.org/wiki/romburning rel=noopener target=_blank class=external>EEPROM on which you burn a boot ROM&lt;/a>.
Fortunately I didn&amp;rsquo;t have to do any of that because the network cards at that time already came with &lt;a href=https://en.wikipedia.org/wiki/Preboot_Execution_Environment rel=noopener target=_blank class=external>PXE ROMs&lt;/a> built-in, just as they do today.
To activate this, you just need to select the network card&amp;rsquo;s option ROM in the boot order, or make it higher up in the boot priority.&lt;/p>&lt;p>&lt;picture>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2016/img/3com-boot-rom-socket.png alt="line drawing of a 3Com network card, with the location of its boot ROM socket pointed to with a label" width=640 height=576 class=half>&lt;/picture>&lt;/p>&lt;p>As part of the boot process, the network card will request an address from the DHCP server,
which also tells the client where it can find the TFTP server with the next boot stage.
The ROM will download this file from the TFTP server and start executing it.&lt;/p>&lt;p>That&amp;rsquo;s how Linux ultimately gets started from the network.&lt;/p>&lt;p>An announcement was made recently &lt;a href=https://www.raspberrypi.org/blog/pi-3-booting-part-ii-ethernet-all-the-awesome/ rel=noopener target=_blank class=external>on the Raspberry Pi blog&lt;/a>
that you can achieve total network boot, just like on the PC,
without any SD cards.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2016/08/netbooting-your-raspberry-pi/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Cloud-Enabling a Bathroom Scale</title><link>https://irq5-7854a1fdb9f4.pages.dev/2014/09/cloud-enabling-a-bathroom-scale/</link><pubDate>Thu, 25 Sep 2014 01:04:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2014/09/cloud-enabling-a-bathroom-scale/</guid><description>&lt;p>Last week as I was making my rounds at the supermarket, I came across this digital bathroom scale on sale.
With some membership card, the discount was almost 50% and at S$16, I thought that was a pretty good deal.
It is &amp;ldquo;wireless&amp;rdquo; in that it has a separate display unit that could be detached from the scale itself.
This bathroom scale had &amp;ldquo;HACK ME&amp;rdquo; written all over it.&lt;/p>&lt;p>&lt;picture>&lt;img src=//farm6.staticflickr.com/5591/15082564568_873cab20b7_c.jpg alt>&lt;/picture>&lt;/p>&lt;p>It turns out that this bathroom scale is the &lt;strong>EB9121&lt;/strong> made by a Chinese (OEM?) company called
&lt;em>Zhongshan Camry Electronic Co. Ltd&lt;/em> (or simply &lt;em>Camry&lt;/em>).
The box specifically mentions that it uses infrared for transmission, and given that I had
&lt;a href=https://irq5-7854a1fdb9f4.pages.dev/tag/infrared rel=noopener>some experience looking at IR signals&lt;/a>, I thought it would be rather straightforward.&lt;/p>&lt;p>&lt;picture>&lt;img src=//farm4.staticflickr.com/3906/15082564748_2feb92e812_c.jpg alt>&lt;/picture>&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2014/09/cloud-enabling-a-bathroom-scale/#more">Continue reading…&lt;/a>&lt;/p></description></item><item><title>Exploring HDMI CEC</title><link>https://irq5-7854a1fdb9f4.pages.dev/2013/10/exploring-hdmi-cec/</link><pubDate>Sun, 27 Oct 2013 03:38:00 +0000</pubDate><guid>https://irq5-7854a1fdb9f4.pages.dev/2013/10/exploring-hdmi-cec/</guid><description>&lt;p>Consumer Electronics Control (CEC) allows control of AV devices that are connected via HDMI. This is the feature of HDMI that enables your TV to automatically turn on and switch to the correct input when you switch on your set-top box, for example. It also allows you to control your set-top box using the TV remote (in some cases).&lt;/p>&lt;p>Electrically, the CEC bus is a single-wire bus that is shared between all HDMI devices, thus any CEC message can be received by all connected devices. Each device then claims one or more logical addresses on which it will receive direct CEC commands.&lt;/p>&lt;p>&lt;picture>&lt;source srcset=/posts/2013/img/lg-remote.jpg.webp type=image/webp>&lt;img src=https://irq5-7854a1fdb9f4.pages.dev/posts/2013/img/lg-remote.jpg alt="LG remote" width=800 height=502>&lt;/picture>&lt;/p>&lt;p>One interesting feature in the HDMI CEC specifications is &lt;em>Remote Control Pass Through&lt;/em>, which allows button presses on the remote control to be passed through to HDMI-connected devices. I thought this feature could be used to unify the various remotes in my living room.&lt;/p>&lt;p>However, not all CEC devices are created equal. As usual, some manufacturers will deviate from the specifications, and/or introduce some quirks in their implementation (as you will see later). They also love to brand CEC with their own funky name, such as &lt;em>SimpLink&lt;/em> or &lt;em>Anynet+&lt;/em>.&lt;/p>&lt;h2 id=raspberry-pi-as-a-cec-bridge>Raspberry Pi as a CEC Bridge&lt;/h2>&lt;p>As a quick and dirty way to check out the capabilities of my TV, I used a Raspberry Pi which has a HDMI connection that can be software-controlled. This also meant that I didn’t have to build my own CEC transceiver circuit.&lt;/p>&lt;p>&lt;a href="https://irq5-7854a1fdb9f4.pages.dev/2013/10/exploring-hdmi-cec/#more">Continue reading…&lt;/a>&lt;/p></description></item></channel></rss>