FreeCalypso > hg > freecalypso-tools
annotate target-utils/pln-ppb-test/erase.c @ 1012:11391cb6bdc0
patch from fixeria: doc change from SE K2x0 to K2xx
Since their discovery in late 2022, Sony Ericsson K200 and K220 phones
were collectively referred to as SE K2x0 in FreeCalypso documentation.
However, now that SE K205 has been discovered as yet another member
of the same family (same PCBA in different case), it makes more sense
to refer to the whole family as SE K2xx.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 23 Sep 2024 12:23:20 +0000 |
| parents | f34261bb3355 |
| children |
| rev | line source |
|---|---|
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
2 * erase command for PPB special mode |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "types.h" |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 void |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
9 cmd_erase(argbulk) |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 char *argbulk; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 { |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
12 char *argv[2]; |
|
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
13 u_long addr; |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u16 buf[256]; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int i; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
17 if (parse_args(argbulk, 1, 1, argv, 0) < 0) |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 return; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (parse_hexarg(argv[0], 8, &addr) < 0) { |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
20 printf("ERROR: argument must be a valid 32-bit hex address\n"); |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (addr & 1) { |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 printf("ERROR: unaligned address\n"); |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
|
990
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
27 *(volatile u16 *)addr = 0x80; |
|
f34261bb3355
pln-ppb-test: implement PPB erase
Mychaela Falconia <falcon@freecalypso.org>
parents:
989
diff
changeset
|
28 *(volatile u16 *)addr = 0x30; |
|
989
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 for (i = 0; i < 256; i++) |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 buf[i] = *(volatile u16 *)addr; |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 for (i = 0; i < 256; i++) |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 printf("%04X%c", buf[i], (i & 15) == 15 ? '\n' : ' '); |
|
a5bff8104b45
pln-ppb-test: implement program operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
