Archive

Posts Tagged ‘tutorial’

How to Download YouTube 4K Videos with Youtube-dl Script

September 20th, 2016 7 comments

Many Android devices can now support 4K VP9 and/or H.264 video decoding, but for some reasons, Google only serves 4K videos to devices running Android TV OS, as opposed to just Android, with the latter limited to 1080p videos. If for some reasons you want to watch a YouTube 4K video on a capable device, you could download it with youtube-dl script written in Python, and available for Linux, Windows, and Mac OS.

youtube-4k-video-downloadI’ve been using the script for a while to download various video or audio files from YouTube, and other website, but for the purpose of this post, I made sure to update it to the latest version:

If you have already installed the script, it can also be updated with:

I’ll use one of the most popular 4K videos on YouTube as example, namely: COSTA RICA IN 4K 60fps (ULTRA HD) w/ Freefly Movi.

The first task is to list the video’s supported formats:

So we can see there are lots of different formats for a given video with different resolution, container formats, and bitrates. You have to find the lines you want and select the corresponding “format code” in the first column to download the video and audio. I’ll select 313 for video and let the script select the best audio format:

The “+” sign is used to merge video and audio. If you don’t add an option for audio, only the video without audio will be downloaded. You can also run “youtube-dl URL” without options, and it should download the video with both “best audio and video”, but you don’t have full control over the exact format of the video.

Youtube-hd script has many others options, include support for YouTube playlist downloads so it’s a very useful script.

Categories: Linux, Testing Tags: 4k, how-to, tutorial, youtube

Receive Android SMS & Call Notifications in Ubuntu 16.04 with KDE Connect (or Not?)

September 15th, 2016 11 comments

I often miss calls, and I may be slow to answer SMS on my Android phone, but I’m often in front of my computer, so I decided to look for solutions to show SMS and call notifications on my computer running Ubuntu 16.04. I first found LinConnect, but it does not seem to be developed anymore, and after some more research I discovered that KDE Connect should do the job. The developer just released KDE Connect 1.0 a few weeks ago with add encryption, the ability to reply to SMS from your computer and more… One person posted instructions for Kubuntu 16.04. There’s just a problem it won’t work with Unity desktop, only KDE Plasma, due to a lack of support for Qt 5.6.

You can still use the older version without encryption and other new features by “simply” running:

However the installation failed for me:

An “apt install -f” did not help, so I uninstalled kde-l10n-th package:

Ran “sudo apt install -f”, and the installation went through. It’s possible it’s an error specific to Thai language only. I’m unclear whether the bug is due to that package, or KDE Connect.

Now you can install KDE Connect Android app on your phone, and start KDE Connect Settings on your computer and enable the server in order to pair your phone.

Click to Enlarge

KDE Connect Settings (Ubuntu) – Click to Enlarge

kde-connect-android-app

I could connect to the server, and set notifications for apps. You can also set several options in KDE Connect in Ubuntu 16.04, and the program seems quite powerful.

Click to Enlarge

Click to Enlarge

Sadly, I only manage to get a notification once in the top right corner for an upcoming call (I was not fast enough for a screenshot), and after it I did work anymore. You can also open KDE Connect Monitor to have a look at notifications, but in the case of calls it will only show you the missed called, not when the call starts. The Blue button on the top right is used to make your phone ring in case you can’t find it.

android-smartphone-notifications-ubuntu-computerIt’s not really ideal, so I decided to go ahead and install the latest version.

The first step is to install the Kubuntu backport.

Sadly I canceled it, because I went through many dependencies errors during installation, maybe I did something wrong.

In case it works, you can use the PPA for Kubuntu 16.04 / 16.10, and install KDE Connect 1.0:

Overall, this was a time consuming experience, and KDE Connect did not work reliably for me. Any tips are welcomed.

Explore M3 Board based on NXP LPC1768 Cortex M3 MCU Comes with Lots of Tutorials (Crowdfunding)

September 12th, 2016 No comments

Explore M3 is an ARM Cortex M3 development board powered by a micro USB port, with plenty of I/Os, Arduino compatible, and the developers have also written many tutorials to help people getting started as fast and easily as possible. A starter kit with cables and sensors is also available with the board.

explore-m3

Specifications:

  • MCU – NXP LPC1768 ARM Cortex M3 @ up to 100MHz with 512KB flash, 64KB RAM,
  • USB – 1x micro USB 2.0 OTG port for programming and power
  • Expansion Headers – 2x 20-pin male headers + 8-pin unpopulated header with 38x GPIOs, 4x UARTs, 2x CAN, 2x SPI, 2x I2C, 6x PWM, 5x ADC, 1x DAC, 2x interrupt pins, I2S audio, and power signal
  • Debugging – JTAG/SWD Debug connector
  • Misc – USB boot and reset buttons
  • Dimensions – 55mm x 25mm

The hardware is somewhat similar to mbed LPC1768 board but with a few more I/Os. The breadboard friendly board can be programmed with the Arduino IDE, but you can also go “bare metal” using ARM-GCC and Ellipse, or other tool chains like Keil or Co-IDE. Alternatively, the board also support FreeRTOS real-time OS. You can find close to 50 tutorials for all three programming options on ExplorerEmbedded Wiki, and some source code is also available on Github.

explore-m3-pinoutExplorer M3 developers are now raising funds via CrowdSupply to help reducing price for mass production. A $19 pledge should get your the board, but for bare metal programming you may want to add $20 for SODA SWD debug adapter, if you don’t already have your own programmer, and the starter kit goes for $49 with various other accessories. Shipping is free, and delivery is planned for mid November.

Getting Started with B&T RTL-00 RTL8710 Module – Serial Console, AT Commands, and ESP8266 Pin-to-Pin Compatibility

August 18th, 2016 13 comments

The announcement of the ultra-low cost ARM based Realtek RTL8710 WiFi modules for IoT applications generated quite a lot of buzz since they can potentially compete with the popular ESP8266 modules. The main problem at the time was documentation and software support, but after some searches we could find that RTL8710 was part of Realtek Ameba family, and found some documents and an SDK for RTL8710/RTL8711/RTL8195. ICStation also kindly provided one B&T RTL-00 module for review, which costs $3.55 shipped per unit, and as low as $2.85 if you purchase 10 or more.

Click to Enlarge

Click to Enlarge

Click to Enlarge

Click to Enlarge

The question here is how to get started? The answer can be found in page 8 of the Chinese datasheet for the module with GB0 and GB1 pins used for Tx and Rx to access the serial console. Time for some soldering…

RTL8710_Soldering

For the first test, we’ll just need Tx (GB1), Rx (GB0), GND and 3.3V, and cut breadboard wires to give me the flexibility to use it with a breadboard just in case.

RTL8710_Serial_Connection

Now you need to connect the module to a USB to TTL debug board with all four pins connected since it will also provide power.

Click to Enlarge

Click to Enlarge

Insert the debug board into a USB port of your computer, and setup a serial connection @ 38400 8N1 using minicom, screen, putty, or other serial capable app. I struggled to get the full boot, until I found ATSR command would reboot the board:

If you type help you’ll see some AT commands:

You can find the full AT command set in RTL8710 forums, and somehow it differs from the AT command set found in AN0025 Realtek at command.pdf application note available in Ameba Standard SDK.

Time to have some fun by trying to connect the board to my WiFi router:

Success, and that was easy. Now AP mode….

ATPA needs four arguments with ESSID,password (8 to 64 characters), channel, and hidden or not (1 or 0). I could not find the new access point with my phone, connected to it and typed the password. The serial console outputted it.

The command ATW? will return lots of info about WiFi status:

I’ll complete those little tests by enabling the web server in the board:

You can now connect to the web interface to configure the access point.

Click to Enlarge

Click to Enlarge

AT commands are all good, and you can configure WiFi, UDP/TCP servers, and even OTA firmware update, but there’s nothing about controlling GPIOs there… So that will be something to look into. [Update: ATSG is the command for GPIOs. See comment]

Dpape on RTL8710 forums discovered something very interesting: B&T RTL-00 module is pin-to-pin compatible with ESP12E module based on ESP8266, so if you already own a board with such module including NodeMCU board, you could unsolder the ESP8266 module, and replace it with RTL8710 and get going.

NodeMCU_RTL8710That’s exactly what he’s done and shown to work, with the module bought from Aliexpress, which appears to come pre-loaded with the exact same firmware. You’d normally not need the red USB debug board as shown above, but he removed the USB to TTL chip on NodeMCU previously, so that’s why…

ESP12E_vs_RTL00

The modules are actually only mostly pin-to-pin compatible, as for example GC5, corresponding to ADC on ESP12E, does not seem to support ADC, but only I2C1 SCL, SPI0 CS2, and GPIO_INT signals. But the power signals, Tx and TX, and most GPIO signal will match.

Realtek RTL8710 is still nowhere near ESP8266 in terms of community and software support however. However an ARM development board company – previously featured in this blog and many news outlets – is involved in the project, and I’ve been informed more details will be provided in 2 to 3 weeks. The current modules sold are for the Chinese market, and an international version is planned with a slightly different radio.

How-to Setup a DLNA/UPnP Server in Linux for Smoother Video Streaming with Kodi and Other Media Players

August 16th, 2016 8 comments

I’m normally playing videos from a SAMBA share installed in a Ubuntu PC to play files from Kodi in Android TV box reviews, but sometimes when I use 10/100 Ethernet, or worse WiFi local “streaming” may not be as smooth as possible. SAMBA is convenient because of access control and read write operations, but if you want to get a bit more performance, you may switch to NFS instead, or like I’ve going to show you here to a DLNA / UPnP server to stream videos locally from Kodi 16.1.

There are several options, but MiniDLNA is lightweight compared to MediaTomb, so it will also run on lower end hardware like cheap ARM Linux development boards like Raspberry Pi, Orange Pi, or NanoPi NEO without taking too many resources.

Installation is very easy in Debian / Ubuntu distributions, and I supposed this should also work with Windows Subsystem for Linux in Windows 10:

MiniDLNA can be configured with the same settings for all users, or different settings for specific users. In both case you’ll need to edit /etc/minidlna.conf configuration file. In my case, I only changed or uncommented the following lines for global settings:

You can add as many media_dir lines as you want, and also add A, V or P letter to separate Audio, Video, and Photo media type. For example:

Please note that minidlna daemon (minidlnad) will automatically scan subdirectories, so they don’t need to be specified.

Now that we have modifed the configuration, let’s restart it:

The Wiki on Ubuntu linked in the introduction also mentions to run the following command to rebuild the database:

However, while I could find my new UPnP server in Kodi, there were no files at all, and the log shows the same error message over and over:

eventually the command:

fixed the issue. But that’s not exactly the right way to fix it as it assumes root is running the daemon.

A better way if you’re going to have a decidated server is probably to set the ownership of media files to minidlna with a command like:

So how do you play videos from your DLNA/UPnP server in Kodi 16.1? Go to Videos->Files, and select Add videos…

Kodi_UPnP_devicesNow select UPnP devices

Kodi_miniDLNA_serverKodi should like your UPnP / DLNA servers. In my case FX8350:root, which correspond to the hostname or friendly_name in the hostname, and to the user, normally minidlna. Select the server, than Browser Folder, or Videos, and click OK.

I’ve shot a short video showing how to setup UPnP devices in Kodi, and compare SAMBA and DLNA performance by playing the same video file in Kodi 16.1 Android through SAMBA and UPnP/DLNA.

You’ll notice the video played from the SAMBA server starts much faster, but buffers several time during playback, while the video played from MiniDLNA server on the same PC will buffer data longer at start, and always fill the buffer fast enough to avoid bufferring.

I took Conky screenshots for another video showing the traffic shape for both SAMBA with relatively constant speed (6600 KB/s to 7400 KB/s) and DLNA which shows very high bitrate (>10000 KB/s) to fill the buffer the first time, and then play consistently around 6400 to 6800 KB/s.

SAMBA_vs_DLNA-UPNP

Of course switching from SAMBA to DLNA won’t do miracles, but if you notice a few buffering while playing videos in SAMBA, switching to DLNA/UPnP may resolve the issue. You can also keep the best of both world, for example using SAMBA to download/copy files, and DLNA to play them back.

How to Resolve Slow Boot Times in Ubuntu 16.04

August 9th, 2016 9 comments

I’ve recently upgraded my machine from Ubuntu 14.04.4 to Ubuntu 16.04.1, but while my computer used to boot in about 40 seconds, after the upgrade boot times increased considerably to 2 to 3 minutes.
Ubuntu_16.04_Boot_timesThe first easy check was to look at dmesg:

There’s a bit 87 seconds gap between checking for the floppy, and VirtualBox drivers loading. So there’s definitely an issue here, but the log does not exactly give a clear queue.

I’ve read you could use systemd-analyze to find which process(es) may be slowing down your computer at boot time:

Two processes are taking close to 8 seconds, but those 16 seconds still do not explain why it takes 2 minutes more to boot…Eventually, I realized systemd-analyze has a few more tricks up its sleeves:

The first command shows there’s no problem with the kernel itself, and something is slow in user space. The second command draws a huge boot chart (SVG), whose shape looks like the picture below.

ubuntu_16.04_BootchartSo we have something to look at, namely the area just before the large gap… I’ve zoomed in on it:

Ubuntu_16.04_Bootchart_ProlificThere are a few things there including the DVDROM drive, and “Prolific Technology Serial Controller” connected to /dev/ttyUSB0. The latter is a USB to TTL debug board based on PL2303, so I removed it and rebooted my machine, and miracle! Boot time was reduced to just 17 seconds:

Ubuntu_16.04_Fast_Boot_TimeThe SVG chart shape, shown on the right, also changed completely as it booted most of the same services in much less time. So since I don’t use the debug board everyday, I’ll make sure I only connect it when needed.  Ideally, I suppose a bug should be filled, but I’m not sure which package cause the issue.

On a rather unrelated note, yesterday I also decided to look into Firefox performance issues (switching or closing tabs would take 2 to 3 seconds), and I discovered recent versions of Firefox browser (47+ and greater) include support for “about:performance” tab showing which add-on(s), plugin(s), or page(s) may be problematic. Just let it run for a while, and go about your business browsing the web, and then come back to the tab to check if any has many alerts. It helped me find an add-on slowing down browsing considerably, so I disabled it, and performance is now much better.

How to Customize Amlogic Android Firmware – A Tutorial with NEXBOX A95X (S905) TV Box

August 6th, 2016 68 comments

CNXSoft: Bear in mind that there are multiple versions of Nexbox A95X. Yesterday, I published the review of Nexbox A95X with Android 6.0, with the model based on Amlogic S905X processor. In this article, Karl had a look at Nexbox A95X with Amlogic S905 processor, which he purchased a couple of months ago, but since he was not happy with the Android 5.1 firmware, he decided to customize it.

Karl here with a review of the Nexbox A95X S905 box. This took a while to even start. I received the box about 2 months ago and I dived right in and broke it. I didn’t have factory firmware, and wasn’t cautious enough and bricked it. I found some firmware that worked but it didn’t work very well for me. Email’s to Nexbox directly didn’t help and I was stuck with a bricked box… I later found someone who had factory firmware and was kind enough to share and I was back in business. But I still didn’t like it, as it felt sluggish when doing anything else besides Kodi and missing notifications and navigation bar.

Click to Enlarge

Click to Enlarge

Click to Enlarge

Click to Enlarge

Quest to find better firmware

There is a dirty little secret with these boxes and it is a little unfair to the manufacturers who do make good software but you can just about flash any firmware on any matching processor box. The biggest thing is to match the WiFi chip. They will sometimes brick hard and to restore requires shorting pins on the NAND flash. It is pins 29 and 30 on this one (TBC). Short the pins while connect to PC, and apply power and you are able to flash new firmware. I never had to do it on this one. The A95X has an RTL8189ETV WiFi chip as can be seen in the picture above. So I did some searching for “S905 RTL8189 Firmware” and I found some, but they were not any better. If WiFi doesn’t matter and you have Ethernet you will have better luck or can use a USB to Ethernet adapter if the firmware supports it.

Review Turned into a How To

I wasn’t happy with anything (I know….I am needy). So what do we do? Go and try a manufacturer’s who put out good software regardless of WiFi and Ethernet. I had used Tronsmart’s S905 firmware on another box and it is pretty good. So I started there and flashed it and the box booted but without WiFi, nor Ethernet, and I assume no remote control either (I don’t typically use the remote and test with Logitech K400R). So I tried to use this firmware as ROM to port from, and now the time consuming part starts…

Setup

Before we begin I will put out the typical disclaimer that you assume all risk and don’t blame me. If you don’t want to have to do this buy a box from a good manufacturer. Several stand out… search for reviews in CNX Software, or other forums.

I do all my work in Windows, so no Linux is necessary but just recently upgraded to Windows 10 and with bash opens up some additional possibilities I have yet to explore. I did try mounting an img but it doesn’t support it yet.

Below is the main software that I use. If you know any other alternatives please leave a comment. Especially Beyond Compare only 30 day evaluation. It is not too expensive and I use it for other things. Install all the programs below with defaults and it should work except the Customization Tool. Install it to someplace other than Program Files. It will save button presses when needing elevated privileges.

Customization Tool

I will be going to go over the basics of this tool. When you first load the tool it will be in Chinese. The 2nd menu Item in the top will set it to English, and it will remember it the rest of the time.

Amlogic_Customization_English

The first step is to unpack the img files. Press the load button, and you will be prompted to what you want to unpack. I check them all at this point except the bottom one. There is an issue right now with the tool with the last one. Then choose the img we are porting to. This will take a while. Amlogic_CustomizationTool_Load

Amlogic_Customization_Tool_Settings

Once the img is unpacked navigate to where you installed the customization tool and rename the tmp directory to Tronsmart.

NEXBOX-A95X-Customization

Now repeat the process again with the Nexbox Stock img. Don’t close the Customization Tool until we are done.

Now we have 2 img’s fully unpacked and in each directory we have 2 folders: Level 1 and Level 2. Level 1 has all the individual partitions and we won’t be doing anything in there today. Level 2 has the different partitions broken out so we can manipulate them. We will only have to go into system to do this port.

NEXBOX-A95X_System

Now in the Nexbox firmware,  delete app, fonts, framework, media, priv-app in the system directory, and copy them over from Tronsmart.

At this point go back to the Customization Tool Press the Pack button and save it somewhere. If I was doing this the first time I would flash and do some testing to see if it booted, Wifi, remote etc. This also gets you to a good spot to go back to so in case something goes bad you don’t have to do the whole thing over again. As you are exploring it is good to do this often to save some headache and time.

Beware once you pack an img, as you must close the customization tool down and unpack the last one you packed. There is a bug if you pack make a change test then pack again without restarting and reopening. All the img’s after that first pack won’t be able to be unpacked by the tool.

Final Tweaks

Here is our chance to remove all the bloat and clean the img up. When I clean an img I take a picture of the app drawer with my phone and remove any unwanted apps from the app directory or priv-app directory. Be aware there is also a pre-install directory that won’t install anything. I removed everything to tidy up. I did try to fix quickly but didn’t spend much time on it.

I also replaced the Tronsmart boot animation with a different one. It is in the media directory.

Extra’s

You can also modify boot img and logos with this tool. I use gimp to modify logos. First I would navigate to the logo folder in the level 2 directory. The largest file bootup is a bmp file. Rename to bootup.bmp, right click on it go to properties and note the dimensions and bit depth. In this case it is a 32bit 1280×720 bmp img. Find whatever picture or logo…your imagination is the limit but you have to make sure your dimension and bit depth are exact. In gimp you export to bmp and choose 32 bit…if done correctly your file will be the exact same size as the original. Rename bootup and delete the original. When done you can pack and enjoy your new logo. I believe the tool itself will import but I like to do it by hand. The only thing I use the tool for is to unpack and pack the img.

Troubleshooting

So we haven’t touched a couple tools so far. That is a good thing. But if we did run into some trouble Beyond compare can drastically reduce the time to find. With this tool you can compare all the files from the stock rom, and the rom you are porting to. If I ran into troubles with booting start with comparing kernel in level 2. Maybe in one of the rc files a reference something differently. This can lead to many hours lost. I have lost many and not succeeded. Be prepared to do lots of reading and research. I included HXD and Notepad++ if you had to modify a file. In the Windows notepad it doesn’t recognize Linux carriage returns.

If you’d just like to install the custom image on your NEXBOX A95X (Amlogic S905 only) TV box, here’s the custom firmware link.

Embedded Android (Marshmallow) and Brillo / Weave Internals Presentation Slides

August 3rd, 2016 1 comment

Karim Yaghmour – founder of Opersys, a company specializing in Embedded Linux and Android training and development – is currently at Android Devcon 2016 were he gave a full day Embedded Android Workshop on August 1st, as well as a separate 1+ hour talk about Brillo/Weave internals on August 2, and more talks scheduled on the next two days about Android memory management, debugging and development, and Project Ara.

He has just released the presentation slides on Slideshare, with the first “Embedded Android Workshop with Marshmallow” presentation totaling 175 pages, and dealing with Linux and Android concepts, overall architecture, system startup, the Linux kernel, hardware support, native user-space, Java for Android, JMI, AOSP, and more…

The second presentation is much shorter with 29 slides, and deals specifically with Brillo / Weave internals including Embedded Linux, Android, Binder, DBUS, HAL, the source tree architecture, and so on.

While you’d probably learn a lot more by attending the live workshop and session, you may still earn a few things about Embedded Android and Brillo by scrolling through the slides.

Categories: Android, Brillo Tags: Android, brillo, opersys, tutorial