login

Author Topic: Compiling kernel: Which kernel source code?  (Read 4187 times)

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Compiling kernel: Which kernel source code?
« on: August 22, 2013, 09:41:31 AM »
I'm starting with compilation of a custom kernel. I've setup the build environment on ubuntu and I'd like to know where to get the best kernel source code for sunxi/cubieboard?

The buildroot website suggests this one:
https://github.com/matson-hall/linux-sunxi

But some other docs point to this one:
https://github.com/linux-sunxi/linux-sunxi


What's the difference?

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #1 on: August 22, 2013, 11:48:32 AM »
I'm starting with compilation of a custom kernel. I've setup the build environment on ubuntu and I'd like to know where to get the best kernel source code for sunxi/cubieboard?

The buildroot website suggests this one:
https://github.com/matson-hall/linux-sunxi

But some other docs point to this one:
https://github.com/linux-sunxi/linux-sunxi


What's the difference?
https://github.com/linux-sunxi/linux-sunxi is the "official" kernel sources for allwinner chips.  If you look at the matson-hall repo, you'll see that it's "forked from linux-sunxi/linux-sunxi".  The cubieboard branch hasn't been updated since October last year, so it's pretty far behind the current kernel sources.  He made changes to get the cubieboard's linux up and running (Matson works for cubieboard), but it looks like these changes were then pulled into https://github.com/linux-sunxi/linux-sunxi, and this fork subsequently abandoned.

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #2 on: August 23, 2013, 01:59:00 PM »
Thank you, sunxi-linux it is then.

I have another question. Could you please point out which guide should I follow to compile the kernel? I've compiled kernels before for x86 systems. Basically all I had to do was download the kernel source code, invoke "make menuconfig", import the configuration + customize it a bit, and finally compile the kernel with "make". But now I'm seeing that for sunxi some tutorials that tell you to download and use buildroot while some others don't. Should I use buildroot? Where can I get the kernel configuration file?

Obviously I'll have to cross-compile. I'm using an ubuntu machine, and I've already downloaded the gnueabihf gcc.

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #3 on: August 23, 2013, 03:49:12 PM »
Thank you, sunxi-linux it is then.

I have another question. Could you please point out which guide should I follow to compile the kernel? I've compiled kernels before for x86 systems. Basically all I had to do was download the kernel source code, invoke "make menuconfig", import the configuration + customize it a bit, and finally compile the kernel with "make". But now I'm seeing that for sunxi some tutorials that tell you to download and use buildroot while some others don't. Should I use buildroot? Where can I get the kernel configuration file?

Obviously I'll have to cross-compile. I'm using an ubuntu machine, and I've already downloaded the gnueabihf gcc.

If you've built x86 kernels, I wouldn't bother with buidroot.  Just follow the tutos that show you where to get the cross tools and set up the kernel config, like this one: http://linux-sunxi.org/Building_on_Debian.  Most are using the hardfloat compiler now:  gcc-4.6-arm-linux-gnueabihf (make sure you read up on incompatibilities of gcc versions and ARM kernel builds; I'm still using 4.6.3). 

menuconfig works, but you have to specify ARCH and CROSS_COMPILE settings and set up the initial .config from an Allwinner specific one depending on your SoC first, e.g.,

Code: [Select]
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun4i_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #4 on: August 23, 2013, 05:17:46 PM »
I've already installed the cross compiler from a ubuntu repository. The arm-linux-gnueabihf-gcc reports version 4.7.3-ubuntu1. So you're saying it's better to get an older gcc like 4.6.3? If I go with my compiler it seems I'll have to test the kernel a bit.

Question. Some guides suggest that we install the sunxi linux hwpack when setting up Cubieboard 1.0. But what is it for? I mean it has a built kernel, but is it still up to date? The only thing I've used from the hwpack is the bootloader, which caused my Cubieboard to increase the RAM size from 512MB to 1GB. The kernel inside seems to be missing a lot of kernel modules. This is part of the reason I decided to recompile it. I've seen that other images use their own kernels i.e. roman's debian headless or the cubian image. What's the difference here?


Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #5 on: August 23, 2013, 06:15:32 PM »
I've already installed the cross compiler from a ubuntu repository. The arm-linux-gnueabihf-gcc reports version 4.7.3-ubuntu1. So you're saying it's better to get an older gcc like 4.6.3? If I go with my compiler it seems I'll have to test the kernel a bit.
Can't say, as I've only used 4.6.3, and it works just great.  Others have complained of newer compilers, especially folks with ubuntu 13.04, which no longer has the 4.6 arm toolchain in the repositories (but it should still be possible to install them from an older one).

Quote
Question. Some guides suggest that we install the sunxi linux hwpack when setting up Cubieboard 1.0. But what is it for? I mean it has a built kernel, but is it still up to date? The only thing I've used from the hwpack is the bootloader, which caused my Cubieboard to increase the RAM size from 512MB to 1GB. The kernel inside seems to be missing a lot of kernel modules. This is part of the reason I decided to recompile it. I've seen that other images use their own kernels i.e. roman's debian headless or the cubian image. What's the difference here?
Last I checked, the hwpack kernel was reasonably up-to-date for the 3.0 branch.  Of course, there's been talk of deprecating 3.0 for some time.

The biggest draw of the hwpacks for most is the automated install; for someone who's capable of building their own kernel, installing one is a matter of a two-line shell script, and building/installing u-boot is a matter of a make and another two-line shell script.  I personally never even looked at a hwpack until I decided to make one for the CB2.  But then I started putzing around with the A10 before there was such a thing as a hwpack  :)

I supposed the hwpack could also be useful to someone who's getting started testing a newly purchased board or a balky SD card -- having something that's known-good allows you to factor out kernel build issues (e.g., gcc version) and such.

Offline xtofury

  • Newbie
  • *
  • Posts: 41
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #6 on: August 23, 2013, 07:57:25 PM »
what's the best android kernel so far?  I was hoping for allwinner tvbox 2.2 but the cubieboard-tv-sdk I found still has that issue with the storage portion of settings (which is the same as the image that the cubie came with).  Any thoughts?  Which git repository should I be aiming for and are there any issues with getting it downloaded?  I noticed JB one hangs, and the other ones I've tried have issues with linux-allwinner needing swapped for linux-sunxi in the manifest?  I was confused by all the different options too, when all I wanted was some clear answer where the source for the tvbox 2.2 is....

Offline xtofury

  • Newbie
  • *
  • Posts: 41
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #7 on: August 26, 2013, 05:27:11 PM »
I'm attempting to use the openbox code from github, the sdk was old code and therefore I deleted it and started again from scratch.
I'm aiming to take my project on the go, so I've ordered a battery, short wires, accelerometer, and will have to come up with a case.  I plan to install AIDE to develop the project right on the device and sync with my laptop as needed.
I was thinking of stripping useless stuff out of the sdk but figured I'd leave it till I have an adk.  I guess I'll let people know if this is worth it or if I'll have to give jellybean fork a try.

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #8 on: August 27, 2013, 07:02:07 AM »
patwood: Thanks for your help so far. I have compiled and tested the kernel a bit, and it seems to be working fine. The only problem is this:
Quote
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun4i_defconfig

This default configuration seems to be extremely minimalistic. It has almost everything imaginable disabled, from filesystems, to cryptographic API, hardware drivers, IPv6, netfilter, you name it. Even the SATA port no longer works. Is there perhaps a more advanced kernel configuration available somewhere? Possibly an "official" one for cubieboard? The linux-sunxi kernel sources do not contain one specifically for cubieboard. I know I can make one myself, but I need some reference point.

Roman's kernel image seems to have one. I haven't found one for Cubian yet.


Also, is there a *.deb package available for sunxi-tools?

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #9 on: August 27, 2013, 09:45:42 AM »
Kernels are interchangeable, and so are config files for the same version. Just grab roman's config file and copy it to .config in the top level directory before running make (but don't run the make ...defconfig if you do this -- it overwrites the .config file).  You can also run:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

And select any features you want.

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #10 on: August 27, 2013, 09:51:03 AM »
There's no .deb for sunxi tools since they're device specific.  All the .deb packages are for all arm processors and the archives are maintained for the entire arm community, not just us.

So you can find the sunxi tool sources on the same github as the kernel.  Just go up one level.

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #11 on: August 27, 2013, 02:16:43 PM »
Kernels are interchangeable, and so are config files for the same version. Just grab roman's config file and copy it to .config in the top level directory before running make (but don't run the make ...defconfig if you do this -- it overwrites the .config file).
I've got the configs, the thing is many of them come with some different options that the other one lacks (even for the same kernel version). I was comparing the Roman's config for 3.4.43 with that of the default defconfig-sun4i line by line, and they seem to differ significantly on certain segments i.e. roman's has some extra entries at the very top where the sun4i one lacks them. Importing roman's config causes the make script to throw out a crapload of Y/N questions. Seems like the text configuration gets triggered by make because some entries are missing in the imported config...

I'm gonna consult my linux guidebook about kernel compilation. We'll see how this goes on.

There's no .deb for sunxi tools since they're device specific.
Ah, thank you. I guess this means more compiling for me. Yes, I already have the sources. I was wondering whether there was simply a deb package I could install on the cubieboard directly. Looks like I'ma have to make one myself. Funny thing is I compiled the tools for ARCH=arm, and the resulting binaries run fine on my AMD64 box :-/

Another question. Cubieboard has 2 USB host type-A ports and one client mini-B port. Is it possible to utilize this 3rd usb port as a regular USB host so that I can attach and use a USB flash key to it by using some custom USB cabling?

Best regards!

EDIT: I've found this in the fex file for cubieboard. Perhaps modifying it will have an effect?
Quote
[usbc0]
usb_used = 1
usb_port_type = 2
usb_detect_type = 1
usb_id_gpio = port:PH04<0><1><default><default>
usb_det_vbus_gpio = port:PH05<0><0><default><default>
usb_drv_vbus_gpio = port:PB09<1><0><default><0>
usb_host_init_state = 0

[usbc1]
usb_used = 1
usb_port_type = 1
usb_detect_type = 0
usb_id_gpio =
usb_det_vbus_gpio =
usb_drv_vbus_gpio = port:PH06<1><0><default><0>
usb_host_init_state = 1

[usbc2]
usb_used = 1
usb_port_type = 1
usb_detect_type = 0
usb_id_gpio =
usb_det_vbus_gpio =
usb_drv_vbus_gpio = port:PH03<1><0><default><0>
usb_host_init_state = 1

[usb_feature]
vendor_id = 6353
mass_storage_id = 1
adb_id = 2
manufacturer_name = "USB Developer"
product_name = "Android"
serial_number = "20080411"
« Last Edit: August 27, 2013, 03:01:33 PM by Cubear »

Offline patwood

  • Linux geek
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1660
  • Karma: +128/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #12 on: August 27, 2013, 07:22:38 PM »
Kernels are interchangeable, and so are config files for the same version. Just grab roman's config file and copy it to .config in the top level directory before running make (but don't run the make ...defconfig if you do this -- it overwrites the .config file).
I've got the configs, the thing is many of them come with some different options that the other one lacks (even for the same kernel version). I was comparing the Roman's config for 3.4.43 with that of the default defconfig-sun4i line by line, and they seem to differ significantly on certain segments i.e. roman's has some extra entries at the very top where the sun4i one lacks them. Importing roman's config causes the make script to throw out a crapload of Y/N questions. Seems like the text configuration gets triggered by make because some entries are missing in the imported config...

I'm gonna consult my linux guidebook about kernel compilation. We'll see how this goes on.
You should definitely look into the "make menuconfig" mechanism.  Once you've got a configuration you like, just save the .config file somewhere so it doesn't get blown away by any experiments you do.

Quote
There's no .deb for sunxi tools since they're device specific.
Ah, thank you. I guess this means more compiling for me. Yes, I already have the sources. I was wondering whether there was simply a deb package I could install on the cubieboard directly. Looks like I'ma have to make one myself. Funny thing is I compiled the tools for ARCH=arm, and the resulting binaries run fine on my AMD64 box :-/
Do you have qemu for ARM installed?  I forget, but if the tools are linked statically, you can probably run them w/o a chroot if you have qemu.

Quote
Another question. Cubieboard has 2 USB host type-A ports and one client mini-B port. Is it possible to utilize this 3rd usb port as a regular USB host so that I can attach and use a USB flash key to it by using some custom USB cabling?

Best regards!

EDIT: I've found this in the fex file for cubieboard. Perhaps modifying it will have an effect?
I've read about various problems with the mini-usb port.  This is from Hans de Goede's Fedora 18 release notes:
Quote
The OTG USB controller in host mode only supports a limited number of
devices, plugging in a hub + mouse + keyboard typically will make either
the mouse or keyboard not work. This is a hardware limitation which we
will likely not be able to work around.

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #13 on: August 29, 2013, 03:27:25 PM »
I will test the usb0 port once I get a proper cable, will report back. I've also noticed there's a kernel option to set the usb0 mode - can be set to host only, otg and some other options.

Anyway, I've tried out to import roman's config and I'm getting some kernel compile errors now. This didn't happen with devconfig-sun4i config. What can I do when I get these?

Quote
  CC      drivers/usb/sun4i_usb/udc/sw_udc.o
drivers/usb/sun4i_usb/udc/sw_udc.c: In function ‘sw_usb_device_enable’:
drivers/usb/sun4i_usb/udc/sw_udc.c:3236:33: error: ‘g_udc_pdev’ undeclared (first use in this function)
drivers/usb/sun4i_usb/udc/sw_udc.c:3236:33: note: each undeclared identifier is reported only once for each function it appears in
drivers/usb/sun4i_usb/udc/sw_udc.c: In function ‘sw_usb_device_disable’:
drivers/usb/sun4i_usb/udc/sw_udc.c:3309:33: error: ‘g_udc_pdev’ undeclared (first use in this function)
drivers/usb/sun4i_usb/udc/sw_udc.c: In function ‘sw_udc_probe_otg’:
drivers/usb/sun4i_usb/udc/sw_udc.c:3375:2: error: ‘g_udc_pdev’ undeclared (first use in this function)
drivers/usb/sun4i_usb/udc/sw_udc.c: In function ‘sw_udc_remove_otg’:
drivers/usb/sun4i_usb/udc/sw_udc.c:3413:2: error: ‘g_udc_pdev’ undeclared (first use in this function)
drivers/usb/sun4i_usb/udc/sw_udc.c: At top level:
drivers/usb/sun4i_usb/udc/sw_udc.c:3371:12: warning: ‘sw_udc_probe_otg’ defined but not used [-Wunused-function]
drivers/usb/sun4i_usb/udc/sw_udc.c:3409:12: warning: ‘sw_udc_remove_otg’ defined but not used [-Wunused-function]
make[2]: *** [drivers/usb/sun4i_usb/udc/sw_udc.o] Error 1
make[1]: *** [drivers/usb/sun4i_usb] Error 2
make: *** [drivers] Error 2

Best regards!

EDIT: It would appear there is a config bug present:
https://groups.google.com/forum/#!msg/linux-sunxi/zLm9cn-Gem8/QcGbwUV4660J
« Last Edit: August 29, 2013, 03:55:04 PM by Cubear »

Offline Cubear

  • Newbie
  • *
  • Posts: 36
  • Karma: +1/-0
    • View Profile
Re: Compiling kernel: Which kernel source code?
« Reply #14 on: August 31, 2013, 05:04:30 AM »
Okay, I've changed the type back to OTG, and now it compiles fine.
Can you help me with something else? I tried to build the deb package on my XUbuntu 13.04, and I get the following error:

Code: [Select]
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KBUILD_IMAGE=uImage -j6 deb-pkg
.......
dpkg-deb: building package `linux-firmware-image' in `../linux-firmware-image_3.4.43-7_armhf.deb'.
dpkg-gencontrol: error: current host architecture 'armhf' does not appear in package's architecture list (amd64)
make[1]: *** [deb-pkg] Error 255
make: *** [deb-pkg] Error 2