Merge pull request #1327 from Pondorasti/patch-1
[RRG-proxmark3.git] / include / pmflash.h
blobc2f90bfc19e22ad9cec5aaf8d187a6d4d0e764c0
1 //-----------------------------------------------------------------------------
2 // (c) RFID Research Group - 2019
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //
8 //-----------------------------------------------------------------------------
9 // RDV4 flash constants
10 //-----------------------------------------------------------------------------
12 #ifndef __PMFLASH_H
13 #define __PMFLASH_H
15 #include "common.h"
17 // RDV40 Section
18 // 256kb divided into 4k sectors.
20 // 0x3F000 - 1 4kb sector = signature
21 // 0x3E000 - 1 4kb sector = settings
22 // 0x3D000 - 1 4kb sector = default T55XX keys dictionary
23 // 0x3B000 - 1 4kb sector = default ICLASS keys dictionary
24 // 0x39000 - 2 4kb sectors = default MFC keys dictionary
26 #ifndef FLASH_MEM_BLOCK_SIZE
27 # define FLASH_MEM_BLOCK_SIZE 256
28 #endif
30 #ifndef FLASH_MEM_MAX_SIZE
31 # define FLASH_MEM_MAX_SIZE 0x40000 // (262144)
32 #endif
34 #ifndef FLASH_MEM_MAX_4K_SECTOR
35 # define FLASH_MEM_MAX_4K_SECTOR 0x3F000
36 #endif
38 #ifndef FLASH_MEM_ID_LEN
39 # define FLASH_MEM_ID_LEN 8
40 #endif
42 #ifndef FLASH_MEM_SIGNATURE_LEN
43 # define FLASH_MEM_SIGNATURE_LEN 128
44 #endif
46 #ifndef FLASH_MEM_SIGNATURE_OFFSET
47 // -1 for historical compatibility with already released Proxmark3 RDV4.0 devices
48 # define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN - 1)
49 #endif
51 #ifndef T55XX_CONFIG_LEN
52 # define T55XX_CONFIG_LEN sizeof( t55xx_configurations_t )
53 #endif
55 #ifndef T55XX_CONFIG_OFFSET
56 # define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000)
57 #endif
59 // Reserved space for T55XX PWD = 4 kb
60 #ifndef DEFAULT_T55XX_KEYS_OFFSET
61 # define DEFAULT_T55XX_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x3000)
62 #endif
64 // Reserved space for iClass keys = 4 kb
65 #ifndef DEFAULT_ICLASS_KEYS_OFFSET
66 # define DEFAULT_ICLASS_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x4000)
67 #endif
69 // Reserved space for MIFARE Keys = 8 kb
70 #ifndef DEFAULT_MF_KEYS_OFFSET
71 # define DEFAULT_MF_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x6000)
72 #endif
74 // RDV40, validation structure to help identifying that client/firmware is talking with RDV40
75 typedef struct {
76 uint8_t magic[4];
77 uint8_t flashid[FLASH_MEM_ID_LEN];
78 uint8_t signature[FLASH_MEM_SIGNATURE_LEN];
79 } PACKED rdv40_validation_t;
81 // SPIFFS current allocates 128kb of the 256kb available.
82 #ifndef FLASH_SPIFFS_ALLOCATED_SIZE
83 # define FLASH_SPIFFS_ALLOCATED_SIZE (1024 * 128)
84 #endif
86 #endif // __PMFLASH_H