Merge pull request #2593 from Akury83/master
[RRG-proxmark3.git] / include / pmflash.h
blob65e373f8f204ee9564e84b005581c04f26df06f9
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // RDV4 flash constants
17 //-----------------------------------------------------------------------------
19 #ifndef __PMFLASH_H
20 #define __PMFLASH_H
22 #include "common.h"
24 // RDV40 Section
25 // 256kb divided into 4k sectors.
27 // 0x3F000 - 1 4kb sector = signature
28 // 0x3E000 - 1 4kb sector = settings
29 // 0x3D000 - 1 4kb sector = default T55XX keys dictionary
30 // 0x3B000 - 1 4kb sector = default ICLASS keys dictionary
31 // 0x38000 - 3 4kb sectors = default MFC keys dictionary
33 #ifndef FLASH_MEM_BLOCK_SIZE
34 # define FLASH_MEM_BLOCK_SIZE 256
35 #endif
37 #ifndef FLASH_MEM_MAX_SIZE
38 # define FLASH_MEM_MAX_SIZE 0x40000 // (262144)
39 #endif
41 #ifndef FLASH_MEM_MAX_4K_SECTOR
42 # define FLASH_MEM_MAX_4K_SECTOR 0x3F000
43 #endif
45 #ifndef FLASH_MEM_ID_LEN
46 # define FLASH_MEM_ID_LEN 8
47 #endif
49 #ifndef FLASH_MEM_SIGNATURE_LEN
50 # define FLASH_MEM_SIGNATURE_LEN 128
51 #endif
53 #ifndef FLASH_MEM_SIGNATURE_OFFSET
54 // -1 for historical compatibility with already released Proxmark3 RDV4.0 devices
55 # define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN - 1)
56 #endif
58 #ifndef T55XX_CONFIG_LEN
59 # define T55XX_CONFIG_LEN sizeof( t55xx_configurations_t )
60 #endif
62 #ifndef T55XX_CONFIG_OFFSET
63 # define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000)
64 #endif
66 // Reserved space for T55XX PWD = 4 kb
67 #ifndef DEFAULT_T55XX_KEYS_OFFSET
68 # define DEFAULT_T55XX_KEYS_LEN (0x1000)
69 # define DEFAULT_T55XX_KEYS_OFFSET (T55XX_CONFIG_OFFSET - DEFAULT_T55XX_KEYS_LEN)
70 # define DEFAULT_T55XX_KEYS_MAX ((DEFAULT_T55XX_KEYS_LEN - 2) / 4)
71 #endif
73 // Reserved space for iClass keys = 4 kb
74 #ifndef DEFAULT_ICLASS_KEYS_OFFSET
75 # define DEFAULT_ICLASS_KEYS_LEN (0x1000)
76 # define DEFAULT_ICLASS_KEYS_OFFSET (DEFAULT_T55XX_KEYS_OFFSET - DEFAULT_ICLASS_KEYS_LEN)
77 # define DEFAULT_ICLASS_KEYS_MAX ((DEFAULT_ICLASS_KEYS_LEN - 2) / 8)
78 #endif
80 // Reserved space for MIFARE Keys = 12 kb
81 #ifndef DEFAULT_MF_KEYS_OFFSET
82 # define DEFAULT_MF_KEYS_LEN (0x3000)
83 # define DEFAULT_MF_KEYS_OFFSET (DEFAULT_ICLASS_KEYS_OFFSET - DEFAULT_MF_KEYS_LEN)
84 # define DEFAULT_MF_KEYS_MAX ((DEFAULT_MF_KEYS_LEN - 2) / 6)
85 #endif
87 // RDV40, validation structure to help identifying that client/firmware is talking with RDV40
88 typedef struct {
89 uint8_t magic[4];
90 uint8_t flashid[FLASH_MEM_ID_LEN];
91 uint8_t signature[FLASH_MEM_SIGNATURE_LEN];
92 } PACKED rdv40_validation_t;
94 // SPIFFS current allocates 192KB of the 256KB available.
95 #ifndef FLASH_SPIFFS_ALLOCATED_SIZE
96 # define FLASH_SPIFFS_ALLOCATED_SIZE (1024 * 192)
97 #endif
99 #endif // __PMFLASH_H