Ubuntu Kernel and Initrd


#1

Hi.

I’m using the Vim_Ubuntu-server-16.04_Linux-4.9_V170604 image that was released a few days ago but would like to make a few customisations.

Is it possible to extract the Kernel and Initrd from the update.img? I have extracted the ramdisk.PARTITION from the .img file using aml_image_v2_packer but I can’t work out how to further break that down into kernel and initrd.

I basically want to do the opposite of this:

$ ./utils/mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/boot.img

I want to take boot.img and get the Image and initrd.img from it. Is that possible?

Otherwise, would you be able to provide these files from your build environment? Maybe they could be in the /boot directory of the rootfs.

Cheers.
Shaun.


#2

Hi, Shaun:
FYI:

MD5SUM: 5abe7a4697f9cc8706d35ebdc9981a43

Note that the ramdisk.img is generated with follows command:

./utils/mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/ramdisk.img

Enjoy!


#3

@Gouwa can you also share the config used with the kernel 4.9.26
Also can you tag kernel archive for that ubuntu version (so it is easy to download archive


#4

It’s available on Khadas Github.

Will keep doing this in the future, thanks for the feedback!


#5

Are you sure? I mean if i use just “make kvim_defconfig” I get “restarting config” and need to confirm a lot of questions. But if I fire “make menuconfig” and load that kvim_defconfig and then just clicked save to save it as .config I was not asked after for any config value.
So can you check if that is really latest (compare .config in linux directory with kvim_defconfig).

But it fails to compile here (Note: I am compiling directly on Khadas VIM).

 CC      arch/arm64/kernel/topology.o
arch/arm64/kernel/topology.c: In function ‘parse_cluster’:
arch/arm64/kernel/topology.c:133:40: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 3 [-Werror=format-truncation=]
   snprintf(name, sizeof(name), "cluster%d", i);
                                    ^~

Help would be needed.
Here you can find both logs: https://defuse.ca/b/KmntDM7v

You could still tag it as there are no changes till now (and tag could be server/mate release date)…
because last release “linux-170421.tar.gz” is only 124MB where git clone to the commit=8bc293d2ffc704b92e56aea0820498605ac2dfdd is: Receiving objects: 100% (3543395/3543395), 819.98 MiB | 500.00 KiB/s, done.


#6

You just missed to pass the arg ARCH=arm64 :

make ARCH=arm64 kvim_defconfig

#7

ok that fixed the .config problem. but it still fail to compile regarding that “CC arch/arm64/kernel/topology.o” file.


#8

It couldn’t be. can you post more details for this? for example, your host build environment?


#9

@Gouwa as I wrote before I am doing it on Khadas VIM Pro device with ArchLinuxArm on it. Please note that I can compile the ArchLinuxArm mainline kernel just fine (yes it takes hourse but that i don’t care) also modified mainline kernel were WiFi is fixed and that works also fine.


#10

Yes, I know you did great work with ArchLinuxArm on VIM.

But we did build the images based on the follow commit we pushed on Khadas Github:

commit 8bc293d2ffc704b92e56aea0820498605ac2dfdd
Author: terry <terry@szwesion.com>
Date:   Sat Jun 3 16:54:20 2017 +0800

    DTS: enable UART-Bus at PIN15/16 as default

So I just can’t figure out why you got the compile issue: CC arch/arm64/kernel/topology.o. :confused:


#11

Well I do use same commit (is in that pastelog).

$ cd src/linux
$ git log
commit 8bc293d2ffc704b92e56aea0820498605ac2dfdd (HEAD -> makepkg, origin/ubuntu-4.9)
Author: terry terry@szwesion.com
Date: Sat Jun 3 16:54:20 2017 +0800

weird is that i can cross compile on Arch Linux (virtual server) but directly on Khadas VIM Pro compile fails on that file. Did you tried to compile on Khadas device itself or you do only cross compile? I can not do it currently as i don’t have Ubuntu your provide on device (re partitioned and format the eMMC to use with ArchLinuxArm).


#12

What we did is cross-compile.

Do you mean that you compiled the linux kernel on local VIM device?


#13

Yes I do exactly that “nativ compiling on ARM” (it is also test how device acts on load, and as there is no GPU mainline driver i can’t use it as media player device with code, so why not? And yes I takes long to compile, 7 hours to compile mainline 4.12-rc4 Kernel and?) .

And it fails on that file, but only with your/amlogic source, if i take mainline 4.9.26 kernel it pass this file but I did not compile till the end.


#14

You can reduce compilation time by using the -j command switch, e.g.

make -j 4 Image modules dtbs

If you have more arm64 boxes you can save even more time using distcc.


#15

Indeed, I forgot about it. But I setup it under ArchLinuxArm directly in /etc/makepkg.conf file.
Now it takes only around 2,5 hours, and in past without -j4 it took around 7 hours.
now:

==> Making package: linux-aarch64-rc 4.12.rc4-4 (Sun Jun 11 01:20:11 CEST 2017).
==> Finished making: linux-aarch64-rc 4.12.rc4-4 (Sun Jun 11 03:54:12 CEST 2017)

was:

==> Making package: linux-aarch64-rc 4.12.rc4-3 (Wed Jun 7 18:04:41 CEST 2017)
==> Finished making: linux-aarch64-rc 4.12.rc4-3 (Thu Jun 8 00:55:12 CEST 2017)

Regarding:

I read about distcc but it does not need to be an arm64 box right? It could be let say x86_64 installation just setup correctly (which I did not setup, but would probably do it today).

Still I am unable to compile khadas linux (ubuntu-4.9) branch here. Seems there is something in Makefile which tells that all warning being treated as errors, as i don’t have these with mainline Kernel:

arch/arm64/kernel/topology.c:78:3: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 10
snprintf(name, sizeof(name), “thread%d”, i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:294: arch/arm64/kernel/topology.o] Error 1
make: *** [Makefile:992: arch/arm64/kernel] Error 2
==> ERROR: A failure occurred in build().
Aborting…


#16

I was able to compile the ubuntu-4.9 branch (using gcc-5.4.1) but I didn’t manage to boot this kernel

Starting kernel ...
uboot time: 5238283 us
domain-0 init dvfs: 4
efuse_pw_en: 0x3
WARNING! efuse bits is disabled
Enable A53 JTAG to AO
INFO:    HDCP22 key read fail!
INFO:    p1d 0
INFO:    pd1 0

while the plain vanilla mainline kernel boots fine at the same time (but has other deficiencies).

The u-boot version is

U-Boot 2015.01-g0f90c8e (Mar 04 2017 - 09:13:33)
aarch64-linux-gnu-gcc (Ubuntu/Linaro 4.8.4-2ubuntu1~14.04.1) 4.8.4
GNU ld (GNU Binutils for Ubuntu) 2.24

How can I perform a non-destructive update to the 4.9 kernel instead of reflashing the eMMC storage?


#17

I haven’t tried distcc over different architectures so far.


#18

To build the kernel 4.9.26 you need gcc 4.9 (for example, the compiler from Linaro, which is specified in the rules to build the kernel\buildroot from Amlogic). I gather this kernel with that compiler and it is normally loaded.


#19

Well I am compiling directly on Khadas VIM Pro device with ArchLinuxArm running and there is newer gcc and I don’t think to downgrade.

$ gcc --version
gcc (GCC) 7.1.1 20170516


#20

hi @Gouwa
where I can get Vim_Ubuntu-mate-16.04_Linux-4.9_V170605 kernel package ? and how to compile & install it ? thanks!