From 3095ac1f98b0a634a7d9aa4bd8dc43989d9d496e Mon Sep 17 00:00:00 2001 From: xiangfu Date: Wed, 24 Jun 2009 10:13:50 +0000 Subject: [PATCH] add file check for usb_boot.cfg --- flash-tool/src/ingenic_cfg.c | 15 ++++++++++++++- flash-tool/src/main.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/flash-tool/src/ingenic_cfg.c b/flash-tool/src/ingenic_cfg.c index fa26b81..ece4d12 100644 --- a/flash-tool/src/ingenic_cfg.c +++ b/flash-tool/src/ingenic_cfg.c @@ -19,7 +19,9 @@ * Boston, MA 02110-1301, USA */ +#include #include +#include #include "ingenic_cfg.h" #include "usb_boot_defines.h" @@ -33,6 +35,7 @@ int hand_init_def(struct hand *hand) hand->nand_bw = 8; hand->nand_rc = 3; hand->nand_ps = 2048; + hand->nand_os = 64; hand->nand_ppb = 64; hand->nand_eccpos = 6; hand->nand_bbpage = 0; @@ -138,6 +141,12 @@ int check_dump_cfg(struct hand *hand) int parse_configure(struct hand *hand, char * file_path) { + if (access(file_path, F_OK)) { + fprintf(stderr, "Error - can't read file: %s\n", + file_path, strerror(errno)); + return -1; + } + hand_init_def(hand); cfg_opt_t opts[] = { @@ -178,8 +187,12 @@ int parse_configure(struct hand *hand, char * file_path) cfg_t *cfg; cfg = cfg_init(opts, 0); - if (cfg_parse(cfg, file_path) == CFG_PARSE_ERROR) + if (cfg_parse(cfg, file_path) == CFG_PARSE_ERROR) { + fprintf(stderr, "Error - can't read file: %s\n", + file_path, strerror(errno)); return -1; + } + cfg_free(cfg); hand->fw_args.cpu_id = 0x4740; diff --git a/flash-tool/src/main.c b/flash-tool/src/main.c index 7fb9ba8..3880869 100644 --- a/flash-tool/src/main.c +++ b/flash-tool/src/main.c @@ -36,7 +36,7 @@ static void help(void) " -h --help\t\t\tPrint this help message\n" " -v --version\t\t\tPrint the version number\n" " -c --command\t\t\tDirect run the command\n" - "Report bugs to ." + "Report bugs to .\n" ); }