Wrong linux headers and source


Recommended Posts

Armbianmonitor:

I had compiled the Armbian image: Buster server. It shows like: Linux version 5.4.35-rockchip64 (root@ubuntu-bionic) ???

 uname -r
5.4.35-rockchip64


 

 

If I download the linux headers it downloads them, but version 5.4.32-rockchip64. If  I do :

apt-get source linux-source-$(uname -r)
Reading package lists... Done
E: You must put some 'source' URIs in your sources.list
root@rockpi-4b:~#


 

I can't compile the device drivers, since the headers are different.

Link to post
Share on other sites
Want Armbian t-shirt or a cup?

@Werner Thanks for that, they really installed.  @Igor Will try next time, but I don't think I will find this feature, I have built many times and never seen this option. But I did switch back to official Armbian buster with Linux 5.4.32-rockchip64 image. I did update, upgrade, install headers,  linux source everything now has the same version.  What I want is to compile a driver module: /drivers/staging/fbtft   So I did:

 

cd  cd linux-source-5.4.32-rockchip64/drivers/staging/fbtft/
make fb_ssd1306

 

I got errors:

 

root@rockpi-4b:~/fbtft# make fb_ssd1306
cc     fb_ssd1306.c   -o fb_ssd1306
fb_ssd1306.c:10:10: fatal error: linux/init.h: No such file or directory
 #include <linux/init.h>
          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: fb_ssd1306] Error 1
 

It looks like the header files are not properly found. How should I correctly set the directive? Any help is very appreciated. 

Link to post
Share on other sites
24 minutes ago, Marko Buršič said:

I have built many times and never seen this option

 

95% of config options from that link are not in the menu since menu is there to do minimal steps which you should do to achieve what you want: choose to recompile kernel, enable staging drivers and this fbtft and wait that it finishes.

 

You choose to go the complicated way where things can get messy :P Armbian Linux is in a good state, better that many Linux distros out there but its not automotive grade Linux as no free Linux is. If things doesn't go the way you want, you will have to fix them. Go rather recommended way. It should work, if drivers are O.K.

 

I do understand that recompiling the module out of the tree perhaps with DKMS is the best / desired way ... but we still manage lots of kernels with way too small resources. We recently did a lot of improvements in this area, but I guess the task is not fully done yet. Perhaps this can be related to the fact that drivers come from a staging areas, which nobody care for its quality yet.

Link to post
Share on other sites

@Igor Actually I want to make a new driver for fbtft which is not included in mainline kernel, I did a userpatch but when it compiles it gives an error and I don't know why.  It takes hours on Vagrant to compile, so I am looking for alternatives to compile only those modules, instead of making entire image. 

So my intention is not build/load existing drivers, rather to build these working drivers to then compile my non-working driver and make a final userpatch.  I have installed headers,  but it seems that compiler does not include them, any hint? 

Link to post
Share on other sites
41 minutes ago, Marko Buršič said:

It takes hours on Vagrant to compile


For development its recommend to use bare metal or full virtualization. I use my desktop and kernel recompilation with packing takes 1-2 minutes, image with writing to the device, less than 10m.

 

44 minutes ago, Marko Buršič said:

any hint?


Before you dig deeper, check @Larry Bank https://github.com/bitbank2 work.

Link to post
Share on other sites

I did in Vagrant, at module directory:

 

make -C /lib/modules/`uname -r`/build M=`pwd` modules obj-m=FILENAME.o

 

FILENAME is the name of module e.g. fb_ssd1322

 

I don't exactly know if the modules were built for host system or for the target system, but what's important is that I have found the error in the driver source. I made a user patch, now it is building new Armbian image, will see.

Link to post
Share on other sites

It's not so difficult as it seems, to build a module for driver.

Copy header and source packages, in my case linux-headers-current-rockchip64_20.05.0-trunk_arm64.deb and linux-source-current-rockchip64_20.05.0-trunk_all to your board. Then install:

dpkg -i linux-headers-current-rockchip64_20.05.0-trunk_arm64.deb

It does automatically all. Next is to install source:

dpkg -i  linux-source-current-rockchip64_20.05.0-trunk

This step only copies a tar.xf file into a directory /usr/src/ , but if you untar it it will reside in /usr/src/ directory, so let's make a new dir:

 

mkdir /usr/src/linux-source-$(uname -r)

And move the tar.xz file into that dir. (Perhaps there is a also different way to untar that untars into new dir, but I don't know it). Next untar the source archive:

tar xf linux-source-5.4.38-rockchip64.tar.xz

(5.4.38 is the current, you may have a newer file)

Now both headers and source is installed, let's build a driver. Exactly my fbtft device from staging dir.

 

 cd /usr/src/linux-source-5.4.38-rockchip64/drivers/staging/fbtft/

 

Rename Makefile to Makefile.bak. Then  write a new Makefile with nano Makefile:

 

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

Save this, to make the fb_ssd1322 (or whichever you want) and execute make.

 

make
make -C /lib/modules/5.4.38-rockchip64/build M=/usr/src/linux-source-5.4.38-rockchip64/drivers/staging/fbtft modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.38-rockchip64'
  CC [M]  /usr/src/linux-source-5.4.38-rockchip64/drivers/staging/fbtft/fb_ssd1322.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC [M]  /usr/src/linux-source-5.4.38-rockchip64/drivers/staging/fbtft/fb_ssd1322.mod.o
  LD [M]  /usr/src/linux-source-5.4.38-rockchip64/drivers/staging/fbtft/fb_ssd1322.ko

 

The driver module fb_ssd1322.ko is generated. 

 

To be continued .... (removing the driver, replacing the new one and installing back)
 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...