On Board Compiling - how to install linux headers

Started by Ilh, June 25, 2014, 10:00:57 AM

Previous topic - Next topic

Ilh

Hello,

I am learning how to write linux drivers and as they are quite small modules and I'll probably do a lot of experimenting, I find it a lot more suitable to compile directly on the board.  ::)

Problem is, that after following the tutorials for building and installing the Kernel, Debian and xfce4, I have

/usr/src/

directory blank.  :-\

I'll be very thankful if you propose a solution or tutorial on how to configure A13 Olinuxino Debian for compiling driver modules.

Thanks in advance!  :)


Ilh

Hello John,
Thanks for your response.
This is the first I tried, but apparently, the kernel from the tutorials has no such package.

sudo apt-get install linux-headers-$(uname -r)

I receive an error "Unable to locate package" and "Couldn't find any package"

So in my opinion I need either to build package from the Kernel I used and add it manually, or apt-get some compatible version.

Package I use is 3.4.90

Could someone give some ideas on that manner?

JohnS

I'd install the kernel sources.

(Actually, I cross compile.)

John

Ilh

And my question is how to do that? Is there any tutorial on the topic?  :)

JohnS

Try google with words like
how to install linux kernel sources

John

Ilh

I do this for like 2days - it is way easier than registering asking in forums. I still can't find something suitable though.

jlucius

Did you read through the olimex how-to? This is for A10 but should be similar to A13

https://docs.google.com/file/d/0B-bAEPML8fwla21JNU12RnYxZmM/edit

In this case you build the kernel on a intel machine and just copy it over to sd-card.

Ilh

Hello jlucius,

Thanks for your response.
This manual is like the ones that are for A13 and I made all the steps from it when initially installing the Kernel and the Debian on the SD card. The thing is that it does not explain how to build libraries for use from Kernel space - which is needed to use for drivers development.

oldpenguin

Hello llh

Not sure if this what you want this is an extract from a progress report I have written for myself to document the whole building process for kernel and file-system to run from NAND flash on A13. It is a work-in-progress because things tend to change rapidly. As you can see, last time I compiled the bsp was in October 2013. At that time kernel version was 3.4.61, which is a version I am still running with success in my boards (nand flash drivers aside).

[...]
Try 4
Update 18/10/2013. With newer sunxi-bsp some things have changed

git clone https://github.com/linux-sunxi/sunxi-bsp.git
mv sunxi-bsp sunxi-bsp-20131018
cd sunxi-bsp-20131018
PATH=/opt/gnueabihf/bin:$PATH
./configure a13-olinuxino (1)
make (2)
make linux-config (3)
make linux
make hwpack
./cp_hwpack.sh (4)
make livesuit ROOTFS=rootfs.ext4

(1) On previous version was a13_olinuxino :(
(2) First time make takes very long
(3) When modifying the kernel, be sure to enable
Networking support
   Networking options
      IP kernel level autoconfiguration
         DHCP support
Device Drivers
   Network Device Support
      USB network adapters
         Multi-purpose USB networking framework
            (comment on asix driver compiled with kernel to be able to
            boot from nfs)
   Misc devices
      ugly sun4i gpio driver
   USB support
      USB serial converter support
         USB serial generic driver
         FTDI
         MCT
         Prolific
      USB modem (CDC_ACM)
   SPI support
      User mode SPI device driver support
   HID devices (HID_SUPPORT)
      Special HID drivers
         Sunplus Wireless Desktop
File systems
   Network file systems
      Root file system on nfs (necessary for nfs boot)
(4) Copy linux kernel modules to the rootfs.ext4 file-system
Other modifications
1. Copy the asix driver source code from a13/asix_src to linux-sunxi/drivers/net/usb/
2. Modify sysconfig_linux.fex (as in previous tries). This file is now located in  allwinner-tools/livesuit/default/sys_config_linux.fex
3. Modify a13-olinuxino.fex for 4.3"lcd and other changes. This file is in sunxi-boards/sys_config/a13. This file will eventually become script.bin in /build/a13-olinuxino_hwpack/kernel/
Modules are now in /build/a13-olinuxino_hwpack/rootfs (after make hwpack)
cd build/a13-olinuxino_hwpack/rootfs
tar -czvf libmod.tar.gz lib
To program image using Livesuit do:
open Livesuit and select file-system
unplug power
plug USB OTG cable and connect to PC
press "home" button
plug power
release "home" button

chosen_board.mk defines BOARD=a13-olinuxino This definition is used in
Makefile that converts sunxi-boards/sys_config/a13/a13-olinuxino.fex into a13-olinuxino.bin
mk_hwpack.sh converts a13-olinuxino.bin into script.bin

Don't forget to add to a13-olinuxino.fex
[target]
...
power_start = 1
This allows startup when battery is connected


I am cross-compiling with /opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/ on a debian 64bit machine (with symbolic link to /opt/gnueabihf). The compiler PATH is added to the environment.

Concerning module compilation  I think you can use that standard way:
In the kernel directory, create folder for your driver
mkdir mydriver
cd mydriver

If your driver is named mycode1.c
Create a standard makefile with:
  obj-m := mycode1.o (really .o and not .ko)

Compile module with the following command:
make -C .. subdirs=$PWD modules

Hope this helps
Regards
Antonio

esohns

These are all good hints. Unfortunately, the question has not been answered yet.

After installing the packages
- linux-source-3.2
- linux-headers-3.2.0-4-all-armhf

and sym-linking the kernel sources /usr/src/linux

I am still receiving the following error message:
/usr/src/linux-source-3.2/include/linux/kconfig.h:4:32: fatal error: generated/autoconf.h: No such file or directory
compilation terminated.


when I try to compile a kernel module (Note: I am running the Debian Linux distribution).

It seems that a third platform-specific package is missing (i.e. linux-headers-3.4-29.sunxi.4-sunxi-sun4i).

Any hints ?

Gerrit

https://github.com/linux-sunxi/linux-sunxi/releases/tag/sunxi-v3.4.29-r0

get them from here, first configure them for your board, look at the instructions how to compile your own kernel if you want to know how to do that.