Archive

Posts Tagged ‘nanopi’

Using GPIOs on NanoPi NEO 2 Board with BakeBit Starter Kit

May 21st, 2017 9 comments

NanoPi NEO 2 is a tiny 64-bit ARM development board powered by Allwinner H5 processor. FriendlyELEC sent me a couple of NEO 2 samples together with their BakeBit Start Kit with a NanoHat and various modules via GPIOs, analog input or I2C. I’ve already tested both Armbian with Linux 4.11 and Ubuntu Core Qt with Linux 3.10, and ran a few benchmarks on NanoPi NEO 2. You would normally prefer to use the Armbian image with Linux mainline since it provided better performance, but at the time I was told GPIO support was not there.

Configuring NanoPi NEO 2 board with BakeBit library

So this week-end, when I decided to test GPIO support and BakeBit Starter Kit, I decided to follow this advice, especially nanopi-neo2-ubuntu-core-qte-sd4g-20170329.img.zip image is still the recommended one in the Wiki. So I went with that image.

I’ll use Python examples from Bakebit library, but if you prefer something similar to WiringPi, you may consider using WiringNP library directly instead of using Bakebit. Since NanoHat Hub comes with header with digital I/O (including 2 PWM), analog input, I2C and UART interfaces, I’ll make sure I try samples for all interfaces I have hardware for. FriendlyELEC did not include a module with a UART interface, so I’ll skip that one.

I followed instructions in BakeBit wiki from a terminal which you can access from the serial console or SSH. First, we need to retrieve the source code:

Then we can start the installation:

The last line will install the following dependencies:

  • python2.7           python2.7
  • python-pip         alternative Python package installer
  • git                        fast, scalable, distributed revision control system
  • libi2c-dev           userspace I2C programming library development files
  • python-serial     pyserial – module encapsulating access for the serial port
  • i2c-tools              This Python module allows SMBus access through the I2C /dv
  • python-smbus   Python bindings for Linux SMBus access through i2c-dev
  • minicom             friendly menu driven serial communication program
  • psutil                   a cross-platform process and system utilities module for n
  • WiringNP           a GPIO access library for NanoPi NEO

This will take a while, and after it’s done, the board will automatically reboot.

We can check if everything is properly running, but try out one of the Python scripts:

hmm, python-smbus was supposed to be installed via the installation script. Let’s try to install it manually:

Running the command again with verbose option shows the download URL is not valid:

So I went to https://pypi.python.org/simple/ looking for another python-smbus library in case the name has changed, and I finally installed the pysmbus:

I could go further, but the I2C bus was not detected:

So maybe the driver needs to be loaded. But running sudo modprobe i2c_sunxi it does nothing, and I could notice the .ko file is missing from the image…

So let’s try to build the source code for the board following the Wiki intructions:

We also need to install required build packages…

… download gcc-linaro-aarch64.tar.xz toolchain, and copy it to lichee/brandy/toolchain directory (do not extract it, it will be done by the build script).

Now we can try to build the kernel for NanoPi NEO 2 (and other Allwinner H5 boards).

and it failed with more errors possible related to CROSS_COMPILE flag. There must be a better solution… FriendlyELEC guys might not work on Saturday afternoon, and while I did contact them, I decided to try one of their more recent images with Linux 4.11 available here.

Let’s pick nanopi-neo2_ubuntu-core-xenial_4.11.0_20170518.img.zip since it has a similar name, and is much newer (released 3 days ago). I repeated the installation procedure above, and …

Success! Albeit after 4 to 5 hours of work… Let’s connect hardware to ind out whether it actually works, and not just runs.

Analog Input and Digital Output – Sound Sensor Demo

The simplest demo would be to use the LED module, but let’s do something more fun with the Sound Sensor demo I found in BakerBit Starter Kit printed user’s manual, and which will allow us to use both digital output with the LED module connected to D5 header, and analog input with the Sound sensor module connected to A0 header. Just remember the long LED pin is the positive one.

You can run the code as follows:

I changed the source a bit including the detection threshold, and timing to make it more responsive:

The LED will turn on each time the the sound level (actually analog voltage) is above 1.46V.

PWM and Analog Input – Servo and Rotary Angle Sensor Demo

We can test PWM output using the Servo module connected to D5 header, and control it using the rotary angle sensor module connected the A0 analog input header .

Click to Enlarge

The sample for the demo runs fine, and use the potentiometer is detected:

However, the servo is not moving at all. Raspberry Pi relies on rpi-config to enable things like I2C and other I/Os, and I noticed npi-config in the Wiki for NEO 2. So I ran it, and sure enough PWM was disabled.

So I enabled it, and answered Yes when I was asked to reboot. The only problem is that it would not boot anymore, with the system blocked at:

So maybe something went wrong during the process, so I re-flashed the Ubuntu image, reinstalled BakeBit, and re-enabled PWM0. But before rebooting, I checked the boot directory, and noticed boot.cmd, boot.scr, and the device tree file (sun50i-h5-nanopi-neo2.dtb) had been modified. The DTB looks fine, as I could decode it, and find the pwm section:

Let’s reboot the board. Exact same problem with the boot stuck at “Starting kernel…”. So there’s something wrong with the way npi-config modifies one or more of the files. With hindsight, I should have made a backup of those three files before enabling PWM the second time… I’ll give up on PWM for now, and ask FriendlyELEC to look into it.

I2C and Analog Input – OLED UI controlled with Joystick

The final test I’ll use the I2C OLED display module connected to one of the I2C headers, together with the analog joystick module connected to A0 header.

Click to Enlarge

Let’s run the sample for the demo:

It works, but there’s a bit of a lag, and the sample may have to be improved to better detect various states. I’ll show what I mean in the video below.

The bad parts are that documentation is not up-to-date, enabling PWM will crash the image, and while the Python sample do demonstrate IO capabilities, they should probably be improved to be more responsive. The good part is that we’re getting there, the hardware kit is a really nice, and I think the documentation and software should become much better in June, as FriendlyELEC has shown to be responsive to the community issues.

What? Python sucks? You can use C language with GPIOs too

If Python is not your favorite language, FriendlyELEC also provided some C languages samples in the C directory:

As we’ve seen above, Bakebit library appears to rely on WiringNP, and you’d normally be able to list the GPIOs as follows:

The utility is not too happy about seeing an Allwinner H5 board. But maybe the library in the board is not up-to-date, so I have built it from source:

and run the gpio sample again:

Excellent! It’s not quite a work-out-of-box experience, but NanoPi NEO 2 can be used with (most) GPIOs.

My adventures with NanoPi NEO 2 board are not quite done, as I still have to play with NanoHat PCM5102A audio add-on board, which I may end up combining with a USB microphone to play with Google Assistant SDK, and I’m expecting NanoPi NAS Kit v1.2 shortly. I’ll also update this post once PWM is working.

NAS Kit v1.2 Gets Support for NanoPi NEO 2, an UAS Capable USB to SATA Bridge, and an RTC Battery

May 12th, 2017 32 comments

Last month, FriendlyELEC launched a NAS Dock kit for NanoPi NEO board, but they’ll already removed it from their store. That’s because they have a new version NAS Dock v1.2 that also supports NanoPi NEO 2 with Gigabit Ethernet, replaces JMicron JM20329 by UAS capable JMicron JMS567 USB 3.0 to SATA bridge, and adds an RTC battery.

The rest of NAS Dock Kit v1.2 specifications remain the same:

  • 1-bay NAS Dock expansion board with
    • JMicron JMS567 USB 3.0 to SATA bridge
    • SATA connector for 2.5″ HDD drive
    • Extra USB host port
    • On/off switch, and dual color status LED
    • Header to connect NanoPi NEO / NEO 2 board
    • 12V DC power input
    • Dimensions – 151 x 89.7 mm
  • NS-120 aluminum enclosure (154 x 100 x 47.5 mm, 414 grams)
  • Heatsink set for NanoPi NEO / NEO 2
  • 4x M3 6mm screws, 8x M2.5 6 mm screws
  • Four rubber pads
  • Front and back covers

Since NEO 2 has a low profile Ethernet jack, the company provides both NEO and NEO 2 back covers in the kit. It’s probably less hassle than providing two kits.

Software has also improved, as while the company still provides an OpenMediaVault image, it’s now based on Linux 4.11 + Debian 8. You’ll find the download links and instructions in the Wiki. FriendlyELEC also added the better iozone benchmark to the quick hdparm test to compare the “SATA” performance to Raspberry Pi 3, NanoPi NEO, and NanoPi NEO 2 boards.

They should really have done a file copy test over Gigabit Ethernet, as NanoPi NEO 2 should be about 2 to 3 times faster while copying a large file. Raspberry Pi 3 shared Ethernet and USB bandwidth may also affect the performance badly in some specific use cases, while NanoPi NEO 2 won’t have this type of problem since Ethernet and USB are two separate interfaces in Allwinner H5 processor.

The other good news is that despite the improvements, FriendlyELEC NAS Dock Kit price has not changed, and it is still sold for $12.99 + shipping. You’ll also need a  $14.99 NanoPi NEO 2, a micro SD card, a 12V/2A power supply to complete the setup. In other news, the company has also introduced a kit with NanoPi NEO 2 board, and a cute metal case with OLED display going for $34 in total (board included).

NanoPi NEO Boards Get a New Arduino UNO Compatible Dock to Play with Arduino Shields

April 26th, 2017 2 comments

FriendlyELEC has launched a new accessory board for their NanoPi NEO / NEO 2 / NEO Air boards with UNO Dock V2.0 board compatible with Arduino UNO board thanks to its Microchip ATMeaga328P MCU and compatible headers, and also equipped with headers to plug a NanoPi NEO board.

Key features for UNO Dock v2.0 for NanoPi NEO:

  • MCU – Microchip ATmega328 8-bit AVR  MCU @ 16 MHz with 2KB SRAM, 32KB flash, 1024 bytes EEPROM
  • USB – 2x USB 2.0 ports connected to NEO board
  • Expansion
    • Arduino UNO headers for shields
    • Female headers to insert the NanoPi NEO board
    • Male headers to access NanoPi NEO boards’ IOs
  • Debugging & Programming – 1x micro USB port (USB to UART), ICSP header, NEO debug UART header
  • Misc – Power on/off, reset button, UART select jumper
  • Power Supply – 12V DC via 2.1mm power barrel

 

Click to Enlarge

The system would be great if NanoPi NEO boards actually had an HDMI output port, as it would be an all-in-one Arduino development platform that does not require an extra computer, just like UDOO NEO, but cheaper. But sadly that’s not case, so you still need a separate computer to program the board, and NanoPi NEO board here is mainly used to process data from sensors and modules connected to the Arduino and NEO headers, potentially sending & receiving data to/from a cloud service.  In some ways it’s similar to NanoHAT Hub for instead of being designed for Groves modules, it’s designed for Arduino Shields. You’ll find some more details in the Wiki (Chinese version only for now). Based on the schematics, NanoPi NEO board and the Microchip MCU communicate over I2C.

UNO Dock v2.0 sells for $6.99 plus shipping, quite cheaper than the first version (UNO Dock v1.0) going for $14.99 plus shipping.

Thanks to theguyuk for the tip.

FriendlyELEC Introduces $12.99 1-bay NAS Dock Kit for NanoPi NEO & NEO 2 Boards

April 3rd, 2017 34 comments

NanoPi NEO is a tiny board with Fast Ethernet and USB 2.0 interface, so in theory it could make a nice low-end NAS as long as you don’t need the best performance. As always the problem is that there was no case for it, but FriendlyELEC changes that as they just launched a 1-bay NAS Dock Kit for NanoPi NEO / NEO 2 board selling for just $12.99 (promotional price at launch).

The kit comes with the following:

  • 1-bay NAS Dock expansion board with
    • JMicron JM20329 USB to SATA bridge
    • SATA connector for 2.5″ HDD drive
    • Extra USB host port
    • On/off switch, and dual color status LED
    • Header to connect NanoPi NEO board
    • 12V DC power input
    • Dimensions – 151 x 89.7 mm
  • NS-120 aluminum enclosure (154 x 100 x 47.5 mm, 4141 grams)
  • Heatsink set for NanoPI NEO
  • M3 6mm screws, M2.5 6 mm screws
  • Four rubber pads
  • Front and back covers

The company provides an OpenMediaVault image and all instructions on the Wiki. Talking about performance, FriendlyELEC gave me a comparison table showing USB to SATA performance for NanoPi NEO (512MB), Raspberry Pi 3 board, and Synology DS916+ NAS.

The USB to SATA speed is actually pretty much as expected considered data is going through a USB 2.0 interface, and somewhat comparable to the values I get doing USB storage tests on Android TV boxes. We can also see the performance on Raspberry Pi 3 is about the same as with NanoPi NEO + NAS Dock, but obviously not matching actual NAS with a native SATA interface. Nevertheless, all this does not matter that, as once the 32 MB/s get down to the Fast Ethernet port in NEO board, it has to drop to around 10 MB/s, which is why NanoPi NEO 2 is a better choice.

Tkaiser of Armbian community also had a look at the hardware and software, and one complain was the lack of UASP support on Jmicron JM20329 chip which would  yield slightly better performance, and the OpenMediaVault image relies on Linux 3.4.39 which lacks many security updates (the latest available version is 3.4.113). If you prefer having a recent Linux kernel, it’s always possible to install Armbian, plus whatever NAS software you’d like to use.

Nevertheless, it’s difficult to beat the price as with $12.99 for the NAS board and enclosure, $9.99 for NanoPi NEO 512MB RAM, and a few extra dollars for shipping you get a complete NAS solution with limited performance, but that should still work as well as current Raspberry Pi NAS solutions on the market. Just add a micro SD card with the operating systems of your choice, a 2.5″ hard drive or SSD, and a 12V/2A power supply, and you’re done.

NanoPi NEO 2 Board, NanoHats, and BakeBit Starter Kit Review – Part 1: Hardware Overview & Assembly

March 26th, 2017 28 comments

NanoPi NEO 2 development board is an update of NanoPi NEO with a quad core 64-bit Allwinner H5 processor + 512 MB RAM, Gigabit Ethernet, and an extra audio header, which can be a great little board for headless application since there’s no video output. FriendlyELEC ask me whether I wanted to review to board with some of their NanoHATs add-on boards, and while I asked for NanoHat PCM5102A audio board and NEO Hub which I intended to use with Grove modules from my Wio Link Started Kit, I get a bit more than expected, as the company included sets of NEO 2 boards and accessories, NanoHATs, two serial debug board, and their BakeBit Starter Kit with several Grove modules to play with.

Click to Enlarge

Since I have so many things to look at in this first post, I’ll just describe the hardware, assemble it, quickly check the paper documentation, and give some of my impressions about the kit I receive.

Let’s start with NanoPi NEO 2. It’s super tiny, as exactly the same forum factor as NanoPi NEO, except for the low profile Ethernet jack.

The bottom side comes with Allwinner H5 processor SoC, and Samsung K4B4G1646E-BYK0 DDR3L memory (512MB), while the top of the board features Realtek RTL8211E Gigabit Ethernet Transceiver. The board just has four ports/connectors: a micro SD slot, a micro USB port for power, a USB 2.0 host port, and an RJ45 connector.

Click to Enlarge

There are also two headers (2x 12 pin + 12x pin) for I/O just like for the first NEO board, as well as an extra 5-pin header for audio on the right of the 4-pin UART header. The audio header is also present on NanoPi NEO v1.3 board, but not the older boards. See pinout table for details.

Click to Enlarge

Each package with the board also includes a Quick Start Guide describing the board, and explaining how to use the company’ Ubuntu Core + Qt image. As you can see from the photo above, the boards also make great paper weights, but I’m sure you’ll find something more interesting to do with them… 🙂

I also get a heatsink + thermal pads + screws and nuts kit, not included by default. Installation is very easy. First remove the two protective plastic sheets on the blue thermal pad, place it on Allwinner H5 processor, and then add the heatsink on top and secure it with the screws and nuts. Just make sure you orientate properly without covering the IO pins.

I did that for both, and checked possible combinations for those who want to build NanoPi NEO (2) farms. The first combination is to place the boards in opposite direction, and then use some spacers (mine were not suitable) to hold both boards in place as shown here.

The configuration above takes the less space, however, you may want to have all Ethernet ports on the same side, and the low profile Ethernet jack allows for a more compact design compared to what was possible with NanoPi NEO.

This takes about 5 x 4.5 x 4 cm, so if we round that up you could have 1 meter x 1 meter x 4.5 cm deep cluster with 800 NanoPi boards (3,200 cores). You’d just have to find out how to power and cool it down… The 512MB memory might limit use cases for clusters. FriendlyELEC also sells an acrylic case for 8 board clusters.

The main use case for NanoPi NEO (2) board is probably IoT and electronics projects, so I soldered the two headers which are provided with the board (inside the package).

First I thought I made a mistake when I installed the heatsink first, but actually the nuts help keep the headers in place while soldering, so I did not have to use a sponge to push the headers while soldering, as I normally do.


NanoPi NEO 2 boards are now ready. So let’s checkout the two add-on board I got: NanoHAT PCM5102A audio board with Texas Instruments PCM5102A audio stereo DAC,  stereo audio output via RCA connectors, and an IR receiver, as well as NEO Hub (aka NanoHAT Hub) with 12 Grove connectors (I2C, Digital I/O, Analog Inputs, UART)  compatible with Seeed Studio offerings.

Click to Enlarge

NEO Hub also includes an unpopulated SPI header.

Click to Enlarge

The NanoHats sit on top of NEO (2) board, and you can still connect the UART to TTL debug board if you need to access the serial console. NanoHat PCM5102A also comes with 2x RCA to 3.5mm female jack to connect headphones or speakers.

Click to Enlarge

Since NanoHats includes male headers, it’s also possible to stack them.

In some ways, NanoPi NEO (2) and NanoHAT are the more powerful equivalent of Wemos D1 Mini and shields based on ESP8266, and I really like the design of both solutions.

If you already own some Seeed Studio grove modules, you just need the NEO Hub, but Bakebit Starter Kit appears to be a nice way to expereriment with all sorts of sensors, LEDs, and servo.

Click to Enlarge

There are twelve modules in total: 2 LED modules, an LED bar, on OLED display, a button, a joystick, a buzzer, an ultrasonic sensor, a servo, a potentiometer, a light sensor, and a sound sensors. The kit includes two detailed user manuals: one in good English, one in Chinese.

Click to Enlarge

The first part explains the features and interface for each module with a Wiki link, and latter on you have some easy projects with source code leveraging the NEO hub and some of the modules.

Click to Enlarge

You can also access the documentation online.

FriendlyELEC boards may be slightly more expensive than Shenzhen Xunlong’s Orange Pi boards, but documentation appears to be clearly a step or two ahead, and they have an ecosystem of modules that’s currently lacking on Orange Pi boards.

Some price info about the kit I’ve received:

  • NanoPi Neo 2 board – $14.99
  • Heatsink set – $2.97
  • NanoHat PCM5102A – $9.99
  • NEO Hub – $12.99 (Not needed if you buy Bakebit Starter Kit)
  • BakeBit Starter Kit – $29.99

You’ll need to add shipping, but it’s normally only a few dollars extra for registered airmail. You’ll find additional accessories by scrolling down on NanoPi Neo 2 page on FriendlyARM store. The next step will be to install an operating system, which will be FriendlyELEC’s Ubuntu Core + Qt image, or Armbian nightly build, in order to do some basic tests and run benchmarks like I did for NanoPi NEO, and following up on that I plan to write an extra post reporting on my experience playing with NanoHat PCM5102A and Bakebit Starter Kit.

Linux 4.10 Release – Main Changes, ARM & MIPS Architectures

February 20th, 2017 3 comments

Linus Torvalds has just released Linux 4.10:

So there it is, the final 4.10 release. It’s been quiet since rc8, but we did end up fixing several small issues, so the extra week was all good.

On the whole, 4.10 didn’t end up as small as it initially looked. After the huge release that was 4.9, I expected things to be pretty quiet, but it ended up very much a fairly average release by modern kernel standards. So we have about 13,000 commits (not counting merges – that would be another 1200+ commits if you count those). The work is all over, obviously – the shortlog below is just the changes in the last week, since rc8.

Go out and verify that it’s all good, and I’ll obviously start pulling stuff for 4.11 on Monday. Linus

Linux 4.9 added Greybus staging support, improved security thanks to virtually mapped kernel stacks, and memory protection keys, included various file systems improvements, and many more changes.

Some newsworthy changes for Linux 4.10 include:

  • Virtual GPU support – Intel GVT-g for KVM (KVMGT) is a full GPU virtualization solution with mediated pass-through, starting from 4th generation Intel Core processors with Intel Graphics. Unlike direct pass-through alternatives, the mediated device framework allows KVMGT to offer a complete virtualized GPU with full GPU features to each one of the virtualized guests, with part of performance critical resources directly assigned, while still having performance close to native.
  • New ‘perf c2c’ tool, for cacheline contention analysis – perf c2c (for “cache to cache”) is a new tool designed to analyse and track down performance problems caused by false sharing on NUMA systems. The tool is based on x86’s load latency and precise store facility events provided by Intel CPUs. Visit C2C – False Sharing Detection in Linux Perf for more details about the tool.
  • Improved writeback management – Linux 4.10 release adds a mechanism that throttles back buffered writeback, which makes more difficult for heavy writers to monopolize the I/O requests queue, and thus provides a smoother experience in Linux desktops and shells than what people was used to. The algorithm for when to throttle can monitor the latencies of requests, and shrinks or grows the request queue depth accordingly, which means that it’s auto-tunable, and generally, a user would not have to touch the settings. Read Toward less-annoying background writeback for more details about this improvement.
  • FAILFAST support –  This release also adds “failfast” support. RAID disk with failed IOs are marked as broken quickly, and avoided in the future, which can improve latency.
  • Faster Initial WiFi Connection – Linux 4.10 adds support for using drivers with Fast Initial Link Setup as defined in IEEE 802.11ai. It enables a wireless LAN client to achieve a secure link setup within 100ms. This release covers only the FILS authentication/association functionality from IEEE 802.11ai, i.e., the other changes like scanning optimizations are not included.

Some notable ARM architecture improvements and new features:

  • Allwinner:
    • Allwinner A23 – Audio codec driver
    • Allwinner A31/A31s – Display Driver (first pipeline), audio codec support
    • Allwinner A64 – clock driver
    • Allwinner A80 – External SDIO WiFi
    • Allwinner H3 – Audio codec driver, SPI
    • New boards support: NextThingCo CHIP Pro, Pine A64, NanoPi M1
  • Rockchip:
    • Initial support for Rockchip PX5 & PX3 automotive platforms
    • Added Rockchip RK1108 evaluation board
    • Added support for Rikomagic MK808 Android TV stick based on Rockchip RK3066
    • Update Rockchip PCI driver to support for max-link-speed
    • Rockchip rk3399,rk3066 PLL clock optimizations
  • Amlogic
    • Support for the pre-release “SCPI” firmware protocol shipped by Amlogic in their GXBB SoC
    • Initial support for Amlogic S905D, and S912 (GXM) SoCs
    • Added support for Nexbox A1 and A95X Android TV boxes
    • Cleanup for the Amlogic Meson PWM driver
    • New Amlogic Meson Graphic Controller GXBB (S905)/GXL (S905X/S905D)/GXM (S912) SoCs (meson)
    • Resets for 2nd USB PHY
    • Initial support for the SD/eMMC controller in the Amlogic S905/GX* family of SoCs
    • Updated DTS to enable support for USB, I2C, SPI, maibox/MHU, PWM, ethernet MAC & PHY, secure monitor, IR, and watchdog.
  • Samsung
    • Device Tree for Samsung Exynos5433 mobile phone platform, including an (almost) fully supported phone reference board
    • Added support for TOPEET itop/elite board based on exynos4412
    • DeviceTree  updates:
      • Add Performance Monitor Unit to Exynos7.
      • Add MFC, JPEG and Gscaler to Exynos5433 based TM2 board.
      • Cleanups and fixes for recently added TM2 and TM2E boards.
      • Enable ADC on Odroid boards
      • Remove unused Exynos4415 DTSI
  • Qualcomm
    • Add support for Qualcomm MSM8992 (Snapdragon 808) and MSM8994 (Snapdragon 810) mobile phone SoCs
    • Added support for Huawei Nexus 6P (Angler) and LG Nexus 5X (Bullhead) smartphones
    • Support for Qualcomm MDM9615 LTE baseband
    • Support for WP8548 MangOH Open Hardware platform for IOT, based on Qualcomm MDM9615
    • Other device tree changes:
      • Added SDHC xo clk and 1.8V DDR support
      • Add EBI2 support to MSM8660
      • Add SMSC ethernet support to APQ8060
      • Add support for display, pstore, iommu, and hdmi to APQ8064
      • Add SDHCI node to MSM8974 Hammerhead
      • Add Hexagon SMD/PIL nodes
      • Add DB820c PMIC pins
      • Fixup APQ8016 voltage ranges
      • Add various MSM8996 nodes to support SMD/SMEM/SMP2P
  • Mediatek
    • Added clock for Mediatek MT2701 SoCs
    • New Mediatek drivers: mtk-mdp and mtk-vcodec (VP8/VP9/H.264) for MT8173
    • Updated the Mediatek IOMMU driver to use the new struct device->iommu_fwspec member
  • Other new ARM hardware platforms and SoCs:
    • Hisilicon – Hip07 server platform and D05 board
    • NXP – LS1046A Communication processor, i.MX 6ULL SoC, UDOO Neo board, Boundary Devices Nitrogen6_SOM2 (i.MX6), Engicam i.CoreM6, Grinn i.MX6UL liteSOM/liteBoard,  Toradex Colibri iMX6 module
    • Nvidia – Early support for the Nvidia Tegra Tegra186 SoC, NVIDIA P2771 board, and NVIDIA P3310 processor module
    • Marvell – Globalscale Marvell ESPRESSOBin community board based on Armada 3700, Turris Omnia open source hardware router based on Armada 385
    • Renesas “R-Car Starter Kit Pro” (M3ULCB) low-cost automotive board, Renesas RZ/G (r8a7743 and r8a7745) application processors
    • Oxford semiconductor (now Broadcom) OX820 SoC for NAS devices, Cloud Engines PogoPlug v3 based on OX820
    • Broadcom – Various wireless devices: Netgear R8500 router, Tenda AC9 router, TP-LINK Archer C9 V1, Luxul XAP-1510 Access point
    • STMicro  – stm32f746 Cortex-M7 based microcontroller
    • Texas Instruments – DRA71x automotive processors, AM571x-IDK industrial board based on TI AM5718
    • Altera – Macnica Sodia development platform for Altera socfpga (Cyclone V)
    • Xilinx – MicroZed board based on Xilinx Zynq FPGA platforms

That’s a long list of changes and new boards and devices… Linux 4.10 only brings few MIPS changes however:

  • KVM fixes: fix host kernel crashes when receiving a signal with 64-bit userspace,  flush instruction cache on all vcpus after generating entry code (both for stable)
  • uprobes: Fix uprobes on MIPS, allow for a cache flush after ixol breakpoint creation
  • RTC updates:  Remove obsolete code and probe the jz4740-rtc driver from devicetree for jz4740, qi_lb60
  • microblaze/irqchip: Moved intc driver to irqchip. The Xilinx AXI Interrupt Controller IP block is used by the MIPS based xilfpga platform and a few PowerPC based platforms.
  • crypto: poly1305 – Use unaligned access where required, which speeds up performance on small MIPS routers.
  • MIPS: Wire up new pkey_{mprotect,alloc,free} syscalls

You can also read Linux 4.10 changelog with comments only, generated using git log v4.9..v4.10 --stat, in order to get a full list of changes. Alternatively, you could also read Linux 4.9 changelog on kernelnewbies.org.

How to use Sonoff POW with ESPurna Firmware and Domoticz Home Automation System

January 21st, 2017 12 comments

Sonoff POW is an ESP8266 based wireless switch with a power meter that comes pre-loaded with a closed-source firmware that works with eWelink app for Android or iOS by default. But we’ve also seen Sonoff POW, and other Sonoff wireless switches from the same family, can be flash with open source firmware supporting MQTT (Message Queuing Telemetry Transport) lightweight messaging protocol such as ESPurna, and I initially sent data from Sonoff POW to ThingSpeak via an MQTT broker (mosquitto) to draw some pretty charts. I did that with the switch connected to a lightbulb, but I’ve since installed Sonoff POW in my office to measure the room’s power consumption minus the ceiling light and aircon as shown below.

Wall Mounted Sonoff POW WiFi Switch – Click to Enlarge

Sonoff cable mechanism is really a pain for hard copper wires, as they are hard to push inside the mechanism, and something come out. I finally managed by it took longer than expected to install. I had to cut the mains cable, and rewire the gang box too. The good thing is that I did not need to drill a hole in my wall, as the device is very light.

I could see the power value updated in ESPurna web interface, depending on the load on my computer, and whether I turned on or off other devices. That’s all good, but instead of using ThingSpeak, whose open source implementation is not updated, I decided to try Domoticz, and already wrote a short guide showing how install Domoticz in NanoPi NEO ARM Linux development board. I had not gone through the setup yet, as I had to study a little more, and upgrade Sonoff POW firmware first. I also planned to use vThings CO2 monitor with Domoticz, but canceled since it can’t be configured remotely, and a USB connection is needed.

ESPurna OTA Firmware Update

So I’ll focus only on Sonoff POW in this post, and first we need to update the firmware since Domoticz support is only recent. I’ll assume you have already followed the post entitled How to Build and Flash ESPurna Open Source Firmware to Sonoff POW Wireless Switch.

First we need to update platformio and ESP8266 development platform to the latest version otherwise we’ll get some build issues:

I updated the source code with git pull, but for whatever reasons the build failed, even after cleaning the code. So I did what any developer with enough experience would do in that case: start with a fresh check out ;), and rebuild the OTA firmware from there:

In order to update the firmware over the network, you’ll need to change sonoff-pow-debug-ota section in platformio.ini with your own IP address (upload_port) and password (in upload_flags) used in ESPurna web interface:

Once it’s done, you can upgrade the firmware, and then the file system as follows:

The Sonoff POW will reboot, and cut the power for about 2 seconds after both updates. My Sonoff POW is controlling my computer power, but that’s OK since I’m behind a UPS. Now I can access the web interface, and one of the improvement is that you’re being asked to setup a new password right after the update.

Click to Enlarge

I was then redirected to the Status page showing power, voltage (a bit low?), current, and power factor.

Click to Enlarge

I then jumped to MQTT menu to set the IP address to my NanoPi NEO board, and clicked Update.

Click to Enlarge

There’s a new DOMOTICZ menu which we’ll check out a little later.

Installing and Configuring MQTT in Domoticz

ESPurna communicates with Domoticz via MQTT, so the first task was to follow and adapt Domoticz MQTT wiki.

First login to your Domoticz server (NanoPi NEO) and access a terminal window to update the packages, install npm, node.js, Node RED, and mosquitto:

We then need to go to the Hardware page in Domoticz and configure a new “MQTT Client Gateway with LAN Interface” as shown in the screenshot below.

Click to Enlarge

We can test whether it works or not by creating a new Dummy device in the same Hardware section

Then click on Create Virtual Sensors, to add a new Temperature sensor which we’ll call Fictive Temp.

Now go to the list of Devices (Setup->Devices) to check the idx value (1 in our case), and a publish a MQTT message to update the temperature value of our virtual sensor:

The temperature switch from 0 to 25°C. Our installation is working. Great!

Using Sonoff POW with Domoticz

In theory, we should be able to get two type of data for Sonoff POW: relay status and power levels. However, after looking at ESPurna source code, domoticz.ino only seems to handle the relay status that can be changed from Domoticz web interface, but the power values are only send in pow.ino to the MQTT server, with data not directly compatible with Domoticz. Maybe I missed something as Tinkerman – ESPurna developer – can use Sonoff SC to send temperature data to Domoticz. Alternatively, it might be possible to convert that data somehow with Node RED, but that’s something I’ll try later. So today, I’ll only try to control the switch from Domoticz.

To do so, I created another Dummy device called Sonoff POW Switch, and from there, another Virtual Sensor of Switch type.

Click to Enlarge

Click to Enlarge

We’ve already configured MQTT in ESPurna web interface, and from the screenshot above,we can see that “Sonoff POW Switch” Idx is 3, a value we need to update in the DOMOTICZ section of ESPurna web interface.

Now I can go Domoticz interface in my phone, and not my computer since my office’s Ethernet switch will be turned off, click on the Switch tab, and turn on and off Sonoff POW by clicking on the lightbulb as shown below.

Click to Enlarge

It works fine, however note that the initial switch status was wrong (off instead on on), despite the switch sending regular updates to the MQTT server.

NanoPi NEO Power Adjustments and Installation

Normally, at this stage, it should be easy simply install NanoPi NEO outside the office close to my router in the living room. But I’ve come across a few issues doing so, which I’m going to report.

First I decided to make a very short Ethernet cable to connect NanoPi NEO directly to my router. I have done a couple of Ethernet cables in the past a few meters long, and they all work. I tested my ultra short straight Ethernet cable connections with a multimeter, and the 8 wires were properly connected, however, when I connected NanoPi NEO to the router with that cable it failed to get a link. Maybe there was aonther issue with the cable, so I made another one just as short… Another fail. It turns out very short Ethernet cables may cause issues, which are normally solved by twister pairs, but with such short cables the length of the twisted pairs is also extremely short, maybe 2 to 3 cm which may not be sufficient. So I ended up using a “normal” 1.5 meter cable, not as neat but it works.

The power strip close to my router was full, and since I did not want to add another, I decided to use the spare USB port on my modem router in order to power NanoPi NEO board. A USB 2.0 port can only deliver 2.5W max, so I was clearly looking for problems here. In order to avoid an issues, I made use of h3consumption script to adjust the behavior of CPU cores and disable unused peripherals.

Let’s check NanoPi NEO current settings in a terminal:

h3consumption allows us to change the following settings:

So I decided to disable USB, and use two CPU cores at most in order to limit the board’s power consumption, and avoid random reboots:

The changes were properly applied after a reboot.

I powered the board with my modem router, and could use it without issue. I’ll monitor NanoPi NEO’s uptime to check if this works.

How to Install Domoticz Home Automation System in NanoPi NEO and Other ARM Linux Boards

January 19th, 2017 7 comments

I’ve recently started experimenting with IoT projects, and the first hurdle is to select the hardware and software for your projects are there are simply so many options. For the hardware your first have to choose the communication protocols for your sensors and actuators, and if you are going to go with WiFi, ESP8266 is the obvious solution, used together with your favorite low cost Linux development board such as Raspberry Pi or Orange Pi to run some IoT server software locally or leveraging the cloud. But the most difficult & confusing part for me was to select the server software / cloud services as there are just so many options. I prefer having a local server than something running only in the cloud, as my Internet goes a few hours a month, so I started with a solution combining ThingSpeak with MQTT gathering data from Sonoff power switches running ESPurna firmware and vThings CO2 monitor. This works OK, but while ThingSpeak.com cloud service is continuously update, its open source version has not been updated since mid 2015. Among the many service and software framework available, one seems to have come more often than other, is supported by vThings air monitoring platforms, and recently been added to ESPurna. I’m talking about Domoticz described as:

a Home Automation system that lets you monitor and configure various device like lights, switches, various sensors/meters like temperature, rain, wind, UV, Electra, gas, water and much more. Notifications/Alerts can be sent to any mobile device.

The system can run on Linux, Mac OS, Windows on x86 platform, but also on 32-bit and 64-bit ARM Linux boards such as Raspberry Pi and Cubieboard with just 256MB memory recommended, and 200MB free hard disk space. It can also generate charts from the data like the ones below.

Click to Enlarge

On top of that, the forums appear to be very active, and the last stable version was released in November 2016, and the last beta release yesterday according the download page.

I’m going to take it slow, so today I’ve just tried to install it on NanoPi NEO since it’s compact and runs Linux. However, it does not appear to be officially supported by Domoticz, so we’ll have to see whether it’s possible to install it on the board.

Domoticz is not a Linux distributions but a framework, so first we need to install a Linux distributions on the board, and the obvious choice for NanoPi NEO is to use the latest Armbian release either Debian Jessie or Ubuntu Xenial.

I downloaded Debian, extracted the image, and flashed it to a micro SD card on a Ubuntu computer:

Replace /dev/sdX with your own SD card device, which you can find with lsblk command.  If you are a Windows user, you can flash the firmware like you’d do for a Raspberry Pi using Win32DiskImager after uncompress Armbian firmware.

Now we can insert the micro SD card into the board, and connect the power to start the board. If you have not connected the serial console to your board, please be patient for the first boot as the system may take around 3 to 4 minutes to boot before you can login to it, as it expands the micro SD card to full capacity, and creates a 128MB emergency SWAP file.

Once it’s done we can login through the serial console or SSH using root / 1234 credentials. The first time, you’ll be asked to go through the first setup, changing the root password, and creating a new user with sudo privileges.

So now that we have Linux running on the board, and after login again as the new user, we can follow the instructions for Raspberry Pi board and other ARM boards to install domoticz with a single command line that works on systems running Debian/Ubuntu:

After a minute or two, as the system update the packages, and download domoticz, the setup wizard should start.

At some points we’ll need a fixed IP address, either by configuring Linux with static IP, or setting a permanent IP linked to the board MAC address in the router. The second option is usually my favorite option. Nevertheless, let’s click on OK to proceed.

You’ll be asked whether you want to enabled HTTP or/and HTTPS access. I selected both for now, but it’s probably a good idea to only select HTTPS for better security.Next is the HTTP port number set to 8080 by default, followed by the HTTPS port number to 443 by default (no screenshot), and finally the installation folder which defaults to ~/domoticz. You should now have reached the Installation Complete! window, and you can click Ok to exit the installation wizard.
Wow.. That was easy, and no errors. But does it work? Let’s access https://192.168.0.110:443 from a web browser.

We have a “Your Connection is not secure” error, but it’s expected as Domoticz simply generated a self-certificate, you can safely add exception to your browser to avoid this issue next time. Your data will still be encrypted, but if you plan to access your Domoticz setup from the Internet, you should probably install an other certificate using Let’s Encrypt certificate authority for example.
Once we have added an exception to the web browser we can indeed access Domoticz web interface, so the installation worked, but it will only show “No favorite devices defined…” Again that’s normal, because we need to configure it for example by clicking on the Hardware link.

Adding Hardware to Domoticz – Click to Enlarge

This will allow you to configure the system with MQTT, local I2C sensors, all sort of gateways, and even Kodi Media Center.  I’m pretty sure all devices working over the network or USB should work, but things like “Local I2C Sensors” which may be connected directly to the board may or may not work. Anyway, that looks promising, but I’ll stop here for today, as I have a lot more to study before going further, including upgrading Sonoff firmware, and configuring vThings CO2 monitor for Domoticz.