# HG changeset patch # User Mychaela Falconia # Date 1511995910 0 # Node ID 30804198d5d0374b1ea91becdc08a2e2c8a300bd # Parent 81ab8dec2259fbf245acf73c6a2be003585d33e8 Pirelli's a_pwr_thresholds[] table found diff -r 81ab8dec2259 -r 30804198d5d0 .hgignore --- 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$ diff -r 81ab8dec2259 -r 30804198d5d0 miscprog/Makefile --- 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 diff -r 81ab8dec2259 -r 30804198d5d0 miscprog/pirbattextr.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 +#include +#include +#include +#include + +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); +} diff -r 81ab8dec2259 -r 30804198d5d0 pirelli/battery --- /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