How could I compile a hello.ko that can run on my BBB?

Hi,

I connect my BBB to internet do update. When I use “uname -r” to check the version, it displays: 3.8.13-bone79.

Now, I hope to compile a hello.ko module driver on PC and run it on the board.

Could someone please tell me how to get the correct version of kernel and compile it?

Best Regards,
Mian

You seem to have a test kernel module that you want to compile and insert
into a running kernel. Normally, you'd just 'make hello.ko' and 'insmod
hello.ko'. This wouldn't work if the kernel API used by the module was so
different that it wouldn't work with the header files used by your current
kernel (btw. for this to work, your system has to have kernel development
packages installed).
Try this and report if you encounter errors--it'll be much easier to help
if you say in detail what you did and what happened as a result.

OK. This is the error:

root@beaglebone:~# insmod hello.ko
Error: could not insert module hello.ko: Invalid module format

And I checked the current version below:

root@beaglebone:~# uname -r
3.8.13-bone79

Could you please tell me where I can get the kernel source which has the same version as my BBB board?

I downloaded the bb-kernel-3.8.13-bone79, and hello sample driver to my PC.

Compiled it without problem. When using modinfo to see hello.ko, it displays:

filename: hello.ko
version: 0.1
description: A simple Linux driver for the BBB.
author: Derek Molloy
license: GPL
srcversion: 0DD9FE0DE42157F9221E608
depends:
vermagic: 3.8.13+ SMP mod_unload modversions ARMv7 thumb2 p2v8
parm: name:The name to display in /var/log/kern.log (charp)

The “vermagic” is “3.8.13+ SMP…”, it should be 3.8.13-bone79, right?

Best Regards,
Mian

I reply myself. It’s fixed…

And now, I plan to switch to kernel 4.1.1… It seems that 3.8.13 is an old version and will be replaced sooner or later…