logger: add firmware verification capability
I've added two logger flags for firmware version verification: -e - enables checking fw version with default file -v ver_file - enables checking fw version with ver_file file Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
This commit is contained in:
parent
937032fb5f
commit
a73c4f63ca
14
README
14
README
|
@ -65,11 +65,25 @@ Usage sof-logger <option(s)> <file(s)>
|
|||
-p Get traces from stdin, instead of the default
|
||||
"/sys/kernel/debug/sof/etrace"
|
||||
-c Set timestamp clock in MHz
|
||||
-e Enable checking firmware version with default verification file
|
||||
"/sys/kernel/debug/sof/fw_version"
|
||||
-v ver_file Enable checking firmware version with ver_file file,
|
||||
instead of default: "/sys/kernel/debug/sof/fw_version"
|
||||
-s Take a snapshot of state
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
- Get traces from "/sys/kernel/debug/sof/etrace" file, verifies fw_version with
|
||||
"/sys/kernel/debug/sof/fw_version" and prints logs to stdout
|
||||
|
||||
$ sof-logger -l ldc_file -e
|
||||
|
||||
- Get traces from "/sys/kernel/debug/sof/etrace" file, verifies fw_version with
|
||||
ver_file file and prints logs to stdout
|
||||
|
||||
$ sof-logger -l ldc_file -v ver_file
|
||||
|
||||
- Get traces from "/sys/kernel/debug/sof/etrace" file and prints logs to stdout
|
||||
|
||||
$ sof-logger -l ldc_file
|
||||
|
|
|
@ -36,6 +36,9 @@ struct convert_config {
|
|||
const char *ldc_file;
|
||||
FILE* ldc_fd;
|
||||
int input_std;
|
||||
int version_fw;
|
||||
char *version_file;
|
||||
FILE *version_fd;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sof/uapi/ipc.h>
|
||||
#include "convert.h"
|
||||
|
||||
#define CEIL(a, b) ((a+b-1)/b)
|
||||
|
@ -32,15 +32,15 @@
|
|||
#define SND_SOF_LOGS_SIG_SIZE 4
|
||||
#define SND_SOF_LOGS_SIG "Logs"
|
||||
|
||||
/*
|
||||
* Logs dictionary file header.
|
||||
*/
|
||||
struct snd_sof_logs_header {
|
||||
/* "Logs" */
|
||||
unsigned char sig[SND_SOF_LOGS_SIG_SIZE];
|
||||
/* address of log entries section */
|
||||
uint32_t base_address;
|
||||
/* amount of bytes following this header */
|
||||
uint32_t data_length;
|
||||
/* offset to first entry in this file */
|
||||
uint32_t data_offset;
|
||||
unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; /* "Logs" */
|
||||
uint32_t base_address; /* address of log entries section */
|
||||
uint32_t data_length; /* amount of bytes following this header */
|
||||
uint32_t data_offset; /* offset to first entry in this file */
|
||||
struct sof_ipc_fw_version version;
|
||||
};
|
||||
|
||||
struct ldc_entry_header {
|
||||
|
@ -145,7 +145,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log,
|
|||
entry.params[2], entry.params[3]);
|
||||
break;
|
||||
}
|
||||
fprintf(out_fd, "\n");
|
||||
fprintf(out_fd, "%s\n", KNRM);
|
||||
fflush(out_fd);
|
||||
}
|
||||
|
||||
|
@ -319,5 +319,25 @@ int convert(struct convert_config *config) {
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* fw verification */
|
||||
if (config->version_fd) {
|
||||
struct sof_ipc_fw_version ver;
|
||||
int i;
|
||||
/* here fw verification should be exploited */
|
||||
count = fread(&ver, sizeof(ver), 1, config->version_fd);
|
||||
if (!count) {
|
||||
fprintf(stderr, "Error while reading %s. \n", config->version_file);
|
||||
return -ferror(config->version_fd);
|
||||
}
|
||||
|
||||
ret = memcmp(&ver, &snd.version, sizeof(struct sof_ipc_fw_version));
|
||||
if (ret) {
|
||||
fprintf(stderr, "Error: fw version in %s file "
|
||||
"does not coincide with fw version in "
|
||||
"%s file. \n", config->ldc_file, config->version_file);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return logger_read(config, &snd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ static void usage(void)
|
|||
#ifdef LOGGER_FORMAT
|
||||
fprintf(stdout, "%s:\t -l *.ldc_file\t\t*.ldc files generated by rimage\n", APP_NAME);
|
||||
fprintf(stdout, "%s:\t -p \t\t\tInput from stdin\n", APP_NAME);
|
||||
fprintf(stdout, "%s:\t -e \t\t\tEnable checking firmware version with default verification file\n", APP_NAME);
|
||||
fprintf(stdout, "%s:\t -v ver_file\t\tEnable checking firmware version with ver_file file\n", APP_NAME);
|
||||
#endif
|
||||
fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME);
|
||||
fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME);
|
||||
|
@ -123,11 +125,16 @@ int main(int argc, char *argv[])
|
|||
config.in_fd = NULL;
|
||||
#ifdef LOGGER_FORMAT
|
||||
config.ldc_file = NULL;
|
||||
config.ldc_fd = NULL;
|
||||
config.input_std = 0;
|
||||
/* checking fw version is disabled by default */
|
||||
config.version_file = NULL;
|
||||
config.version_fd = NULL;
|
||||
config.version_fw = 0;
|
||||
#endif
|
||||
|
||||
#ifdef LOGGER_FORMAT
|
||||
while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:tev:")) != -1) {
|
||||
#else
|
||||
while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) {
|
||||
#endif
|
||||
|
@ -153,6 +160,18 @@ int main(int argc, char *argv[])
|
|||
case 'p':
|
||||
config.input_std = 1;
|
||||
break;
|
||||
case 'e':
|
||||
/* enabling checking fw version with default verification
|
||||
* file
|
||||
*/
|
||||
config.version_fw = 1;
|
||||
config.version_file = "/sys/kernel/debug/sof/fw_version";
|
||||
break;
|
||||
case 'v':
|
||||
/* enabling checking fw version with ver_file file */
|
||||
config.version_fw = 1;
|
||||
config.version_file = optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'h':
|
||||
default: /* '?' */
|
||||
|
@ -161,8 +180,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
#ifdef LOGGER_FORMAT
|
||||
|
||||
if (!config.ldc_file) {
|
||||
fprintf(stderr, "error: Missing ldc file");
|
||||
fprintf(stderr, "error: Missing ldc file\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
|
@ -173,6 +193,16 @@ int main(int argc, char *argv[])
|
|||
ret = -errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (config.version_fw) {
|
||||
config.version_fd = fopen(config.version_file, "r");
|
||||
if (!config.version_fd) {
|
||||
fprintf(stderr, "error: Unable to open ver file %s\n",
|
||||
config.version_file);
|
||||
ret = -errno;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (config.out_file) {
|
||||
|
@ -223,6 +253,8 @@ out:
|
|||
#ifdef LOGGER_FORMAT
|
||||
if (config.ldc_fd)
|
||||
fclose(config.ldc_fd);
|
||||
if (config.version_fd)
|
||||
fclose(config.version_fd);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue