Installing UBports Ubuntu Touch on the Meizu MX4 Ubuntu Edition


Thursday 21st March 2019

I recently decided to switch back to using my Meizu MX4 Ubuntu Edition that I originally purchased in 2015 (which is what the first article on this blog was about).

Unfortunately, Canonical decided to end development of Ubuntu Touch due to a lack of market interest, but luckily the UBports community took over development, and are running the project successfully to this day as the (soon to be at the time of writing) UBports Foundation.

In this article, I have documented the installation process using the ubports-installer application, and included a manual bug fix that is currently required for installation on some MX4 phones. This fix was kindly put together by AlainW94 on the UBports forum, and documented here with their permission.

Skip to Section:

Installing UBports Ubuntu Touch on the Meizu MX4 Ubuntu Edition
┣━━ Standard Installation Procedure
┣━━ Fixing the FAILED (remote: unknown command) Error
┣━━ Using Ubuntu Touch on the Meizu MX4 in 2019
┗━━ Things I'd Like to See

Standard Installation Procedure

Notice:

There is currently a bug in ubports-installer affecting some Meizu devices, preventing the installation from succeeding. It may be worth reading ahead so you know what to look out for. The fix involves making a manual code change and recompiling the application.

The official method for installing Ubuntu Touch is using the ubports-installer application, which can be installed from the Snap Store:

$ snap install ubports-installer

Other installation methods are also available, if you'd prefer. Please see the repository on GitHub: https://github.com/ubports/ubports-installer

I recommend running ubports-installer using the ubports-installer command, rather than using the desktop/menu shortcut, as seeing the verbose log output can be very useful for debugging errors and ensuring that everything is working properly.

A screenshot of the UBports installer application, showing the main welcome screen.

The welcome screen will try to auto-detect your phone if it is plugged in. For me, this unfortunately didn't work, so I selected it manually.

Then, you can select your desired installation options:

A screenshot of the UBports installer application, showing my phone selected and the 'Install Options' menu.

The latest version at the time of writing is Ubuntu Touch 16.04.

A screenshot of the UBports installer application, showing the installation confirmation screen.

Then, you'll need to put your phone in Fastboot mode, by holding down the power and volume down buttons while your device is in a powered-off state. You may have to hold them for a while, as in some cases it can take up to 30 seconds. This also doesn't seem to work reliably while your device is plugged in via USB, so I suggest temporarily disconnecting it while you do this.

A screenshot of the UBports installer application, asking the user to reboot their phone into the bootloader, with a static graphic demonstrating how to do this.

After you've done this, the installation should begin properly. However, on some Meizu devices you will run into the FAILED (remote: unknown command) error. If this is the case, then this is a known bug. The temporary fix involves making a minor code change and recompiling ubports-installer - I have documented the entire process below.

If you encounter another error, it may be that you don't have permission to access your device over USB. You should add the following rules to /etc/udev/rules.d/51-meizu.rules (or another name of your choice), and ensure that your Linux user account is in the plugdev group:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2a45", MODE="0666", GROUP="plugdev"

...then restart udev by running udevadm control --reload-rules followed by udevadm trigger as root.

If your installation is working successfully, you'll see the following screen:

A screenshot of the UBports installer application, showing the installation running successfully with a 'Pushing files to device...' notice.

Installation takes around 5 minutes, and then there is another stage of installation that takes place on the phone itself. This also takes around 5 minutes.

Your phone will reboot, and you can begin using Ubuntu Touch!

Fixing the FAILED (remote: unknown command) Error

At the time of writing, there is a known bug in ubports-installer affecting some Meizu devices. Essentially, the installer tries to reboot the phone into recovery mode, but Meizu phones don't fully support this, so you have to put it into recovery mode manually by holding the power button and volume up.

If you're affected by this, you'll see the following error both in the GUI and terminal output of ubports-installer:

debug: fastboot: flash; [{"type":"recovery","url":"http://cdimage.ubports.com/devices/recovery-arale.img","checksum":"27160d1ce2d55bd940b38ebf643018b33e0516795dff179942129943fabdc3d8","path":"/home/j/snap/ubports-installer/183/.cache/ubports/images/arale"}]
info: Booting into recovery image...
error: Devices: Error: Fastboot: Unknown error:  downloading 'boot.img'...
OKAY [  0.702s]
booting...
FAILED (remote: unknown command)
finished. total time: 0.716s

Unfortunately the error handling in ubports-installer doesn't allow you to bypass this error by manually rebooting into recovery mode. As a temporary fix, you can manually remove the offending error handling code and recompile the application.

Thank You to AlainW94 on the UBports Forum

I'd like to give a massive thanks to AlainW94 on the UBports Forum for devising this solution and assisting with my problem in my forum thread. They provide a lot of valuable support and contributions to UBports, so I am very grateful for their help!

In order to implement the workaround, you'll need to download a copy of the ubports-installer source code:

$ git clone https://github.com/ubports/ubports-installer.git

cd into the downloaded repository, and open the src/devices.js in your text editor.

Next, scroll down to the following section:

                 // If we can't find it, report error!
                  if (!recoveryImg){
                    bootstrapEvent.emit("error", "Cannot find recoveryImg to boot: "+images);
                  }else {
                    fastboot.boot(recoveryImg, p, (err, errM) => {
                      if (err) {
                        handleBootstrapError(err, errM, bootstrapEvent, () => {
                          instructBootstrap(fastbootboot, images, bootstrapEvent);
                        });
                      }else
                        bootstrapEvent.emit("bootstrap:done", fastbootboot);
                    })
                  }

Then, comment out the error handling code, and replace it with the contents of the corresponding else condition. I've marked the modified lines below with **:

                 // If we can't find it, report error!
                  if (!recoveryImg){
                    bootstrapEvent.emit("error", "Cannot find recoveryImg to boot: "+images);
                  }else {
                    fastboot.boot(recoveryImg, p, (err, errM) => {
                      if (err) {
**                      bootstrapEvent.emit("bootstrap:done", fastbootboot);
**                      //handleBootstrapError(err, errM, bootstrapEvent, () => {
**                      //  instructBootstrap(fastbootboot, images, bootstrapEvent);
**                      //});
                      }else
                        bootstrapEvent.emit("bootstrap:done", fastbootboot);
                    })
                  }

Once you've saved this change, you need to compile the application. To do this on Ubuntu 18.04, you'll need the npm and libgconf2-4 packages. You can also just run setup-dev.sh which should set up your build environment for you.

Next, run npm run-script dist:linux (or dist:mac/dist:win, for whichever your platform is).

Finally, you can run the application with npm start. Now, ubports-installer will bypass errors at the point where the phone is required to be booted into recovery mode. This should allow you to proceed with the installation by manually putting your phone into recovery (hold power + volume up) when it prompts you to.

This is of course not a perfect solution, as anything that involves bypassing error handling code is generally a bad idea, but as a temporary solution is does the job.

Using Ubuntu Touch on the Meizu MX4 in 2019

On my Meizu MX4, Ubuntu Touch performs well, and the battery lasts a long time. The OS has all of the features required for general smartphone usage, especially the way that many technical/security-oriented people use their phone. However, if you are a big social media/app user, then you may have issues due to the lack of official apps for most platforms.

Ubuntu Touch is ideal for privacy and security conscious users, as well as those who like the convenience of having a fully capable native Linux device in their pocket. The fact that there is a native and unrestricted Linux terminal is also brilliant!

Things I'd Like to See

There are a few things that I'd really like to see in Ubuntu Touch, so I thought I'd document them here:

This article is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.