Merge pull request #2747 from Eltrick/stylise-dormakaba
[RRG-proxmark3.git] / doc / ext_flash_notes.md
blob25ba2be14cb46a72368c3e168641bdae77f73b53
1 # External flash
2 <a id="Top"></a>
4 External 256kbytes flash is a unique feature of the RDV4 edition.
6 # Table of Contents
7 - [External flash](#external-flash)
8 - [Table of Contents](#table-of-contents)
9   - [Addresses](#addresses)
10   - [Layout](#layout)
11   - [Page3 Layout](#page3-layout)
12   - [RSA signature](#rsa-signature)
13 - [backup first!](#backup-first)
17 ## Addresses
18 ^[Top](#top)
20 Flash memory is
22 * 256KB (0x40000 = 262144)
23 * divided into 4 pages of 64KB (0x10000 = 65536)
24 * 4 pages divided into 16 sectors of 4KB (0x1000 = 4096), so last sector is at 0x3F000
26 Therefore a flash address can be interpreted as such:
27 ```
28 0xPSxxx       e.g. 0x3FF7F
29   ^ page             ^ page 3
30    ^ sector           ^ sector 0xF
31     ^^^ offset         ^^^ offset 0xF7F
32 ```
34 Please note that for other flash memory sizes than 256KB a "Page 3" will be the last page of the memory, and address offsets would be dependant on the memory size.
36 ## Layout
37 ^[Top](#top)
39 Page 0:
40 * available for user data
41 * to dump it: `mem dump -f page0_dump -o 0 -l 65536`
42 * to erase it: `mem wipe -p 0`
44 Page 1:
45 * available for user data
46 * to dump it: `mem dump -f page1_dump -o 65536 -l 65536`
47 * to erase it: `mem wipe -p 1`
49 Page 2:
50 * available for user data
51 * to dump it: `mem dump -f page2_dump -o 131072 -l 65536`
52 * to erase it: `mem wipe -p 2`
54 Page 3 (or the last page for memories other than 256KB):
55 * used by Proxmark3 RDV4 specific functions: flash signature, see below for details
56 * to dump it: `mem dump -f page3_dump -o 196608 -l 65536`
57 * to erase it:
58   * **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!
59   * edit the source code to enable Page 3 as a valid input in the `mem wipe` command.
60   * Updating keys dictionaries doesn't require to erase page 3.
62 ## Page3 Layout
63 ^[Top](#top)
65 Page3 (or the last page for memories other than 256KB) is used as follows by the Proxmark3 RDV4 firmware:
67 * **RSA SIGNATURE**, see below for details
68   * offset: page 3 sector 15 (0xF) offset 0xF7F @ 3*0x10000+15*0x1000+0xF7F=0x3FF7F  (decimal 262015)
69   * length: 128 bytes
70   * offset should have been 0x3FF80 but historically it's one byte off and therefore the last byte of the flash is unused
72 * **Reserved for future use**
73   * offset: page 3 sector 14 (0xE)
75 * **SPIFFS sectors**
76   * offset: page 3 sectors 13..0 (0xD..0x0)
78 ## RSA signature
79 ^[Top](#top)
81 To ensure your Proxmark3 RDV4 is not a counterfeit product, its external flash contains a RSA signature of the flash unique ID.
82 You can verify it with: `mem info`
85 Here below is a sample output of a RDV4 device.
86 ```
87 [usb] pm3 --> mem info                                                
88                                                                       
89 [=] --- Flash memory Information ---------                            
90 [=] ID................... 25AD99A782A867D5                            
91 [=] SHA1................. 67C3B9BA2FA90AD4B283926B70017066C082C156    
92 [+] Signature............ ( ok )                                      
93                                                                       
94 [=] --- RDV4 RSA signature ---------------                            
95 [=]  C7C7DF7FA3A2391A2B36E97D227C746ED8BB475E8766F54A13BAA9AAB29299BE 
96 [=]  37546AACCC29157ABF8AFBF3A1CFB24275442D565F7E996C6B08090528ADE25E 
97 [=]  ED1498E3089C72C68348D83CBD13F1247327BDBC9D75B09ECE3E051E19FE19BB 
98 [=]  98CB038757F2EDFD2DC5060D05C3296BC19A6F768290D555DFD50407E0E13A70 
99                                                                       
100 [=] --- RDV4 RSA Public key --------------                            
101 [=] Len.................. 128                                         
102 [=] Exponent............. 010001                                      
103 [=] Public key modulus N                                              
104 [=]  E28D809BF323171D11D1ACA4C32A5B7E0A8974FD171E75AD120D60E9B76968FF 
105 [=]  4B0A6364AE50583F9555B8EE1A725F279E949246DF0EFCE4C02B9F3ACDCC623F 
106 [=]  9337F21C0C066FFB703D8BFCB5067F309E056772096642C2B1A8F50305D5EC33 
107 [=]  DB7FB5A3C8AC42EB635AE3C148C910750ABAA280CE82DC2F180F49F30A1393B5 
108                                                                       
109 [+] RSA public key validation.... ( ok )                              
110 [+] RSA private key validation... ( ok )                              
111 [+] RSA verification..... ( ok )                                      
112 [+] Genuine Proxmark3 RDV4 signature detected                         
115 # backup first!
116 ^[Top](#top)
118 To make a backup of the signature to file:
120 `mem dump -f flash_signature_dump -o 262015 -l 128`