NE W !
Raspberry Pi 3 B+
Full details on the all-powerful Pi and essential starter project!
The best of arch Arch labs manjaro Arch 32 & more
The #1 open source mag
robots! Learn to design, build and code the most amazing Pi-powered and AI-controlled machines
Projects! get started with machine learning build a file and ad-block server
Oluseun Onigbinde Nigerian open data activist network storage
Get the best open source file-sharing solutions
Distribute your workloads and get all your PCs working
Create A custom wordpress theme
Subscribe & save! On digital and print, see p24
wh0 we are This issue we asked our experts: We’re building Raspberry Pi robots this issue, what task would your Pibot help you complete… or help make you unemployed? Jonni Bidwell I’d like a robot to write some questions for the recently reprised Answers section. Come to think of it, I’d like another robot to answer those questions too, because I have enough Linux problems of my own. And you know what? I rather miss my DiddyBorg robot. How come I don’t get fun hardware to play with anymore?
Sean D Conway A husbandry pibot that could feed the dog. Sounds simple enough in theory. The pibot would have to be a doppelganger of me for it to work, mind. The animal has imprinted on me as her only source of food and refuses to acknowledge anyone else. That’s loyalty for you.
Matthew Hanson I’ve been eyeing up one of those robot vacuum cleaners with envy. Anything that can help clean up after my house full of pets and give me more time to play with my new Raspberry Pi and gaming on Linux sounds like a solid investment to me!
Les Pounder I see that a US burger joint has installed the first full-time burger-flipping robot. Skynet is clever. It wants to fatten us up with tasty burgers so that we’re easier to hunt due to our lack of exercise. Clever A.I. from Skynet!
Shashank Sharma I doubt if the PiBot will be able to procrastinate as well as I do, having mastered the art over several years, so I’m not worried about anything. Although they’ve now automated the drawing of contracts and agreements, threatening my day job. I certainly don’t see any bot writing for this wonderful magazine.
It’s the Pi-mageddon! If you’re wondering if things are looking a little different around here, don’t worry, you’re not going mad. After 152 issues and almost 12 years (October 2006) Linux Format Towers has finally been able to afford a fresh lick of paint, but don’t panic! All your favourite sections remain intact and as they were. They’re hopefully just easier to read for everyone! And the good news keeps on coming, because we have a double whammy of Raspberry Pi content this issue. First there’s the lowdown on the new Raspberry Pi 3 B+. Then there’s our lead feature on building, much like the Pi itself, all-conquering Pi robots! It feels like the Raspberry Pi Foundation has got into the swing of releasing these Pi boards, which is great. We now have a major board release and then an enhance update, so this latest B+ offers a minor processor speed boost, a significant drop in operating temperatures and a large boost in its networking prowess. Get all the details and a starter tutorial beginning on page 52! No matter if you have a Raspberry Pi old or new, have one gathering dust or are simply looking for something fun to do this weekend, then have we got something for you… a complete guide to building and coding robots! We’re going to look at the parts, the code and how you can put a kit together to make a fun, affordable Pibot. Don’t worry, we’ve still got plenty of pages dedicated to non-Pi based delicacies. We look at the new graphics-packing AMD Radeon 2400G processor, which is ideal for budget gaming or home theatre systems. Roundup reviews five NAS distros for storing your files with. We explore machine learning through code and projects, and turn our hand to creating our own WordPress themes. Elsewhere, we look at how open source is helping Nigeria transform government spending through accountability. That’s before we (takes a deep breath) delve into cgroups, build a cloud back-up system, finish our MicroPython tutorials and set up distributed computing loads. Is there anything open source can’t do? Enjoy the issue!
Neil Mohr Editor firstname.lastname@example.org
May 2018 LXF236 3
This ISSUE: Vulkan update Sailfish OS 3 Linux on Chrome OS Collabora Online 3.0 KDE Slimbook II Signal Foundation
Major Vulkan graphics update makes a splash The Vulkan ecosystem goes from strength to strength, as the latest update delivers a number of new features. he Khronos Group (www.khronos.org), the open consortium made up of some of the biggest names in hardware and software, recently announced the release of Vulkan 1.1, the latest version of the crossplatform open source graphics/compute API. This is the first major update to the API since Vulkan 1.0 in 2016, and it coincided with the Games Developers’ Conference (GDC 18) held in March. It also follows the news that Vulkan is now available on Apple’s iOS and macOS platforms. While Apple is still to officially support Vulkan, this news, along with the release of Vulkan 1.1, demonstrates how successful the API is becoming. Along with Apple’s platforms it’s now also available on Linux, Android and Windows. While this is the first major update in two years, Vulkan 1.1 focuses on tidying up existing functionality, especially those added in Vulkan 1.0.x point releases, rather than adding a long list of brand new features. Many of these existing features, in the form of extensions, are now being promoted to core Vulkan 1.1, and these include multi-view, device groups, cross-API and advanced compute functionality. One of the most exciting extensions that’s now part of core Vulkan 1.1 is support for multiple graphics cards in a single system, working with Nvidia’s SLI and AMD’s CrossFire technology for even more impressive graphics performance. While this feature has a particularly niche appeal, it makes Vulkan a more appealing API for games developers building graphically intensive AAA games.
6 LXF236 May 2018
As for new functionality, protected content and sub-group operations have now been added to Vulkan 1.1. The latter enables highly efficient sharing and manipulation of data between multiple tasks running in parallel on a graphics card. This could bring a major boost to performance, as well as being a welcome addition for compute scenarios. Support for protected content now restricts playback, displaying and copying protected video content. This will be a feature that’s welcomed more by people creating digital content than by most users, but it’s a fact of life that you need to get the content creators – and copyright holders – on board to ensure the success of the API.
Vulkan 1.1 sees the graphics API get even more competitive.
“now part of core Vulkan 1.1 is support for multiple graphics cards in a single system” Alongside the release of Vulkan 1.1, a new SPIR-V 1.3 specification has been released, which expands on the Vulkan shader, and according to the press release by the Khronos Group to announce the release (which can be read at www.khronos.org/news/press/ khronos-group-releases-vulkan-1-1), the SPIR-V tools ecosystem “continues to gain significant momentum with front-end compilers for both GLSL and HLSL”. Explore the SPIRV-Tools project at https:// github.com/KhronosGroup/SPIRV-Tools.
Vulkan 1.1 adds proper support for multiple GPUs at API level
Tell us what you think!
Complete the LXF reader survey now!
Write to us at Linux Format, Future Publishing, Quay House, The Ambury, Bath BA1 1UA or email@example.com. Controversial!
you can do to make Ubuntu your own. Including get Unity back. Spoiler alert: sudo apt install unity . As far as we can fathom, Unity 7 will be available in the repos for 18.04 LTS too, so if you really want you can keep using it until 2023, just don’t expect it to gain any new features, or new apps to integrate with it. Meanwhile, open source being what it is, Unity 8 has been picked up by the community and we look forward to seeing what they do with it. Gnome is different, but it’s also pretty powerful if you’re prepared to overlook certain things. Such as massive titlebars and the lack of minimise/maximise buttons. It’s worth remembering that a lot of people didn’t like Unity when it first appeared. Although a lot of people were glad to see it go, too.
I daresay you won’t be alone in your dislike of Gnome. That’s why LXF231’s main feature revealed all the things
Can I be first to start the controversy? I’ve loaded Linux Ubuntu 17.10 on to a spare hard drive and don’t like what I see! It’s the Unity desktop that separates Ubuntu from other distros. With Gnome in its place it looks and feels like many other distributions to those of us that just do simple things on computers. In the absence of Unity my next preference would be Mint’s Cinnamon desktop. Please would you run an article on how to replace Gnome with Unity 7 on Ubuntu 17.10 and 18.04 LTS (when released). Without this, Ubuntu and myself will be parting company. John Bourne, via email What? People actually like Unity now? Amazing how times change…
In LXF230, Bobby Moss’ article on managing email states that Mozilla Thunderbird requires separately installing of Lightning. Yet Thunderbird now comes with the Lightning add-on preinstalled. There’s more... “Lightning only creates local calendars, so to sync with Google Calendar you need install a provider add-on, too.” No, Lightning supports network calendars without any other add-ons. You can use iCalendar, CalDAV or Sun Java System Calendar servers. It’s not necessary to install an add-on to sync Lightning with Google Calendar. It can be done with CalDAV most reliably. “Unfortunately, at the moment this is only compatible with Thunderbird if it’s the 32-bit incarnation and version 52.0 or earlier.” Why did he make up this nonsense? And then I stopped reading the magazine and left it on the bus for some unsuspecting person to read. Gary Curtin, via email
10 LXF236 May 2018
Got a burning question about open source or the kernel? Whatever your level, email it to firstname.lastname@example.org for a solution and suggestions from the eminent Dr Bidwell. I got news for you? Q Have It’s hard to find a good RSS reader
nowadays. Liferea works, but looks a little dated. It seems like every other client has its own quirks and niggles. There are lots of hosted services, many of which are inferior to the once ever-sopopular, now shuttered Google Reader service. Feedly is popular, but if I’m going to use a hosted service I’d rather it’d be one that I hosted myself. I’ve recently upgraded my Nextcloud instance to 13.0 and thought I’d try its News app. It works very well, I can use the Android app to check feeds on my phone, and I can use Feedreader on my desktop. However, I’m seeing this strange error in the News app itself: Non UTF-8 charset for MySQL/MariaDB database detected! Learn how to convert
your database to utf8mb4 (make a backup beforehand) . The error links to a
StackExchange post with very involved instructions for manually converting SQL tables. This doesn’t seem like a good way of doing things, so I beseech any Nextcloud gurus at LXF Towers for a more helpful solution. Why do I even need this weird character set anyway? Bonnie Archwell
We also like the Nextcloud News app and have seen this error. We followed the instructions in that StackExchange post, but to no avail. The issue at stake is the four-byte UTF8 character set, which encodes emoji. Pictures may be worth a thousand words, but the codepoints representing emoji need only four bytes. If you don’t want to
Traditionalists may prefer to browse software using Synaptic or similar, rather than the Ubuntu Software app.
Open (source) sesame Q
From the Roundup piece in LXF233 I think the article missed a central issue: I would like the password solution to work well on my Android, Windows and Linux desktop platforms. As some of the candidates are use cloud storage, I imagine that multi-platform support is a design goal. Perhaps there are as yet no OSS solutions, but you’ve given me a place to start. Perhaps there’s room here for a follow-up article? Enjoying the read. Colm, by email
14 LXF236 May 2018
You make a good point. I’ve just done a large-scale password reset, which took a Very Long Time. A lot of this was spent finding all the sites where I still had active accounts. Once that list was compiled I spent a lot of time looking for a quality FLOSS password manager and eventually settled on Padlock. You can securely store your data using the Padlock Cloud service, either on its cloud storage or your own. You could also use a homebrew solution such as Duplicity to do arrange your own secure storage.
Jonni Bidwell Attempts to fix your Tuxbased faults.
see them and don’t mind the error then just ignore it. But if you want to see the upside-down face and other expressions in your news feeds then read on. Back up your data first, please. You can use the Next/Owncloud’s builtin occ utility to change the character set setting, and then set your Nextcloud instance to Maintenance mode to update the tables. Before we do this though, we need to make some adjustments to the database. The wider character set needs a larger key prefix, otherwise scary errors will result. So add the following settings to the InnoDB section of your MySQL/Mariadb configuration (on Debian the default server config file is /etc/mysql/mariadb. conf.d/50-server.cnf) innodb_large_prefix=on innodb_file_format=barracuda innodb_file_per_table=true Now restart the SQL server systemctl restart mysqld and invoke occ as follows $ cd /var/www/nextcloud $ sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value=”true” $ sudo -u www-data php occ maintenance:repair
That should be it. If maintenance mode is still active (Nextcloud will tell you this when you try and log in), then normalcy can be restored by replacing the maintenance argument in the last command with maintenance:mode --off
prefer the remix Q II’ve been following the notes on the remix. I’ve managed to install the standard Ubuntu option. This is the default Gnome desktop which is now working fine. Up until now I’ve used the Unity desktop in Ubuntu so this is all new to me. How do I proceed from here? No choice of desktops is offered in the applications list! And I can’t seem to search from the Ubuntu Software application! What I’d like to do with Gnome is to install a Windows chess program (Fritz 8) on Ubuntu 17.10. I installed PlayOnLinux using the terminal. It now
AMD Ryzen 5 2400G Finally, next-gen integrated graphics performance arrives inside a CPU worthy of your main desktop system. Jarred Walton is suitably impressed. fter the tour de force of the Ryzen processor rollout over 2017, many had high hopes for the future Ryzen APUs (that’s with integrated graphics) and finally AMD has released its first models. The eternal problem with integrated graphics is trying to combine a good CPU with a decent GPU while keeping price, power, and other aspects in check. This is the best APU AMD has ever released, and it effectively kills off the Ryzen 5 1500X and lower CPUs. On the CPU side of things, the first batch of Ryzen processors all used the same dual CCX (CPU Complex) design, with Threadripper going so far as to include two of those chips on a single package. The Ryzen CCX consists of four CPU cores, each with 512K of L2 cache, and a shared 8MB L3 cache. On the previous quad-core implementations (Ryzen 3 1200/1300X and Ryzen 5 1400/1500X), each CCX ends up with two disabled cores, and depending on the product, half of the L3 cache may also be disabled. For the Ryzen APUs, there’s only a single CCX, and a maximum of 4MB of L3 cache. That simplifies some aspects of multi-core operation – there are no cross-CCX latencies to worry about – but the reduced L3 cache size may at times be a factor. In place of the second CCX, AMD has included a nice little graphics solution. The Ryzen 5 2400G calls it Vega 11, which is a Vega core with 11 enabled CUs (Compute
Socket: AM4 Type: 64-bit Process: 14nm Cores: Four Threads: Eight Clock: 3.6GHz (3.9GHz turbo) Cache: 384KB L1, 2MB L2, 4MB L3 Mem: DDR4, two channels, ECC support TDP: 65W PCIe 3.0: 8x lanes GPU: Radeon RX Vega 11 GPU Clock: 1,250MHz
Gaming benchmarks Tomb Raider (2013) Frames
Default no AA
Medium no AA
Units), each of which includes 64 streaming processors (aka GPU cores). Eleven seems like an odd number, so there might be another CU disabled, but AMD didn’t comment on this. As with most integrated solutions there’s no dedicated graphics memory, and that affects performance. But the Vega 11 brings along all the other new Vega architecture features, such as rapid-packed math (aka FP16), the Draw Stream Binning Rasterizer, reworked geometry engine, and more. Interestingly, Intel is getting around this in its future Core + Vega M chips by opting to include 4GB of HBM2, which should prove substantially faster, but also far more expensive – and it’s only for mobile solutions.
Unlocked and loaded Like all of AMD’s Ryzen processors, the Ryzen 5 2400G comes fully unlocked – on both the CPU and GPU sides of the fence. Not to spoil the performance results, but at stock the 2400G basically sounds the death knell for the existing Ryzen 5 1500X. It’s officially priced lower, it has slightly higher clockspeeds, but half the L3 cache, 12 fewer PCIe lanes and it hits a similar overclocking limit. Both chips run in the same AM4 socket, so there’s now almost no reason to buy a four-core Ryzen 5 solution or the Ryzen 3 CPUs either, for that matter. The test system supplied by AMD is extremely compact and showcases the type of super-small miniITX solution that would be ideal for a home theatre box. The entire system idles at just 21W, while under full load it peaks at about 90W. You won’t need any crazy cooling setup to keep things running within an acceptable temperature range. What do you get from 704 streaming processors clocked at 1,250MHz, sharing system RAM with a four-
*all games tested at 1,920x1,080 resolution
Geekbench Single core
18 LXF236 May 2018
The boxed retail version of the AMD Ryzen 5 2400G ships with a low-profile, low-noise Wraith Stealth cooler.
roundup NAStons distributions We compare of stuff so you don’t have to!
Roundup EasyNAS FreeNAS NAS4Free OpenMediaVault Rockstor
Shashank Sharma By day a New Delhi trial lawyer, by night an open source vigilante!
Looking for a way to create a central storage repository? Who isn’t these days! Shashank Sharma has some NAS solutions worth considering.
how we tested… Unlike desktop distributions that require extensive RAM and graphic cards for optimum performance, a NAS box requires little more than ample storage space. The off-theshelf solutions sold by manufacturers typically feature a two- or four-disk setup and we’ve got the same for our distributions, with 4GB RAM. The distributions are all fairly simple to install, but it’s the post-install configuration that’s the real test, coupled with the ability to provide additional functionality through addons. Most NAS distributions provide an easyto-navigate web-based administration interface, but we still want it to be intuitive. Because a NAS system is primarily concerned with data, we’ll keep an eye out for associated capabilities such as data encryption. Since the idea is to share disks across different devices, we want our NAS solution to support multiple protocols such as NFS and AFP. Owing to their range of configuration options, clear documentation is important too.
26 LXF236 May 2018
typical home user with access to a terabyte or two of disk space will have no use for a network attached storage (NAS) setup. While using multiple storage disks is an easy-enough solution for single machine setups, it’s not practical for a household or an office where you have several devices. With a NAS solution, users can easily share storage space across users and devices. More often than not, a typical NAS setup comprises a specific combination of hardware and software that is designed to provide file sharing through services such as NFS and SMB.
Many manufacturers offer a variety of NAS boxes, but thanks to distributions such as the ones featured in this Roundup, it’s possible to configure your own NAS system. Configuring NAS, however, is far more complex a process than merely installing a distribution. Unlike desktop distributions, these don’t offer a live environment for you to fiddle with before deciding on the one that suits. If you’ve never used a NAS before, it can be quite daunting to decide on a distribution. Hopefully, this Roundup will, if not make the final decision for you, help you realise some of the key factors to consider before selecting a distribution.
NAS distributions roundup
Volume management Will they work with your disk drives? iles stored in a central location and easily accessible by multiple machines is the primary function of a NAS. Because most of the distributions in our list take over an entire installation disk, it’s best if you start with at least a two-disk NAS setup. While it’s possible to carve your existing disk into different partitions, then installing NAS to one and using the spare partitions for storage, this isn’t recommended. What’s more, some distributions, such as FreeNAS and Rockstor, only work with whole drives and not partitions. When choosing the installation target for your NAS distribution, remember that the NAS distributions provide a webbased administrative interface that can be accessed from any machine on the network, and thus don’t feature a graphical environment of their own. This means that these distributions don’t require too much disk space for themselves, so it makes little sense to surrender a large capacity disk for installation. Almost all the distributions on our list can be just as easily installed onto a USB drive, which leaves you free to use the disks only for installation. You can also install these distributions onto a SSD drive if you have one handy, but they’ll work just fine even with your regular disk drives. If you’ve never needed NAS before, you can also install these distributions onto a VirtualBox and add virtual disks for storage as required. FreeNAS, like many other available NAS solutions, is designed around the ZFS filesystem. This provides many of the advanced features typical for NAS, such as data integrity, creating
OpenMediaVault, like most distributions, also offers SMART monitoring for the attached disks and enables you to schedule tests.
snapshots, deduplication (the ability to remove duplicate copies of data), and so on. NAS4Free and Rockstor also support all the same partitions as FreeNAS. Thanks to its copy-on-write and snapshot features, Btrfs is considered to be a strong competitor to the ZFS filesystem and is the default on EasyNAS and Rockstor. In addition to support for EXT3/4, XFS, and JFS filesystem, with OpenMediaVault, you also get the option to create quotas for each configured volume and set up access control list (ACL). The filesystem you choose also depends on the NAS features you wish to exploit. For instance, many ZFS features, such as deduplication, are quite RAM intensive.
VERDICT EasyNAS 9/10 OpenMediaVault 9/10 FreeNAS 9/10 Rockstor 9/10 NAS4Free 9/10 The distributions all support a variety of file systems and associated features.
Sharing files It’s the bread and butter of NAS. centralised data storage system will be of little use if you can’t access the data from across different devices. All of the distributions support the popular network protocols such as Samba/CIFS, Apple Filing Protocol (AFP), Network File System (NFS) and Secure File Transport Protocol (SFTP). Although little official documentation is offered on the subject, it’s also possible to configure Samba/SSH to enable remote access to your data over the internet. You can also configure WebDAV shares on FreeNAS, enabling authenticated users to browse the contents of the specified volume or directory from the comfort of a web browser. Both FreeNAS and Rockstor support creating shares. The type of share you create will depend on various factors, such as your security requirement and the operating system being used by the machines on the network. For each share, you must specify user specific permissions to ensure safety of the data. Regardless of the protocol you choose to use, we’d recommend referring to the official FreeNAS documentation for an introduction to the different protocols, best practices, and useful tips and tricks. In addition to the services described above, you can also use rsync with FreeNAS, OpenMediaVault and Rockstor. However, the process for configuring each one is different for every distribution.
The FreeNAS wizard can be used to configure various aspects of your NAS installation, such as shares.
For instance, on Rockstor, a Pool is a set of disk drives put together and represented as a single volume. Space carved out of a Pool is identified as a share, and each share on Rockstor behaves like directories on a desktop distribution.
VERDICT EasyNAS 8/10 OpenMediaVault 9/10 FreeNAS 9/10 Rockstor 9/10 NAS4Free 9/10 Much like FreeNAS, Rockstor also makes it possible for you to define user/ share specific access permissions.
May 2018 LXF236 27
Feature Raspberry Pi Robots
Supervillain Jonni Bidwell is constructing an army of Pi robots. Sneak into his lair and steal his techniques!
obotics needn’t be about building intimidating humanoid automatons. We can build machines that can perform all kinds of other useful, instructive or fun functions. Even better, you can power them with Linux. You won’t need costly electronics to build these devices. A Raspberry Pi will do just fine. It doesn’t need to be any more advanced than constructing a LEGO set, either. There are plenty of off-the-shelf kits suitable for any budding electronics enthusiast. We’ll reveal how to put together your own roving robot, and show you a couple of neat Python programs to get you started. And if you’re feeling more adventurous, then why not build your own robotic helpers from scratch? All the components are easy to get hold of, thanks to the growing maker community. If you want to take it to extremes, then 3D print your own custom parts and add some pseudo-sentience to your creation with some machine-learning voodoo. Or build your own robotic pet and have it follow you around like a puppy. The possibilities are endless. So power up that Pi, get yourself some components and let’s start hacking some robots together.
32 LXF236 May 2018
Raspberry Pi Robots Feature
A Pi bot’s potential We’re not talking about engineering an Arnie-shaped T-101: Pi Edition, but don’t let us stop you from doing so. he Raspberry Pi was launched six years ago, and since then has grown into something amazing. We’ve seen four different major versions (Zero, 1, 2 and 3), and a couple of minor versions, most recently the powerful 3 B+ which launched in March 2018. Pi retailer ModMyPi.com was there at the beginning, and was good enough to lend us some treats for this feature. Founder Jacob Marsh offers his take on the Pi’s remarkable success. “I didn’t realise that the Raspberry Pi would grow to what it is now, I don’t think even the Pi Foundation did. ModMyPi was conceived in a university bedroom. Now we have a global e-shop with more than 2,000 product lines, a £3 million turnover, seven fulltime staff, and a 300 square metre warehouse that we’re rapidly outgrowing. Long may it continue!” What makes the Pi so special, and what’s contributing to Jacob’s real-estate shortage, is the limitless scope for expansion. A tiny general-purpose computer that can be connected to sensors, motors or your central heating system, coupled with the collective imaginations of the open source community, has led to all kinds of wonderful physical computing applications.
Robot Platforms We’ll concentrate on bread-and-butter software, namely Raspbian and Python, but there are a number of interesting platforms than can be run on top of, alongside or instead of these. One such platform is Robot OS (ROS, see www.ros.org) which isn’t really an operating system at all, but more of a middleware. ROS is a BSD-licensed project with thousands of contributors worldwide. It can be built from source for Raspbian, but since it provides packages for the Pi edition of Ubuntu MATE, that’s the preferred base. ROS aims to be truly general-purpose robot software that works on many platforms and encourages collaboration. We’re also impressed with the work of Dexter Industries (www.dexterindustries.com), which makes the GoPiGo robot car. The GoPiGo is a kit designed for the classroom, and is programmed using Bloxter, a browser-based language similar to Scratch. Within the Blockly interface it’s possible for more advanced students to program in Python, too. Fans of LEGO will enjoy Dexter’s BrickPi, which connects the Raspberry Pi with the popular LEGO Mindstorms kit. If that weren’t enough, it also makes the Grove Pi, a kit of 12 plug ‘n’ play sensors for exploring IoT programs.
And one of the most wonderful is robotics. Nevermind our fanciful cover illustration. Any situation where a computer-controlled device performs a mechanical function is a robot at heart. Robotic vehicles are particularly popular with Pi hobbyists just now. These might at first appear to be little more than the radio-controlled cars, but they can do much more than scoot around the kitchen table. Having a tiny Linux machine inside enables all kind of tinkering. With a few easy-to-connect components, some open source libraries and just a little bit of Python programming to connect everything together, you’re limited only by your imagination. Well, small caveat, you may have to solder a few wires. This is daunting at first, but there are plenty of guides on the internet. Check out
The Dexter GoPiGo robot is a popular choice for education, and is almost certainly not bent on world domination.
keeping your robot occupied “A Pi-powered robot might take pictures, zoom around your house quoting Shakespeare or even take to the skies” the Pi Foundation’s director of education Carrie Anne Philbin giving an excellent demonstration at https://youtu.be/P5L4Gl6Q4Xo. A Pi robot can run the same Raspbian Linux we all know and love. It can connect to wireless networks, so you can SSH in and perform diagnostics while it’s on the move. You can even run apt upgrade while it’s driving around. A Pi-powered robot might also take pictures, zoom around your house quoting Shakespeare or even take to the skies to admire the city below. With the aid of the OpenCV library and a little bit of image processing we can give our robot computer vision, so that it can target and follow objects, or even recognise objects or people. So get dig into our guide, and don’t forget to check out www.modmypi.com for inspiration.
May 2018 LXF236 33
Interview Oluseun Onigbinde
Adam Oxford wonders how do you build a successful civil tech initiative in a country where only one in four people go online. Turns out the pioneering co-founder of Nigeria’s BudgIT, Oluseun Onigbinde, found a way… 42 LXF236 May 2018
Feature Machine learning
MACHINE LEARNING Jonni Bidwell challenges you to be anything but agog at the combined forces of neural networks and open source learning
0 1 2 3 4 5
A neural network with two hidden layers. Imagine 784 (28x28) nodes (on the left) that represents each pixel.
6 7 8 9 ost people will have heard of machine learning (ML). If you’ve been anywhere near the internet in that time you’ll almost certainly have been fed data that was combobulated using machine-learning algorithms, and your usage will have fed into training models to advance other such algorithms. In 1958, when the Mark 1 Perceptron (an early neural network for image recognition) was built, pundits declared it “the embryo of an electronic computer that [the Navy] expects will be able to walk, talk, see, write, reproduce itself and be conscious of its existence.” The field has advanced a long way since then, and though we haven’t yet seen conscious machines (or a Skynet-esque robot uprising), there have been some amazing results. ML has contributed to drug discovery,
46 LXF236 May 2018
finding exoplanets and better Netflix recommendations for everyone. Thanks to the availability of huge datasets, advances in hardware such as GPUs and TPUs and the development of tools (especially FOSS ones) that greatly simplify training models, ML is now fairly ubiquitous. Much of the growth has been spurred by that of the industrial-academic complex. Boffins have been studying formal ML techniques from a theoretical standpoint since the 50s (and one finds germs of the field some 200 years earlier). Yet the hardware (or more correctly, the budgets to build the hardware) needed to do anything practical were only available to the likes of IBM or government labs. But now, through new partnerships, innovations and that dragon cloud computing, access has become much more democratised.
Reviews Raspberry Pi 3 B+
Raspberry Pi 3 B+ Les Pounder has found another slice of Pi to tuck into. This one is incrementally better than the last, but will it end his hunger…? in brief The latest in the Raspberry Pi series, this time we see better networking (802.11ac and “Gigabit” via USB 2.0) The processor speed is slightly increased but RAM remains the same as the previous model. The Pi 3+ now comes with PoE via dedicated GPIO pins, but it retains compatibility with the standard 40 pin GPIO.
nother Raspberry Pi! Will this be the fabled Raspberry Pi 4 offering USB3.0, SATA, GTX 1080 GPU, Octa Core CPU and 16GB of RAM? So let’s first address the obvious questions. No, this isn’t the Raspberry Pi 4 and no, it has none of those features. Rather, the Raspberry Pi 3+ is an incremental improvement of the Pi 3 B that gives us a little more power, and much better connectivity. This is not the first B+ board – that was the original B+ released in 2014 and saw the first board design morph into what has become the de facto standard board layout, often emulated, but so far unbeaten by its competitors.
Incremental update Let’s start with System on a Chip (SOC), which is a BCM2837B0 containing the CPU. Just like the Pi 3, we have an ARM Cortex A53 64-bit CPU, but now running at 1.4GHz, which is an increase of 200MHz over the Pi 3. It’s not a massive increase, but it helps to make Raspbian run a little bit smoother. In general operation Raspbian felt more responsive and it was a genuine pleasure to use, so that extra power did the trick. RAM remains the same at 1GB. That’s enough for most Pi power users, but it would of been nice to see
Family Resemblance When the Raspberry Pi first appeared on the scene in 2012, it came with a unique form factor that had one complaint: poor placement of screw holes. In fact the first version of the board had no screw holes. But why are screw holes important? Well, add-on boards for the Raspberry Pi came in all sorts of shapes and sizes and this caused a few issues for users. For example, the Pibrella board was designed for a 26-pin GPIO and it had a rubber foot to stop it shorting out on the HDMI port when pressed. What was needed was a standard connection, so with the Raspberry Pi B+ in 2014 we saw a 40-pin GPIO and screw holes added to the corners of the board. This offered a consistent mechanical point to which boards could be secured using M3 standoffs. This new standard was part of the HAT (Hardware Attached on Top) which saw EEPROM chips that would talk with the new 40-pin GPIO and enable configuration of the board. This then became the de facto Pi form factor and subsequent model B boards have followed this layout, enabling a board designed to meet this standard to work across the range of compatible Raspberry Pi.
52 LXF236 May 2018
The latest in the Raspberry legacy. It may look like nothing’s changed, but this update offers plenty of enhancements.
2GB of RAM which is rapidly becoming the norm thanks to boards such as Asus Tinkerboard. We ran a sysbench test, computing prime numbers up to 10,000 using all four cores of the CPU. The Pi 3 B+ did this in 36.583 seconds, versus 45.7046 for the original Pi 3. That’s nearly 20 per cent quicker than the original Pi 3!
Improved networking With the Pi 3 in 2016 we saw the inclusion of onboard Wi-Fi and Bluetooth, and this has been further improved for the Pi3 + with Wi-Fi now offering 5GHz 802.11ac. This has a much higher throughput – theoretically up to 1.3Gbits per second – but in tests we found it to be 74Mbits/sec (9.25MB/s) versus the standard 802.11n speed of 47.8Mbits/sec (5.875MB/s). Taking a feature from the Pi Zero W we find that the wireless antenna is the same design, a licensed feature from Proant AB. There’s no connection for an external antenna. This new 5GHz Wi-Fi option works remarkably well and in our tests we were able to watch a 1,080p YouTube video with only a slight amount of buffering when it started to play. Another improvement is with Ethernet. On the previous models of Pi we have seen a LAN9512 and LAN9514 controller chip that offered USB 2.0 ports and an Ethernet connection. For the Pi 3 B+ we see the new LAN7515 providing Gigabit Ethernet over a USB 2.0 interface. So with this new chip running the Ethernet at 325Mbits/sec (40.6MB/s) we see a vast improvement – over three times the performance – when compared to the previous Pi 3, which had a bandwidth of 94.3Mbits/sec (11.78MB/s). When compared to the Asus Tinkerboard, which uses
Tutorial File server
Set up a compact file server and ad blocker Les Pounder shows us how to use the power of the new Raspberry Pi 3 B + to create a file server and ad blocker in one compact device! o celebrate the release of the new Raspberry Pi 3 B+ we’ll use it to create our own Samba server to store files and media for access across our home network. We’ll then use the same Pi to block ads and create a better browsing experience.
our expert Les Pounder is a freelance maker who works with organisations such as the Raspberry Pi Foundation to promote maker skills. He blogs at www.bigl.es.
Samba file server Let’s make sure that we have the latest version of Raspbian. Download this from the Raspberry Pi website and then using your favourite tool flash the image to a blank micro SD card. When completed eject the card and place it into your Pi, then connect your keyboard, mouse, screen, Ethernet and finally the power. Your Pi will boot up and as this is the first boot it’ll expand the filesystem to fully utilise the space on your SD card. Soon you’ll see the Raspbian desktop, so let’s update our Pi. Open a terminal; the icon is in the top left of the screen. In the terminal type the following, line by line, and press Enter at the end of each line: $ sudo apt update $ sudo apt upgrade -y
You need Raspberry A Pi 3 or 3 B+ An Internet connection A USB flash drive or USB hard drive Keyboard, Mouse and Screen for your Pi A 2.5A official power supply Another computer running Linux or Windows
54 LXF236 May 2018
To ensure that we can always find the Pi on the network let’s fix the IP address of our Pi. Right-click the networking icon and select Wireless and Wired Network Settings. In the Network Preferences dialog configure interface eth0. Tick “Automatically configure empty options” and then change the IPv4 Address to match that of your network. For example, our network uses 192.168.0.xxx so we chose to fix the IP address to 192.168.0.100. Click Apply and then Close. Now reboot the Pi to ensure that the IP address has been changed, and to check we can open a terminal and type. $ hostname -I
With the terminal still open, let’s install the Samba package. Type the following and press Enter. $ sudo apt install samba samba-common-bin
With everything installed we now need to insert our USB storage device, which we shall use as our shared storage. Raspbian will automatically mount the drive for us, but we need to know where it’s mounted. In the terminal enter the following command: $ mount | grep /dev/sd
Now if there’s only one USB stick inserted we should see a device labelled /dev/sda1. This is our USB stick, so make a note of the device and where it’s mounted,
Our simple Samba server/ad blocker is powered via the new Pi3 B+, so we have a lean, energy efficient appliance for all of our home needs.
typically in /media/pi/. Make a note of the full path to the drive. So we now have the device that’s our USB drive, and it has a directory that we wish to share using Samba. Let’s tell Samba where to find the drive. In the Terminal type the following to edit the smb.conf file. $ sudo nano /etc/samba/smb.conf
When the file loads, go to the bottom of the file and recreate the following lines: [share] Comment = Pi shared folder Path = /media/pi/<NAME OF DRIVE> Browseable = yes Writeable = Yes only guest = no create mask = 0777 directory mask = 0777 Public = yes Guest ok = yes
To save and exit the editor press Ctrl+O, then Enter, then Ctrl+X. Now let’s ensure that the default user, pi, is added as a Samba user. In the Terminal type: $ sudo smbpasswd -a pi
Next, to ensure that our Samba config is correct and ready to use we need to tell Samba to restart, so in the Terminal type the following: $ sudo /etc/init.d/samba restart
Remote compiling: Share your workload
Mats Tage Axelsson likes to share the love and save time when tackling high-load tasks, by passing some of the workload on to other computers… our day-to-day computer activities usually pass without a hitch, until you fill up your memory and start swapping. And if you’re compiling software or rendering graphics when this happens, then you’ll soon know that something’s amiss. Both activities are memory and CPU intensive, and can take a lot of time to complete. The solution lies in distributed computing, which is the technique of using many computers to do one job. In this article, we’ll focus on how to compile your software projects on your own computers. We’ll also see what solutions animators are using to speed up their workflow. We’ll also investigate in what circumstances a special set-up for cross-compiling is necessary. Your first step is to install gcc. The packages you need are defined in most distributions by the buildessential package or similar. Because gcc supports many languages apart from C or C++, there are many additional packages available if you intend to program in other languages. Java is an interesting example because Android uses it, but Gradle is the most common way to control your Java build. Here we’ll cover the gcc used for C and C++. We’ll begin by demonstrating how to make gcc compile, and this is achieved by issuing the make command. This becomes a habit when you compile your own code, or someone else’s. The point now is to make sure you can compile in parallel. The make command takes the jobs parameter to set how many jobs can run at the same time:
our expert Mats Tage Axelsson When Mats started with Linux he had an IBM Thinkpad and floppy disks. He still tries to squeeze the maximum out of ageing hardware, the cheapskate!
$ cd [your build directory] $ make -j 4
When testing your setup, pick a small package from www.gnu. org/software to make sure that the software compiles before you try to distribute the compiling load.
62 LXF236 May 2018
This parameter needs to be set to a value that’s between one-and-a-half and twice the number of cores you have in your system. Before you can successfully distribute your load, it first has to be made parallel. This makes it possible for other systems to spread it across many computers. The other parameters will differ significantly between builds and so won’t be covered here. When counting your cores you need to take into account how many cores each CPU has in your “cluster”. The jobs parameter is sometimes that can be complemented with the load parameter -l , which specifies the maximum load the compiler should wait for, before
Here’s distccmon showing the level of activity in the other CPU, and in this case using the localhost for compiling the test package.
starting a new job. This is useful if you want to use the computer while compiling, because it may become sluggish otherwise. A common problem for home programmers is that they own just one computer. The best way to avoid such sluggish performance is to spread the job over many computers. One way to do this is to use the distcc package, which will take the make command and distribute the load according to the order that you’ve defined in your configuration. The distcc package is available on many distributions by default in a fairly new version. Ubuntu features the 3.1 version, while the newest RC is 3.2, which was released in 2014. That’s obviously a little old, but the package seems stable and usable despite the seemingly freeze in development.
Installing distcc and redirecting
The package with both distcc and its daemon is included in the standard package. If you only want to install the daemon your best option is to compile it for the specific platform. If you only have regular user privileges you can still install and run distcc; however, the dependencies will probably be a pain, so try not to! $ sudo apt install distcc
Now that you have distcc on either both or all nodes, you can start the daemon on the server, which is also called contributor. The daemon listens to port 3632, so make sure to keep that port open on your contributors. This option is only valid for TCP connections and while it’s fast, it’s not
The best new open source software on the planet
Alexander Tolstoy Borne on the wings of hope and desire, he helps the best free apps shine and aspire.
Falkon Ternimal Ddrescue Wine Polo Bleachbit Gnome Layout Manager Fstransform VLC Daemon-vs-demon Stupax Web browser
Version: 3.0 Web: https:// github.com/KDE/falkon e love alternative and open source web browsers, especially when they’re good enough to replace Chromium or Firefox for most daily tasks. The abundance of choice is especially important in the modern world, which seems to be dominated by the two titles mentioned above. In issues 212 and 229 we reviewed Qupzilla, a fast and feature-rich web browser that’s been built around QtWebEngine. Realistically, we can’t ignore the world of Chromium clones this time, because QtWebEngine is a repackaged and slightly altered version of the open source Chromium engine (which has been adjusted so it can be used by Qt programs). The name change occurred because of some behind-the-scene developments that resulted in Qupzilla falling under the KDE project umbrella and becoming Falkon. The newly released browser is desktop-agnostic to some extent: it respects your icons and theme settings and looks native in Windows, Gnome, Plasma and more. Falkon combines Chromium’s performance and compatibility with light(ish) weight and some useful outof-the-box features, like the built-in Adblock, the Speeddial page, as well as a bookmark import tool that supports Firefox and Chromium. KDE folks didn’t announced it loudly, but it’s natural to assume that Falkon is a replacement of the stalled Konqueror web browser. We used Falkon for a week or two and found it to be fast, while remaining light on resource-usage. It also performed quite well on tackling various multimedia tasks, although it largely depended on QtWebEngine, rather than the browser itself. For instance, some music-streaming services required proprietary media codecs and we needed to recompile QtWebEngine with extra flags to include it in the build. Note that some Linux distros already do this by default. Overall, Falkon did a great job and proved itself as an up-to-date web browser with useful extras, such as reverse image search, support for custom user scripts, personal information manager and many others. Don’t miss the full list in Preferences>Extensions.
Get to know the Falkon interface... 1
Tabs and bars Falkon offers a convenient and timeproven controls layout with tabbed interface.
Pancake buttons Falkon has lots of features that you can access with one extra mouse click.
Dedicated search field A rare element nowadays, search engine selection at your fingertips.
Extensions out of the box Frequently used browser extensions are already here, so you don’t need to tweak Falkon in most cases.
Block ads by default No need to install ad blocking extension by hand - it’s already here!
May 2018 LXF236 81
Coding academy coding academy Python 3
Machine learning: quick tips and tricks Mihalis Tsoukalos reveals his tried-and-tested approach for processing reams of data using machine-learning techniques and Python 3. hese days, machine learning (ML) is not only important as a research area of computer science, but it’s also started playing a key role in our everyday lives. As if this wasn’t enough, an exponential growth in the usage of ML is expected in the next few years. The biggest advantage of ML is that it offers new and unique ways of thinking about the problems we want to study and solve. ML is all about extracting knowledge from your data using a computer – in this case, all the examples of this tutorial are going to be written in Python 3. However, the topic is huge and can’t be covered in a single article, so the main purpose of this tutorial is to get you started with the various Python 3 libraries and their functions, learn what each library supports, and give you a good reason to explore some or all of them. So, without further ado, let’s get started with the next section, which is a quick introduction to ML.
our expert Mihalis Tsoukalos is a UNIX administrator, a programmer, a DBA and a mathematician. You can reach him at www. mtsoukalos.eu.
Machine learning in a nutshell
If you’re keen to know more about ML, read The Elements of Statistical Learning, Python Machine Learning and An Introduction to Statistical Learning with Applications in R.
88 LXF236 May 2018
ML can help you discover hidden patterns and information that would be difficult to recognise otherwise. Statistics are more or less the foundation of ML in many ways, so it would be helpful if you’re familiar with some basic statistical definitions such as mean value, median, standard deviation, percentile and outlier. The three main areas of ML are Supervised Learning, Unsupervised Learning and Reinforcement Learning. Supervised Learning is about identifying the relationships between some labelled variables. These are variables that we already know what they represent, and a target variable, and includes areas such as Classification and Regression. The techniques of Unsupervised Learning attempt to find hidden patterns in the data without knowing anything about it – including their types. Clustering is the most popular category of Unsupervised Learning. Reinforcement Learning enables you to learn the behaviour of a system based on the feedback you obtain, using techniques such as Markov decision processes and Monte Carlo methods. Now it’s time for some definitions. An Artificial Neural Network models the relationships of the input signal set
This shows the Python 3 code of classify.py that illustrates the use of the scikit-learn module and the iris data set for classification.
and the output signal set in a way that’s inspired by a brain. Put simply, an Artificial Neural Network uses interconnecting nodes to solve problems such as signal processing or pattern recognition using ML. Deep Learning is the subfield of ML that deals with very large Artificial Neural Networks. A Generalised Linear Model is a statistical method that, in simplified terms, uses linear regression models for predicting the behaviour of the data. A clustering technique attempts to group the data in sets, in such a way that objects of the same group are similar in some sense. This mainly depends on the type of data you have to process. Finally, a Classification technique – which is an example of pattern recognition – uses training data to establish some categories and then puts new observations into these categories.
Curved examples The first example of this tutorial will be relatively simple: we’ll attempt to find a mathematical function that best fits the data points of the input. This is called curve fitting and is one of the simplest kinds of ML. It’s closely related to mathematics. The Python 3 code of simple.py is the following: #!/usr/bin/env python3 import numpy as np
On the disc Distros, apps, games, books, miscellany and more…
arch for the elder statesman
Arch Linux 32-2018.02 Neil Bothwick This month, I’ve been doing battle with GRUB. In the good old days, a five-line config file was enough to boot a Linux distro. Now we have the massive GRUB2 with config files more than 100 lines long, full of module loading and conditional statements. GRUB2 is better suited to automatic generation of its menus, which makes it ideal for distro installers. However, hand-crafting menus is nowhere as easy as it was. RTFM I hear you cry! Well, the documentation is quite lengthy, but still lacking in information at times. It’s a classic situation of a program becoming more powerful, yet getting more complex in the process, while the documentation struggles to keep pace. Unlike Marmite, I find myself able to love and hate it at the same time, especially when I discover neat features that no one tells you about. If you’ve already booted this month’s DVD, you’ll see we have different graphics for each distro’s submenu. That was a more or less accidental discovery while I was trying to do something as simple sounding as changing the help text on one menu. The solution was more complex than you would expect, but it opened the way to a neat new feature on the LXF disc.
96 LXF236 May 2018
he number of distros supporting 32-bit PCs continues to dwindle. Now Arch Linux has dropped support for legacy hardware. However, the community has taken up the reins and now maintains 32-bit (i686) packages and installer. Arch32 is a standard Arch Linux installer. In other words you have to do the work yourself, but it means you end up with the distro you want, not what some developer has decided you need. That’s the essence of Arch Linux: you get to make your own choices, but you have to implement those choices, too. For an install guide follow wiki. archlinux.org/index.php/installation_guide.
Rumours of its death are greatly exaggerated – Arch Linux for the 32-bit CPUs is alive and well.
the fancy face of arch
Manjaro XFCE-17.1.6 rch’s ease of customisation makes it a good choice as a build system for other distros, as evidenced by the increasing number of distros now using Arch Linux as a base. Manjaro is one of the more popular of such distros. There are a number of desktop variants of Manjaro, and this is the XFCE version. Apart from the initial desktop, they’re all the same so you can install a different desktop if you wish. Manjaro comes with an easy-to-use installer that both installs and sets up everything to give you a working graphical desktop, which makes it a lot simpler to install than Arch. One of the key features it inherits from its progenitor is that this is a rolling release distro. Instead of a complete new distro every six to nine months, Manjaro is updated regularly as new versions of packages become available. This means you get the newer
Manjaro is Arch Linux made easy, and available in a range of desktops. This is the XFCE version.
software sooner than with distros that employ the more typical release model. Furthermore, there’s no major upgrade to take care of at the next step of the release cycle.
Defective discs: For basic help on running the disc or in the unlikely event of your Linux Format coverdisc being in any way defective, please visit our support site at www.linuxformat.com/dvdsupport. Unfortunately, we’re unable to offer advice on using the applications, your hardware or the operating system itself.
SPECIALS & GUIDES
myfavouritemagazines has over 100 one-off guides and specials which celebrate your favourite subjects. There’s something for everyone treat yourself or give gift.
Or call now – UK: 0344 848 2852 Overseas: +44 344 848 2852 MyFavouriteMagazines is the official magazine subscription store of Future. You can save up to 74% on a huge range of popular magazine titles. Every magazine subscription will be delivered direct to your door, and includes free UK delivery; guaranteeing you don’t miss a copy of your favourite magazine.
You can subscribe to this magazine @ www.myfavouritemagazines.co.uk