Как включить Bootchart в Android
Мой текущий прогресс заключается в следующем,
Включить Bootchart.h с помощью
#ifndef BOOTCHART
# define BOOTCHART 1
#endif
После этого я скомпилировал код, сделав INIT_BOOTCHART=true kernel -j4. Так что после завершения компиляции я сделал
1. adb root
2. adb shell
3. cd data
4. echo 120 > bootchart-start (cat bootchart-start -> 120)
5. mkdir bootchart
6. reboot bootloader
7. fastboot flash kernel kernel.img
8. reboot
Затем я проверяю файлы журнала внутри папки data/bootchart. Но он пуст и через несколько минут.
Поэтому я поместил несколько журналов в system/core/init/init.c -> bootchart_init_action
static int bootchart_init_action(int nargs, char **args)
{
ERROR("#### JACH #### - BOOTCHART'%d':'%s'\n", 0, "bootchart_init_action -start");
bootchart_count = bootchart_init();
ERROR("#### JACH #### - BOOTCHART'%d':'%s'\n", bootchart_count, "bootchart_init_action -bootchart_count");
if (bootchart_count < 0) {
ERROR("bootcharting init failure\n");
} else if (bootchart_count > 0) {
NOTICE("bootcharting started (period=%d ms)\n", bootchart_count*BOOTCHART_POLLING_MS);
} else {
NOTICE("bootcharting ignored\n");
}
ERROR("#### JACH #### - BOOTCHART'%d':'%s'\n", 0, "bootchart_init_action -end");
return 0;
}
После компиляции приведенного выше кода я увидел, что функция bootchart_init() возвращает значение 0. Ниже находится файл журнала.
<11>[ 2.814551] init: #### JACH #### - BOOTCHART'0':'bootchart_init_action -start'
<11>[ 2.814591] init: #### JACH #### - bootchart_init'0':'start'
<11>[ 2.814704] init: #### JACH #### - BOOTCHART'0':'bootchart_init_action -bootchart_count'
<11>[ 2.814721] init: #### JACH #### - BOOTCHART'0':'bootchart_init_action -end'
Итак, bootchart_init() выглядит следующим образом:
#define LOG_STARTFILE "/data/bootchart-start"
int bootchart_init( void )
{
ERROR("#### JACH #### - bootchart_init'%d':'%s'\n", 0, "start");
int ret;
char buff[4];
int timeout = 0, count = 0;
buff[0] = 0;
proc_read( LOG_STARTFILE, buff, sizeof(buff) );
if (buff[0] != 0) {
timeout = atoi(buff);;
ERROR("#### JACH #### - bootchart_init'%d':'%s'\n", timeout, "timeout");
}
else {
/* when running with emulator, androidboot.bootchart=<timeout>
* might be passed by as kernel parameters to specify the bootchart
* timeout. this is useful when using -wipe-data since the /data
* partition is fresh
*/
char cmdline[1024];
char* s;
#define KERNEL_OPTION "androidboot.bootchart="
proc_read( "/proc/cmdline", cmdline, sizeof(cmdline) );
s = strstr(cmdline, KERNEL_OPTION);
if (s) {
s += sizeof(KERNEL_OPTION)-1;
timeout = atoi(s);
}
}
if (timeout == 0)
return 0;
if (timeout > BOOTCHART_MAX_TIME_SEC)
timeout = BOOTCHART_MAX_TIME_SEC;
count = (timeout*1000 + BOOTCHART_POLLING_MS-1)/BOOTCHART_POLLING_MS;
do {ret=mkdir(LOG_ROOT,0755);}while (ret < 0 && errno == EINTR);
file_buff_open(log_stat, LOG_STAT);
file_buff_open(log_procs, LOG_PROCS);
file_buff_open(log_disks, LOG_DISK);
/* create kernel process accounting file */
{
int fd = open( LOG_ACCT, O_WRONLY|O_CREAT|O_TRUNC,0644);
if (fd >= 0) {
close(fd);
acct( LOG_ACCT );
}
}
log_header();
ERROR("#### JACH #### - bootchart_init'%d':'%s'\n", 0, "end");
return count;
}
Я думаю, при загрузке запускается вышеуказанный код (proc_read( LOG_STARTFILE, buff, sizeof(buff) );
) не имеет права на чтение или запись данных или файлы разделов не создаются. А также я жестко закодировал таймаут, но все же bootchart_step()
Функция работает, но файлы журнала не записываются в папку data/bootchart.
Но я не знаю, как разрешить эту проблему. Спасибо, что посетили мой вопрос.