cp210x.ko kompilieren für Raspberry

Begonnen von jostmario, 01 November 2013, 12:05:10

Vorheriges Thema - Nächstes Thema

jostmario

Hallo

wer könnte mir die cp210x.ko für mein Raspberry Pi kompilieren um mein Stommesser per USB zu integrieren bekomme das irgendwie nicht zum laufen.
bekomme die fehlermeldung :  could not insert 'cp210x': Exec format error
die Datei findet sich hier
http://www.meintechblog.de/2013/10/smart-metering-mit-owl-usb-und-fhem-live-tracking-des-stromverbrauchs/
evtl zeigen wie es geht per Skype und Teamviewer.
evtl für ne kleine Spende :-)

Danke Gruß Josty

das wäre die anleitung dazu wenn damit jemand was anfangen kann:

Run

./install.sh

to install the pre compiled cp210x driver kernel module.
This will only work on a raspbian 3.6.11 kernel (2013-02-09-wheezy-raspbian.zip).
If this does not work on your raspberypi then you
will need to compile the driver for the kernel version that you have
installed. Some details of how this may be done are shown below.




BUILDING THE RASPBERRYPI cp210x DRIVER
/
The following details how the cp210x driver may be rebuilt. It also
serves as a basic guide to cross compiling the raspberrypi kernel.

This guide assumes
- You have an Ubuntu 12.04 machine
- You have a raspberrypi running raspybian (either the 3.2.27+ or the 3.6.11+ kernel)
- You have the ssh server on the raspberrypi and the Ubuntu machine and they are
  connected to the same IP network.
   
When complete the raspberrypi will be able to run the cm160server and the Ubuntu
machine will be able to run the electricowl GUI.   

ON THE RASPBERRYPI
Grab the current kernel configuration as follows
- From a terminal window or ssh session, take a copy of the current kernel configuration using the following command.
  zcat /proc/config.gz > /tmp/.config
- Copy the current kernel configuration to the Ubuntu machine
  scp /tmp/.config <USERNAME>@<UBUNTU MACHINE IP ADDRESS>:/tmp
      replace <USERNAME> with your username on the Ubuntu machine and
      <UBUNTU MACHINE IP ADDRESS> with its IP address.


ON THE UBUNTU MACHINE
Cross compile the raspberrypi kernel as follows
- cd ~
- mkdir raspberrypi_kernel
- cd raspberrypi_kernel
- sudo apt-get install git (only required if git is not installed on your ubuntu machine)
- git clone --depth 1 git://github.com/raspberrypi/linux.git
- git clone git://github.com/raspberrypi/tools.git
- cd linux
- git fetch
- git checkout rpi-3.2.27 (for the 3.2.27 kernel) or git checkout rpi-3.6.y (for the 3.6.11 kernel)
- Edit the Makefile (in the current folder) and
  Change the following line
   HOSTCXXFLAGS = -O2
  to
   HOSTCXXFLAGS = -O2 -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
- PATH=$PATH:$HOME/raspberrypi_kernel/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
- make mrproper
- cp /tmp/.config .
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
   Enter return to select the default option for each kernel option presented

  The raspberrypi kernel will then be built, this will take some time....

Now that the kernel has been built we need to copy the cp210x driver source code into the kernel
source tree and compile it. The following cmds detail how this may be done.

- mv ~/raspberrypi_kernel/linux/drivers/usb/serial/cp210x.c /tmp/cp210x.c.org
- copy the cp210x.c (from the tarball) file to ~/raspberrypi_kernel/linux/drivers/usb/serial/cp210x.c
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

   This time only the new cp210x driver will be rebuild, this shouldn't take long

- Copy the cp210x kernel module to the raspberry pi using the following command
    scp drivers/usb/serial/cp210x.ko pi@192.168.0.115:/tmp
    (The IP address should be the IP address of the raspberrypi)

ON THE RASPBERRYPI
The modified cp210x kernel driver needs to be copied from /tmp/cp210x.ko to its correct location.
by running the following commands from a terminal on the raspberry pi. The 3.2.27+ text should be
substituted with 3.6.11+ if the raspbery pi has a 3.6.11 kernel.

- sudo mv /lib/modules/3.2.27+/kernel/drivers/usb/serial/cp210x.ko /lib/modules/3.2.27+/kernel/drivers/usb/serial/cp210x.ko.old1
- sudo cp /tmp/cp210x.ko /lib/modules/3.2.27+/kernel/drivers/usb/serial/cp210x.ko
- Edit the /etc/modules file and add the following line to the end of the file to ensure the cp210x module is loaded on restart
   cp210x
- Remove the previous cp210x kernel driver
    sudo rmmod cp210x
- Add the modified cp210x kernel driver
    sudo modprobe cp210x


Note !!!
If you run 'sudo modprobe cp210x' and get the following error then you have probably compiled the
cp210x module  for the wrong processor architecture. Check that you edited the Makefile as detailed
in the steps above.

ERROR: could not insert 'cp210x': Exec format error
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

PeMue

Hallo jostmario,

dann solltest Du aber noch Deine Kernel Version posten. Denn derjenige, der compiliert, sollte dieselbe haben, wie Du.
uname -rFalls Du die 3.6.11+ haben solltest, einfach das angehängte Paket (irgendwohin) auspacken und mit
./install.sh installieren.

Gruß PeMue
RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

jostmario

#2
Hallo

ja Super Danke erst mal

ja mit dem Konsolenbefehl  uname -r   sagt er 3.6.11+
hab die 4 Files jetzt per FTP ins verzeichnis tmp auf den Raspberry hochgeladen.
bin nach stunden ein wenig weiter.
jetzt kommt


pi@raspberrypi /tmp $ ./install.sh
mv: cannot move `/lib/modules/3.6.11+/kernel/drivers/usb/serial/cp210x.ko' to `/lib/modules/3.6.11+/kernel/drivers/usb/serial/cp21
Error: Module cp210x is not currently loaded
cp: cannot create regular file `/lib/modules/3.6.11+/kernel/drivers/usb/serial/cp210x.ko': Permission denied
./install.sh: 14: ./install.sh: cannot create /etc/modules: Permission denied
pi@raspberrypi /tmp $



was kann ich tun ?

Gruß Josty
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

jostmario

Hallo

Ok mit    sudo su
konnt ich den befehl ./install.sh ausführen urrrggg jedoch bin ich wieder da wo ich vor 15 stunden war:

root@raspberrypi:/tmp# ./install.sh
Error: Module cp210x is not currently loaded
ERROR: could not insert 'cp210x': Exec format error
root@raspberrypi:/tmp#


Gruß Josty
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

jostmario

wenn ich in die install.sh datei von dir reinschaue sthet da

#!/bin/sh
KERNEL=$(uname -r)
if [ "$KERNEL" != "3.6.11+" ]; then
   echo "This pre compiled cp210x module is for a 3.6.11 kernel. This is $KERNEL kernel."; exit 1


und ich hab ja 3.6.11+ also geht er doch in exit oder ?

Gruß Josty
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

PeMue

Hallo Josty,

was kommt denn bei Dir auf der Konsole nach Ausführen von install.sh?
Wenn
cp210x module installed.kommt, war alles ok.
Wenn nicht, hast Du recht (allerdings passt in der install.sh der Text nicht zur Abfrage).

Vermutlich scheitert die Installation bei dem Befehl
modprobe cp210x -> Treiber passt nicht, neucompilieren ist wohl notwendig  :(

Gruß PeMue
RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

jostmario

Hallo,

Ja hab jetzt ubuntu in ner virtuellen Maschine im Windows installiert.
Aber klappt irgendwie ohne linuxkenntnisse nicht so richtig :-(

Gruß Josty
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

jostmario

Hallo

Hier mal die exportierte .Config datei aus dem Raspberry.
kann damit jemand was anfangen.
bin am verzweifeln....

Gruß Josty
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

Hans Franz

Moin,
Ich denke, den Versuch des Kompilierens des Treibers, kannst du dir ersparen.
Ich habe es  duchexerziert: Der Treiber von PeMue ist gegen 3.6.11 kompiliert und müsste bei dir problemlos eingebunden werden.

pi@raspberrypi ~ $ ls -l /lib/modules/3.6.11+/kernel/drivers/usb/serial/cp*
-rwxr--r-- 1 root root 26377 Nov  2 02:00 /lib/modules/3.6.11+/kernel/drivers/usb/serial/cp210x.ko
-rwxr--r-- 1 root root 26377 Nov  2 01:59 /lib/modules/3.6.11+/kernel/drivers/usb/serial/cp210x.ko.org
-rw-r--r-- 1 root root 26098 Jun 19 12:08 /lib/modules/3.6.11+/kernel/drivers/usb/serial/cp210x.ko.orig

pi@raspberrypi ~ $ uname -r
3.6.11+

pi@raspberrypi ~ $ sudo modprobe cp210x

pi@raspberrypi ~ $ lsmod
Module                  Size  Used by
cp210x                 11859  0
usbserial              32890  1 cp210x


Stimmt die Größe (26377) der Datei?

Viel Glück,
Hans
Raspi
CUL, Nano-CUL
FHT8V, FHT80B, S300TH
WM1000WZ, ELRO
LW12, LD382,DS18B20

PeMue

Hallo Josty,

und wenn, dann würde ich direkt auf dem Raspberry Pi compileren. Das ist das Originalsystem.

Gruß PeMue
RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

PeMue

ok, war doof. Ich habe die Anleitung nicht gelesen und nicht gesehen, dass derjenige, der die Anleitung geschrieben hat, ein "cross compile" macht. Müsste aber eigentlich auf dem Raspberry Pi ähnlich gehen ...

Gruß PeMue
RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

PeMue

Hallo Josty,

schau mal hier, vielleicht geht das Kommando auch beim Raspberry Pi und hilft Dir beim Compilieren.
Bist Du weitergekommen?

Gruß PeMue
RPi3Bv1.2 rpiaddon 1.66 6.0 1xHM-CC-RT-DN 1.4 1xHM-TC-IT-WM 1.1 2xHB-UW-Sen-THPL-O 0.15 1x-I 0.14OTAU  1xCUNO2 1.67 2xEM1000WZ 2xUniroll 1xASH2200 3xHMS100T(F) 1xRFXtrx 90 1xWT440H 3xTFA30.3150 5xFA21
RPi1Bv2 LCDCSM 1.63 5.8 2xMAX HKT 1xMAX RT V200KW1 Heizung Wasser

jostmario

Hallo

ne noch nicht wirklich biste da ?

Gruß Mario
Raspberry Pi  ---  HM-LAN ---  8X HM_HM_CC_RT_DN --- OWL+USB Strommesser    UVR1611

netbus

hast du schon einen Treiber für 3.10.25 kompiliert?

netbus

leider habe ich auf 3.10.33+ upgegraded.  :(
daher wollte ich selber kompilieren bekomme aber folgende Fehlermeldung
root@ubuntu:/home/user/raspberrypi_kernel/linux# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTLD  scripts/mod/modpost
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  CC [M]  drivers/usb/serial/cp210x.o
drivers/usb/serial/cp210x.c: In function 'cp210x_get_config':
drivers/usb/serial/cp210x.c:309:3: error: implicit declaration of function 'dbg' [-Werror=implicit-function-declaration]
drivers/usb/serial/cp210x.c: In function 'cp210x_get_termios':
drivers/usb/serial/cp210x.c:477:17: error: invalid type argument of '->' (have 'struct ktermios')
drivers/usb/serial/cp210x.c: In function 'cp210x_change_speed':
drivers/usb/serial/cp210x.c:639:21: error: invalid type argument of '->' (have 'struct ktermios')
drivers/usb/serial/cp210x.c: In function 'cp210x_set_termios':
drivers/usb/serial/cp210x.c:673:22: error: invalid type argument of '->' (have 'struct ktermios')
drivers/usb/serial/cp210x.c:676:18: error: invalid type argument of '->' (have 'struct ktermios')
cc1: some warnings being treated as errors
make[3]: *** [drivers/usb/serial/cp210x.o] Error 1
make[2]: *** [drivers/usb/serial] Error 2
make[1]: *** [drivers/usb] Error 2
make: *** [drivers] Error 2

Laut diversen Foren hat sich der "pointer" ab Kernel 3.6 geändert.
Daher die Frage ob jemand ein angepasstes cp210x.c File hat?