olegk0 / rk3x_kernel_3.0.36

3.0.36 kernel for rockchip rk3066, mk808 (RK901 wifi)
Other
4 stars 4 forks source link

Kernel not booting on MK808B Mediatek chip #3

Open donluca opened 2 years ago

donluca commented 2 years ago

I've tried to flash the pre-compiled kernel found in the "last" folder on your Google Drive ( https://drive.google.com/drive/u/0/folders/0B6QRwjacGTzCU3RWZ1M2d1FkcTg?resourcekey=0-bcGMLpMPQ_6qfxDbL8GLiw ) to the recovery partition of my MK808B (a newer clone made by TEAN using the Mediatek MT5931, Bluetooth v2.1: Mediatek MT6622 – more information and pictures here: https://forum.freaktab.com/forum/tv-player-support/rk3066-devices/mk-models-mk808-802-etc/11472-help-mk808b-clone-not-working-noob?p=232438#post232438 ).

The process of writing to the recovery partition goes well, but when I boot into Android and restart to recovery, I just get a black screen.

I've dumped the firmware and it's pretty strange: it loads the kernel from within boot.img and disregards the one in the kernel partition (as a matter of fact I've tried deleting the kernel partition and it still boots into Android fine). The loader is different from the older ones (even the clones) which generally used the RK30xxLoader(L)_V1.xx.bin. This one works with the RK30xxLoader(L)_V2.xx.bin (I'm using the latest one available on https://github.com/neo-technologies/rockchip-bootloader which is 2.15, the stock loader on the firmware was 2.13).

Here's the dump of the firmware, I've also unpacked it so you can take a peek inside: https://drive.google.com/drive/folders/1HHljDCRI2OeuUaDbQx9EdmT63vOO8Axi?usp=sharing

I've tried using lots and lots of different boot.img and none work, only the original one with the kernel inside it.

Any help would be immensely appreciated, I'd love to use this with Linux!

olegk0 commented 2 years ago

it was a long time ago

it seems you need to flash recovery.img into the kernel and recovery partitions

this kernel does not support MK808B

https://www.slatedroid.com/threads/ubuntu-12-10-_-mk808-v1-0-rootfs-img-hw-mali400.63658/

donluca commented 2 years ago

Thanks for the reply.

For now I'm just trying to have Linux booting. Having wireless/bluetooth up and running will be another step.

I've tried flashing recovery.img to both kernel and recovery partition but it didn't change the result.

I have also tried the kernel in this thread: https://www.slatedroid.com/threads/pre-alpha-0-3-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1.41654

It says that it has been tested and working with the UG007 which has the same hardware as my MK808B, but unfortunately it didn't work either.

I'm looking inside boot.img from other ROMs (such as Finless) and they are very different. It looks like they just have the ramdisk inside without any kernel (which is probably loaded from the kernel partition).

Is the bootloader responsible for what needs to happen in boot.bin and what it needs to have inside?

Is it possible that the new 2.xx bootloader expects a boot.bin to have both the kernel and the ramdisk arranged in a certain way? That could explain why no other ROM work on this MK808B: all the other ROMs use 1.xx bootloader with boot.img having only the ramdisk + separate kernel in kernel partition.

Please let me know if you can remember anything about something simillar.

donluca commented 2 years ago

Well, I stand corrected: following this guide on how to build a working image for a Rockchip powered board, it looks like boot.img is actually required to have both the kernel and the ramdisk: https://wiki.radxa.com/Rock/Booting_Linux

I think I'll try to make my own boot.img by using both the compiled kernel and the ramdisk you provided on your Google Drive and flash that to boot.img and see what happens.

olegk0 commented 2 years ago

another guide http://cobecoballes-embedded.blogspot.com/2013/08/writing-image-from-mk808rk3066-in-linux.html

I don't know about the bootloader version

very old topic

donluca commented 2 years ago

I think I understood what happened and why I'm unable to boot anything but the original firmware/kernel on this thing.

It looks like that with 2.xx Loader, Rockchip switched to U-Boot and so the ROMs had to be changed how they were loaded. Theoretically speaking, having U-Boot should make Linux booting easier but my knowledge is very limited in that.

~~My last attempt, for now, will be trying to flash an older 1.xx Loader although I'm pretty sure that will result in a brick. But if it works, then I should be able to load all the older kernels, yours included.~~

IF YOUR BOOTLOADER IS 2.XX DO NOT DOWNGRADE TO 1.XX OR YOU'LL BRICK YOUR DEVICE!! Luckily it is not the end of the world, you can still recover by shorting the pins 8 and 9 of the NAND chip and connecting it to the usb port of your PC while keeping those two pin shorted (it can be quite tricky). RKAndroidTool will find your MK808 in Mask ROM mode and you'll be able to flash back a 2.xx bootloader.

I'll keep this thread updated should anyone find this via Google and is willing to help/contribute.

olegk0 commented 2 years ago

if problem is in bootloader (uboot mode) i think need find tutorial that describes how to prepare raw kernel for use with uboot

i add file zImage in my google drive folder (for test)

donluca commented 2 years ago

Thank you for the zImage.

Unfortunately there's just no way to make your kernel boot and the lack of a serial console to see what's happening is truly infuriating.

I think I'll have to put all of this on hold until I can find where the TXD serial pin is on the board so I can see what is causing your (and others) kernel to not boot/crash.

The most I managed to get is with alok's 3.0.8+ kernel which manages to reach a point where it enables the HDMI output for a millisecond before a kernel panic and a reboot.

I managed to grab a screenshot by hooking the TV stick to my HDMI capture card just in time:

Schermata 2021-11-10 alle 18 00 14

That LZMA data is corrupt makes me think that it's trying to read data from the wrong region and is unable to move forward.

I'll get back to you when I'll be able to get a serial console on this thing to understand better the boot process and what it is expecting in order to boot at least into the initramfs.

olegk0 commented 2 years ago

kernel doesn't seem to find initramfs or initramfs not in LZMA

donluca commented 2 years ago

Managed to find the damn TXD pin, now we're talking!

This is what happens when I try to boot your kernel:

Starting kernel...@0x60408000
Uncompressing Linux... done, booting the kernel.
DDR Version 1.04 20140217
In
SRX
DDR3
300MHz
Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
OUT
BUILD=====2
No.1 FLASH ID:98 de 84 93 72 57
OK! 544159
unsigned!
SecureBootEn = 0 0
Boot ver: 2014-06-27#2.15
start_linux=====553363
 2370522 Starting kernel...@0x60408000

Uncompressing Linux...

Compressed data violation

 -- System halted 

It looks like there's definitely some issue with how the kernel (or maybe the initramfs?) is decompressed. I don't know if the "Unsigned!" thing might be an issue, I can definitely sign your kernel using rkcrc if needed, but I'm not sure if that's going to make a difference.

Here I used your recovery.img from the "last" folder in your Google Drive.

From here I guess it's all guesswork. I will try to make a new recovery.img following Rockchip's guidelines and see what happens, now that I have a proper output I think I can debug this.

olegk0 commented 2 years ago

almost a similar problem https://github.com/rockchip-linux/kernel/issues/75

yes, need make new recovery.img

my recovery.img make with cmd ./mkbootimg --kernel zImage --ramdisk ramdisk.gz --base 60400000 --pagesize 16384 --ramdiskaddr 62000000 -o recovery.img

ramdisk.gz - fake ramdisk

donluca commented 2 years ago

I tried rebuilding the recovery.img following the link you posted but unfortunately I got the same result.

It looks like it doesn't like the integrated initramfs in the kernel, or at least I think that's where the issue is.

I wonder if it would be best at this point to try and start "fresh", maybe using mainline kernel or the proprietary Rockchip kernel https://github.com/rockchip-linux/kernel

I think something changed at some point in Rockchip boards with the introduction of the 2.xx bootloader which changed significantly how they worked.

The problem is that all I can find is for Marsboard RK3066 which is probably very different from the MK808B, I wonder if I can find a way to adapt it...

donluca commented 2 years ago

Finally I've made some progress: without having to compile an entire kernel from scratch, I've found one that finally works and it's this fork of Gallard's kernel: https://github.com/usumfabricae/Linux3188 (it says 3188 but it's for 3066 as well).

There are some compiled binaries in another repo but the issue is that it's unbelievably unstable: sometimes it would crash without even arriving at unpacking the kernel, other times it would reach the busybox and sometimes it managed to boot all the way to the login prompt (edit: and crash slightly after, even when doing nothing).

This looks like the kind of behavior I get from CPU/RAM not working at the correct frequency/voltage and I can't help but think if my stick needs some strange settings to make it work properly.

I'll keep documenting my findings but at this point I think that I'll go ahead and try to compile that particular kernel and see if I manage to get anywhere.

If I don't then I'll try Rockchip's own kernel and finally mainline.

donluca commented 2 years ago

Found it!!

The issue is that for whatever reason the DDR RAM is initialized in the .config file at 400Mhz but the bootloader explicitly says that it's 300Mhz!

I've recompiled the kernel with the correct DDR frequency and now I'm able to at least reach initramfs and play around without having random crashes happening.

Now I need to understand why I'm unable to boot from USB and try and create a minimal rootfs on the only SD Card I have around which is, sadly, just 256MB, so it's going to be a tight squeeze!

olegk0 commented 2 years ago

Great

probably some 808B versions have cpu voltage regulators and my kernel version doesn't support that

donluca commented 2 years ago

I've found a very interesting document about how DDR is managed in Rockchip SoC with some examples of rk3066: https://usermanual.wiki/Document/RockchipDeveloperGuideDDREN.583134866/html

I'll be studying this because while I'm now able to boot to initramfs (and even into a small linux rootfs on my 256MB SD Card), I've noticed that there's still some instability: from time to time there will be pagefaults and after a certain amount the system won't be able to cope with them and either hang or reboot.

I think this explains the issue with the LZMA decompression I spoke of earlier: the issue is not in the bootloader, but I believe there's something off with the RAM configuration which slowly corrupts the data over time and causes all sort of random issues.

EDIT: and to add, you're probably right that there's some kind of issue with the voltage regulator. I've read in the logs that it tries to use the TPS65910 but it seems like it can't find it (or maybe the GPIO pins are misconfigured, who knows), but on the pull request I've linked before seems to add support for another regulator, WM831x, which might be the one I have on this board, although I can't find it anywhere... everything is so small you can barely read what's etched on each chip.

donluca commented 2 years ago

I've made some progress and discovered that all the kernels I've tried so far (yours included, I believe) are originated from omegamoon's work here https://github.com/omegamoon/Rockchip-GPL-Kernel Unfortunately he/she decided at some point to apply some fixes to DDR timing which might have worked for the MK808B, but completely messed up my (possibly others?) board.

After lots of trial and error I gave up on that kernel and found a "vanilla" one here: https://github.com/BalintBanyasz/kernel_rockchip

This looks like exactly the one leaked and worked perfectly, I didn't have a single stability issue.

The other issues I had, unfortunately, were that apart from the USB, SD card and HDMI output, nothing else is recognized. No NAND (I have no mtd devices on /dev/ ), no Wi-Fi, no Bluetooth... which means that I'll have to work with other people's kernel (most likely Galland's) to integrate their changes into this kernel to finally have a fully working kernel with NAND, Wi-Fi and Bluetooth.

Yaksinikos commented 9 months ago

I've tried to flash the pre-compiled kernel found in the "last" folder on your Google Drive ( https://drive.google.com/drive/u/0/folders/0B6QRwjacGTzCU3RWZ1M2d1FkcTg?resourcekey=0-bcGMLpMPQ_6qfxDbL8GLiw ) to the recovery partition of my MK808B (a newer clone made by TEAN using the Mediatek MT5931, Bluetooth v2.1: Mediatek MT6622 – more information and pictures here: https://forum.freaktab.com/forum/tv-player-support/rk3066-devices/mk-models-mk808-802-etc/11472-help-mk808b-clone-not-working-noob?p=232438#post232438 ).

The process of writing to the recovery partition goes well, but when I boot into Android and restart to recovery, I just get a black screen.

I've dumped the firmware and it's pretty strange: it loads the kernel from within boot.img and disregards the one in the kernel partition (as a matter of fact I've tried deleting the kernel partition and it still boots into Android fine). The loader is different from the older ones (even the clones) which generally used the RK30xxLoader(L)_V1.xx.bin. This one works with the RK30xxLoader(L)_V2.xx.bin (I'm using the latest one available on https://github.com/neo-technologies/rockchip-bootloader which is 2.15, the stock loader on the firmware was 2.13).

Here's the dump of the firmware, I've also unpacked it so you can take a peek inside: https://drive.google.com/drive/folders/1HHljDCRI2OeuUaDbQx9EdmT63vOO8Axi?usp=sharing

I've tried using lots and lots of different boot.img and none work, only the original one with the kernel inside it.

Any help would be immensely appreciated, I'd love to use this with Linux!

Hi, searching for about 3 weeks I for every possible ROM over the net, I found about 20 zips and just four worked out for my Android Dual Code A9 TV Stick. Sadly I did not save my original Stock firmware, with was a R-BOX "update_v409j2404_overseas.img", named "BUILD NUMBER: rk30sdk-eng 4.2.2 JDQ39 eng.zs.20140311.160622 test-keys​". It works with Kernel 3.0.36+ and has Mediatek MT5931SA as well as MEDIATEK MT6622N modules.

The original stock firmware is only available on two websites in the internet and both are not possible to download, the one seems like a scam website, the other is only limited to china residents.

I also found: T005_T011_public_root_8723_20141029_V4.4.img T005_public_8723_20141230_V1.0.img E809 Xing update.img those three are possible to run on my device, but than it does not support bluetooth and wlan, but yours recovered my functionality to run wlan and bluetooth.

Do you have actually the same Stick, I would really like to know, what device it is, how it is versioned. As nor in any ROM, nor on the Board itself there is not "MK808/MR806/MK808B" listed.

MB: HTC-T011-V4 2014-02-18 CPU: Rockchip RK3066 ANGW734 1326 (Dual or Quad Core - Idk) BEB15 -15E F1332 MEDIATEK: MT6622N _GAL _6558 (8723) MEDIATEK MT5931SA 1314_BMJH BTPKU610 892 MB RAM 8 GB Intern Storage ROM/VENDOR SOFTWARE VERSION: RK3066_R-BOX_ANDROID4.2.2-SDK_V1.0.0_130308 SERIAL NUMBER: R9RMT5F58V MODEL NUMBER: rk30sdk

I found out that the only CWM working on it is the MK806_CWM.zip, but it has some issues regarding the boot of misc.img.

I would really like to build up a working kernel for it and recreate a new ROM, with the newest drivers, Loader and so on. Actually I am assuming, that Kernel 4.4 will not work out, as someone has written, that is does not support rk3066, though it is written on the rockchip wiki.

Rockchip kernel 4.4 supports: RK3036, RK3066, RK312X, RK3188, RK322X,RK3288, RK3328, RK3368, RK3399, PX30

Also I found in the xda forum, a "RK30xxLoader(L)_V2.19.bin" working for my device as well, packed in some roms.

I would really like to use my device as a PiHole, or at least flash any new Android on it, so I can start YouTube on it using my Mobile-Phone. Does someone have any Idea whether it is possible to run Arch Linux on it - I would really not like to use ubuntu or so on it.