changeset 412:bf49e348576b

fc-loadtool: flcmplboot.c (boot-reflash-hack) code started
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 17 Jun 2014 05:07:17 +0000
parents d7f409493eb6
children 1ed2d78f150c
files loadtools/Makefile loadtools/flcmplboot.c loadtools/flmain.c
diffstat 3 files changed, 80 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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 \
--- /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 <sys/types.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#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;
+}
--- 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 <sys/types.h>
+#include <ctype.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>