I 'm trying to cross-compile rtl8192cu Driver in my Linux x86 machine for an ARM machine. I downloaded driver from Realtek website. Compilation guide refers editing Makefile as follows:
Ensure that the $PATH variable includes the location of the toolchain that you will be using to cross-compile the module. Refer to the setup instructions for the location of this directory.
Set the KSRC environment variable is set to the location of your Beagleboard's kernel source (see cross-compilation environment setup instructions for this directory path).
Set the KVER environment variable to your beagleboard's kernel version.
For this reson, I edited:
KVER := 2.6.32 (2.6.32. is BB's kernel version)
KSRC ?= /home/demetres/linux-2.6.32.61 (compiled kernel sources, taken from BB, stored on home/demetres/linux-2.6.32.61 location)
My question is:
What do I have to edit on Makefile's field CROSS_COMPILE:? I edited the path /home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin but
make fails with these errors:
make ARCH=arm CROSS_COMPILE=/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin -C /home/demetres/linux-2.6.32.61 M=/home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911 modules
make[1]: /home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bingcc: Command not found
make[1]: Entering directory `/home/demetres/linux-2.6.32.61'
CC [M] /home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911/core/rtw_cmd.o
/bin/sh: /home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bingcc: No such file or directory
make[2]: *** [/home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911/core/rtw_cmd.o] Error 1
make[1]: *** [_module_/home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911] Error 2
make[1]: Leaving directory `/home/demetres/linux-2.6.32.61'
make: *** [modules] Error 2
INFO: Cross-toolchain on x86 machine is from CodeSourcery. I cross-compiled a helloworld.c for BB, by running arm-none-linux-gnueabi-gcc helloworld.c –o helloworld, on CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin location.
_CodeBench_Lite_for_ARM_GNU_Linux/bingcc: Command not found
This error is due to you are not passing correct parameter
pass arm-none-linux-gnueabi-
where ever it finds {CROSS_COMPILE}gcc {CROSS_COMPILE}ld ...etc
this will be replaced with arm-none-linux-gnueabi-gcc arm-none-linux-gnueabi-ld
Edit
make ARCH=arm CROSS_COMPILE=/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi- -C /home/demetres/linux-2.6.32.61 M=/home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911 modules
If your cross-toolchain exported then try this
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C /home/demetres/linux-2.6.32.61 M=/home/demetres/Downloads/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911 modules
Related
I am trying to make modifications to the UVC kernel module and then insert it into my running kernel. To do this, I performed these steps:
Install linux-headers with sudo apt install linux-headers-$(uname -r)
Checkout the UVC drivers folder from the Linux kernel GitHub repository
Enter directory and try to compile with make -C /lib/modules/`uname -r`/build M=$PWD as specified by Building External Modules from the kernel.org docs.
But I get this error from Make, complaining that it can't find an include from the tree above (which I do not have checked out)
me#bionic:~/src/media/usb/uvc$ make -C /lib/modules/`uname -r`/build M=$PWD
make: Entering directory '/usr/src/linux-headers-5.4.0-131-generic'
CC [M] /home/me/src/media/usb/uvc/uvc_driver.o
/home/me/src/media/usb/uvc/uvc_driver.c:23:10: fatal error: media/v4l2-uvc.h: No such file or directory
#include <media/v4l2-uvc.h>
^~~~~~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.build:270: recipe for target '/home/me/src/media/usb/uvc/uvc_driver.o' failed
make[1]: *** [/home/me/src/media/usb/uvc/uvc_driver.o] Error 1
Makefile:1762: recipe for target '/home/me/src/media/usb/uvc' failed
make: *** [/home/me/src/media/usb/uvc] Error 2
make: Leaving directory '/usr/src/linux-headers-5.4.0-131-generic'
But shouldn't it be able to find this include from my running kernel (given by -C /lib/modules/`uname -r`/build)? How can I compile this kernel module?
The Makefile from inside the UVC folder contains:
# SPDX-License-Identifier: GPL-2.0
uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
uvc_status.o uvc_isight.o uvc_debugfs.o uvc_metadata.o
ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
uvcvideo-objs += uvc_entity.o
endif
obj-$(CONFIG_USB_VIDEO_CLASS) += uvcvideo.o
and the Kconfig file contains:
config USB_VIDEO_CLASS
tristate "USB Video Class (UVC)"
depends on VIDEO_V4L2
select VIDEOBUF2_VMALLOC
---help---
Support for the USB Video Class (UVC). Currently only video
input devices, such as webcams, are supported.
For more information see: <http://linux-uvc.berlios.de/>
config USB_VIDEO_CLASS_INPUT_EVDEV
bool "UVC input events device support"
default y
depends on USB_VIDEO_CLASS
depends on USB_VIDEO_CLASS=INPUT || INPUT=y
---help---
This option makes USB Video Class devices register an input device
to report button events.
If you are in doubt, say Y.
I'm trying to make a profile in Volatility 2. I tried on Debian, Kali and Ubuntu 120.04 and Ubuntu 18 (gcc 7.5.0). I tried to update the headers, export pathes etc.. but still I have the same error . I tried also to dowload a profile from github but they are too old ( i didn't found nothing new - just Ubuntu 14) . I also checked module.h info but didn't find antything helpfull. Any idea what i can do?
make -C //lib/modules/4.15.0-162-generic/build CONFIG_DEBUG_INFO=y M="/root/volatility-master/tools/linux" modules
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-162-generic'
CC [M] /root/volatility-master/tools/linux/module.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: modpost: missing MODULE_LICENSE() in /root/volatility-master/tools/linux/module.o
see include/linux/module.h for more information
CC /root/volatility-master/tools/linux/module.mod.o
LD [M] /root/volatility-master/tools/linux/module.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-162-generic'
dwarfdump -di module.ko > module.dwarf
make -C //lib/modules/4.15.0-162-generic/build M="/root/volatility-master/tools/linux" clean
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-162-generic'
CLEAN /root/volatility-master/tools/linux/.tmp_versions
CLEAN /root/volatility-master/tools/linux/Module.symvers
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-162-generic'
I am trying to create an package for dietsplash for buildroot, and I've added the files
Config.in
config BR2_PACKAGE_DIETSPLASH
bool "dietsplash"
help
dietsplash is an simple splash screen service for
embedded devices. It has support for animations.
dietsplash.mk
################################################################################
#
# dietsplash
#
################################################################################
DIETSPLASH_VERSION = v0.3
DIETSPLASH_SOURCE = dietsplash-$(DIETSPLASH_VERSION).tar.gz
DIETSPLASH_SITE = git://github.com/lucasdemarchi/dietsplash.git
DIETSPLASH_AUTORECONF = YES
$(eval $(autotools-package))
The github repository is
https://github.com/lucasdemarchi/dietsplash
The output of make is:
>>> dietsplash v0.3 Building
PATH="/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/host/bin:/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/host/sbin:/home/justus_fluegel/.pub-cache/bin/:/usr/share/flutter/flutter/bin/cache/dart-sdk/bin/:/usr/share/flutter/flutter/bin/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/snap/bin:/usr/local/texlive/2019/bin/x86_64-linux" /usr/bin/make -j5 -C /media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/
make[1]: Entering directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
/usr/bin/make all-am
make[2]: Entering directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
GEN src/background.h
/bin/bash: src/genstaticlogo: cannot execute binary file: Exec format error
Makefile:1017: recipe for target 'src/background.h' failed
make[2]: *** [src/background.h] Error 126
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
Makefile:400: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
package/pkg-generic.mk:238: recipe for target '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/.stamp_built' failed
make: *** [/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/.stamp_built] Error 2
And file of src/genstaticlogo
src/genstaticlogo: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 4.19.0, not stripped
I think the problem is that src/genstaticlogo is compiled for the target but executed by the Makefile.am during the build process. How do I tell make to compile src/genstaticlogo for the build machine and not for the target? Altough the repository is not my work, it's theoretically possible to modify the makefile after download.
Thank you for your help!
You will need to patch the Makefile.am to support cross-compilation. See this old answer for details. In short, you will need something like this in the Makefile.am:
$(genstaticlogo_OBJECTS): CC=$(CC_FOR_BUILD)
$(genstaticlogo_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
$(genstaticlogo_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
Since you will be patching Makefile.am, you will also need to set DIETSPLASH_AUTORECONF = YES in the Buildroot dietsplash.mk file.
GOAL: compile samples/bpf, compile bpf/bpftool and use them.
PROBLEM: on a VM with Ubuntu 18.04 bionic with a kernel 4.18.0-25-generic I've installed kernel src code executing apt install linux-source-4.18.0.
Now I cd into /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf and I run make and the result is
make -C ../../ /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf/ BPF_SAMPLES_PATH=/usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf
make[1]: Entering directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
scripts/kconfig/conf --syncconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
scripts/kconfig/Makefile:40: recipe for target 'syncconfig' failed
make[3]: *** [syncconfig] Error 1
Makefile:562: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop.
make[1]: Leaving directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
Makefile:203: recipe for target 'all' failed
make: *** [all] Error 2
If I cd into ../samples/bpf and I run sudo make the result is
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ OFF ]
CC map_perf_ring.o
CC xlated_dumper.o
CC perf.o
CC cfg.o
CC common.o
CC cgroup.o
CC main.o
main.c:36:10: fatal error: bfd.h: No such file or directory
#include <bfd.h>
^~~~~~~
compilation terminated.
Makefile:92: recipe for target 'main.o' failed
make: *** [main.o] Error 1
QUESTIONS: what am I missing? After I compile them if I want to write a program which, for example, needs to use bpftool I have to write the program inside the source kernel directory or I can write it everywhere?
Build errors
The first case (Makefile:562: recipe for target 'syncconfig' failed) fails because you run make from the top of the linux kernel repository, and before trying to compile the samples, the build system tries to load a config file to use for your system (but does not find one).
Before trying to build the samples (make -C samples/bpf), you can create a .config file from your current kernel configuration like this:
$ cp /usr/src/linux-headers-$(uname -r)/.config <path to repo>/.config
$ make olddefconfig
Or even simply generate a default config file from scratch:
$ make defconfig
See make help from top directory to see the available make options.
Your second error, regarding bfd.h not found, is that you miss a library. Libbfd on Ubuntu comes with binutils-dev, so apt install binutils-dev should do the trick.
Compiling the programs
Finally, regarding your question on compiling the programs:
You can write and build program from the kernel repository, just by creating a new sample and reusing the existing Makefiles.
You can also write and compile programs outside of the kernel tree. The basic clang (v4.0 or above, if possible v6.0 or above) command to compile them usually looks something like this:
$ clang -O2 -emit-llvm -c my_bpf_prog.c -o - | \
llc -march=bpf -filetype=obj -o my_bpf_prog.o
You can find examples of programs compiled out of the kernel tree in that repository (disclaimer: by my company) or in the XDP tutorial repo.
I am new to compiling.
I am trying to compile iperf3 for Windows 10 because there is no official Windows distribution of iperf3 and for the learning experience. I am trying to do so on the new Windows Subsystem for Linux feature via Bash on Ubuntu on Windows, also for the learning experience.
I installed mingw-w64, which should give me the proper compiler and environment necessary for cross-compiling:
sudo apt-get install mingw-w64
This put two directories into my /usr directory:
i686-w64-mingw32
x86_64-w64-mingw32
It also put a bunch of things that look like compilers into /usr/bin.
I unzipped the .tar.gz file from iperf3 and navigated into it. Then, I run ./configure --host=i686-w64-mingw32.static and it completes without errors.
I note that the output of the command has a worrisome line: checking for i686-w64-mingw32.static-gcc... no
I note that the Makefile's CC variable is set to gcc, which doesn't sound like the proper compiler.
Then, I run make. It fails with errors:
collect2: error: ld returned 1 exit status
make[2]: *** [iperf3] Error 1
make[2]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make: *** [all-recursive] Error 1
I also see the line: libtool: warning: undefined symbols not allowed in i686-w64-mingw32.static shared libraries; building static only
I think that the ./configure is not working correctly since it appears to have not found the right compiler for my --host argument and put it in the Makefile.
What am I doing wrong?
EDIT:
I changed the command to ./configure --host=i686-w64-mingw32 per comments and it completes without error. But no makefile is created so make yields make: *** No targets specified and no makefile found. Stop.
What am I doing wrong, now?
EDIT 2:
Looks like the ./configure actually is failing. Last line of its output is nanosleep() required for timing operations., which seems to mean that its missing a library for nanosleep.
How do I get nanosleep?
mingw doesn't support nanosleep. So programs using it cannot be compiled using mingw-w64.