Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: danny on May 04, 2020, 08:30:42 PM

Title: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 04, 2020, 08:30:42 PM
Hi
I want to symlink to the kernel source in "/lib/modules/'uname -a'/build".
But there is not "/usr/src/linux-headers-XXX/" directory on piCore11.X.
How can I produce file "/lib/modules/'uname -a'/build"?

Thanks
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 05, 2020, 11:10:48 PM
If you wish to compile kernel modules, you often need to symlink "/lib/modules/'uname -r'/build" to the unpacked and prepared kernel source.

For example, if you unpacked your kernel source at /usr/src/linux-rpi-4.19.81, then you would do this:
Code: [Select]
$ sudo ln -s /usr/src/linux-rpi-4.19.81 /lib/modules/4.19.81-piCore-v7l/build
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 05, 2020, 11:38:31 PM
I got the following message.
Code: [Select]
ln: /lib/modules/4.19.81-piCore-v7l/build: No such file or directory
Thanks
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 06, 2020, 12:46:15 AM
It looks like you either miss-typed the command or you did not create /usr/src/linux-rpi-4.19.81?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 06, 2020, 05:50:47 PM
How can I create /usr/src/linux-rpi-4.19.81?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Rich on May 06, 2020, 06:16:44 PM
Hi danny
This should do it:
Code: [Select]
sudo su
mkdir /usr/src
cd /usr/src
wget http://www.tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/linux-rpi-4.19.81.tar.xz
tar Jxvf linux-rpi-4.19.81.tar.xz
exit

Are you trying to build a kernel module? There are a lot more pre-compiled modules available in  modules.tar.gz  found here:
http://www.tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 10, 2020, 08:01:53 PM
The file in linux-rpi-4.19.81.tar.xz is too large to unzip to /usr/src.
It is only 833MB available /usr/src.
So I unzip it to /mnt/mmcblk0p3/linux-rpi-4.19.81 and execute the following:
Code: [Select]
sudo ln -s /mnt/mmcblk0p3/linux-rpi-4.19.81 /lib/modules/4.19.81-piCore-v7/buildBut my wifi driver still can't identify kernel.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 10, 2020, 08:37:06 PM
Please paste the error message here.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 11, 2020, 12:14:13 AM
The message is:
Code: [Select]
insmod: can't insert 'onebox_common_gpl.ko': invalid module format
insmod: can't insert 'wlan.ko': invalid module format
insmod: can't insert 'wlan_wep.ko': invalid module format
insmod: can't insert 'wlan_tkip.ko': invalid module format
insmod: can't insert 'wlan_ccmp.ko': invalid module format
insmod: can't insert 'wlan_aes_cmac.ko': invalid module format
insmod: can't insert 'wlan_acl.ko': invalid module format
insmod: can't insert 'wlan_xauth.ko': invalid module format
insmod: can't insert 'wlan_scan_sta.ko': invalid module format
insmod: can't insert 'onebox_wlan_nongpl.ko': invalid module format
insmod: can't insert 'onebox_wlan_gpl.ko': invalid module format
insmod: can't insert 'onebox_nongpl.ko': invalid module format
insmod: can't insert 'onebox_gpl.ko': invalid module format
cat: can't open '/proc/rpine0/stats': No such file or directory
Exiting: Driver init is not yet completed, Please check the coex mode / protocol selected

I want to use wifi module RYWDB00 on piCore.
I have used it successfully on Raspbian.
RYWDB00 support Kernel versions from 2.6.38 to 5.1.6.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 11, 2020, 12:19:21 AM
Kernel drivers taken from raspbian will not work on piCore.

You need the symlink to compile an out of tree driver, not use it.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 11, 2020, 12:45:48 AM
Does it mean compile file in linux-rpi-4.19.81.tar.gz and let /lib/modules/4.19.81-piCore-v7/build symlink to it?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 11, 2020, 01:18:55 AM
No - I presume the driver source code for the RYWDB00 is not available in the linux kernel source.

If the above is true, then you need to obtain the source code for the RYWDB00 driver.

Once you have the source code for the driver you need to compile it against the prepared piCore kernel source.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 11, 2020, 01:43:34 AM
OK,it sounds difficult.
I have obtained the source code of driver.
But I have no idea to make it compile it against the prepared piCore kernel source.
Could you provide any advice?
Thank you so much!
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 11, 2020, 02:07:52 AM
The first problem is to find the kernel config for piCore-11beta - I don't have it  :(
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Paul_123 on May 11, 2020, 01:52:12 PM
grab configs.ko from the complete modules pack,

modprobe configs.ko
zcat /proc/config.gz
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 11, 2020, 05:36:43 PM
Hi Paul,
Thanks for your help.
I pasted in terminal:
Code: [Select]
modprobe configs.ko
zcat /proc/config.gz

And then I see Linux/arm 4.19.81 Kernel Configuration.
What is the next step I can compile driver source code against the prepared piCore kernel source?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 11, 2020, 11:08:51 PM
I learnt something there  :)

Once you have the kernel config, to prepare the kernel source you need to do something like this using:

http://tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/linux-rpi-4.19.81.tar.xz
http://tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/Module.symvers

Code: [Select]
$ tce-load -i compiletc bash bc perl5 ncurses-dev openssl-dev libelf-dev
$ tar xf linux-rpi-4.19.81.tar.xz
$ cd linux-rpi-4.19.81

$ make mrproper
$ cp ../config-4.19.81-piCore-v7 .config
$ make oldconfig
$ make prepare
$ make modules_prepare

$ cp ../Module.symvers ./
$ make SUBDIRS=scripts/mod

.and the kernel source will be ready to compile your RYWDB00 source against it.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 12, 2020, 06:40:00 PM
I met some problem:
1.Where is the directory of config-4.19.81-piCore-v7 and the file of .config?
2.Does the file of Module.symvers exist on piCore or I need to download it?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 12, 2020, 10:17:07 PM
config-4.19.81-piCore-v7 is the piCore kernel config file as revealed by @Paul_123.

The config has been uploaded to the server here: http://tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/config-4.19.81-piCore-v7

Once you have downloaded the config file config-4.19.81-piCore-v7, you need to copy it into the kernel source and rename it to .config as explained previously.

As mentioned earlier, you need to download the Module.symvers file from here: http://tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/Module.symvers

Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 13, 2020, 02:39:52 AM
Does it exist iw phy | greg phy command on piCore?
When I pasted iw phy | greg phy I got
Code: [Select]
-sh: iw: not found
-sh: greg: not found
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 13, 2020, 03:35:34 AM
The command is "grep" and not "greg".

There is no iw extension in piCore-11.x - use wireless_tools or, better still, wifi.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 13, 2020, 10:36:04 PM
How can I use wireless_tools to find usable wifi interface?
Like:
Code: [Select]
iw phy | grep phy
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 13, 2020, 11:00:07 PM
Code: [Select]
$ iwconfig
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 14, 2020, 12:07:52 AM
This list when I execute "iwconfig"
Code: [Select]
wlan0     IEEE 802.11  ESSID:"MIT_5G"
          Mode:Managed  Frequency:5.22 GHz  Access Point: 68:FF:7B:1A:43:CF
          Bit Rate=433.3 Mb/s   Tx-Power=31 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-34 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:8  Invalid misc:0   Missed beacon:0

eth0      no wireless extensions.

rpine0    no wireless extensions.

lo        no wireless extensions.
I want to use "rpine0" be default wifi interface.
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 14, 2020, 03:00:31 AM
Have you tried:
Code: [Select]
$ sudo iwconfig wlan0 down
$ sudo iwconfig rpine0 up
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 14, 2020, 05:41:59 PM
It show:
Code: [Select]
iwconfig: unknown command "down"
iwconfig: unknown command "up"
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 14, 2020, 10:34:40 PM
Sorry - I meant ifconfig...
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 17, 2020, 07:05:24 PM
Can I use the following resource to install libnl and wi on piCore?
Code: [Select]
https://www.infradead.org/~tgr/libnl/files/
Code: [Select]
https://mirrors.edge.kernel.org/pub/software/network/iw/
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Rich on May 17, 2020, 07:46:32 PM
Hi danny
The info files from previous versions list where the sources were downloaded from:
http://tinycorelinux.net/10.x/armv7/tcz/libnl.tcz.info
http://tinycorelinux.net/10.x/armv7/tcz/iw.tcz.info

There are some build scripts for  libnl  and  iw  here:
http://tinycorelinux.net/10.x/armv7/tcz/src/libnl/
http://tinycorelinux.net/10.x/armv7/tcz/src/iw/
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 17, 2020, 09:21:58 PM
libnl is in piCore-11.x and iw is provided by wireless-tools, which is also in piCore-11.x
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 17, 2020, 10:00:31 PM
Should I execute
Code: [Select]
./configure --host=arm-linux --prefix=/home/tc/workand compile Makefile in iw-4.14 and libnl-3.4.0 like
Code: [Select]
make mrproperor other instruction to compile them?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 17, 2020, 10:15:10 PM
You should do it like this:
Code: [Select]
CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --disable-static

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make
sudo make install

..but why compile them when they already exist?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 17, 2020, 10:35:52 PM
When I pasted
Code: [Select]
CC="gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe" CXX="g++ -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local --localstatedir=/var --disable-staticthen show
Code: [Select]
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking whether make supports nested variables... (cached) no
checking for style of include used by make... none
checking for gcc... gcc -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe
checking whether the C compiler works... no
configure: error: in `/home/tc/libnl-3.4.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 17, 2020, 11:40:17 PM
Did you load compiletc and are you compiling on an RPi?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: danny on May 18, 2020, 07:03:03 PM
Thanks for help Juanito and Rich.
I have installed it successfully.
By the way,
Can I change default Wifi interface "wlan0" to another one on piCore?
Title: Re: How can I symlink to the kernel source in "/lib/modules/'uname -a'/build"?
Post by: Juanito on May 18, 2020, 10:17:21 PM
What are you try to do exactly?

If you wish to disable the built-in wifi on an RPi3, for example, you can add the following to /mnt/mmcblk0p1/config.txt:
Code: [Select]
dtoverlay=pi3-disable-wifi
Once the built-in wifi is disabled, the wifi.sh script from the wifi extension looks like it would detect rpine0 from your extenal adapter.

Edit: it also looks like "dtoverlay=disable-wifi" would disable the built-in wifi on both RPi3 and RPi4.