]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/arm-ds5-gator.git/blob - README_Streamline.txt
gator: Prevent BUG() when no device-tree cpu nodes present.
[android-sdk/arm-ds5-gator.git] / README_Streamline.txt
1 \r
2 *** Purpose ***\r
3 \r
4 Instructions on setting up ARM Streamline on the target.\r
5 The gator driver and gator daemon are required to run on the ARM linux target in order for ARM Streamline to operate.\r
6 The driver should be built as a module and the daemon must run with root permissions on the target.\r
7 \r
8 *** Introduction ***\r
9 \r
10 A linux development environment with cross compiling tools is most likely required, depending on what is already created and provided.\r
11 -For users, the ideal environment is to be given a BSP with gatord and gator.ko already running on a properly configured kernel. In such a scenario, a development environment is not needed, root permission may or may not be needed (gatord must be executed with root permissions but can be automatically started, see below), and the user can run Streamline and profile the system without any setup.\r
12 -The ideal development environment has the kernel source code available to be rebuilt, usually by cross-compiling on a host machine. This environment allows the greatest flexibility in configuring the kernel and building the gator driver module.\r
13 -However, it is possible that a user/developer has a kernel but does not have the source code. In this scenario it may or may not be possible to obtain a valid profile.\r
14         -First, check if the kernel has the proper configuration options (see below). Profiling cannot occur using a kernel that is not configured properly, a new kernel must be created. See if /proc/config.gz exists on the target.\r
15         -Second, given a properly configured kernel, check if the filesystem contains the kernel source/headers, which can be used to re-create the gator driver. These files may be located in different areas, but common locations are /lib/modules/ and /usr/src.\r
16         -If the kernel is not properly configured or sources/headers are not available, the developer is on their own and kernel creation is beyond the scope of this document. Note: It is possible for a module to work when compiled against a similar kernel source code, though this is not guaranteed to work due to differences in kernel structures, exported symbols and incompatible configuration parameters.\r
17 \r
18 *** Kernel configuration ***\r
19 \r
20 menuconfig options (depending on the kernel version, the location of these configuration settings within menuconfig may differ)\r
21 - General Setup\r
22   - Kernel Performance Events And Counters\r
23     - [*] Kernel performance events and counters (enables CONFIG_PERF_EVENTS)\r
24   - [*] Profiling Support (enables CONFIG_PROFILING)\r
25 - Kernel Features\r
26   - [*] High Resolution Timer Support (enables CONFIG_HIGH_RES_TIMERS)\r
27   - [*] Use local timer interrupts (only required for SMP, enables CONFIG_LOCAL_TIMERS)\r
28   - [*] Enable hardware performance counter support for perf events (enables CONFIG_HW_PERF_EVENTS)\r
29 - CPU Power Management\r
30   - CPU Frequency scaling\r
31     - [*] CPU Frequency scaling (enables CONFIG_CPU_FREQ)\r
32 - Kernel hacking\r
33   - [*] Compile the kernel with debug info (optional, enables CONFIG_DEBUG_INFO)\r
34   - [*] Tracers\r
35     - [*] Trace process context switches and events (#)\r
36 \r
37 (#) The "Trace process context switches and events" is not the only option that enables tracing (CONFIG_GENERIC_TRACER or CONFIG_TRACING) and may not be visible in menuconfig as an option if other trace configurations are enabled. Other trace configurations being enabled is sufficient to turn on tracing.\r
38 \r
39 The configuration options:\r
40 CONFIG_GENERIC_TRACER or CONFIG_TRACING\r
41 CONFIG_PROFILING\r
42 CONFIG_HIGH_RES_TIMERS\r
43 CONFIG_LOCAL_TIMERS (for SMP systems)\r
44 CONFIG_PERF_EVENTS and CONFIG_HW_PERF_EVENTS (kernel versions 3.0 and greater)\r
45 CONFIG_DEBUG_INFO (optional, used for analyzing the kernel)\r
46 CONFIG_CPU_FREQ (optional, provides frequency setting of the CPU)\r
47 \r
48 These may be verified on a running system using /proc/config.gz (if this file exists) by running 'zcat /proc/config.gz | grep <option>'. For example, confirming that CONFIG_PROFILING is enabled\r
49   > zcat /proc/config.gz | grep CONFIG_PROFILING\r
50   CONFIG_PROFILING=y\r
51 \r
52 *** Checking the gator requirements ***\r
53 \r
54 (optional) Use the hrtimer_module utility to validate the kernel High Resolution Timer requirement.\r
55 \r
56 *** Building the gator module ***\r
57 \r
58 To create the gator.ko module,\r
59         cd /path/to/gator/driver-src\r
60         tar xzf gator-driver.tar.gz\r
61         cd gator-driver\r
62         make -C <kernel_build_dir> M=`pwd` ARCH=arm CROSS_COMPILE=<...> modules\r
63 for example when using the linaro-toolchain-binaries\r
64         make -C /home/username/kernel_2.6.32/ M=`pwd` ARCH=arm CROSS_COMPILE=/home/username/gcc-linaro-arm-linux-gnueabihf-4.7-2013.01-20130125_linux/bin/arm-linux-gnueabihf- modules\r
65 If successful, a gator.ko module should be generated\r
66 \r
67 *** Building the gator daemon ***\r
68 \r
69 cd /path/to/gator/daemon-src\r
70 tar -xzf gator-daemon.tar.gz (may need to issue with 'sudo')\r
71 For Linux targets,\r
72         cd gator-daemon\r
73         make CROSS_COMPILE=<...> # For ARMv7 targets\r
74         make -f Makefile_aarch64 CROSS_COMPILE=<...> # For ARMv8 targets\r
75         gatord should now be created\r
76 For Android targets (install the android ndk, see developer.android.com)\r
77         mv gator-daemon jni\r
78         ndk-build\r
79                 or execute /path/to/ndk/ndk-build if the ndk is not on your path\r
80         gatord should now be created and located in libs/armeabi\r
81 \r
82 *** Running gator ***\r
83 \r
84 Load the kernel onto the target and copy gatord and gator.ko into the target's filesystem.\r
85 Ensure gatord has execute permissions\r
86         chmod +x gatord\r
87 gator.ko must be located in the same directory as gatord on the target or the location specified with the -m option or already insmod'ed.\r
88 With root privileges, run the daemon\r
89         sudo ./gatord &\r
90 Note: gatord requires libstdc++.so.6 which is usually supplied by the Linux distribution on the target. A copy of libstdc++.so.6 is available in the DS-5 Linux example distribution.\r
91 \r
92 *** Customizing the l2c-310 Counter ***\r
93 \r
94 The l2c-310 counter in gator_events_l2c-310.c contains hard coded offsets where the L2 cache counter registers are located.  This offset can also be configured via a module parameter specified when gator.ko is loaded, ex:\r
95         insmod gator.ko l2c310_addr=<offset>\r
96 Further, the l2c-310 counter can be disabled by providing an offset of zero, ex:\r
97         insmod gator.ko l2c310_addr=0\r
98 \r
99 *** Compiling an application or shared library ***\r
100 \r
101 Recommended compiler settings:\r
102         "-g": Debug information, such as line numbers, needed for best analysis results.\r
103         "-fno-inline": Speed improvement when processing the image files and most accurate analysis results.\r
104         "-fno-omit-frame-pointer": ARM EABI frame pointers (Code Sourcery cross compiler) allow recording of the call stack with each sample taken when in ARM state (i.e. not -mthumb).\r
105         "-marm": This option is required if your compiler is configured with --with-mode=thumb, otherwise call stack unwinding will not work.\r
106 \r
107 *** Hardfloat EABI ***\r
108 Binary applications built for the soft or softfp ABI are not compatible on a hardfloat system. All soft/softfp applications need to be rebuilt for hardfloat. To see if your ARM compiler supports hardfloat, run "gcc -v" and look for --with-float=hard.\r
109 To compile for non-hardfloat targets it is necessary to add options '-marm -march=armv4t -mfloat-abi=soft'. It may also be necessary to provide a softfloat filesystem by adding the option --sysroot, ex: '--sysroot=../DS-5Examples/distribution/filesystem/armv5t_mtx'. The gatord makefile will do this when run as 'make SOFTFLOAT=1 SYSROOT=/path/to/sysroot'\r
110 The armv5t_mtx filesystem is provided as part of the "DS-5 Linux Example Distribution" package which can be downloaded from the DS-5 Downloads page.\r
111 Attempting to run an incompatible binary often results in the confusing error message "No such file or directory" when clearly the file exists.\r
112 \r
113 *** Bugs ***\r
114 \r
115 There is a bug in some Linux kernels where perf misidentifies the CPU type. To see if you are affected by this, run ls /sys/bus/event_source/devices/ and verify the listed processor type matches what is expected. For example, an A9 should show the following.\r
116 \r
117 # ls /sys/bus/event_source/devices/\r
118 ARMv7_Cortex_A9  breakpoint  software  tracepoint\r
119 \r
120 To workaround the issue try upgrading to a later kernel or comment out the gator_events_perf_pmu_cpu_init(gator_cpu, type); cal in gator_events_perf_pmu.c\r
121 \r
122 *** Profiling the kernel (optional) ***\r
123 \r
124 CONFIG_DEBUG_INFO must be enabled, see "Kernel configuration" section above.\r
125 Use vmlinux as the image for debug symbols in Streamline.\r
126 Drivers may be profiled using this method by statically linking the driver into the kernel image or adding the driver as an image to Streamline.\r
127 To perform kernel stack unwinding and module unwinding, edit the Makefile to enable GATOR_KERNEL_STACK_UNWINDING and rebuild gator.ko.\r
128 \r
129 *** Automatically start gator on boot (optional) ***\r
130 \r
131 cd /etc/init.d\r
132 vi rungator.sh\r
133         #!/bin/bash\r
134         /path/to/gatord &\r
135 update-rc.d rungator.sh defaults\r
136 \r
137 *** GPL License ***\r
138 \r
139 For license information, please see the file LICENSE after unzipping driver-src/gator-driver.tar.gz.\r
140 \r