Firefly Open Source Community

Title: How To get your brand new RK3399 to actually boot linux. [Print This Page]

Author: rpk.firefly    Time: 5/13/2018 14:53
Title: How To get your brand new RK3399 to actually boot linux.
I've seen a few posts here by users figuring they have a defective unit.

Whenever they ask for help they are just pointed to some web page that's badly written with directions that don't work.

I'm not sure if a recent batch of FireFly RK3399's were shipped to people like me with only the Android image installed, whether the Quick Start > Starter Guide is just really out of date or there's a QC (Quality Cotroll) problem with the shipments.

My shiny new unit, booted up Android fine and I immediately wanted to boot to Linux as the Fly is advertised as being dual-boot.

(I personally have no interest in Android and will probably never use it and question why it's installed as the default boot, but someone must have figured that's what most users want.)

The problem is, if you follow Quick Start > Sarter Guide > Q1: How to switch to Ubuntu from Android - it will always boot to a black screen - because there is no Ubuntu pre-installed. Why on earth that option was set in Android if there is no Ubuntu partition to boot to is beyond me.

I've discovered that most of the documentation I've run across on the FireFly site is badly written and/or out of date. This is probably because quite a lot of it comes from the RockChip site. To make matters worse, there are so many versions of dev programs that probably originated at RockChip and ended up on gihub and gitlab and elsewhere.

Add to the list that Downloads pages such as the following for Firmware Upgrade Tool only have notes in Chinese. Two tools are listed there with different names and versions.

Anyway, let's hope FireFily do something about making this experience of purchasing one of their products enjoyable instead of painful.

Here's how I got linux installed on my Fly.

1.        I don't use Windows, so I had to install Linux on an old Mac Mini. I set it up for dual boot.

2.        Download an Ubuntu Linux image file onto your Linux host machine.

        There were a couple listed around here, somewhere I dound and downloaded the one named:
                Firefly-RK3399-ubuntu16.04-20180416112819.img

        which unpacked (tar xzf) to
                Firefly-RK3399-ubuntu16.04-20180416112819.img

3.        Download both of the upgrade tools from Download > Tools > Firmware > Linux to your host
        linux machine:

                Linux_Upgrade_Tool_v1.24.zip
                upgrade_tool_v1_26.tar.gz

4.        Untar/Unzip each in a separate directory.

        Name the directories something like:

                ut-v1_24
                ut-v1_26

        Unzip Linux_Upgrade_Tool_v1.24.zip         in ut-v1_24
        Untar upgrade_tool_v1_26.tar.gz                        in ut-v1_26

        The v1.24 probably works, but I used the v1_26.

        (There is also a v1_33 on RockChip's github area that I found later on, but I haven't
        tested it).

5.        The compressed tar file upgrade_tool_v1_26.tar.gz is missing an important file called
        config.ini, so copy if rom the ut-v1_24 directory to the ut-v1_26 directory.

        You can also create your own config.ini with the following lines:

                firmware=
                loader=
                parameter=
                misc=
                boot=
                kernel=
                system=
                recovery=
                rockusb_id=
                msc_id=

6.        I made a symbolic link in the v1_26 update_tool directory to the image file that I'd downloaded
        in step 2 to make life easier. I called it 'update.img' because that seems to be the norm.

        So in the v1_26 directory:

                ln -s ../path/to/Firefly-RK3399-ubuntu16.04-20180416112819.img        update.img

        (Be careful, if you're new to using 'ln -s' it's easy to nuke the source file if you swap the
        source and target names)

7.        Make sure your FireFly RK3399 is powered up.

        Plug in the USB -> USB-C cable between your linux host and the FireFly and then
        get it into loader mode:

                Press and *hold* the Recovery button (left hand side)
                Briefly press and release the Reset button (right hand side)
                Wait a second and release the Recovery button.

8.        Fire up upgrade_tool in the v1_26 directory. it should give a list of connected
        devices, yours is likely to be 1, so type 1 and press return:

        sudo ./upgrade_tool

        List of rockusb connected
        DevNo=1        Vid=0x2207,Pid=0x330c,LocationID=107        Loader
        Found 1 rockusb,Select input DevNo,Rescan press <R>,Quit press <Q>:1

        ---------------------Tool Usage ---------------------
        Help:             H
        Quit:             Q
        Version:          V
        Clear Screen:     CS
        ------------------Upgrade Command ------------------
        ChooseDevice:        CD
        SwitchDevice:        SD
        UpgradeFirmware:        UF <Firmware>
        UpgradeLoader:        UL <Loader>
        DownloadImage:        DI <-p|-b|-k|-s|-r|-m image> [parameter file]
        DownloadBoot:        DB <Loader>
        EraseFlash:        EF <Loader|firmware>
        LowerFormat:        LF
        ----------------Professional Command -----------------
        TestDevice:        TD
        ResetDevice:        RD [subcode]
        ResetPipe:        RP [pipe]
        ReadFlashID:        RID
        ReadFlashInfo:        RFI
        ReadChipInfo:        RCI
        ReadSector:        RS  <BeginSec> <SectorLen> [-decode] [File]
        WriteSector:        WS  <BeginSec> <File>
        ReadLBA:        RL  <BeginSec> <SectorLen> [File]
        WriteLBA:        WL  <BeginSec> <File>
        EraseBlock:        EB <CS> <BeginBlock> <BlokcLen> [--Force]
        -------------------------------------------------------

        Now  just run the UpgradeFirmware command with the name of the image file:

        Rockusb>uf update.img


        Once it's done uploading, type 'Q' to quite.

9.        Reboot the FireFly - you can probably just press and hold the Reset button (right hand side)
        for a second and let go.

10.        With some luck, you will boot into Linux.


I'm very impressed with the built quality of my FireFly RK3399. It's just such a pity that support and documentation are so poor.

Case in point, next I want to install the rootfs (linux) onto my Samsung T5 portable SSD just plugged into the USB 3.0 port. It can average about 350 MB/sec versus 40 MB/sec on the eMCC.

I've been able to unpack the image file above and alter the parameter file to use /dev/sdaX,  but I've been unable to re-pack things together. It's frustrating as hell and really shouldn't be.


Author: kimkk    Time: 5/14/2018 10:44
@rpk.firefly
Thanks for your kind sharing the information.

Unfortunately,  In my case, RK3399 MAX (wtih 4GB/128GB) refuse to enter the so called upgrade mode with Recovery (hold) - Reset - Recovery (release) sequence.

I have tried MASK ROM mode but only to fail.

I expect your information on rootfs (linux) onto my Samsung T5 portable SSD just plugged into the USB 3.0 port.
It would be super solution for relatively slow EMM.

Cheers

Cheers

Author: rpk.firefly    Time: 5/15/2018 15:31
kimkk Posted at 5/14/2018 10:44
@rpk.firefly
Thanks for your kind sharing the information.

Sorry to hear about not getting into a loader mode.

Were you able to initially boot and it came up with Android?


Author: rpk.firefly    Time: 5/15/2018 15:55
I've made some headway on re-packing the image file.

All the examples I've come across from this site and RockChip are extremely messed up. The toolsets are included in parent folders named 'rktools' and 'rockdev'. The two main programs there are 'afptool' and 'rkImageMaker' - however the scripts set up to pack/unpack are badly written as far as pipeline is concerned. Also the 'package-file' is some generic default and won't work until you fix it. Kinda lame.

I partitioned the Samsung T5 with 3 standard partitions (my reasoning was I could always
plug the drive into another box after modding the EFI partition):

EFI - 500MB (sda1)
swap - 500MB (sda2)
rootfs - remainder (sda3)

and modified the CMDLINE to use root=/dev/sda3 in the parameter.txt file.

Everything uploaded fine, but didn't boot to the disk. I'm not sure yet if I need to clear the eMMC flash first.

Anyway, I've reloaded the old image file, and I'm just going to format the drive with a single partition and try that.

I'll post some sensible instructions if/when I get this all sorted out.

I hope that when China puts a bunch of dudes in a rocket to the Moon they're not using RockChip or FireFly software
and instructions [hah!]

Author: rpk.firefly    Time: 5/15/2018 20:05
I had to jump through some hoops, but I was able to get Linux installed and booting the FireFly on the Samsung T5 SSD via the USB 3.0 port.

I'm going to repartition the drive tomorrow and add swap and a general filesystem so that I can run the gnome_disks benchmark (you can't run it on a partition that's running the system).

I'll post instructions later.

Author: rpk.firefly    Time: 5/16/2018 14:40


Here's a benchmark made with gnome-disks on a partition of a Samsung T5 portable SSD mounted via the USB 3.0 port on the FireFly RK3399. The FireFly was running Ubuntu 16.04 and booted from a different partition on the same drive.

Average Read Rate is 373.3 MB/s and Average Write Rate is 381.4 MB/s.

Tied with the 10/100/1000 based ethernet port, this model of the "Fly" has the potential of being a cool little server.




RockChip, the suppliers of the main chipset in the RK339 state on their website that the unit can have the boot (kernel) and the rootfs mounted via a USB device, however I haven't located documentation of the FireFly site yet as to how to specify a USB based partition for boot.

Unfortunately there appears to be a bug in the current firmware when the RK3399 is in the firmware update mode. It should be possible to upload the linuxrootfs.img portion of the update.img to an external USB device. The program update_tool does not give any errors when an upload is made, but the image does not get installed.

I realized later that there is no power on either the USB 3.0 or the USB 2.0 ports when the unit is in the update mode.

I used gnome-disks to install the linuxrootfs_normal.img (extracted from the update.img package with unpack.sh in the RockChip rockdev utilities) to a partition and then ran resize2fs to utilize the full partition size.

It occurred to me that if you are running Linux (as opposed to Windows) on the machine that you are uploading to the FireFly from, you can manage all the partitioning and installation of the linuxrootfs.img on that machine instead of the FireFly.

I haven't looked at the Android image installation process, but I assume you could have multiple Android images pre-installed on their own partitions too.

I formatted this drive with an 500 MB EFI partition (you do not need that) followed by a 5.5 GB linux-swap partition, then two 100 GB ext4 partitions to load different versions of Ubuntu onto.

I haven't looked at configuring the swap partition yet, but I assume it won't be hard and it will 9-10 times faster than using the onboard eMMC Flash memory.

The really cool part of the process is how simple it is to switch the boot partitions on the FireFly.

First of all, you should install a full update to the onboard eMMC Flash so that you can always switch to it as the main boot if you need to as a safety precaution (or I assume load Android onto it).

After that, it's really simple to switch to partitions on a USB drive for startup. You start by putting the FireFly into update mode via the Recovery-Reset-Recovery button combination and run the upgrade_tool application on the other computer.

You just need a simple text file specifying the boot partition and use upgrade_tool to upload that file with the command (after you've selected the FireFly):

  1. di -p parameterFileName
Copy the code



Here's an example, just set the root=/dev/sda(number) to the partition number on the USB drive that has a linuxrootfs installed - in this example I have a rootfs installed on /dev/sda3:

  1. CMDLINE: console=ttyFIQ0 root=/dev/sda3 rw rootwait mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00008000@0x00006000(resource),0x0000A000@0x0000E000(kernel),0x00002000@0x00018000(backup),-@0x0001A000(boot)
Copy the code



To switch back to the eMCC root partition, you can have another text file that specifies /dev/mmcblk1p6 as the partion to use for the rootfs and send that once again with upgrade_tool:

  1. CMDLINE: console=ttyFIQ0 root=/dev/mmcblk1p6 rw rootwait mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00008000@0x00006000(resource),0x0000A000@0x0000E000(kernel),0x00002000@0x00018000(backup),-@0x0001A000(boot)
Copy the code



If you have any questions, just leave a reply here and I'll get back (it might be a day or so).

I've been making lots of screenshots, so at some point I can write something more in depth about the whole process.


Author: phi    Time: 5/24/2018 15:57
HI Rpk
Just ordered a Firefly-RK3399 , I guess it will takes sometime to get it, but as soon as I get it I will try to load debian/ubuntu on it... will see
Cheers

This post is useless, I try it here to see how this forum works

Author: phi    Time: 5/24/2018 15:58
Ok it works

Author: rpk.firefly    Time: 5/25/2018 06:34
phi Posted at 5/24/2018 15:57
HI Rpk
Just ordered a Firefly-RK3399 , I guess it will takes sometime to get it, but as soon as I g ...

Hi phi,

feel free to ask questions if you run into problems and I'll help if I can.

I only check the forums a couple of times a week though.

I really need to spend time on writing up some decent step by step instructions on installing
Ubuntu as I've personally found the FireFly documents and the RockChip utilites somewhat
lacking.

Good luck with your new unit.

I'm actually pretty impressed with it so far but also frustrated at times on the absence of
decent documentation and support.




Author: phi    Time: 5/25/2018 13:53
rpk.firefly Posted at 5/25/2018 06:34
Hi phi,

feel free to ask questions if you run into problems and I'll help if I can.

Hi Rpk,
Cool, I will volunteer to review your install process and may be add some infos to it

If you want to send me preview, or if you have a git repos don't hesitate to send at
phi dot debian at gmail dot com

Cheers,
Phi
Author: jpboard    Time: 5/25/2018 20:23
I tried the how to on flash image page and could not get PC or android tool to see it,
but found the how to on boot mode page http://en.t-firefly.com/doc/product/info/265.html
was different and worked to put board into loader mode and then PC saw it and android tool
worked to install to emmc
Author: mcdane    Time: 6/3/2018 05:06
Hi guys

You finally saved my day! I flashed my RK3399 with latest ubuntu from the boards offical google drive repo:

https://drive.google.com/drive/f ... ewKCmYIH-vU_tSjEKvL

However, I just realize that for example Youtube videos are lagging and even normal websites with text and images are loading not as fast as it did on Android as inital setup when I got the board running the first time. Everything just loads a bit slower and seems to be laggy.

Do I have to install any drivers or enable something to have the whole hardware capacity?
It cannot be that such a powerful board is not able to handle all that stuff, right?
Author: rpk.firefly    Time: 6/3/2018 09:25
Last edited by rpk.firefly In 6/3/2018 09:36 Editor

Hi mcdane,

I haven't logged in for a while, and just saw your post.

Although it's on my list, I haven't messed with compiling ubuntu or the kernel yet. In looking at the FireFly Ubuntu build destructions, I don't see any mention of the 'extras' that appear to be in the FireFly Ubuntu image, so I would assume devices/drivers will be missing for the framebufer and hardware codecs.
I have a feeling there should be more drivers somewhere. In my /dev/dri/ from the FireFly image, I see:

card0
controlD64
renderD128

but they could just be a default for a Linux install, I'm not sure.

[ edit, I just checked on the Ubuntu install on my older Mac Mini, which has card0 and renderD128, so yes they're part of the standard install ].

I do see /dev/mali0 on the FireFly though, which would be RockChip. It's possible that's part of the debian default installer for Arm processors, afraid I don't know for sure.

I bet that without proper framebuffer support a regular Linux install will be slow as the defaults won't utilize hardware acceleration.

Speaking of which, I never could get ffmpeg compiled to use the hardware accellerators, I probably need another package installed or compiled. I bet it needs to be in /dev/dri. I also messed with gstreamer a little (it's in /opt in FireFly's ubuntu image) and found it to be a convoluted mess in true Linux fashion, however I was able to use the decoder chip for playback.

btw. I found rkflashtool to be sort of flakey sometimes. I've found 'upgrade_tool' to be pretty good for installs. It just needs that config.ini file which is missing from one of the FireFly images.

I just tried your google drive link, but it throws an error for me, no doubt because I block many google domains due to them being low-life, bottom-feeding scum when it comes to user privacy. I personally avoid any google products (or FaceF*ck etc.) because I don't find them to be trustworthy companies.

[edit - I forgot to mention that there are 2 ubuntu images I found via the FireFly site, the 'xubuntu' one is older and I only loaded it once, anyway here's the names of the downloaded files (I'll try a search and update if I locate the links again):

Firefly-RK3399_xubuntu16.04_20180412.7z

Firefly-RK3399-ubuntu16.04-20180416112819.tgz

]



Author: enrogued    Time: 6/5/2018 00:06
Regarding the graphics acceleration - I think you might also see errors for missing rockchip_dri.so on the console like I do. The rockchip/teechip trees have the mali drm driver included but are missing the component needed for full accelerated X

On the subject of building your kernel - I have successfully built my own kernel with KVM enabled (work project) & it appears to run fine - I'll need to do it again to enable everything needed for LXD, so I'll report back again on the results

I used a previous version of the instructions that required you to grab their precompiled build tools & the only thing missing from the instructions then was the requirement to point at the correct path

I'm now investigating an issue where the pcie controller doesn't seem to be on (nothing from lspci) whether there is an M.2 card plugged in or not - I've read elsewhere that it may be a device tree thing, so I guess I'll be digging in to which dts file it's using

If anyone has experience with bringing up an M.2 card I'd appreciate any pointers you may have


Author: phi    Time: 6/9/2018 04:01
Hi Rpk and All

Well, I am hitting the same wall, bought this board with linux in mind (ubuntu is fine), don't care about android and my host is an ubuntu 16.04 with a valid cu(1) connection to the senial usb (dunno if I need that)

I can't find what image to download for ubuntu I did grab that
https://drive.google.com/drive/f ... gAqAdXBsaG9NMEl5bm8

This is an ubuntu image unable to say if it is an update image or a partition image.

I don't really know how to proceed from there, the RK3399 page seems to say  

You can download firmwares on [compiled update.img], uncompress them after download.
with [complied update.img] pointing to http://en.t-firefly.com/en/firenow/Firefly_RK3399/download/
But it goes cockoo and redirect to some marketing things.

So basically I am stuck there, still browsing the net to find out how to install ubuntu on this board.

Any pointers appreciated

Cheers,
Phi



Author: phi    Time: 6/9/2018 13:34
Hi All,

I succeeded to load ubuntu from RPK receipe

Got the kernel here
https://drive.google.com/drive/f ... gAqAdXBsaG9NMEl5bm8

update_tool with symlink didn't worked for me so ran it with the real name
sudo ./upgrade_tool uf ../Firefly-RK3399-ubuntu16.04-20180416112819.img

Then the USB type C I used my samsung T5 cable for that, and did the recov/reset sequence.

So from there I can work.

Cheers,
Phi


Author: robodan65    Time: 6/10/2018 07:54
This work for me.  Thanks!

I got kernel 4.4.77 #329.  It doesn't appear as a linux-image package or seem to have any modules built for it.

I see there is a 4.15.0 version of linux-image available as a package.  Can I install a packaged linux, or to I have to stick to the pre-installed kernel?

Dan

Author: enrogued    Time: 6/11/2018 15:29
The packaged linux image from ubuntu won't work, you can either use the firefly/rockchip kernel (4.4.77) - you can recompile & extra modules for that, or you can try & go down the route of building a stock upstream kernel (someone has posted a method for 4.16 here https://github.com/VenKamikaze/f ... rking-4.16-rockchip )
Author: kimkk    Time: 6/12/2018 09:30
Last edited by kimkk In 6/12/2018 09:31 Editor
rpk.firefly Posted at 5/15/2018 15:31
Sorry to hear about not getting into a loader mode.

Were you able to initially boot and it came ...

Thanks for your care.
The boards were initially booted with Android well.

I send back boards and get them fixed.
After that, I successfully flashed ubuntu images out with instructions as you provided.

It might be problem of board themselves.

If someone experience similar problem, it would be better to send back problematic board to firefly and get them fixed it.
Cheers !!

Author: Pschae    Time: 7/30/2018 16:49
Hello rpk.firefly
Great tutorial: it lead me straightforward into Linux.
Thanks a lot for sharing.




Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) Powered by Discuz! X3.1