textual
[RRG-proxmark3.git] / doc / ext_flash_notes.md
blob76b4d9279e6103a756642f8381c3b73919d934a8
1 # External flash
3 External 256kbytes flash is a unique feature of the RDV4 edition.
5 ## Addresses
7 Flash memory is
9 * 256kb (0x40000= 262144)
10 * divided into 4 pages of 64kb (0x10000 = 65536)
11 * 4 pages divided into 16 sectors of 4kb (0x1000 = 4096), so last sector is at 0x3F000
13 Therefore a flash address can be interpreted as such:
14 ```
15 0xPSxxx       e.g. 0x3FF7F
16   ^ page             ^ page 3
17    ^ sector           ^ sector 0xF
18     ^^^ offset         ^^^ offset 0xF7F
19 ```
21 ## Layout
23 Page 0:
24 * available for user data
25 * to dump it: `mem dump f page0_dump o 0 l 65536`
26 * to erase it: `mem wipe p 0`
28 Page 1:
29 * available for user data
30 * to dump it: `mem dump f page1_dump o 65536 l 65536`
31 * to erase it: `mem wipe p 1`
33 Page 2:
34 * available for user data
35 * to dump it: `mem dump f page2_dump o 131072 l 65536`
36 * to erase it: `mem wipe p 2`
38 Page 3:
39 * used by Proxmark3 RDV4 specific functions: flash signature and keys dictionaries, see below for details
40 * to dump it: `mem dump f page3_dump o 196608 l 65536`
41 * to erase it:
42   * **Beware** it will erase your flash signature so better to back it up first as you won't be able to regenerate it by yourself!
43   * edit the source code to enable Page 3 as a valid input in the `mem wipe` command.
44   * Updating keys dictionaries doesn't require to erase page 3.
46 ## Page3 Layout
48 Page3 is used as follows by the Proxmark3 RDV4 firmware:
50 * **MF_KEYS**
51   * offset: page 3 sector  9 (0x9) @ 3*0x10000+9*0x1000=0x39000
52   * length: 2 sectors
54 * **ICLASS_KEYS**
55   * offset: page 3 sector 11 (0xB) @ 3*0x10000+11*0x1000=0x3B000
56   * length: 1 sector
58 * **T55XX_KEYS**
59   * offset: page 3 sector 12 (0xC) @ 3*0x10000+12*0x1000=0x3C000
60   * length: 1 sector
62 * **T55XX_CONFIG**
63   * offset: page 3 sector 13 (0xD) @ 3*0x10000+13*0x1000=0x3D000
64   * length: 1 sector (actually only a few bytes are used to store `t55xx_config` structure)
66 * **RSA SIGNATURE**, see below for details
67   * offset: page 3 sector 15 (0xF) offset 0xF7F @ 3*0x10000+15*0x1000+0xF7F=0x3FF7F  (decimal 262015)
68   * length: 128 bytes
69   * offset should have been 0x3FF80 but historically it's one byte off and therefore the last byte of the flash is unused
71 ## RSA signature
73 To ensure your Proxmark3 RDV4 is not a counterfeit product, its external flash contains a RSA signature of the flash unique ID.
74 You can verify it with: `mem info`
77 Here below is a sample output of a RDV4 device.
78 ```
79 [usb] pm3 --> mem info                                                
80                                                                       
81 [=] --- Flash memory Information ---------                            
82 [=] ID................... 25AD99A782A867D5                            
83 [=] SHA1................. 67C3B9BA2FA90AD4B283926B70017066C082C156    
84 [+] Signature............ ( ok )                                      
85                                                                       
86 [=] --- RDV4 RSA signature ---------------                            
87 [=]  C7C7DF7FA3A2391A2B36E97D227C746ED8BB475E8766F54A13BAA9AAB29299BE 
88 [=]  37546AACCC29157ABF8AFBF3A1CFB24275442D565F7E996C6B08090528ADE25E 
89 [=]  ED1498E3089C72C68348D83CBD13F1247327BDBC9D75B09ECE3E051E19FE19BB 
90 [=]  98CB038757F2EDFD2DC5060D05C3296BC19A6F768290D555DFD50407E0E13A70 
91                                                                       
92 [=] --- RDV4 RSA Public key --------------                            
93 [=] Len.................. 128                                         
94 [=] Exponent............. 010001                                      
95 [=] Public key modulus N                                              
96 [=]  E28D809BF323171D11D1ACA4C32A5B7E0A8974FD171E75AD120D60E9B76968FF 
97 [=]  4B0A6364AE50583F9555B8EE1A725F279E949246DF0EFCE4C02B9F3ACDCC623F 
98 [=]  9337F21C0C066FFB703D8BFCB5067F309E056772096642C2B1A8F50305D5EC33 
99 [=]  DB7FB5A3C8AC42EB635AE3C148C910750ABAA280CE82DC2F180F49F30A1393B5 
100                                                                       
101 [+] RSA public key validation.... ( ok )                              
102 [+] RSA private key validation... ( ok )                              
103 [+] RSA verification..... ( ok )                                      
104 [+] Genuine Proxmark3 RDV4 signature detected                         
107 # backup first!
108 To make a backup of the signature to file:
110 `mem dump p f flash_signature_dump o 262015 l 128`