Friday, 1 December 2017

Linux on MINIX NEO Z83-4 and Z83-4 Pro

(update)

The final piece of the jigsaw is now in place for running Linux on the MINIX NEO Z83-4 and Z83-4 Pro devices with the mainline kernel now patched to support wifi, audio and bluetooth.

It has been an interesting kernel journey with:

v4.9 including the eMMC v5.0 driver required for accessing the internal storage
v4.11 including the HDMI audio driver.
v4.12 recognizing the BCM43455 wifi driver but suffered a regression with the release of v4.13
v4.13.2/v4.14 including a fix for BCM43455 wifi driver
v4.14 including a fix for the headphone audio driver
v4.15-rc1 now includes a fix for the bluetooth driver

However to run fully working Ubuntu on either device still requires additional steps.

Previously: The Canonical v4.15-rc1 mainline build was built using a patched config using default settings and does not include the changes required for including Intel ASoC Audio Drivers or the Serial Device Bus with serial drivers.

(previously)

So first it is necessary to create a new config and compile the kernel.

Update: The latest development kernel for Bionic ('unstable') now includes the required config changes and is available in the 'daily' Canonical build.

Then it is just respinning the official Ubuntu ISO using my 'isorespin.sh' script to add this kernel the compiled packages providing the latest kernel, the required UCM files and missing wifi firmware.

Unfortunately the most recent UCM file for the headphone audio driver isn't compatible so I've had to modify it specifically to work with these devices.

Also the wifi firmware file first needs to be extracted from the Windows installation where it is located at 'C:\Windows\System32\drivers\4345r6nvram.txt'.

Two additional files are required and they can be downloaded from:
and then rename 'MINIX-Z83-4_wrapper-linuxium-install-UCM-files.sh' as 'wrapper-linuxium-install-UCM-files.sh' and make it executable ('sudo chmod 755 wrapper-linuxium-install-UCM-files.sh').

Once everything is prepared the following respin command was used to create the Ubuntu ISO as shown above:

isorespin.sh -i ubuntu-17.04-desktop-amd64.iso -l "linux-headers-4.15.0-rc1-linuxium_4.15.0~rc1~linuxium_amd64.deb linux-image-4.15.0-rc1-linuxium_4.15.0~rc1~linuxium_amd64.deb" -f "linuxium-install-broadcom-drivers.sh wrapper-linuxium-install-broadcom-drivers.sh" -c wrapper-linuxium-install-broadcom-drivers.sh -f 4345r6nvram.txt -c "mv /usr/local/bin/4345r6nvram.txt /lib/firmware/brcm/brcmfmac43455-sdio.txt" -f HdmiLpeAudio.conf -c "mv /usr/local/bin/HdmiLpeAudio.conf /usr/share/alsa/cards" -f MINIX-Z83-4-chtrt5645.conf -c "mv /usr/local/bin/MINIX-Z83-4-chtrt5645.conf /usr/share/alsa/ucm/chtrt5645/chtrt5645.conf" -f MINIX-Z83-4-chtrt5645-HiFi.conf -c "mv /usr/local/bin/MINIX-Z83-4-chtrt5645-HiFi.conf /usr/share/alsa/ucm/chtrt5645/HiFi.conf"

isorespin.sh -i ubuntu-16.04.3-desktop-amd64.iso --atom -k daily \
-f 4345r6nvram.txt \
-c "mv /usr/local/bin/4345r6nvram.txt /lib/firmware/brcm/brcmfmac43455-sdio.txt" \
-f MINIX-Z83-4_usr_share_alsa_ucm_chtrt5645_HiFi.conf \
-f wrapper-linuxium-install-UCM-files.sh

At this stage it is still very early in the release cycle and there is still work to be undertaken to simplify the respinning of ISOs for these devices.

However the key point is that the mainline kernel now supports MINIX NEO Z83-4 and Z83-4 Pro devices. Meaning over time as various distros and OS migrate to the v4.15 kernel and later versions they should work flawlessly on them.

Please donate if you find my work useful using the following link http://goo.gl/nXWSGf.

33 comments:

  1. Hi Linuxium,
    I have some questions, some generic some other specific to my laptop:

    1. How can I apply the patch, that you install to the kernel during the isorespin process, in an already installed linux ?

    2. in your post you say that audio is working on 4.14 but it doesn't work for me. It didn't work also with the kernel that come from the isorespin process.
    [ 8.256512] bytcht_es8316 bytcht_es8316: ASoC: CODEC DAI ES8316 HiFi not registered
    [ 8.256526] bytcht_es8316 bytcht_es8316: snd_soc_register_card failed -517

    I don't know if this lines are related to the audio, but the word "CODEC" let me think that.

    I tried to copy UCM files from https://github.com/kernins/linux-chwhi12/tree/master/configs/audio/ucm/bytcht-es8316 and to put them in /usr/share/alsa/ucm/bytcht-es8316 but the results when I try it are:
    # alsaucm -c bytcht-es8316 set _verb HiFi set _disdev HSMic set _enadev IntMic
    ALSA lib main.c:432:(execute_sequence) unable to open ctl device 'hw:bytchtes8316'
    ALSA lib main.c:1698:(set_verb_user) error: failed to initialize new use case: HiFi
    alsaucm: error failed to set _verb=HiFi: No such device

    3. also touchpad doesn't work. The only reaction I obtained is moving 3 fingers on it. The reaction obtained is like ALT-TAB : switching by windows.
    4. no battery management

    Every suggestions is welcome.


    Thank you.
    Best regards.

    MaxC

    ReplyDelete
    Replies
    1. It is difficult to provide specific answers as you haven't specified your device nor included a 'dmesg' however:

      1. Respinning doesn't apply any patch to the kernel so what patch are you referring to?

      2. As the post is specific to MINIX NEO Z83-4 and Z83-4 Pro devices YMMV with the v4.14 kernel on different devices. Try editing the resultant file '/usr/share/alsa/ucm/bytcht-es8316' (see the comment on lines 135/136) and remove the comment hash ('#') from line 138 through to line 156 then reboot (if installed) or respin ISO with equivalent modification and post the result.

      3. Have you added the Silead touchpad driver or equivalent depending on your device?

      4. Dependant on device AFAIK at the moment.

      Delete
    2. This sound driver was put in to the script already so you should not need to download it

      Delete
  2. Hi Linuxium, you are my saviour! I had lost the hope of installing linux on the Minix but you helped me to regain it, thank you.

    Just one question: where can I find all the files you used to rebuild the ISO... I mean all .conf , because I can't find them even "googling".

    I would like to build an ISO based on Lubuntu or Peppermint.
    Are they preliminary or optional to make the distro works (wifi, audio, hdmi etc.)?

    Thanks in advance
    Gabriele

    ReplyDelete
    Replies
    1. Ok, I found all files in your tutorial except:
      1 - MINIX-Z83-4-chtrt5645-HiFi.conf
      2 - HdmiLpeAudio.conf (can I use the one on takaswie alsa-lib github?)

      Delete
    2. I'm still developing what is required to respin an ISO for these devices and will post a solution later.

      Delete
  3. Hello,
    It looks like you have put a great piece of work into getting Ubuntu running on this device. I notices in you example that you used Ubuntu 17.04, will this work also for Lubuntu 16.04.3, I am a newby on this respin process, and i will have to go through your tutorial here, but before I do this I would like to know the chances for success.
    Thanx in Advance for your inputs
    Regards
    Joe

    ReplyDelete
    Replies
    1. I'm still developing what is required to respin an ISO for these devices and will post a solution later.

      Delete
  4. Hello Linuxium,
    good job, but where can i buy or download the iso-image?

    CU mike

    ReplyDelete
    Replies
    1. At the moment I am waiting for Canonical to update their config used in the mainline builds however this is probably a low priority for them at the moment.

      Delete
  5. Does your script add support for using the TF port on the machine? No matter how I format my SD card, I can't get Linux Mint to recognize it.

    ReplyDelete
    Replies
    1. In the past there was a problem with SD cards depending on the kernel version and even with later kernels Sandisk SD cards still had problems. What kernel/SD card combo are you using?

      Delete
  6. A couple of questions:

    1. I wiped windows from my device before grabbing the firmware file. Is there another source for this?

    2. Is it really necessary to rebuild the kernel? I have no idea how to do that...

    ReplyDelete
    Replies
    1. 1. http://www.minixforum.com/threads/z83-4-windows-10-drivers.14297/
      2. Yes or wait for Canonical to patch their kernel (I've raised a request).

      Delete
    2. Linixium, you're fantastic for your work on this. My wearable robotics work is waiting on a functional Ubuntu install (Ideally 16.04 for ROS Kinetic) on my Minix, and because it relies heavily on wifi for non-emergency messaging the old no-wifi constraint is not workable.

      Is there anywhere specific we need to advocate for your fixes integration to be prioritized? I can point to a whole autonomous robotics class worth of minix Pros that are eagerly awaiting functional wifi, if it'd help!

      Also, in your post you mention having to modify the headphone audio driver, and your respin command references multiple files I am not finding available anywhere. While we wait for the changes to make it into mainline, is there anywhere I can find the various files you respun it with?

      Thank you, again!
      -Hani

      Delete
    3. If everyone adds to the 'bug' report (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1739939) that it 'affects me' the visibility will be improved.

      Once the kernel config is fixed I'll either release a specific 'MINIX-Z83-4-chtrt5645-HiFi.conf' or raise a CR for the existing UCM files depending on which way works the best.

      Delete
  7. When I run your script, I keep getting errors pertaining to files not being found. After Googling some of the names, I was able to grab a few of them, but when still cannot find the HdmiLpeAudio.conf file. Can you point me in the direction?

    ReplyDelete
    Replies
    1. As mentioned I'm still developing what is required to respin an ISO for these devices and will post a solution later. Currrently it is dependent on the config change to be made (see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1739939).

      Delete
  8. Hello, Linuxium

    I have a Z83-4, I just need to run the above steps, get the iso file and install you can get wifi, audio, Bluetooth? Thank you very much for your answer.

    Thanks,
    Hu

    ReplyDelete
    Replies
    1. Once Canonical update their config so the kernel works I'll retest and issue updated instructions.

      Delete
  9. I've updated the instructions with the files and commands that can be used to respin an ISO with working wifi, audio and bluetooth.

    ReplyDelete
    Replies
    1. Hey Linixium,

      First I want to say thank you. I am a total noob with this stuff and thanks to you it looks like i may be able to convert my z83-4 to a fully functional linux.

      Without knowing the difficulties I would run into, I wiped windows and installed the latest version of xubuntu on my device. I have been really enjoying the OS on the whole, but I found myself without headphone jack functionality, no wi-fi, no bluetooth, and most importantly to me, no ability to turn off my hdmi connected tv monitor without it freezing my computer on a blank black screen. The reason I know it's still running is that when i go to shut it down via the z83 button I see the xubuntu screen flash quick before the shutdown is completed.

      So I am a bit confused on the exact process I need to take here. Please Forgive my noobiness.

      1. I download this iso? bionic-desktop-amd64.iso

      2.I download your respin script - isorespin.sh

      3.I download the windows drivers which I see you have posted in the comments

      4. I download MINIX-Z83-4_usr_share_alsa_ucm_chtrt5645_HiFi.conf and
      MINIX-Z83-4_wrapper-linuxium-install-UCM-files.sh

      5. I then rename 'MINIX-Z83-4_wrapper-linuxium-install-UCM-files.sh' as 'wrapper-linuxium-install-UCM-files.sh' and make it executable ('sudo chmod 755 wrapper-linuxium-install-UCM-files.sh').

      6. Now I do not know how to run your script or to apply this

      isorespin.sh -i ubuntu-16.04.3-desktop-amd64.iso --atom -k daily \
      -f 4345r6nvram.txt \
      -c "mv /usr/local/bin/4345r6nvram.txt /lib/firmware/brcm/brcmfmac43455-sdio.txt" \
      -f MINIX-Z83-4_usr_share_alsa_ucm_chtrt5645_HiFi.conf \
      -f wrapper-linuxium-install-UCM-files.sh

      DO i do this in the terminal and point to the exact location of the isorespin.sh and the iso? I am a bit lost at this point.

      Thanks again for your help and patience.

      Thanks,

      Eric

      Delete
    2. I installed the xubuntu beta 18.04 and it works like a charm now. doh. thank you!

      -Eric

      Delete
    3. Do you understand the steps now? Step 6 above is how you run my script which you do in a terminal and use './isorespin.sh' rather than 'isorespin.sh' unless you've previously copied the script to '/usr/local/bin'. If you need the Windows file 'C:\Windows\System32\drivers\4345r6nvram.txt' then check the MINIX forums as MINIX has posted the firmware file in one of the comments.

      Delete
    4. Thank you, that does clarify things. However, I did not in fact respin the iso. I simply installed the given version of xubuntu 18.04 beta. The freeze sleep/hibernate screen problem was eliminated, the headphone jack is recognized, and the bluetooth is recognized (although was so bad as to not work at all with my bluetooth speaker. I never tested it when I had Windows 10 installed previously.) The only thing that hasn't worked is the wi-fi, understandbly. I now have the txt file, and have tried to tinker around a bit to try and apply it or put it in the right place to no avail. Its honestly of no consequence to me, though, since I am hard wired in. Thanks for your help!

      Eric

      Delete
    5. If you have the wifi file then simply copy it like 'cp 4345r6nvram.txt /lib/firmware/brcm/brcmfmac43455-sdio.txt' and then restart networking.

      Delete
  10. hi
    Thanx for all infos great work!

    "However the key point is that the mainline kernel now supports MINIX NEO Z83-4 and Z83-4 Pro devices. Meaning over time as various distros and OS migrate to the v4.15 kernel and later versions they should work flawlessly on them."

    I have installed Lubuntu 16.04.3 plus Mainline Kernel 4.15.3, Bluetooth works but not wifi. I understood that with kernel + 4.15 the respin should be not neccessary anymore, isn't it ?

    ReplyDelete
  11. I found out whats the problem the file brcmfmac43455-sdio.txt is missing in /lib/firmware/brcm/. The solution is to copy the file 4345r6nvram.txt from the Windows driver to /lib/firmware/brcm/ and rename it to brcmfmac43455-sdio.txt and reboot the device.

    ReplyDelete
    Replies
    1. The respin instructions above includes this step and another step to fix audio so respinning is still required unless you do these steps manually.

      Delete
  12. Hi Linuxium, I have a Z83-4,I want to use Lubuntu 16.03, but it seems the sound cannot work, any suggest?

    ReplyDelete
    Replies
    1. Can you post the output of your 'isorespin.log' together with a link to your booted 'dmesg'?

      Delete