olegk0 / rk3x_kernel_3.0.36

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

Boot from MicroSD card doesn't work. #1

Closed rkkoszewski closed 6 years ago

rkkoszewski commented 7 years ago

Hi, I'm not sure if this project is still alive. I just wanted to ask if booting from an MicroSD is broken or only some specific cards are supported.

So far I tried with 3 different cards (16GB Samsung (class 10), 32GB Samsung (class 10) and 4GB Kingston (class 4)) and none of them were able to boot Mini-Ubuntu. The same system installed on an USB works without any issues.

olegk0 commented 7 years ago

As far as I know, the RK3066 can not boot from SD and USB devices.

Probably you mean placing the rootfs (the kernel will be located in the nand). Yes, you can put rootfs on SD or USB, but you need to check the kernel parameter CONFIG_CMDLINE = root= ... and/or initramfs if it is used.

ps: You can check access to SD card from a working system, pre-booted eg from USB.

rkkoszewski commented 7 years ago

Hi, yes, that's what I meant. I've been trying to compile your Kernel to use a custom CONFIG_CMDLINE but I haven't been successful so far.

I've used this tutorial http://hwswbits.blogspot.dk/2013/03/compiling-picuntu-kernel-ubuntu-linux.html to find all the required tools to build this kernel. But there seems to be a missing file in the /usr folder.

Here is the complete error:

root@ubuntu:~/rk/rk3x_kernel_3.0.36# make
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  /root/rk/rk3x_kernel_3.0.36/scripts/gen_initramfs_list.sh: Cannot open '../initramfs/initrd.cpio.gz'
/root/rk/rk3x_kernel_3.0.36/usr/Makefile:67: recipe for target 'usr/initramfs_data.cpio' failed
make[1]: *** [usr/initramfs_data.cpio] Error 1
Makefile:959: recipe for target 'usr' failed
make: *** [usr] Error 2

So far I'm just trying to compile your Kernel as is (Without modifying CONFIG_CMDLINE). But I'm aiming to compile it to boot from NAND. I haven't seen so far any 3.0.36 NAND Linux Kernel for the MK808. It is supposed that the latest Initramfs from Galland (https://github.com/Galland/rk30_linux_initramfs) supports booting from NAND for the 3.0.36 Kernel. So by using its Initramfs + CONFIG_CMDLINE="root=/dev/mtdblock4 init=/sbin/init loglevel=8 rootfstype=ext4 rootwait mtdparts=rk29xxnand:0x00002000@0x00000000(parameter),0x00002000@0x00002000(misc),0x00004000@0x00004000(kernel),0x00008000@0x00008000(boot),0x00008000@0x00010000(recovery)"

should theoretically work (As long as it compiles).

I formated /dev/mtdblock4 to EXT4 from Mini Ubuntu that I booted from USB by using your Kernel and copied the root file system by using rsync. So it should work as long as it mount's /dev/mtdblock4.

Any chance @olegk0 or anybody else could point me to the right direction on how to get this Kernel to compile?

Thanks a lot! Greetings.

olegk0 commented 7 years ago

Hi

error|/root/rk/rk3x_kernel_3.0.36/scripts/gen_initramfs_list.sh: Cannot open '../initramfs/initrd.cpio.gz'|

|you can disable |initrd in kernel config (if you use direct link to root, like this - ||root=/dev/mtdblock4)|

rkkoszewski commented 7 years ago

Hi, so I changed CONFIG_BLK_DEV_INITRD=y to CONFIG_BLK_DEV_INITRD=n and the compilation got further.

This time there is an other error:

scripts/kconfig/conf --silentoldconfig Kconfig
#
# configuration written to .config
#
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CC      init/main.o
  CHK     include/generated/compile.h
  CC      init/do_mounts.o
  CC      arch/arm/kernel/setup.o
  CC      arch/arm/mm/init.o
  LDS     arch/arm/kernel/vmlinux.lds
  LD      arch/arm/kernel/built-in.o
arch/arm/mm/init.c: In function 'mem_init':
arch/arm/mm/init.c:675:4: warning: format '%lx' expects argument of type 'long unsigned int', but argument 12 has type 'unsigned int' [-Wformat]
  LD      init/mounts.o
  LD      init/built-in.o
  TIMEC   kernel/timeconst.h
Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
/root/rk/rk3x_kernel_3.0.36/kernel/Makefile:141: recipe for target 'kernel/timeconst.h' failed
make[1]: *** [kernel/timeconst.h] Error 255
Makefile:959: recipe for target 'kernel' failed
make: *** [kernel] Error 2
make: *** Waiting for unfinished jobs....
  LD      arch/arm/mm/built-in.o
root@ubuntu:~/rk/rk3x_kernel_3.0.36# 

I'm not sure what is causing this. Could this be related to my Ubuntu version? It's Ubuntu 16.04 (64bit). Any idea what could be causing this? What linux version do you use to compile the kernel?

olegk0 commented 7 years ago

This may depend on the version of the cross compiler.

I do not remember exactly what I used, it seems arm-linux-gnueabihf-gcc-4.7

rkkoszewski commented 7 years ago

Success!! I went to kernel/timeconst.pl line 373 and changed the defined(@something) to defined($something) and it compiled successfully!!! Thank you very much @olegk0 !!

I flashed the kernel and it starts!! BUT.. It is unable to boot the linux edition...

I created two kernels.. One leaving it as is (Boot From USB Drive) by just changing CONFIG_BLK_DEV_INITRD=n. And an other Kernel where I have CONFIG_BLK_DEV_INITRD=n and changed CONFIG_CMDLINE="root=/dev/mtdblock4...

The USB one recognizes the USB Drive, but it is stuck there and nothing happens. The same with the NAND version. It says Waiting for /dev/mtdblock4 device..

Your Kernel (Compiled by You @olegk0) works properly tough with the USB (Not NAND).

Any idea what could be causing this?

rkkoszewski commented 7 years ago

I finally opted to leave the CONFIG_BLK_DEV_INITRD=y and set the path to the initramfs to initramfs-3.0.36+.cpio.gz

This time a lot of kernel module errors appear on screen.. And the it manages to boot from USB!!! But it still is not able to boot from NAND.

IThe eerror messages say

rk30xxnan_ko: version magic '3.0.36+ SMP preempt mod_unload...' should be '3.0.36++ ..." ... modprobe: FATA: Couldnot load /lib/modules/3.0.36++/modules.dep No such file or directory ... (This happens several times).

I really don't know what is going on here.. Seems like the 3.0.36 kernel version is not the same as in the Initramfs? What Initramfs where you using @olegk0 when you were building the 3.0.36 ubuntu kernel?

Any idea how to make this work? Thanks.

olegk0 commented 7 years ago

Check the kernel version - should be 3.0.36+ (you have an extra '+')

suffix may be set in

  1. file Makefile (in kernel src root ) - parameter EXTRAVERSION =
  2. kernel config - CONFIG_LOCALVERSION:
olegk0 commented 7 years ago
  1. if you want to boot from NAND - need initrd with nand driver rk30xxnan_ko

  2. /dev/mtdblock4 - It seems for nand. for usb it should be like /dev/sda1. For SD I do not remember, you need to look at the running system

rkkoszewski commented 7 years ago

It just went completely crazy..

For USB:

When I set: EXTRAVERSION = + and _CONFIGLOCALVERSION: "+" then it searches for /lib/modules/3.0.36+++/ !! (Has 3 +) RESULT: It fails to load all modules from InitRamfs, but Ubuntu boots for USB (No problems)

When I set: EXTRAVERSION = and _CONFIGLOCALVERSION: "+" then it searches for /lib/modules/3.0.36++/ (Has 2 +) RESULT: It fails to load all modules from InitRamfs, but Ubuntu boots for USB (No problems)

When I set: EXTRAVERSION = and _CONFIGLOCALVERSION: "" then it searches for /lib/modules/3.0.36+/ (Has 1 +) RESULT: The modules from InitRamfs DO get loaded, but Ubuntu does NOT boot. A lot of errors are shown. It seems that it starts booting the Ubuntu from USB but it gets stuck (Last message is something ALSA related). The last visible error is Plymouth related.

It looks like it's appending the +'s.. I'm completely confused now how to proceed.

Maybe the Kernel modules that come from the InitRamfs are not good for MK808???? (https://github.com/Galland/rk30_linux_initramfs). What InitRamfs did you use when you made your kernel?

olegk0 commented 7 years ago

In the case

EXTRAVERSION =

CONFIG_LOCALVERSION: ""

kernel load nand drive and try to boot from nand... may be and for some reason can not do this

my initramfs here https://drive.google.com/drive/folders/0B6QRwjacGTzCMERsVFJ2bnNlOFU

rkkoszewski commented 7 years ago

Wow! With your initramfs it boots to linux without any issues. It doesn't seems to see my MTD partitions tough. But when I flash your new kernel (https://drive.google.com/open?id=0B6QRwjacGTzCbV9IMHk2TWwtQjQ) it does sees some MTD partitions. It's just amazing!!

It didn't work still for me, because I have formated it with an other partition layout /mtdblock4 (recovery).

Do you need to flash some different partition/property file in order to use the NAND feature of your "Last" kernel? @olegk0

olegk0 commented 7 years ago

NAND partition describe in kernel config, parameter CONFIG_CMDLINE

mtdparts=rk29xxnand:size@offset(name)

rkkoszewski commented 6 years ago

Hi @olegk0 , I'm still trying to make this work from nand. But with the "last" kernel it is not even able to boot from usb. I think in Mini-Ubuntu they use kernel+ modules, while in your's it's kernel++ modules. What version of linux do you use? Which one is compatible? Thanks.

olegk0 commented 6 years ago

HI

Now i use my rk3066 based device as torrent server. Linux Debian wheezy installed into NAND, kernel rk3066 3.0.36+ with integrated initramfs. Also i use external usb hd as data store.

here my mount list (without temporary fs):

/dev/mtdblock3 on / type ext4 (rw,relatime,errors=remount-ro,barrier=0) /dev/sda1 on /mnt/data type ext4 (rw,relatime,barrier=1,data=ordered)

rkkoszewski commented 6 years ago

Hi @olegk0 ,

It seems like Mini-Ubuntu doesn't works at all with your last kernel, it gives a lot of stack traces and errors, and when the system is booted up, no kernel modules are loaded. When I start from Nand with the same kernel it gets stuck at "loading cpu freq kernel modules" and stays there for ever.

Can you please tell me how you managed to install Debian on your MK808 Nand? Where can you get Debian for ARM and how to install it on MK808 Nand? How can you partition the RKMTDx in the MK808 to the one you have? I have on my MK808 parameter,misc,kernel,boot,recovery, and I need to format it to cache,userdata,linuxroot,user. But how? With ROM_Flash_Tool_137 and parameter file? How should I change the parameter file then?

What I do right now is to use your old linux usb kernel to start Mini-Ubuntu. I use Mini-Ubuntu to dd Mini-Ubuntu.img to /dev/mtdblock4 and then I change kernel to your latest kernel with modified partition to load from /dev/mtdblock4. It detects the linux, but it crashes on boot. When I use your latest kernel, to boot linux from USB, I have the same error, so I think the latest kernel is unable to start Mini-Ubuntu properly.

Here you can see the exception I get on boot: https://drive.google.com/open?id=1mR1Yr2bbiBVEE96mCgPpowqTK0lOCk9v

Is there any way you could help me with the process? Thanks!

olegk0 commented 6 years ago

Many questions%), I'll try to answer...

kernel + modules (my current build): https://drive.google.com/open?id=0B6QRwjacGTzCMERsVFJ2bnNlOFU

1.Debian also provides arm binary packages (i use armhf arch).

2.For create rootfs on debian based distribs (like ubuntu), you can use the following instruction: https://www.acmesystems.it/debian_wheezy.

3.For repartition NAND I use kernel config CONFIG_CMDLINE="root=LABEL=linuxroot init=/sbin/init loglevel=1 rootwait console=tty0 mtdparts=rk29xxnand:0x00040000@0x 000D8000(cache),0x00400000@0x00118000(userdata),0x00100000@0x0051A000(var),-@0x0061A000(linuxroot)", will be active when this kernel is loaded , but not for bootloader!

4.The next step is to copy the resulting rootfs (point 2) to the prepared partition of USB hard disk (this will be an intermediate step) . Set label to "linuxroot" for this partition. Unpack and copy here kernel modules. Flash kernel (recovery.img) into kernel (recovery) partitions of NAND.

  1. Boot on device from USB disk from the rootfs partition created in the previous step (You can use this method later for emergency boot).

  2. From the loaded system prepare NAND partitions (for root partition use block with marker "linuxroot" see point 3), copy on it rootfs from the current hard drive partition.

  3. change label "linuxroot" to another for usb hd, sync and reboot.

the end

rkkoszewski commented 6 years ago

Yes!!! It works!!! Thank you very much @olegk0 for the help. Works pretty nicely from NAND!!!

But one last question. How do you connect to the internet @olegk0 ? Are you using the WiFi from the MK808?

I have a USB2Ethernet device (Davicom DM96xx USB 10/100 Ethernet), which was working with MiniUbuntu. But it seems that in your kernel the dm9601.ko is missing. Do you know where I can get a working dm9601.ko that works with your kernel (3.0.36+)?

(Driver source seems to be here: https://elixir.bootlin.com/linux/v3.0.36/source/drivers/net/usb/dm9601.c but I don't know how to compile it into a .ko module compatible with 3.0.36+ )

olegk0 commented 6 years ago

HI I use internal WiFi chip (it seems rk901 without bluetooth), driver bcm40181 (is present in these kernel sources) + firmware from android. Also i use usb ethernet device Realtek RTL8152 - speed up to 8Mbytes/s.

For compile dm9601.ko - add to kernel config: CONFIG_USB_NET_DM9601=m and recompile kernel

rkkoszewski commented 6 years ago

It's done! Everything works! USB Ethernet + NAND Linux! Though I barely get 5Mbits/sec of transfer, but it will do for what I've planned for it (It's probably a USB bottleneck or just a bad USB Ethernet device). Cannot thank you enough @olegk0 !! This was a really interesting experience. Thanks!