Files
kunlun/mfgtool/oem_tool/oem_tool.c
2024-09-28 14:24:04 +08:00

81 lines
1.7 KiB
C

#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include "iot_oem.h"
#include "oem_common.h"
#include "oem_tool_hw.h"
iot_oem_cfg_t oemcfg;
static void usage (void)
{
die ("usage: oem_tool --input=INPUT --output=OUTPUT --parse=BINFILE\n"
"Generate or parse oem bin based board's configure.\n"
"Options:\n"
" --input=INPUT board configure.\n"
" --output=OUTPUT oem bin file.\n"
" --parse=BINFILE oem bin file.\n"
"\n");
}
static void load_database(const char *filename)
{
load_database_hw(filename);
}
static void save_database(const char *filename)
{
save_database_hw(filename);
}
static void oem_bin_file_parse(const char *filename)
{
oem_bin_file_parse_hw(filename);
}
void dump_oemcfg()
{
uint8_t *buf = (uint8_t*)&oemcfg;
uint32_t i = 0;
printf("\n");
for(i = 0; i < sizeof(iot_oem_cfg_t); i++){
printf("%02x ", buf[i]);
if(i%16 == 15){
printf("\n");
}
}
printf("\n");
}
int main(int argc, char**argv)
{
unsigned int i;
const char *filename = NULL;
memset(&oemcfg, 0x0, sizeof(iot_oem_cfg_t));
for (i = 1; i < (unsigned) argc; i++) {
if (starts_with (argv[i], "--input=")) {
load_database (strchr (argv[i], '=') + 1);
} else if (starts_with (argv[i], "--parse=")) {
oem_bin_file_parse(strchr (argv[i], '=') + 1);
} else if (starts_with (argv[i], "--output=")) {
filename = strchr (argv[i], '=') + 1;
save_database(filename);
} else {
usage();
}
}
//dump_oemcfg();
signal (SIGPIPE, SIG_IGN);
return 0;
}