<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>embedded | Blue Duck Valley Rd</title><link>https://juju.nz/michaelh/tags/embedded/</link><atom:link href="https://juju.nz/michaelh/tags/embedded/index.xml" rel="self" type="application/rss+xml"/><description>embedded</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>© 2017-2025 Michael Hope</copyright><lastBuildDate>Wed, 20 Jan 2016 00:00:00 +0000</lastBuildDate><image><url>img/map[gravatar:%!s(bool=false) shape:circle]</url><title>embedded</title><link>https://juju.nz/michaelh/tags/embedded/</link></image><item><title>LPC810 Hacking</title><link>https://juju.nz/michaelh/note/lpc810hacking/</link><pubDate>Wed, 20 Jan 2016 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/lpc810hacking/</guid><description>&lt;p>The
&lt;a href="http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-arm-cortex-m-mcus/lpc-cortex-m0-plus-m0/lpc800-series/32-bit-arm-cortex-m0-plus-microcontroller-4-kb-flash-and-1-kb-sram:LPC810M021FN8" target="_blank" rel="noopener">LPC810&lt;/a>
is a Cortex-M0+ in a 8 pin PDIP.&lt;/p>
&lt;pre>&lt;code>PIO0_5 /RESET (o ) PIO0_0 U0_RXD
PIO0_4 U0_TXD ( ) Vss
PIO0_3 ( ) Vdd
PIO0_2 ( ) PIO0_1 /ISPEN
&lt;/code>&lt;/pre>
&lt;p>See also the
&lt;a href="http://cache.nxp.com/documents/user_manual/UM10601.pdf" target="_blank" rel="noopener">user
manual&lt;/a>.&lt;/p>
&lt;p>Programming is over serial using
&lt;a href="http://sourceforge.net/projects/lpc21isp/" target="_blank" rel="noopener">lpc21isp&lt;/a>.&lt;/p>
&lt;p>The Sparkfun 3.3V FTDI cable is&lt;/p>
&lt;pre>&lt;code>Black GND (o
Brown CTS (
Red VCC (
Orange TXD (
Yellow RXD (
Green RTS (
&lt;/code>&lt;/pre>
&lt;p>RTS is an output, CTS an input. The LPC needs /RST and /ISPEN which is
tricky. Tie low for development as you can send the GO command to run
the user code.&lt;/p></description></item><item><title>Bone v2</title><link>https://juju.nz/michaelh/note/bonev2/</link><pubDate>Wed, 08 Jul 2015 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/bonev2/</guid><description>&lt;p>I&amp;rsquo;m using a small, no-name RT5370 from
&lt;a href="http://www.ebay.co.uk/itm/For-Raspberry-PI-RT5370-Mini-150Mbps-802-11n-Wireless-USB-Adapter-WiFi-Dongle-/281708681865" target="_blank" rel="noopener">ebay&lt;/a>.
It&amp;rsquo;s not fast but it is compatible and reliable, unlike the other three
adapters that I have.&lt;/p>
&lt;p>Disable interface renaming:&lt;/p>
&lt;pre>&lt;code>cd /etc/udev/rules.d; ln -sf /dev/null 70-persistent-net.rules
&lt;/code>&lt;/pre>
&lt;p>Note that you can&amp;rsquo;t just delete the file as systemd recreates it.&lt;/p>
&lt;p>Setup /etc/network/interfaces:&lt;/p>
&lt;pre>&lt;code>allow-hotplug wlan0
iface wlan0 inet dhcp
pre-up sleep 2
pre-up rfkill unblock all
wpa-ssid &amp;quot;your-ssid-here&amp;quot;
wpa-psk &amp;quot;your-password-here&amp;quot;
&lt;/code>&lt;/pre>
&lt;p>Note that during the boot, systemd seems to randomly set the rfkill bit
which causes dhcpclient to show &amp;lsquo;300 byte&amp;rsquo; errors. The &lt;code>sleep; unblock&lt;/code>
hack works around this. sleep to work around race conditions FTW!&lt;/p>
&lt;p>Update the kernel:&lt;/p>
&lt;pre>&lt;code>cd /opt/scripts/tools
git pull
apt-cache search linux-image bone
./update_kernel.sh --kernel 4.1.1-bone9
&lt;/code>&lt;/pre>
&lt;h2 id="enabling-ports">Enabling ports&lt;/h2>
&lt;p>See
&lt;a href="https://eewiki.net/display/linuxonarm/BeagleBone&amp;#43;Black" target="_blank" rel="noopener">https://eewiki.net/display/linuxonarm/BeagleBone+Black&lt;/a> for building
the device tree overlays.&lt;/p>
&lt;pre>&lt;code> echo BB-UART1 &amp;gt; /sys/devices/platform/bone_capemgr/slots
&lt;/code>&lt;/pre>
&lt;p>The pinouts are at
&lt;a href="http://elinux.org/Beagleboard:Cape" target="_blank" rel="noopener">http://elinux.org/Beagleboard:Cape&lt;/a>_Expansion_Headers#4.5_Serial_UARTs&lt;/p>
&lt;h2 id="adafruit-18-display">Adafruit 1.8&amp;quot; display&lt;/h2>
&lt;p>There seems to be probles with SPI on the 4.1 kernel and the 3.14 kernel
is missing the cape manager. 3.8 works fine though.&lt;/p>
&lt;p>
&lt;a href="https://github.com/notro/fbtft/wiki/LCD-Modules" target="_blank" rel="noopener">https://github.com/notro/fbtft/wiki/LCD-Modules&lt;/a>#adafruit-18&lt;/p>
&lt;pre>&lt;code>GND 1
VCC 2
RST 3 -&amp;gt; 15 (GPIO48)
DC 4 -&amp;gt; 23 (GPIO49)
CARD_CS 5
LCD_CS 6 -&amp;gt; 17
MOSI 7 -&amp;gt; 18
SCK 8 -&amp;gt; 22
MISO 9
LITE 10 -&amp;gt; VCC
echo BB-SPIDEV0 &amp;gt; /sys/devices/bone_capemgr*/slots
modprobe -f fb_st7735r
modprobe -f fbtft_device name=adafruit18 busnum=1 gpios=reset:48,dc:49
con2fbmap 1 1
&lt;/code>&lt;/pre></description></item><item><title>AVR Hacking</title><link>https://juju.nz/michaelh/note/avrhacking/</link><pubDate>Wed, 30 Oct 2013 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/avrhacking/</guid><description>&lt;h2 id="programmer">Programmer&lt;/h2>
&lt;pre>&lt;code>JTAG Name M168 T85
3 - MOSI 17 5
4 - RESET 1 1
5 - SCK 19 7
6 - GND 8 4
7 - MISO 18 6
&lt;/code>&lt;/pre>
&lt;h2 id="attiny85">ATTINY85&lt;/h2>
&lt;pre>&lt;code>PB5 (o ) VCC
PB3 ( ) PB2
PB4 ( ) PB1
GND ( ) PB0
&lt;/code>&lt;/pre>
&lt;h2 id="serial">Serial&lt;/h2>
&lt;pre>&lt;code>5V o o
o o TX
o o RX
&lt;/code>&lt;/pre></description></item><item><title>ARM host</title><link>https://juju.nz/michaelh/note/arm-host/</link><pubDate>Sat, 03 Aug 2013 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/arm-host/</guid><description>&lt;p>I&amp;rsquo;d like a lower power server for inside my home. Some requirements:&lt;/p>
&lt;ul>
&lt;li>Cortex-A9, quad core, 1.2 Ghz or more.&lt;/li>
&lt;li>2 GiB&lt;/li>
&lt;li>Ethernet. USB hosted is OK, native gigabit is better.&lt;/li>
&lt;li>2 or more USB ports.&lt;/li>
&lt;li>A public git tree.&lt;/li>
&lt;/ul>
&lt;p>And would be nices:&lt;/p>
&lt;ul>
&lt;li>In the Linus kernel&lt;/li>
&lt;li>Real datasheets (yay Freescale!)&lt;/li>
&lt;li>Fit within a 3.5&amp;quot; drive envelope (102 x 25 mm, 18 mm for &amp;lsquo;airflow&amp;rsquo;)&lt;/li>
&lt;/ul>
&lt;p>Mass storage will come from the NAS. If it&amp;rsquo;s small enough then it can
fit in a spare drive bay.&lt;/p>
&lt;p>Some potentials:&lt;/p>
&lt;ul>
&lt;li>Wandboard Quad. 95 x 95 mm, unknown height.&lt;/li>
&lt;li>ODROID-X2, 90 x 95 mm, unknown height.&lt;/li>
&lt;/ul>
&lt;p>Update: 2013-08-01: I decided on the Freescale i.MX6 based Wandboard.
Quite happy so far. SATA is broken but possible. Tops out at 70 deg C at
1 GHz.&lt;/p>
&lt;h1 id="synology-213-as-a-freedombox">Synology 213 as a Freedombox&lt;/h1>
&lt;p>I&amp;rsquo;d like to self host and move my current VPS into my home. I have an
ARM-based Synology NAS which can also run Debian in a chroot. Here&amp;rsquo;s the
setup.&lt;/p>
&lt;p>Installing Debian:&lt;/p>
&lt;ul>
&lt;li>Start at
&lt;a href="http://www.synocommunity.com/" target="_blank" rel="noopener">http://www.synocommunity.com/&lt;/a>&lt;/li>
&lt;li>Add the
&lt;a href="http://packages.synocommunity.com/" target="_blank" rel="noopener">http://packages.synocommunity.com/&lt;/a> source&lt;/li>
&lt;li>Open the &lt;code>Package Center&lt;/code>&lt;/li>
&lt;li>Click on &lt;code>Community&lt;/code>&lt;/li>
&lt;li>Install &lt;code>Python&lt;/code>&lt;/li>
&lt;li>Install &lt;code>Debian Chroot&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>It looks like the package does a &lt;code>debootstrap&lt;/code> as part of the install.&lt;/p>
&lt;ul>
&lt;li>Once installed, select &lt;code>Action | Run&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Enter the chroot and do basic setup:&lt;/p>
&lt;ul>
&lt;li>&lt;code>/var/packages/debian-chroot/scripts/start-stop-status chroot&lt;/code>&lt;/li>
&lt;li>&lt;code>vi /etc/apt/sources.list&lt;/code>&lt;/li>
&lt;li>Keep wheezy enabled, drop the others&lt;/li>
&lt;li>&lt;code>apt-get update&lt;/code>&lt;/li>
&lt;li>&lt;code>apt-get dist-upgrade&lt;/code>&lt;/li>
&lt;li>&lt;code>apt-get install -yq jed locales sudo&lt;/code>&lt;/li>
&lt;li>&lt;code>dpkg-reconfigure locales tzdata&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Add the SSH server on a custom port:&lt;/p>
&lt;ul>
&lt;li>apt-get install -yq jed openssh-server&lt;/li>
&lt;li>jed /etc/ssh/sshd_config&lt;/li>
&lt;li>Update &lt;code>Port&lt;/code>&lt;/li>
&lt;li>cd /etc&lt;/li>
&lt;li>mkdir rc.syno.d&lt;/li>
&lt;li>cd rc.syno.d&lt;/li>
&lt;li>ln -s ../init.d/ssh&lt;/li>
&lt;/ul>
&lt;p>Update the DSM-side start script to also start services:&lt;/p>
&lt;ul>
&lt;li>vi /var/packages/debian-chroot/scripts/start-stop-status&lt;/li>
&lt;li>Add the following after the last grep/mount in start_daemon:&lt;/li>
&lt;/ul>
&lt;p>&lt;code>chroot ${CHROOTTARGET}/ /bin/run-parts -a start /etc/rc.syno.d&lt;/code>&lt;/p>
&lt;p>Add the user account:&lt;/p>
&lt;ul>
&lt;li>Add in the DSM side under &lt;code>Control Panel | User&lt;/code>&lt;/li>
&lt;li>Grab the user ID from &lt;code>/etc/passwd&lt;/code>&lt;/li>
&lt;li>Add in the chroot with the same user ID: &lt;code>adduser --uid xxxx username&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>You now have a Debian chroot with SSH access. Have at it!&lt;/p>
&lt;p>Notes:&lt;/p>
&lt;ul>
&lt;li>The chroot is stored at
&lt;code>/volume1/@appstore/debian-chroot/var/chroottarget&lt;/code>. Don&amp;rsquo;t forget to
back it up.&lt;/li>
&lt;li>Add any services manually to &lt;code>/etc/rc.syno.d&lt;/code>&lt;/li>
&lt;/ul></description></item><item><title>Olimex STM32-H103 Notes</title><link>https://juju.nz/michaelh/note/stm32h103/</link><pubDate>Wed, 26 Jun 2013 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/stm32h103/</guid><description>&lt;p>The
&lt;a href="https://www.olimex.com/" target="_blank" rel="noopener">Olimex&lt;/a>
&lt;a href="https://www.olimex.com/Products/ARM/ST/STM32-H103/" target="_blank" rel="noopener">STM32-H103&lt;/a> is a
&lt;a href="http://st.com" target="_blank" rel="noopener">ST&lt;/a> STM32F1 based development. Pluses are the USB port,
proper JTAG connector, and all I/O out on 0.1&amp;quot; pitch pins.&lt;/p>
&lt;p>Details:&lt;/p>
&lt;ul>
&lt;li>STM32F103RBT6 CPU&lt;/li>
&lt;li>128 Ki flash, 20 Ki RAM, 72 Mhz&lt;/li>
&lt;li>Standard 20 pin JTAG connector&lt;/li>
&lt;li>Green STAT LED on PC12&lt;/li>
&lt;li>8 MHz crystal&lt;/li>
&lt;/ul>
&lt;p>Links:&lt;/p>
&lt;ul>
&lt;li>Manual
&lt;a href="https://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103.pdf" target="_blank" rel="noopener">https://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103.pdf&lt;/a>&lt;/li>
&lt;li>Schematic
&lt;a href="https://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103-sch.gif" target="_blank" rel="noopener">https://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103-sch.gif&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="programming">Programming&lt;/h2>
&lt;p>I used the Ubuntu Raring OpenOCD 0.6.0 and a Signalyzer Lite. The host
is a Macbook Air running Windows with Ubuntu Raring in a VM. OpenOCD
sometimes fails with a &lt;code>Error: unable to open ftdi device: unable to fetch product description&lt;/code> error, but re-plugging the JTAG device fixes
that.&lt;/p>
&lt;p>A basic OpenOCD config file works fine:&lt;/p>
&lt;pre>&lt;code># Olimex STM32-H103
source [find interface/signalyzer-lite.cfg]
source [find target/stm32f1x.cfg]
&lt;/code>&lt;/pre>
&lt;p>Programming via &lt;code>telnet localhost 4444&lt;/code> involves:&lt;/p>
&lt;pre>&lt;code>reset halt
flash probe 0
stm32f1x mass_erase 0
flash write_image blink.hex 0 ihex
reset run
&lt;/code>&lt;/pre></description></item><item><title>Fancybox</title><link>https://juju.nz/michaelh/note/fancybox/</link><pubDate>Sun, 17 Jun 2012 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/fancybox/</guid><description>&lt;p>OpenWRT can do quite a few things I need on my network that are running
in many places, including:&lt;/p>
&lt;ul>
&lt;li>DHCP server with DNS hooks - dnsmasq&lt;/li>
&lt;li>Netboot/DHCP/TFTP server - dnsmasq&lt;/li>
&lt;li>Proxy - polipo&lt;/li>
&lt;/ul>
&lt;p>It could let me use IPv6.&lt;/p>
&lt;p>The
&lt;a href="http://www.tp-link.com.au/products/details/?model=TL-MR3220" target="_blank" rel="noopener">TL-MR3220&lt;/a>
has a 400 MHz MIPS CPU, 32 MB of RAM, and 4 MB of flash.&lt;/p>
&lt;h2 id="usb-audio">USB audio&lt;/h2>
&lt;p>Via the MiniDisc USB adapter - sounds really good.&lt;/p>
&lt;p>Choose music via:&lt;/p>
&lt;ul>
&lt;li>
&lt;a href="http://wiki.openwrt.org/doc/howto/pulseaudio" target="_blank" rel="noopener">Pulseaudio sink&lt;/a>&lt;/li>
&lt;li>
&lt;a href="http://mpd.wikia.com" target="_blank" rel="noopener">MPD&lt;/a> with many clients including Android&lt;/li>
&lt;/ul>
&lt;h2 id="other">Other&lt;/h2>
&lt;p>The
&lt;a href="http://wiki.daviddarts.com/PirateBox" target="_blank" rel="noopener">PirateBox&lt;/a> is interesting.&lt;/p></description></item><item><title>LPC1114 Temperature Sensor</title><link>https://juju.nz/michaelh/note/lpc1114/</link><pubDate>Sun, 10 Jun 2012 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/lpc1114/</guid><description>&lt;p>The idea is to use the Cortex-M0 based LPC1114 as a low power micro in a
remote temperature sensor. Use a solar light as the case and power
source and it should run forever.&lt;/p>
&lt;p>Use the
&lt;a href="http://olimex.com/" target="_blank" rel="noopener">Olimex&lt;/a>
&lt;a href="http://olimex.com/dev/lpc-h11xx.html" target="_blank" rel="noopener">LPC-H11U14&lt;/a> as a breakout board.&lt;/p>
&lt;p>Initial code is at
&lt;a href="http://juju.net.nz/src/lpc1114.git/" target="_blank" rel="noopener">http://juju.net.nz/src/lpc1114.git/&lt;/a>&lt;/p>
&lt;p>
&lt;a href="http://www.nxp.com/documents/data_sheet/LPC111X.pdf" target="_blank" rel="noopener">Datasheet&lt;/a>
&lt;a href="http://www.nxp.com/documents/user_manual/UM10398.pdf" target="_blank" rel="noopener">User
manual&lt;/a>&lt;/p>
&lt;h2 id="hardware">Hardware&lt;/h2>
&lt;p>LPC1114FBD48/302:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>LPC1100L&lt;/p>
&lt;/li>
&lt;li>
&lt;p>38 x 38 mm&lt;/p>
&lt;/li>
&lt;li>
&lt;p>32 k flash, 8 k RAM, UART, 2x SSP, I2C, ADC&lt;/p>
&lt;/li>
&lt;li>
&lt;p>TMP102 0.5 deg C?&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>microbuilder reference design:&lt;/p>
&lt;ul>
&lt;li>NCP1402 converter. 0.8 V startup, 200 mA, various outputs.&lt;/li>
&lt;li>24AA32AFT. Microchip I2C 4 k x 8 EEPROM&lt;/li>
&lt;/ul>
&lt;p>&lt;code>PIO0_7&lt;/code> (23) is a 20 mA high current driver. The I2C lines are high
current sinks. A white LED has a ~3.5 V drop. Red is ~1.6 V and
yellow/green ~2.0 V at 10 mA. 10 mA for a (5 V - 1.8 V) drop = 320 Ohms.&lt;/p>
&lt;p>Regulator is a LDO (1.2 V) 800 mA LM1117. Steering diodes give another
0.6 V so it shouldn&amp;rsquo;t work :)&lt;/p>
&lt;p>&lt;code>IOCON&lt;/code> set the routing for different signals like the SPI clock.&lt;/p>
&lt;p>Two SPI ports:&lt;/p>
&lt;ul>
&lt;li>SPI0: SCK0/PIO0_6 (22), MISO0/PIO0_8 (27), MOSI0/PIO0_9 (28),
SSEL0/PIO0_2 (10)&lt;/li>
&lt;li>SPI1: SCK1/PIO2_1 (13), MISO1/PIO2_2 (26), MOSI1/PIO2_3 (38),
SSEL1/PIO2_0 (2)&lt;/li>
&lt;/ul>
&lt;h2 id="power">Power&lt;/h2>
&lt;p>The dev board has a LM1117IMPX-ADJ and 240R + 390R divider. V = IR so I
= 5.2 mA!&lt;/p>
&lt;p>1.8 to 3.6 V supply. Must boost.&lt;/p>
&lt;p>1 mA at 6 MHz. 5 mA at 50 MHz.&lt;/p>
&lt;h2 id="code">Code&lt;/h2>
&lt;ul>
&lt;li>
&lt;a href="https://github.com/microbuilder/LPC1114CodeBase" target="_blank" rel="noopener">https://github.com/microbuilder/LPC1114CodeBase&lt;/a>&lt;/li>
&lt;li>mbed is a LPC11U24 but I can&amp;rsquo;t find the library code&lt;/li>
&lt;li>
&lt;a href="http://www.microbuilder.eu/" target="_blank" rel="noopener">http://www.microbuilder.eu/&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="speed">Speed&lt;/h2>
&lt;p>0.98 CoreMark/MHz with Code Red GCC 4.3.3.&lt;/p>
&lt;h2 id="bootloader">Bootloader&lt;/h2>
&lt;p>The built in bootloader seems fine. ASCII/uuencode based with auto baud.
Starts the user program if &amp;lsquo;valid&amp;rsquo; based on the vectors checksum.&lt;/p>
&lt;p>Pins:&lt;/p>
&lt;ul>
&lt;li>&lt;code>#RESET/PIO0_0&lt;/code> / pin 3&lt;/li>
&lt;li>&lt;code>PIO0_1&lt;/code> / pin 4 low on reset to enter the loader&lt;/li>
&lt;li>&lt;code>RXD/PIO1_6&lt;/code> / pin 46&lt;/li>
&lt;li>&lt;code>TXD/PIO1_7&lt;/code> / pin 47&lt;/li>
&lt;/ul>
&lt;p>Protocol:&lt;/p>
&lt;ul>
&lt;li>&lt;code>?&lt;/code> -&amp;gt;&lt;/li>
&lt;li>&amp;lt;- &lt;code>Synchronized&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code>&lt;/li>
&lt;li>&lt;code>Synchronized&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code> -&amp;gt;&lt;/li>
&lt;li>&amp;lt;- &lt;code>OK&amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt;&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Use my FTD2232 based JTAG?&lt;/p>
&lt;h2 id="interface">Interface&lt;/h2>
&lt;p>Use one of the Nokia DKU-5 clones from Trademe.&lt;/p>
&lt;p>&lt;code>+5V TXD DTR RXD GND&lt;/code>&lt;/p>
&lt;p>&lt;code>RTS ??? ??? ??? ???&lt;/code>&lt;/p>
&lt;p>DTR and RTS can map to reset and BSL. Matches the
&lt;a href="http://www.sparkfun.com/products/714" target="_blank" rel="noopener">Sparkfun
one&lt;/a>.&lt;/p>
&lt;p>Looking from the bottom of the IDC, I have:&lt;/p>
&lt;p>&lt;code>| | | |&lt;/code>&lt;/p>
&lt;p>&lt;code>1 2 3 4 5&lt;/code>&lt;/p>
&lt;p>&lt;code>6 7 8 9 10&lt;/code>&lt;/p>
&lt;ul>
&lt;li>1 = RTS&lt;/li>
&lt;li>2 = TXD&lt;/li>
&lt;li>3 = RXD&lt;/li>
&lt;li>4 = &amp;ndash;&lt;/li>
&lt;li>6 = +5V&lt;/li>
&lt;li>7 = DTR&lt;/li>
&lt;li>8 = GND&lt;/li>
&lt;li>5, 9, 10 = NC&lt;/li>
&lt;/ul>
&lt;h2 id="memory-map">Memory map&lt;/h2>
&lt;p>Bootloader:&lt;/p>
&lt;ul>
&lt;li>0 - 0x7FFF: Flash in 4 k sectors&lt;/li>
&lt;li>0x10000000 + 8 k: RAM&lt;/li>
&lt;li>RAM + 0x17C to 0x025B: ISP work area&lt;/li>
&lt;li>Upper 32 bytes of RAM: Flash work area&lt;/li>
&lt;li>Top of RAM - 32 bytes: top of stack&lt;/li>
&lt;/ul>
&lt;h2 id="hookups">Hookups&lt;/h2>
&lt;p>I have a
&lt;a href="http://olimex.com/dev/mod-nrf24L.html" target="_blank" rel="noopener">MOD-NRF24LR&lt;/a>. NRF24L01.
SPI based.&lt;/p>
&lt;p>And a
&lt;a href="http://olimex.com/dev/mod-lcd3310.html" target="_blank" rel="noopener">MOD-LCD3310&lt;/a>. 84x48. SPI
based. Needs an extra data/command line.&lt;/p></description></item><item><title>BeagleBone</title><link>https://juju.nz/michaelh/note/bone/</link><pubDate>Wed, 07 Mar 2012 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/bone/</guid><description>&lt;p>This page has terse notes on installing the
&lt;a href="http://www.linaro.org/" target="_blank" rel="noopener">Linaro&lt;/a> LEB root filesystem on a
&lt;a href="http://beagleboard.org/bone" target="_blank" rel="noopener">BeagleBone&lt;/a>, setting up the USB Ethernet
gadget, and enabling basic networking.&lt;/p>
&lt;h2 id="initial">Initial&lt;/h2>
&lt;p>Grab the boot partition contents to get MLO, u-boot, and the kernel.&lt;/p>
&lt;p>Grab the modules from the rootfs.&lt;/p>
&lt;p>Use
&lt;a href="https://launchpad.net/linaro-image-tools" target="_blank" rel="noopener">linaro-media-create&lt;/a> to
fill the SD card. Claim we&amp;rsquo;re a BeagleBoard for no real reason.&lt;/p>
&lt;pre>&lt;code>./linaro-media-create --mmc /dev/sdb-check-this --dev beagle \
--rootfs ext4 --console ttyO0,115200n8 \
--hwpack ~/Downloads/hwpack_linaro-omap3_20120210-0_armel_supported.tar.gz \
--binary ~/Downloads/linaro-o-developer-tar-20120210-0.tar.gz \
--hwpack-force-yes --align-boot-part
&lt;/code>&lt;/pre>
&lt;p>Copy the original boot files to the new &lt;code>boot&lt;/code> partition and the
original modules to the new &lt;code>rootfs&lt;/code> partition.&lt;/p>
&lt;h2 id="boot-issues">Boot issues&lt;/h2>
&lt;p>Seems to hang. Use an initial shell via:&lt;/p>
&lt;pre>&lt;code>set ip_method none --verbose init=/bin/sh
&lt;/code>&lt;/pre>
&lt;p>&lt;code>/etc/network/interfaces&lt;/code> includes a DHCP on eth0 which is causing the
long boot time. Disable.&lt;/p>
&lt;p>I prefer LABEL=rootfs instead of UUID in /etc/fstab.&lt;/p>
&lt;h2 id="enabling-gadget-based-networking">Enabling gadget based networking&lt;/h2>
&lt;p>Add &lt;code>g_ether&lt;/code> to &lt;code>/etc/modules&lt;/code> to enable the USB Ethernet gadget.&lt;/p>
&lt;p>Add a &lt;code>iface usb0 inet static&lt;/code> stanza to /etc/network/interfaces:&lt;/p>
&lt;pre>&lt;code>auto usb0
iface usb0 inet static
address 192.168.7.10
netmask 255.255.255.0
gateway 192.168.7.1
hwaddress ether fa:aa:55:aa:55:01
&lt;/code>&lt;/pre>
&lt;p>Set /etc/modprobe.d/gether.conf to &lt;code>options g_ether host_addr=fa:aa:55:aa:55:02&lt;/code> to fix the host MAC address.&lt;/p>
&lt;p>Note the fixed instead of random MAC address.&lt;/p>
&lt;p>Setup usb0 on the host as 192.168.7.1. Note that NetworkManager might
interfere. If so, add a connection for the usb0 MAC address that does
nothing.&lt;/p>
&lt;p>SSH into the host and forward off to the main network proxy:&lt;/p>
&lt;pre>&lt;code>ssh -L 8123:proxy:8123 -N michaelh@192.168.7.1
&lt;/code>&lt;/pre>
&lt;p>Install openssh-server:&lt;/p>
&lt;pre>&lt;code>http_proxy=http://localhost:8123/ apt-get install openssh-server
&lt;/code>&lt;/pre>
&lt;p>Add a user &lt;code>adduser michaelh&lt;/code>, put them in the sudo group &lt;code>adduser michaelh admin&lt;/code>, ssh in from the host.&lt;/p>
&lt;p>You can now ssh into the board.&lt;/p>
&lt;h2 id="internet-access-via-the-host">Internet access via the host&lt;/h2>
&lt;p>The Maemo guys have documented this at
&lt;a href="http://wiki.maemo.org/USB" target="_blank" rel="noopener">http://wiki.maemo.org/USB&lt;/a>_networking.&lt;/p>
&lt;p>On the host, add a usb0 stanza to &lt;code>/etc/network/interfaces&lt;/code>:&lt;/p>
&lt;pre>&lt;code>iface usb0 inet static
address 192.168.7.1
netmask 255.255.255.0
up echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward
up iptables -P FORWARD ACCEPT
up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
down echo 0 &amp;gt; /proc/sys/net/ipv4/ip_forward
down iptables -t nat -F POSTROUTING
&lt;/code>&lt;/pre>
&lt;h2 id="post-boot">Post boot&lt;/h2>
&lt;p>Set the hostname:&lt;/p>
&lt;pre>&lt;code>echo bone &amp;gt; /etc/hostname
&lt;/code>&lt;/pre>
&lt;p>Consider installing &lt;code>avahi-daemon&lt;/code>. Allows &lt;code>ssh bone.local&lt;/code>.&lt;/p>
&lt;p>&lt;code>sudo ntpdate-debian&lt;/code> to set the date. Works best with eth0 due to the
forwarding delays in usb0.&lt;/p>
&lt;p>Make a LED turn on and off:&lt;/p>
&lt;pre>&lt;code>cd /sys/devices/platform/leds-gpio/leds/beaglebone::usr2
echo 255 &amp;gt; brightness
echo 0 &amp;gt; brightness
&lt;/code>&lt;/pre>
&lt;p>Profit.&lt;/p>
&lt;h2 id="wireless">Wireless&lt;/h2>
&lt;p>I have a Edimax EW-7711UTn USB Wifi dongle.&lt;/p>
&lt;p>Add a wlan0 stanza to /etc/network/interfaces:&lt;/p>
&lt;pre>&lt;code>auto wlan0
iface wlan0 inet dhcp
wireless-essid Public
&lt;/code>&lt;/pre>
&lt;p>(I have a profile on my router called &amp;lsquo;Public&amp;rsquo; with no password).&lt;/p>
&lt;p>Actually, it drops after a while. Ignore.&lt;/p>
&lt;h2 id="notes">Notes&lt;/h2>
&lt;p>Env:&lt;/p>
&lt;pre>&lt;code>autoload=yes
baudrate=115200
bootargs_defaults=setenv bootargs console=${console} ${optargs}
bootcmd=if mmc rescan; then echo SD/MMC found on device ${mmc_dev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run mmc_load_uimage; then run mmc_args;bootm 0x80007fc0;fi;fi;run nand_boot;
bootdelay=1
bootenv=uEnv.txt
bootfile=uImage
console=ttyO0,115200n8
ethact=cpsw
ethaddr=40:5f:c2:76:ab:62
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
ip_method=none
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmc_dev} ${loadaddr} ${bootenv}
mmc_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${mmc_root} rootfstype=${mmc_root_fs_type} ip=${ip_method}
mmc_boot=run mmc_args; run mmc_load_uimage; bootm 0x80007fc0
mmc_dev=0
mmc_load_uimage=fatload mmc ${mmc_dev} 0x80007fc0 ${bootfile}
mmc_load_uimage_ext2=ext2load ${mmc_dev} 0x80007fc0 /boot/${bootfile}
mmc_root=/dev/mmcblk0p2 ro
mmc_root_fs_type=ext4 rootwait
nand_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${nand_root} noinitrd rootfstype=${nand_root_fs_type} ip=${ip_method}
nand_boot=echo Booting from nand ...; run nand_args; nand read.i ${loadaddr} ${nand_src_addr} ${nand_img_siz}; bootm ${loadaddr}
nand_img_siz=0x500000
nand_root=/dev/mtdblock7 rw
nand_root_fs_type=jffs2
nand_src_addr=0x280000
net_args=run bootargs_defaults;setenv bootargs ${bootargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
net_boot=echo Booting from network ...; setenv autoload no; dcache off; dhcp; tftp ${loadaddr} ${bootfile}; run net_args; bootm ${loadaddr}
nfsopts=nolock
nor_args=run bootargs_defaults;setenv bootargs ${bootargs} root={nor_root} rootfstype=${nor_root_fs_type} ip=${ip_method}
nor_boot=echo Booting from NOR ...; run nor_args; cp.b ${0x08080000} ${loadaddr} ${nor_img_siz}; bootm ${loadaddr}
nor_img_siz=0x280000
nor_root=/dev/mtdblock3 rw
nor_root_fs_type=jffs2
nor_src_addr=0x08080000
rootpath=/export/rootfs
script_addr=0x81900000
spi_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${spi_root} rootfstype=${spi_root_fs_type} ip=${ip_method}
spi_boot=echo Booting from spi ...; run spi_args; sf probe ${spi_bus_no}:0; sf read ${loadaddr} ${spi_src_addr} ${spi_img_siz}; bootm ${loadaddr}
spi_bus_no=0
spi_img_siz=0x280000
spi_root=/dev/mtdblock4 rw
spi_root_fs_type=jffs2
spi_src_addr=0x62000
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial
&lt;/code>&lt;/pre></description></item><item><title>libmad on the BeagleBone</title><link>https://juju.nz/michaelh/note/bonemad/</link><pubDate>Wed, 07 Mar 2012 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/bonemad/</guid><description>&lt;p>(or really any Cortex-A)&lt;/p>
&lt;p>[[notes/bonemad]]&lt;/p>
&lt;p>I&amp;rsquo;m mainly interested in performance as power used ~= 1/performance.&lt;/p>
&lt;p>Using libmad-0.15.1b-7ubuntu1 from Precise and Linaro GCC 4.6 2012.02 as
a cross build setup.&lt;/p>
&lt;p>Has its own complicated and out of date way of selecting the
optimisations. Ubuntu turns this into a -O2. Scans the &lt;code>CFLAGS&lt;/code> to pull
out the optimisation.&lt;/p>
&lt;p>At 720 MHz over USB.&lt;/p>
&lt;p>Default -O2 setup: 23.4 s, 21.4 s, 21.5 s, 21.5 s&lt;/p>
&lt;p>Switch to userspace governor and lock at 720 MHz: 21.2 s, 21.2 s, 21.2 s&lt;/p>
&lt;p>-O3 setup: 21.2 s, 21.2 s&amp;hellip;&lt;/p>
&lt;p>&amp;hellip;as it&amp;rsquo;s picking up the system libmad!&lt;/p>
&lt;p>-O3 setup: 21.5 s, 21.5 s&lt;/p>
&lt;p>-O2 setup: 21.5 s, 21.5 s&lt;/p>
&lt;p>There&amp;rsquo;s very little difference in size - ~30 bytes. As the Ubuntu patch
forces it to -O2 and ignores the earlier CFLAGS parsing.&lt;/p>
&lt;p>-O3 setup: 21.7 s, 21.7 s - slower!&lt;/p>
&lt;p>Disable the assembly routines and see how it changes.&lt;/p>
&lt;p>-O3 noasm: 20.0 s, 20.0 s&lt;/p>
&lt;p>-O2 noasm: 20.4 s, 20.4 s&lt;/p>
&lt;p>-O3 noasm -mfpu=neon (turns on the vectoriser): 19.9 s, 19.9 s.&lt;/p>
&lt;p>Not much change which suggests a very hot function or some bad code.
perf time!&lt;/p>
&lt;p>perf report:&lt;/p>
&lt;pre>&lt;code>55.17% minimad libc-2.13.so [.] _IO_putc
15.50% minimad libmad.so.0.2.1 [.] synth_full
7.02% minimad libmad.so.0.2.1 [.] III_decode
6.51% minimad libmad.so.0.2.1 [.] loop
5.29% minimad libmad.so.0.2.1 [.] dct32
2.64% minimad minimad [.] output
1.81% minimad libmad.so.0.2.1 [.] III_imdct_l
1.29% minimad libmad.so.0.2.1 [.] mad_bit_read
0.97% minimad libmad.so.0.2.1 [.] III_aliasreduce
0.96% minimad libmad.so.0.2.1 [.] normal_block_x0_to_x17
0.89% minimad libmad.so.0.2.1 [.] normal_block_x18_to_x35
0.54% minimad minimad [.] mad_stream_errorstr@plt
0.41% minimad minimad [.] mad_decoder_finish@plt
&lt;/code>&lt;/pre>
&lt;p>Or, in other words, dominated by the sample writer in minimad. Probably
due to this:&lt;/p>
&lt;pre>&lt;code>sample = scale(*left_ch++);
putchar((sample &amp;gt;&amp;gt; 0) &amp;amp; 0xff);
putchar((sample &amp;gt;&amp;gt; 8) &amp;amp; 0xff);
if (nchannels == 2) {
sample = scale(*right_ch++);
putchar((sample &amp;gt;&amp;gt; 0) &amp;amp; 0xff);
putchar((sample &amp;gt;&amp;gt; 8) &amp;amp; 0xff);
}
&lt;/code>&lt;/pre>
&lt;p>Writes 1152 samples per callback. Turn this into a scale-to-buffer to
keep some semblance of an output layer&amp;hellip;&lt;/p>
&lt;p>8.3 s, 8.3 s. Much better. perf shows:&lt;/p>
&lt;pre>&lt;code>36.80% minimad libmad.so.0.2.1 [.] synth_full
17.44% minimad libmad.so.0.2.1 [.] III_decode
15.46% minimad libmad.so.0.2.1 [.] loop
13.12% minimad libmad.so.0.2.1 [.] dct32
3.84% minimad libmad.so.0.2.1 [.] III_imdct_l
3.32% minimad libmad.so.0.2.1 [.] mad_bit_read
2.33% minimad libmad.so.0.2.1 [.] III_aliasreduce
2.31% minimad libmad.so.0.2.1 [.] normal_block_x18_to_x35
2.21% minimad libmad.so.0.2.1 [.] normal_block_x0_to_x17
0.59% minimad minimad [.] output
&lt;/code>&lt;/pre>
&lt;p>-O3 noasm novect: 8.6 s, 8.7 s&lt;/p>
&lt;p>Note the noasm version is lower fidelity. I guess the assembly version
keeps things in 64 bits for longer.&lt;/p>
&lt;p>-O3 asm novect: 10.3 s, 10.3 s&lt;/p>
&lt;p>-O3 noasm vect -marm: 8.2 s, 8.2 s. So Thumb-2 is similar to ARM mode.&lt;/p>
&lt;p>-O3 noasm vect -mtune=cortex-a8: 8.8 s, 8.1 s, 8.1 s. Tuned for A8
instead of A9 is slightly better.&lt;/p>
&lt;h2 id="hot-functions">Hot functions&lt;/h2>
&lt;p>Decent so far is -O3 noasm vect -mtune=cortex-a8 in Thumb-2. Hot
functions are:&lt;/p>
&lt;pre>&lt;code>37.33% minimad libmad.so.0.2.1 [.] synth_full
17.46% minimad libmad.so.0.2.1 [.] loop
15.93% minimad libmad.so.0.2.1 [.] III_decode
12.10% minimad libmad.so.0.2.1 [.] dct32
4.23% minimad libmad.so.0.2.1 [.] III_imdct_l
2.75% minimad libmad.so.0.2.1 [.] mad_bit_read
&lt;/code>&lt;/pre>
&lt;p>synth_full is dominated by ML0 and MLAs. There&amp;rsquo;s a 1..16 loop in there
which the vectoriser could hit. The compiler is spotting the mlas.&lt;/p></description></item><item><title>BeagleBone playing media</title><link>https://juju.nz/michaelh/note/bonemedia/</link><pubDate>Fri, 02 Mar 2012 00:00:00 +0000</pubDate><guid>https://juju.nz/michaelh/note/bonemedia/</guid><description>&lt;p>I have a XITEL MD-PORT AN1 USB Audio adapter. It sounds quite good. Can
I hook it to my BeagleBone and use it as a remote audio player?&lt;/p>
&lt;p>On Precise I
see:&lt;/p>
&lt;pre>&lt;code>[33777.196130] usb 6-2: new full-speed USB device number 6 using uhci_hcd
[33777.475281] input: XITEL MD-PORT AN1 as \
/devices/pci0000:00/0000:00:1d.0/usb6/6-2/6-2:1.2/input/input17
[33777.475522] generic-usb 0003:09EF:0101.0006: input,hidraw0: \
USB HID v1.00 Device [XITEL MD-PORT AN1] on usb-0000:00:1d.0-2/input2
&lt;/code>&lt;/pre>
&lt;p>The new nodes under /dev are:&lt;/p>
&lt;ul>
&lt;li>/dev/bus/usb/006/006&lt;/li>
&lt;li>/dev/char/116:7&lt;/li>
&lt;li>/dev/char/116:8&lt;/li>
&lt;li>/dev/char/13:68&lt;/li>
&lt;li>/dev/char/189:645&lt;/li>
&lt;li>/dev/char/250:0&lt;/li>
&lt;li>/dev/hidraw0&lt;/li>
&lt;li>/dev/input/by-id/usb-XITEL_MD-PORT_AN1_XA292-event-if02&lt;/li>
&lt;li>/dev/input/by-path/pci-0000:00:1d.0-usb-0:2:1.2-event&lt;/li>
&lt;li>/dev/input/event4&lt;/li>
&lt;li>/dev/snd/by-id&lt;/li>
&lt;li>/dev/snd/by-id/usb-XITEL_MD-PORT_AN1_XA292-00&lt;/li>
&lt;li>/dev/snd/by-path/pci-0000:00:1d.0-usb-0:2:1.0&lt;/li>
&lt;li>/dev/snd/controlC1&lt;/li>
&lt;li>/dev/snd/pcmC1D0p&lt;/li>
&lt;li>/dev/vboxusb/006/006&lt;/li>
&lt;/ul>
&lt;p>The new input device is interesting. Windows automatically changes to
the port when a headphone jack is plugged in - I wonder if the input
fires on insert/remove?&lt;/p>
&lt;p>On the bone I see:&lt;/p>
&lt;ul>
&lt;li>/dev/bus/usb/001/002&lt;/li>
&lt;li>/dev/char/116:0&lt;/li>
&lt;li>/dev/char/116:16&lt;/li>
&lt;li>/dev/char/13:64&lt;/li>
&lt;li>/dev/char/189:1&lt;/li>
&lt;li>/dev/input/by-id&lt;/li>
&lt;li>/dev/input/by-id/usb-XITEL_MD-PORT_AN1_XA292-event-if02&lt;/li>
&lt;li>/dev/input/by-path&lt;/li>
&lt;li>/dev/input/by-path/platform-musb-hdrc.1-usb-0:1:1.2-event&lt;/li>
&lt;li>/dev/input/event0&lt;/li>
&lt;li>/dev/snd/by-id&lt;/li>
&lt;li>/dev/snd/by-id/usb-XITEL_MD-PORT_AN1_XA292-00&lt;/li>
&lt;li>/dev/snd/by-path&lt;/li>
&lt;li>/dev/snd/by-path/platform-musb-hdrc.1-usb-0:1:1.0&lt;/li>
&lt;li>/dev/snd/controlC0&lt;/li>
&lt;li>/dev/snd/pcmC0D0p&lt;/li>
&lt;li>/dev/usbdev1.2&lt;/li>
&lt;/ul>
&lt;p>So that&amp;rsquo;s good!&lt;/p>
&lt;p>Use mpg321 and madplay as tests. Using Linaro, so &lt;code>apt-get install&lt;/code>
them. Need alsa-utils for the Alsa support.&lt;/p>
&lt;p>Audio is terrible - choppy. kworker/0:1 sits at 95 % CPU. Can&amp;rsquo;t set
snd-usb-audio nrpacks as it&amp;rsquo;s compiled in.&lt;/p>
&lt;p>0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch may fix
this. Build Angstrom and see.&lt;/p>
&lt;p>Still fails with
uImage-3.1-r2l+gitr1d84d8853fa30cf3db2571a5aec572accca4e29d-beaglebone-20120127084313.bin.&lt;/p>
&lt;p>Try PIO only? Might be that the patch works fine for high speed devices
but spends too much time spinning on others.&lt;/p>
&lt;h2 id="new-kernel">New kernel&lt;/h2>
&lt;p>It&amp;rsquo;s a confusing OpenEmbedded recipe based setup.&lt;/p>
&lt;p>Kernel is at git://arago-project.org/git/projects/linux-am33x.git&lt;/p>
&lt;p>meta-ti layer is at
git://git.angstrom-distribution.org/meta-texasinstruments&lt;/p>
&lt;p>The recipe is
&lt;a href="http://git.angstrom-distribution.org/cgi-bin/cgit.cgi/meta-texasinstruments/tree/recipes-kernel/linux/linux-ti33x-psp_3.2.bb" target="_blank" rel="noopener">linux-ti33x-psp_3.2&lt;/a>
and will be out of date when you read this :)&lt;/p>
&lt;p>The config is under
recipes-kernel/linux/linux-ti33x-psp-3.2/beaglebone/defconfig.&lt;/p>
&lt;p>There&amp;rsquo;s a large patch list on top of the kernel. I hacked a script to
apply the patches on top of the Git tree.&lt;/p>
&lt;p>Install the modules using &lt;code>make modules_install INSTALL_MOD_PATH=/media/rootfs&lt;/code>&lt;/p>
&lt;h2 id="playback">Playback&lt;/h2>
&lt;p>vlc looks viable. Run against local files and use a/any VLC remote to
control.&lt;/p>
&lt;p>DNLA seems pretty dire.&lt;/p></description></item></channel></rss>