Power & Source of Big Ideas

Which kernel source tree for NanoPi Neo?

Moderators: chensy, FATechsupport

Hi,

recently I successfully installed kernel modules for Raspberry Pi Zero and was able to compile loadable kernel modules.

Today I received two NanaPi Neos and they work fine. Now I want to be able to compiler loadable kernel modules for the Neo. I found linux kernel source trees here:
https://github.com/friendlyarm

Is linux-3.4.y the correct one for NanoPi Neo?

Hermann.

Image
Think the Wiki is suggesting Compile lichee Source Code.
You are right:
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO#Make_Your_Own_Ubuntu-Core_with_Qt-Embedded

So it is not "linux-3.4.y" but "h3_lichee".
I got confused because on Github "h3_lichee" only the M1 is mentioned, and not the Neo.
But above Wiki page directly points to "h3_lichee".

Hermann.
HermannSW wrote:
You are right:
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO#Make_Your_Own_Ubuntu-Core_with_Qt-Embedded

So it is not "linux-3.4.y" but "h3_lichee".
I got confused because on Github "h3_lichee" only the M1 is mentioned, and not the Neo.
But above Wiki page directly points to "h3_lichee".

Hermann.


Hello,
NanoPi M1 and NanoPi NEO use the same kernel source .

thanks
HermannSW wrote:
Hi,

recently I successfully installed kernel modules for Raspberry Pi Zero and was able to compile loadable kernel modules.

Today I received two NanaPi Neos and they work fine. Now I want to be able to compiler loadable kernel modules for the Neo. I found linux kernel source trees here:
https://github.com/friendlyarm

Is linux-3.4.y the correct one for NanoPi Neo?

Hermann.

Image


Hello,
You can get it from our github:

git clone https://github.com/friendlyarm/h3_lichee.git lichee

Note: "lichee" is the project name named by Allwinner for its CPU's source code which contains the source code of U-boot, Linux kernel and various scripts.


thanks
Finally I got kernel module compiled and "insmod"ed:

Code: Select all

root@FriendlyARM:~/hello-1# make
make -C /lib/modules/3.4.39-h3/build M=/root/hello-1 modules
make[1]: Entering directory '/root/linux-3.4'
  CC [M]  /root/hello-1/hello-1.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /root/hello-1/hello-1.mod.o
  LD [M]  /root/hello-1/hello-1.ko
make[1]: Leaving directory '/root/linux-3.4'
root@FriendlyARM:~/hello-1#
root@FriendlyARM:~/hello-1# insmod hello-1.ko
root@FriendlyARM:~/hello-1#
root@FriendlyARM:~/hello-1# dmesg | tail -2
[   13.650331] PHY: gmac0-0:00 - Link is Up - 100/Full
[  222.084963] Hello World :)
root@FriendlyARM:~/hello-1#


I followed the instructions on Neo Wiki page, the "git clone" completed in 1:47min on my home 120Mbps connection.
I had to replace "mingw32" by "mingw-w64" and compiled the whole package on a PC running a 64-bit Linux (Ubuntu 16.04 LTS in my case):
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO#Make_Your_Own_Ubuntu-Core_with_Qt-Embedded

Then I copied the whole (2GB!) directory "linux-3-4" via "scp" over to my NanoPi Neo.
And did these needed steps:

Code: Select all

root@FriendlyARM:~# cd /lib/modules/`uname -r`
root@FriendlyARM:/lib/modules/3.4.39-h3# ln -sf /root/linux-3.4 build
root@FriendlyARM:/lib/modules/3.4.39-h3# ln -sf /root/linux-3.4 source
root@FriendlyARM:/lib/modules/3.4.39-h3#

I tried to compile hello world sample module:

Code: Select all

#include <linux/module.h>
#include <linux/kernel.h>

int hello_init(void)
{
    pr_alert("Hello World :)\n");
    return 0;
}
void hello_exit(void)
{
    pr_alert("Goodbye World!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");


With this Makefile:

Code: Select all

obj-m += hello-1.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


Got a compile error on missing "linux/compiler-gcc5.h".
Added a link to compiler-gcc4.h for that in "linux-3-4/include/linux".

Next compile error was on x86 executables encountered -- it seems that I am the very first trying to compile loadable kernel modules with Nanopi Neo or M1! I had to recompile these programs (without the ".x86" suffix on Nanopi Neo):

Code: Select all

root@FriendlyARM:~# find linux-3.4/scripts -name "*.x86" -print
linux-3.4/scripts/mod/modpost.x86
linux-3.4/scripts/mod/mk_elfconfig.x86
linux-3.4/scripts/basic/fixdep.x86
linux-3.4/scripts/recordmcount.x86
root@FriendlyARM:~#


That was all that was necessary to compile loadable kernel module and insmod it as shown above.

I am not done completely, since unlike on Ubuntu and Raspberry Pi Zero I am not able to rmmod that module:

Code: Select all

root@FriendlyARM:~/hello-1# lsmod
Module                  Size  Used by
hello_1                  807  0
root@FriendlyARM:~/hello-1# rmmod hello_1
rmmod: ERROR: ../libkmod/libkmod-module.c:793 kmod_module_remove_module() could not remove 'hello_1': Device or resource busy
rmmod: ERROR: could not remove module hello_1: Device or resource busy
root@FriendlyARM:~/hello-1#


Too late now, will work on that tomorrow,

Hermann.
I found a partial solution for the "Device or resource busy" issue when trying to remove a loadable kernel module with "rmmod".

What I really want is to be able to install the module again and again in order to execute code in "module_init()" function "in kernel space". This can be done with "rmmod -f". The very first statement on "-f" in "rmmod" man page says:
This option can be extremely dangerous: ...


So do not use this for other modules, but for the install and execute type of modules I am interested in "-f" is perfectly OK:

Code: Select all

root@FriendlyARM:~/hello-1# insmod hello-1.ko 
root@FriendlyARM:~/hello-1# rmmod -f hello-1.ko
root@FriendlyARM:~/hello-1# insmod hello-1.ko
root@FriendlyARM:~/hello-1# rmmod -f hello-1.ko
root@FriendlyARM:~/hello-1# insmod hello-1.ko
root@FriendlyARM:~/hello-1#
root@FriendlyARM:~/hello-1# dmesg | tail -5
[   12.990267] PHY: gmac0-0:00 - Link is Up - 100/Full
[   83.193976] Hello World :)
[  538.852037] Disabling lock debugging due to kernel taint
[  567.876798] Hello World :)
[  572.195812] Hello World :)
root@FriendlyARM:~/hello-1#


The main difference to Ubuntu and Raspbian (Pi Zero) doing normal "rmmod" without "-f" flag is that "module_exit()" does not get executed and therefore the goodbye message from above "hello-1.c" does not occur in dmesg output.

The kernel gets tainted by the first "rmmod -f", not sure whether this is a problem yet.

I looked on Raspberry Pi Zero and the main difference is that after startup 23 modules are reported by "lsmod" on Pi Zero, and 0 modules are reported for Nanopi Neo. Another difference is the "srcversion" included in Pi Zero module only:

Code: Select all

pi@raspberrypi01:~/hello-1 $ modinfo hello-1.ko
filename:       /home/pi/hello-1/hello-1.ko
license:        GPL
srcversion:     8D35A66DD68C15E90E01257
depends:       
vermagic:       4.4.19+ mod_unload modversions ARMv6
pi@raspberrypi01:~/hello-1 $

Code: Select all

root@FriendlyARM:~/hello-1# modinfo hello-1.ko 
filename:       /root/hello-1/hello-1.ko
license:        GPL
depends:       
vermagic:       3.4.39-h3 SMP preempt mod_unload ARMv7 p2v8
root@FriendlyARM:~/hello-1#


Hermann.
Hello,
We suggest you add and compile kernel module in the source of h3_lichee on computer .
You can use this command to compile:./build.sh -p sun8iw7p1 -b nanopi-h3 -m kernel , after compiling you need to copy .ko file to NanoPi NEO board then you can insmod the module.
I'm currently using these sources:
https://github.com/megous/linux/tree/orange-pi-4.6

There are also some development images on the armbian forum:
http://forum.armbian.com/index.php/topi ... nanopi-neo

Who is online

In total there are 46 users online :: 0 registered, 0 hidden and 46 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 46 guests