# HG changeset patch # User Michael Spacefalcon # Date 1402981637 0 # Node ID bf49e348576b795bfcd1f0297b40427e3b5d75d2 # Parent d7f409493eb6ce634571d93019c5d19338420e0f fc-loadtool: flcmplboot.c (boot-reflash-hack) code started diff -r d7f409493eb6 -r bf49e348576b loadtools/Makefile --- a/loadtools/Makefile Tue Jun 17 04:31:16 2014 +0000 +++ b/loadtools/Makefile Tue Jun 17 05:07:17 2014 +0000 @@ -8,11 +8,11 @@ IRAM_OBJS= defpath.o hexdecode.o hwparam.o hwparamstubs.o romload.o \ sercomm.o sertool.o srecreader.o ttypassthru.o ${EXTRA_OBJ} -LOADTOOL_OBJS= crc32tab.o defpath.o flashops.o flmain.o flmisc.o flprogbin.o \ - flprogsrec.o flutil.o hexdecode.o hwparam.o labaud.o \ - ltdispatch.o ltdump.o ltexit.o lthelp.o ltmain.o ltmisc.o \ - ltpassthru.o ltscript.o romload.o sercomm.o srecreader.o \ - tpinterf.o tpinterf2.o tpinterf3.o ${EXTRA_OBJ} +LOADTOOL_OBJS= crc32tab.o defpath.o flashops.o flcmplboot.o flmain.o flmisc.o \ + flprogbin.o flprogsrec.o flutil.o hexdecode.o hwparam.o \ + labaud.o ltdispatch.o ltdump.o ltexit.o lthelp.o ltmain.o \ + ltmisc.o ltpassthru.o ltscript.o romload.o sercomm.o \ + srecreader.o tpinterf.o tpinterf2.o tpinterf3.o ${EXTRA_OBJ} XRAM_OBJS= chainload.o clmain.o defpath.o hexdecode.o hwparam.o \ hwparamstubs.o initscript.o labaud.o romload.o sercomm.o \ diff -r d7f409493eb6 -r bf49e348576b loadtools/flcmplboot.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/flcmplboot.c Tue Jun 17 05:07:17 2014 +0000 @@ -0,0 +1,74 @@ +/* + * This module contains the implementation of the flash erase-program-boot + * hack for brickable Compal phones. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "flash.h" + +static int hack_enabled; +static uint32_t boot_sector_size; +static uint32_t ram_buffer_addr; + +/* called from hwparam.c config file parser */ +void +set_boot_reflash_hack(arg, filename_for_errs, lineno_for_errs) + char *arg; + char *filename_for_errs; + int lineno_for_errs; +{ + char *cp, *np, *ep; + + if (hack_enabled) { + fprintf(stderr, + "%s line %d: duplicate boot-reflash-hack setting\n", + filename_for_errs, lineno_for_errs); + exit(1); + } + for (cp = arg; isspace(*cp); cp++) + ; + if (!*cp || *cp == '#') { +too_few_arg: fprintf(stderr, + "%s line %d: boot-reflash-hack setting: too few arguments\n", + filename_for_errs, lineno_for_errs); + exit(1); + } + for (np = cp; *cp && !isspace(*cp); cp++) + ; + if (!*cp) + goto too_few_arg; + *cp++ = '\0'; + ram_buffer_addr = strtoul(np, &ep, 16); + if (*ep) { +invhex: fprintf(stderr, + "%s line %d: syntax error (hex arguments expected)\n", + filename_for_errs, lineno_for_errs); + exit(1); + } + while (isspace(*cp)) + cp++; + if (!*cp || *cp == '#') + goto too_few_arg; + for (np = cp; *cp && !isspace(*cp); cp++) + ; + if (*cp) + *cp++ = '\0'; + boot_sector_size = strtoul(np, &ep, 16); + if (*ep) + goto invhex; + while (isspace(*cp)) + cp++; + if (*cp && *cp != '#') { + fprintf(stderr, + "%s line %d: boot-reflash-hack setting: too many arguments\n", + filename_for_errs, lineno_for_errs); + exit(1); + } + hack_enabled = 1; +} diff -r d7f409493eb6 -r bf49e348576b loadtools/flmain.c --- a/loadtools/flmain.c Tue Jun 17 04:31:16 2014 +0000 +++ b/loadtools/flmain.c Tue Jun 17 05:07:17 2014 +0000 @@ -3,6 +3,7 @@ */ #include +#include #include #include #include