How can I compile usb-storage.ko (only) from kernel source tree ?
Running kernel version: 2.6.35-22-generic (uname -r)
Source version: linux-2.6.35
Doing modprobe usb-storage gives the below error.
FATAL: Error inserting usb_storage (/lib/modules/2.6.35-22-generic/kernel/drivers/usb/storage/usb-storage.ko): Invalid module format
Doing insmod gives the below error.
insmod: error inserting 'drivers/usb/storage/usb-storage.ko': -1 Invalid module format
dmesg gives as below.
usb_storage: no symbol version for module_layout
How can I change the top level Makefile to get it inserted into running version of kernel ?
Makefile(top level)
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 35
EXTRAVERSION =
NAME = Sheep on Meth
During kernel development one often encounters these 2 frustrating errors upon insmod ing locally built ko modules.
Error1: <module-name> no symbol version for module_layout
Why?
This means that the Kernel source is NOT built. Once the entire kernel source is built, then a file Modules.symvers will be generated in the top-level directory of the Linux Kernel source. This will contain the address of the symbol module_layout. Henceforth, this will be used when any kernel modules are built.
Fix
Build the complete Kernel source. Ensure that Modules.symvers is generated and it contains a line with the symbol module_layout. Following this, build the kernel module.
Error2: <module-name> disagrees about version of symbol module_layout
Why?
The error means that the kernel source being used differs significantly from the one used to build the kernel image used to boot.
Fix
Manually modifying the ko module file to match the value of module_layout in the ko file with the value in the kernel image being used to boot.
To do so we first need to determine the valid value of module_layout. This is essentially present in each of the valid working ko files present on the system. A quick way to obtain this info is from a valid ko file that successfully loads. Use lsmod to get a list of potential "working.ko" files.
# modprobe --dump-modversions <working.ko> | grep module_layout
0x0b11e775 module_layout
# modprobe --dump-modversions <your.ko> | grep module_layout
0x2719d41e module_layout
NOTE: IF there is no instance of module_layout symbol in your ko file then first follow steps to fix ERROR1 before proceeding below.
Using your favorite hex editor, find and replace the value (4 bytes) in your ko file with the value from the working ko file.
Before Modification:
00016c701e d4 19 276d 6f 64 75 6c 65 5f 6c 61 79 6f 75 |u...module_layou|
After Modification:
00016c7075 e7 11 0b6d 6f 64 75 6c 65 5f 6c 61 79 6f 75 |u...module_layou|
With the above changes, insmod ing the locally built ko file should be successfull.
Related
I have been using the flamegraph profiler, rs-flamegraph, quite successfully over the past few days. When I run it from bash it works fine. No sudo or anything.
~/.cargo/bin/flamegraph -o "$f flamegraph.svg" ./binary
When I invoke the binary from Rust using process::Command it fails saying that it cannot sample collapsed stack.
let svgfilename = format!("{} flamegraph.svg", path);
let execution = std::process::Command::new("/home/arkadiusz/.cargo/bin/flamegraph")
.arg("-o").arg(&svgfilename)
.arg("./binary").arg("solve").arg("real-data").arg("/dev/null")
.output().unwrap();
Full error:
WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.
Samples in kernel functions may not be resolved if a suitable vmlinux
file is not found in the buildid cache or in the vmlinux path.
Samples in kernel modules won't be resolved at all.
If some relocation was applied (e.g. kexec) symbols may be misresolved
even with a suitable vmlinux or kallsyms file.
Couldn't record kernel reference relocation symbol
Symbol resolution may be skewed if relocation was used (e.g. kexec).
Check /proc/kallsyms permission or run as root.
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0,000 MB (null) ]
thread 'main' panicked at 'unable to generate a flamegraph from the collapsed stack data: Io(Custom { kind: InvalidData, error: "No stack counts found" })', /home/arkadiusz/.cargo/registry/src/github.com-1ecc6299db9ec823/flamegraph-0.4.0/src/lib.rs:315:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I just installed simavr from the following:
https://github.com/buserror/simavr
I did a quick
make all
sudo make install
No problem, but when running
$ ./simavr/run_avr tests/atmega88_example.axf
I get
AVR_MMCU_TAG_VCD_TRACE 00c6:00 - UDR0
Loaded 1708 .text at address 0x0
Loaded 114 .data
Loaded 4 .eeprom
But, what I'm expecting is
AVR_MMCU_TAG_VCD_TRACE 00c6:00 - UDR0
AVR_MMCU_TAG_VCD_TRACE 00c0:20 - UDRE0
Loaded 1780 .text
Loaded 114 .data
Loaded 4 .eeprom
Starting atmega88 - flashend 1fff ramend 04ff e2end 01ff
atmega88 init
avr_eeprom_ioctl: AVR_IOCTL_EEPROM_SET Loaded 4 at offset 0
Creating VCD trace file 'gtkwave_trace.vcd'
Read from eeprom 0xdeadbeef -- should be 0xdeadbeef..
Read from eeprom 0xcafef00d -- should be 0xcafef00d..
simavr: sleeping with interrupts off, quitting gracefully
I've got GTKWave installed and all dependencies (otherwise, it wouldn't build, right?)...Not sure where the VCD trace is failing to execute.
Thanks
Use this:
$ ./simavr/run_avr -v -v tests/atmega88_example.axf
I have an ACS ACR122T-E2 NFC reader. I downloaded the linux driver and the ct-api library from
http://www.acs.com.hk/en/products/109/acr122t-usb-tokens-nfc-reader/ .
I have extracted the sample C program from the header given in the ct-api library archive file. I compiled it. I also created the ctacs.ini file with this content:
[CardTerminal]
CTN1=ACR122T
[ACR122T]
ICC1=ACS ACR122 25 00
When I running the compiled executable I just get:
Error: CT_init failed with error -8
where -8 is for "CT Error" based on the documentation in the header file.
Does somebody have some experience with this ACR122T-E2 and the official C API given for it?
Does anyone have some idea on what should I check for or what should I try to do?
The only one thing I guess I might be wrong with, is the ctacs.ini file. I am not really sure if the
ICC1=ACS ACR122 25 00
line is right. I used "lsusb -t" which shows:
Bus 03.Port 1: Dev 25, If 0, Class=Chip/SmartCard, Driver=pn533, 12M
Of course I already have tried
ICC1=ACS ACR122 03 01
config line, but did not help.
Does anybody have some idea, what this configuration line should be?
A after several hour of reading different posts at different sites, studying the available NFC related packages on Ubuntu, and also got a bit of help from the maintainer/developer of the official ACS driver I managed to get this example program to work.
The solution is, to unload/remove the kernel's default drivers.
modprobe -r np533
modprobe -r nfc
Then to install and run pcscd:
apt-get install pcscd
service start pcscd
Install pcsc_scan:
apt-get install pcsc-tools
Now pcsc_scan can be used to figure out the right ICC line for the ini file:
...
Reader 0: ACS ACR122U 00 00
...
Thus the right content the ini file is:
[CardTerminal]
CTN1=ACR122T
[ACR122T]
ICC1=ACS ACR122U 00 00
Now running the compiled example C program (from the ct-api library archive file downloaded from ACS) the output is:
Response: 62 00
Not much, but at least it is working now and I can continue exploring this NFC world.
I am using Windows and was struggling with the ctacs.ini file too. The trick (for me) was retrieving and using the actual CCID name. I retrieved mine by using "Springcard pcsc quick start" which shows the CCID name when the program opens. I use an ACS ACR122U-A9 with windows 8.1. The ini file below works for me.
[CardTerminal]
CTN1=ACS-ACR122-0 ;Just a name, can be an arbitrary value
[ACS-ACR122-0] ;Must correspond to name given above
ICC1=ACS ACR122 0 ;This is the actual name of the device (CCID)
My OS is Fedora 17. Recently, kernel tainted warning "kernel bug at kernel/auditsc.c:1772!-abrt" occurs:
This problem should not be reported (it is likely a known problem). A kernel problem occurred, but your kernel has been tainted (flags:GD). Kernel maintainers are unable to diagnose tainted reports.
Then, I get the following:
# cat /proc/sys/kernel/tainted
128
# dmesg | grep -i taint
[ 8306.955523] Pid: 4511, comm: chrome Tainted: G D 3.9.10-100.fc17.i686.PAE #1 Dell Inc.
[ 8307.366310] Pid: 4571, comm: chrome Tainted: G D 3.9.10-100.fc17.i686.PAE #1 Dell Inc.
It seems that the value "128" is much serious:
128 – The system has died.
How about this warning? Since chrome is flagged as the "Tainted" source, anybody also meet this matter?
To (over) simplify, 'tainted' means that the kernel is in a state other than what it would be in if it were built fresh from the open source origin and used in a way that it had been intended. It is a way of flagging a kernel to warn people (e.g., developers) that there may be unknown reasons for it to be unreliable, and that debugging it may be difficult or impossible.
In this case, 'GD' means that all modules are licensed as GPL or compatible (ie not proprietary), and that a crash or BUG() occurred.
The reasons are listed below:
See: oops-tracing.txt
---------------------------------------------------------------------------
Tainted kernels:
Some oops reports contain the string 'Tainted: ' after the program
counter. This indicates that the kernel has been tainted by some
mechanism. The string is followed by a series of position-sensitive
characters, each representing a particular tainted value.
1: 'G' if all modules loaded have a GPL or compatible license, 'P' if
any proprietary module has been loaded. Modules without a
MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by
insmod as GPL compatible are assumed to be proprietary.
2: 'F' if any module was force loaded by "insmod -f", ' ' if all
modules were loaded normally.
3: 'S' if the oops occurred on an SMP kernel running on hardware that
hasn't been certified as safe to run multiprocessor.
Currently this occurs only on various Athlons that are not
SMP capable.
4: 'R' if a module was force unloaded by "rmmod -f", ' ' if all
modules were unloaded normally.
5: 'M' if any processor has reported a Machine Check Exception,
' ' if no Machine Check Exceptions have occurred.
6: 'B' if a page-release function has found a bad page reference or
some unexpected page flags.
7: 'U' if a user or user application specifically requested that the
Tainted flag be set, ' ' otherwise.
8: 'D' if the kernel has died recently, i.e. there was an OOPS or BUG.
9: 'A' if the ACPI table has been overridden.
10: 'W' if a warning has previously been issued by the kernel.
(Though some warnings may set more specific taint flags.)
11: 'C' if a staging driver has been loaded.
12: 'I' if the kernel is working around a severe bug in the platform
firmware (BIOS or similar).
13: 'O' if an externally-built ("out-of-tree") module has been loaded.
14: 'E' if an unsigned module has been loaded in a kernel supporting
module signature.
15: 'L' if a soft lockup has previously occurred on the system.
16: 'K' if the kernel has been live patched.
The primary reason for the 'Tainted: ' string is to tell kernel
debuggers if this is a clean kernel or if anything unusual has
occurred. Tainting is permanent: even if an offending module is
unloaded, the tainted value remains to indicate that the kernel is not
trustworthy.
Also showing numbers for the content of /proc/sys/kernel/tainted file:
Non-zero if the kernel has been tainted. Numeric values, which can be
ORed together. The letters are seen in "Tainted" line of Oops reports.
1 (P): A module with a non-GPL license has been loaded, this
includes modules with no license.
Set by modutils >= 2.4.9 and module-init-tools.
2 (F): A module was force loaded by insmod -f.
Set by modutils >= 2.4.9 and module-init-tools.
4 (S): Unsafe SMP processors: SMP with CPUs not designed for SMP.
8 (R): A module was forcibly unloaded from the system by rmmod -f.
16 (M): A hardware machine check error occurred on the system.
32 (B): A bad page was discovered on the system.
64 (U): The user has asked that the system be marked "tainted". This
could be because they are running software that directly modifies
the hardware, or for other reasons.
128 (D): The system has died.
256 (A): The ACPI DSDT has been overridden with one supplied by the user
instead of using the one provided by the hardware.
512 (W): A kernel warning has occurred.
1024 (C): A module from drivers/staging was loaded.
2048 (I): The system is working around a severe firmware bug.
4096 (O): An out-of-tree module has been loaded.
8192 (E): An unsigned module has been loaded in a kernel supporting module
signature.
16384 (L): A soft lockup has previously occurred on the system.
32768 (K): The kernel has been live patched.
65536 (X): Auxiliary taint, defined and used by for distros.
131072 (T): The kernel was built with the struct randomization plugin.
Source: https://www.kernel.org/doc/Documentation/sysctl/kernel.txt
Credit: https://askubuntu.com/questions/248470/what-does-the-kernel-taint-value-mean
LNK4099 warnings can occur when building on Windows during the link phase of a static compilation.
E.g. when building using nmake and VC10 I get a stream of LNK4099 warnings like:
libcurl_a_debug.lib(rc2_cbc.obj) : warning LNK4099: PDB 'lib.pdb' was not found with 'libcurl_a_debug.lib(rc2_cbc.obj)' or at 'C:\dev\scaler\center\dlux\lib.pdb'; linking object as if no debug info
StackOverflow gives a good overview of the problem, but not the detail required to understand it.
Rather than ignore the warning or disable the warning, I would like to fix the makefiles in my build to remove the problem.
How does the problem arise? How do I remove the cause of the warnings?
Understand that the underlying problem is a missing debug symbols file (.pdb) for the library mentioned in the warning. Library files contain a static reference to the .pdb on an object file basis. When a library is used by another library and static compilation is used, Visual Studio collects all the symbols into a single .pdb and the .pdb references in the object files are updated. However, if it cannot find the symbols, it will leave the old path in place.
Fix the warning by recompiling the library mentioned in the warnings, and make sure the compiler has access to the .pdb of every referenced library. This involves determining which .pdb file cannot be found, and then making changes to ensure the .pdb can be found.
Which object file (and thus library) are we missing the symbols (.pdb) for?
#goth provided a blog link explaining where the .pdb reference comes from, but here is my summary:
A library contains a number of object files. Each object file includes a path to the debug symbols. We can use tools extract this information. Based on the object file and path, we can figure out which debug symbols file (.pdb) could not be found.
Open the Visual Studio Command Prompt. This creates a command shell with environment variables required to access Visual Studio tools. (Should be under "Visual Studio Tools" buried in the Start Menu, but this varies)
Obtain the internal path of the object file in the library using the lib tool's /list option. E.g.
C:\dev\libcurl\win\lib>lib /list libcurl_a_debug.lib > list_of_object_files_in_library.txt
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>more list_of_object_files_in_library.txt
Microsoft (R) Library Manager Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/file.obj
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/timeval.obj
..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/rc2_cbc.obj
...
Using the path, extract the object file using the lib tool's /extract option.
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>lib /extract:..\builds\libcurl-vc10-x86-debug-static-ssl-static-ipv6-spnego-obj-lib/timeval.obj libcurl_a_debug.lib
Microsoft (R) Library Manager Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
The object file contains a debug section called .debug$T that we can extract using the dumpbin tool. E.g.
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>dumpbin /section:.debug$T /rawdata rc2_cbc.obj > dump_of_object_file_debug_info.txt
C:\dev\scaler\center\agent\thirdparty\libcurl\win\lib>more dump_of_object_file_debug_info.txt
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file ./rc2_cbc.obj
File Type: COFF OBJECT
SECTION HEADER #9
.debug$T name
0 physical address
0 virtual address
5C size of raw data
1D53 file pointer to raw data (00001D53 to 00001DAE)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42100040 flags
Initialized Data
Discardable
1 byte align
Read Only
RAW DATA #9
00000000: 04 00 00 00 56 00 15 15 03 7A 47 A3 3D 4A 8C 4B ....V....zGú=J.K
00000010: A2 A5 26 D3 D6 57 15 46 3A 00 00 00 73 3A 5C 73 óÑ&ËÍW.F:...s:\s
00000020: 63 61 6C 65 78 2E 6E 65 77 5C 63 65 6E 74 72 6F caler.new\center
00000030: 5C 6F 70 65 6E 73 73 6C 5C 62 75 69 6C 64 5C 6F \openssl\build\o
00000040: 70 65 6E 73 73 6C 2D 31 2E 30 2E 30 62 5C 74 6D penssl-1.0.0b\tm
00000050: 70 33 32 5C 6C 69 62 2E 70 64 62 00 p32\lib.pdb.
Summary
5C .debug$T
Above, you see that the object file says its debug symbols s:\scaler.new\center\openssl\build\openssl-1.0.0b\tmp32\lib.pdb. Therefore, the problem lies with the .pdb generated when we built the openssl library used by libcurl.
How do I add the debug symbols to the library generating the warning?
The /Fd option governs the name and location of the .pdb symbols file. E.g. when compiling libcurl, I used the following flags:
...
!IF DEFINED(VC10)
NT_MAK_FLAGS = APP_CFLAG="/GX /GZ /MTd /Fdtmp32.dbg/app" LIB_CFLAG="/Zl /Z7 /Fdtmp32.dbg/lib"
!ENDIF
...
The symbol file name of lib.pdb and its path relative to the build is given by /Fdtmp32.dbg/lib.
The problem is that the NT_MAK_FLAGS is reused for a number of libraries that are generated when openssl is compiled. As a result, lib.pdb is clobbered (overwritten) for all but the last library. To resolve the problem, each library should be given .pdb with a unique name. To simplify matters further, ensure that the compilation location is in the same tree as the libcurl build.
This happened to me with a library .lib and maybe the attached image will help others. In my case I had to make sure that the .lib and the .pdb file were in the same directory, so note how $(OutDir) appears in the settings.
I think they got misaligned when I imported an old 32 bit VS2010 project into VS2013 and set it up for 64 bits.
So I end up with this (good) situation: