changeset 226:30804198d5d0

Pirelli's a_pwr_thresholds[] table found
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 29 Nov 2017 22:51:50 +0000
parents 81ab8dec2259
children bb86424f78e6
files .hgignore miscprog/Makefile miscprog/pirbattextr.c pirelli/battery
diffstat 4 files changed, 86 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Nov 28 02:47:01 2017 +0000
+++ b/.hgignore	Wed Nov 29 22:51:50 2017 +0000
@@ -35,6 +35,7 @@
 ^miscprog/memwrite-grep$
 ^miscprog/mokosrec2bin$
 ^miscprog/osmo2psi$
+^miscprog/pirbattextr$
 ^miscprog/pircalextr$
 ^miscprog/pircksum$
 ^miscprog/pircksum2$
--- a/miscprog/Makefile	Tue Nov 28 02:47:01 2017 +0000
+++ b/miscprog/Makefile	Wed Nov 29 22:51:50 2017 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2
 STD=	atsc calextract factdiff ftmdump grokdsn memwrite-grep mokosrec2bin \
-	osmo2psi pircalextr pircksum pircksum2 rfcap-grep
+	osmo2psi pirbattextr pircalextr pircksum pircksum2 rfcap-grep
 CRYPTO=	imeibrute pirimei
 PROGS=	${STD} ${CRYPTO}
 
@@ -22,6 +22,7 @@
 memwrite-grep:	memwrite-grep.c
 mokosrec2bin:	mokosrec2bin.c
 osmo2psi:	osmo2psi.c
+pirbattextr:	pirbattextr.c
 pircalextr:	pircalextr.c
 pircksum:	pircksum.c
 pircksum2:	pircksum2.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/miscprog/pirbattextr.c	Wed Nov 29 22:51:50 2017 +0000
@@ -0,0 +1,56 @@
+/*
+ * This program extracts the a_pwr_thresholds[] table from one of Pirelli's
+ * fw images and converts the numbers to decimal.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+struct entry {
+	u_char	mvolt[2];
+	u_char	percent;
+	u_char	pad;
+};
+
+struct entry array[21];
+
+read_array_from_image(filename, offset_arg)
+	char *filename, *offset_arg;
+{
+	int fd;
+
+	fd = open(filename, O_RDONLY);
+	if (fd < 0) {
+		perror(filename);
+		exit(1);
+	}
+	lseek(fd, strtoul(offset_arg, 0, 0), 0);
+	read(fd, array, sizeof array);
+	close(fd);
+}
+
+dump_array()
+{
+	int i;
+	unsigned mvolt;
+
+	for (i = 0; i < 21; i++) {
+		mvolt = array[i].mvolt[0] | (array[i].mvolt[1] << 8);
+		printf("%4u\t%u\n", mvolt, array[i].percent);
+	}
+}
+
+main(argc, argv)
+	char **argv;
+{
+	if (argc != 3) {
+		fprintf(stderr, "usage: %s fw-image offset\n", argv[0]);
+		exit(1);
+	}
+	read_array_from_image(argv[1], argv[2]);
+	dump_array();
+	exit(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pirelli/battery	Wed Nov 29 22:51:50 2017 +0000
@@ -0,0 +1,27 @@
+Here is Pirelli's version of the a_pwr_thresholds[] array (see pwr_cust.c in
+the MV100 source), fished out of their firmware images:
+
+Table begins at flash address 0x54C0C8 in fw version D910.0.3.98
+Table begins at flash address 0x54B684 in fw version D910.0.3.99d
+
+4170	100
+4120	95
+4070	90
+4030	85
+3964	80
+3930	75
+3900	70
+3882	65
+3847	60
+3805	55
+3786	50
+3771	45
+3759	40
+3750	35
+3745	30
+3737	25
+3719	20
+3688	15
+3663	10
+3539	5
+3370	0