In my current project with the Jetson TK1 (Linux for Tegra (LT4) 21.1 R) I want to do some performance test. So I want to make use of the CPU’s PMU (Performance Monitor Unit)to read the “Cycle Counter”.
As the access from the user-mode is denied, I have to load a kernel module which sets a flag in the specific register:
cite: Access permissions
Normally the Performance Monitors registers are accessible from all modes executing at PL1 or higher. However, the access permissions for PMU registers can be modified by:
• setting the PMUSERENR.EN bit to 1, to permit access from software executing in User mode, for example for instrumentation and profiling purposes
ref.: http://liris.cnrs.fr/~mmrissa/lib/exe/fetch.php?media=armv7-a-r-manual.pdf#E36.CIHHCBHC (page 2328)
Furthermore I found two interesting links, which already solved this: 1) User-mode performance counters for ARM/Linux:
Then I thought, that the code might be incompatible and so I made the tutorial in the “The Linux Kernel Module Programming Guide” (simplest kernel module possible ;) ) :
-link: Hello, World (part 1): The Simplest Module
And I got the same error again.
Q1: So what the hell is going on?
Q2: Are the wrong Kernel headers installed? I didn’t change a thing, the system is almost freshly set up.
Q3: What has to be considered? (I am quite new to this topic…)
FYI:
I can remember to install a package for cifs some weeks ago, to mount a directory of our buildserver(jenkins)… Maybe this package is here the source of evil. What do you think?
A large number of errors are possible based simply on configuration. I have not read all of the links you gave as reference, but a few things will always remain as initial questions: Are you compiling from Jetson, or cross-compiling? Did you use /proc/config.gz for initial configuration? What changes were made to this configuration before building?
Ahhhh thank you for the hint with the: /proc/config.gz (As I already mentioned, I am quite new to this topic and it seems that I am suffering from some background knowledge.)
“What changes were made to this configuration before building?”
I made no changes at all and I did not unpack the /proc/config.gz to the ~/linux directory as described in the above link.
I thought it is sufficient to have the following dirs:
/lib/modules/3.10.40-ged4f697/build
/usr/src/linux-headers-3.10.40-ged4f697/
Q: Can you give an explanation why the /proc/config.gz is necessary?
Q: Do I have to unpack the /proc/config.gz to the ~/linux directory?
I don’t think there is a standard place for the kernel or it’s headers. And there’s no standard way to install just the kernel headers from a kernel build to a system. There are distro specific ways though.
I suggest that you compile the whole kernel on Jetson to get the proper kernel build tree, including the headers. Technically you should also then use the kernel but maybe that’s not needed.
The most important thing was to install the package:
[i]"The module-assistant package for Debian installs packages and configures the system to build out-of-kernel modules. Install it with:
$ sudo apt-get install module-assistant
That’s it; you can now compile kernel modules…"[/i]
It seems that the content of the"The Linux Kernel Module Programming Guide" is deprecated.
So I changed the interface of the init and exit funtion, added the module_init and module_exit macro, and added the module information macros at the bottom of the file.
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
static int __init Enter_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
static void __exit Leave_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
module_init(Enter_module)
module_exit(Leave_module)
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Roland J...");
MODULE_DESCRIPTION("\"Hello, world 1!\" minimal module");
MODULE_VERSION("with_printk");
After calling make I could call sudo insmod ./hello-1.ko and sudo remmod ./hello-1.
Now I am quite happy and keep you posted if the thing with PMU for reading the Cycle Counter is working :)
Knowing what steps you took to set up for compile, and whether the compile was natively on the Jetson, versus cross compile on PC will change many things. Initial configuration as well will change many things. In the original posts the “no rule to make target” type error is very different from one build to the next even if that wording is exactly the same…the trick is seeing the output before the error hits along wiht the actual error so that it is known what failed prior to that output can be figured out.
@linuxdev, thank you for the response. As mentioned, I am following the exact same steps as the OP; that is, I am compiling on the TX2.
I was able to figure out how to fix this issue! It is frustrating… after searching “Google” for probably an hour, I finally decided to post a reply to this thread. Within 5 minutes of posting my response, I found this: