v4 Kernel on MK902II

Forum to discuss the new MK902II LE RK3288 Quad Core Linux Mini PC.

Moderators: KEgg, twjordo, tatubias

v4 Kernel on MK902II

Postby thorkel » Sat May 16, 2015 10:00 am

I've managed to get a version of v4 kernel (based on the work the firefly guys have been doing) to boot on the MK902II LE.

Note - this is barely functional at the moment. Some things (such as X not working, networking problems, etc) I'll continue to look at. Some others (e.g. no wireless LAN) are a bit more problematic - no driver support at the present time in the (firefly modified) version of the mainline kernel. At the end of this, you'll have a console on HDMI. Networking seems to sort of work, but has some issues. It's a start!

On the plus side, whilst the firefly kernel is modified from mainline, it's much closer to mainline than the heavily modified v3.10 kernel the device comes with.

The instructions here are based on the Firefly work - see http://wiki.t-firefly.com/index.php/Firefly-RK3288/Mainline_Kernel/en

As described in the 'Modified 3.10 Kernel' thread,

http://rikomagic.co.uk/forum/viewtopic.php?f=21&t=7638

make a backup of the key partitions on the eMMC drive before proceeding with the rest of these instructions. With the backups, it's fairly easy to roll-back. Without them, you may have a device that's not easy to recover.

There are a few modifications and changes required to the instructions in the firefly link. I'll assume you're assuming the working directory described in that (~/proj/linux-rockchip).

I'm also going to assume you have the tools AND 3.10 kernel source installed from the 'Modified 3.10 Kernel' thread. That's mainly because that source contains a tool needed to build a new device tree image.

1. Download all the prerequisites in the 'Preparation' section of the firefly link.

2. Make sure you've instaleld rkflashtool as described in the 'Modified 3.10 Kernel thread' (the firefly thread refers to rkflashkit - it apparently does the same thing as rkflashtool, but I'm happier using the latter so that's what the instructions here will cover).

Copy the ramdisk (ramdisk.cpio.gz) that's been extracted from the 3.10 kernel boot.img, as described in the 'Modified 3.10 Kernel thread'. This file is probably unnecessary (and potentially problematic) given the difference in the kernel versions, but it's sufficient for now. I'll look at building something more fit for purpose at some point in the future.

From the firefly 3.10 kernel source that's been installed as per the 'Modified 3.10 Kernel thread', copy the resource_tool application from the source of that directory to /usr/local/bin. So:

Code: Select all
sudo cp <firefly_3.10_kernelsrc_dir>/resource_tool /usr/local/bin


3. The MK902II should be connected to your linux dev machine through a USB cable - this cable should be plugged into the 'target' USB socket on the MK902II (the USB closest to the MicroSD socket). Hold down the button wide a pin on the side of the MK902II using a paper clip or similar for several seconds (whilst the device is powered) to put it into its 'recovery mode' A

Code: Select all
sudo rkflashtool v


on your linux host should return successfully with a version number.

4. Back up the boot and resource images, plus the parameters file from your device by doing the following:

Code: Select all
sudo rkflashtool r boot > boot-original.img
sudo rkflashtool r resource > resource-original.img
sudo rkflashtool p > parameters-original.txt


5. Reboot the MK902II by doing

Code: Select all
sudo rkflashtool b


5. Follow the instructions for compiling and installing the U-Boot update from the Firefly link. Make sure you use the arm-eabi-4.7 toolchain (which should have been installed as per the instruction in the firefly link). So, set up the PATH to look for the 4.7 binaries.

I haven't checked if the U-Boot version the device comes with is new enough to boot the newer kernels. It could be this step is unnecessary. However, the install as per the link worked for me fine.

6. Kernel building is a little changed from the firefly link. The first few instructions are the same, so do the following:

Code: Select all
cd ~/proj/linux-rockchip/kernel
export ARCH=arm
export CROSS_COMPILE=$PWD/../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
make rk3288_firefly_defconfig
make -j4 zImage
make rk3288-firefly.dtb


Do not do the next two steps in the kernel build (the cat and mkkrnimg). Instead, do the following:

Code: Select all
cp arch/arm/boot/zImage ~/proj/linux-rockchip/
cp arch/arm/boot/dts/rk3288-firefly.dtb ~/proj/linux-rockchip/


Then build the modules as per the firefly instructions:

Code: Select all
make -j4 modules
[ -d install_mod ] && rm -rf install_mod
make INSTALL_MOD_PATH=$PWD/install_mod modules_install


Tar up the modules by doing the following.

Code: Select all
cd install_mod
tar cvfz ~/proj/linux-rockchip/4.0.0-modules.tar.gz lib/


7. Install these modules onto the running MK902II. So, scp these to the MK902II whilst it's running the old kernel. Log into it and do:

Code: Select all
cd /
sudo tar zxvf <path_to_tar_file>/4.0.0-modules.tar.gz
sudo depmod -a 4.0.0-rc1+


This ensures we'll have the modules properly installed.

8. Reboot the MK902II, and put it back into recovery mode by holding the button down by the wireless lan antenna for 5 secs.

Important - Remove any MicroSD card you have in your device. The new kernel seems to discover devices in a different order. This means the config described below below won't be able to find the root filesystem if the MicroSD is installed.

9. Build a new boot image.

Code: Select all
cd ~/proj/linux-rockchip
mkbootimg --base 60400000 --kernel zImage --ramdisk ./ramdisk.cpio.gz --pagesize 16384 -o ./boot-v4.img


10. Extract the files from the old resource-original.img

Code: Select all
mkdir tmp
cd tmp
resource_tool --image=../resource-original.img --unpack


This will create a directory called 'out' with two files in it.

11. Build a new resource image.

Code: Select all
cd out
cp ../../rk3288-firefly.dtb rk-kernel.dtb
resource_tool --image=../../resource-v4.img --pack logo.bmp rk-kernel.dtb


This builds a new resource image, but using the firefly device tree file from the latest kernel. This could be the cause of some of the problems when running on the MK902II (it's developed for a slightly different device), but it's necessary as the device tree file the device comes with is developed for the heavily specialised 3.10 kernel the device comes with.

12. Modify the parameters file so we can see the console.

One of the benefits of the mainline kernel is that it seems to handle HDMI initialisation better. That means we can have a console on the HDMI output, rather than on the serial connection.

So:
Code: Select all
cd ~/proj/linux-rockchip
cp parameters-original.txt parameters-v4.txt


then edit parameters-v4.txt and modify the CMDLINE line to remove the 'console=ttyFIQ0,115200' bit. That line should now read:

Code: Select all
CMDLINE:root=/dev/mmcblk0p4 rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(resource),0x00008000@0x0000A000(boot),0x00002000@0x00012000(misc),-@0x00014000(linuxroot)


13. Write these files down to the device:

Code: Select all
sudo rkflashtool w boot < boot-v4.img
sudo rkflashtool w resource < resource-v4.img
sudo rkflashtool P < parameters-v4.txt


14. Reboot, and you should get a text console on a screen connected to HDMI. If you've got a USB keyboard, that can be used to log in.

As I said before, you won't have X. Wired networking seems a bit weird. There's no WiFi.

You *should* be able to revert the changes by doing the following:

Code: Select all
sudo rkflashtool w boot < boot-original.img
sudo rkflashtool w resource < resource-original.img
sudo rkflashtool P < parameters-original.txt


However, this doesn't replace the newly installed UBoot. That UBoot does boot the old images on my install, but YMMV. Follow these instructions at your own risk!

As I make progress in getting some of the other bits up and running, I'll continue to post in this thread.

Thorkel
thorkel
 
Posts: 12
Joined: Sun Jan 11, 2015 6:27 am

Re: v4 Kernel on MK902II

Postby thorkel » Sun May 17, 2015 10:11 am

Some progress with wired networking. With the default device tree from the firefly build, I was getting a lot of packet loss. Whilst the mk902ii uses the same driver, some delays need to be set in the device tree to get it to work properly.

If you download and uncompress the file attached to this post, and place it in the <your-v4-firefly-kernel-checkout>/arch/arm/boot/dts directory.

Then, instead of doing make rk3288-firefly.dtb in the previous instructions, do:

Code: Select all
make rk3288-mk902ii.dtb


and copy the arch/arm/boot/rk3288-mk902ii.dtb file into the resource file directory as per the previous instructions (renaming as rk-kernel.dtb as you do). Then follow the rest of the instructions. This results in stable wired networking, at least for me.

HDMI not working is probably also a device tree issue. Not looked at that yet.
Attachments
rk3288-mk902ii.dts.gz
Update device tree.
(1.28 KiB) Downloaded 123 times
thorkel
 
Posts: 12
Joined: Sun Jan 11, 2015 6:27 am

Re: v4 Kernel on MK902II

Postby thorkel » Sun May 17, 2015 1:28 pm

Ok, HDMI and X *is* working with the config in this thread. The issue I had was that the fbdev detection of resolutions on the target display doesn't seem to be working. I've got my MK902II connected to a Sony 720p TV, and I need to explicitly create an Xorg.conf to get it to initialise.

So, I've created the following file:

/usr/share/X11/xorg.conf.d/15-mali.conf

and put the following in that file:

Code: Select all
Section "Device"
   Identifier "myfbdev"
   Driver "fbdev"
EndSection

Section "Screen"
   Identifier "My screen"
   Monitor "My Panel"
   Device "myfbdev"
   SubSection "Display"
      Virtual 1280 720
   EndSubSection
EndSection


Now have a MK902II, running a v4.0.0rc1 kernel, and with X and wired networking seemingly OK.

There are a few errors in dmesg on boot at the moment. These seem mostly to do with probing for various voltages as part of the sd/mmc driver. Doesn't appear to have any significant effect, but I haven't run my device for long yet.
thorkel
 
Posts: 12
Joined: Sun Jan 11, 2015 6:27 am

Re: v4 Kernel on MK902II

Postby thorkel » Wed May 20, 2015 12:39 pm

Few further notes to this:

- I don't believe the U-Boot upgrade step is necessary in the instructions above. It seems like the version of U-Boot the device comes with is sufficient for booting the newer kernels.

- The modification to the parameters file, that removes the console being outputted to the ttyFIQ0 device, is necessary to get the MK902II to boot - even if you don't care about the console. The serial devices appear to be named differently with the newer kernel, so that parameter causes boots to fail if you don't remove/change it.

- Whilst the firefly mainline kernel is at v4.0.0rc1, it's a fairly straight-forward git merge with mainline to get up to the full v4.0.0 release (one straightforward conflict to deal with). That's now installed and running on my MK902II. I'll look to post the merged tree on github if I get time.
thorkel
 
Posts: 12
Joined: Sun Jan 11, 2015 6:27 am


Return to Rikomagic / Cloudsto MK902II LE RK3288 Quad Core Linux Mini PC

Who is online

Users browsing this forum: No registered users and 1 guest