How to install linux-headers-3.17 on Ubuntu Utopic (14.10)

#1

Hello,

The server is running the official image Ubuntu Utopic (14.10). I want to install header files so I can compile a kernel module.
The following is what I did. It seems like there is no matching package. I think I might need to add a source to the apt source list? Could someone please point me what I should do? Thanks a lot!

-Han

root@hhp-01:~# apt-get update
root@hhp-01:~# apt-get install build-essential linux-headers-$(uname -r)
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package linux-headers-3.17.0-119
E: Couldn’t find any package by regex ‘linux-headers-3.17.0-119’
root@hhp-01:~# apt-cache search linux-headers-3.1
linux-headers-3.16.0-23 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-23-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-23-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.1.10-8-grouper - Linux kernel headers for version 3.1.10 on Nexus 7
linux-headers-3.16.0-24 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-25 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-26 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-28 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-29 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-31 - Header files related to Linux kernel version 3.16.0
linux-headers-3.16.0-24-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-24-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-25-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-25-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-26-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-26-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-28-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-28-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-29-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-29-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-31-generic - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP
linux-headers-3.16.0-31-generic-lpae - Linux kernel headers for version 3.16.0 on ARM (hard float) SMP

Obtaining Headers
#2

Because we compile the kernel, you need our headers. To retrieve them, run:

curl https://raw.githubusercontent.com/online-labs/ocs-scripts/master/skeleton-common/usr/sbin/oc-sync-kernel-headers | bash -e

Then, you should see headers in /usr/include.

#3

Hi jcastets,

Thanks for your support!
I did what you suggested in your post. But people usually use the following makefile to build a kernel module. This folder structure and kernel make file do not exist. So how can I build a kernel module?

obj-m += enable_tsc.o
all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Regards,
Han

#4

Hi @Han,

I just created an issue on github so we can work on this:

Basically I can update the “/usr” link to something like “/lib/modules/$(shell uname -r)/build/” but the current tarball only contains headers files (.h) and you will still miss some KConfig file, Makefiles and scripts needed to build a new kernel module
I will try to create .deb packages with all needed files

For information, which kernel module are you trying to build ?

#5

I need to measure some program performance, so I need to access the on chip counter in the Performance Monitor Unit of ARMV7. But by default the counter is disabled, the easiest way to enable it from user land is to build and install a kernel module like this one:

#include <linux/module.h>
#include <linux/kernel.h>
 
int init_module(void)
{
  asm volatile ("MCR p15, 0, %0, C9, C14, 0\n\t" :: "r"(1));
  asm volatile ("MCR p15, 0, %0, C9, C14, 2\n\t" :: "r"(0x8000000f));
  printk (KERN_INFO "User-level access to CCR has been turned on.\n");
  return 0;
}
 
void cleanup_module(void)
{
}
#6

Hi @Han,

I think that the support of the Performance Monitor Unit for Armada SoCs is not complete with mainline kernels, there’s ongoing efforts on this topic, which can be followed here:

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/327313.html

We’ll provide a kernel including them whenever it gets merged. Maybe what you need is already implemented in 3.2.34 kernel (which, unfortunately is not open, so you won’t be able to have your module on this one).

#7

Hi @Sebastien_Rannou

Thanks for the information.

Actually, what I need is just to enable the PMU and then use one line of assembly code in my programme to read the counter. In total 3 lines of code: enable counter, disable interrupt -->in kernel; read counter–> in user land.

Or, could you please help to build that module(in post 5) and I just install it?

Thanks!