7
7
* <PageSize> = 2 ^ Shift. Shift = 3 => <PageSize> = 2^3 = 8 bytes
8
8
*
9
9
*/
10
- #define PAGE_SIZE_SHIFT (2 )
10
+ #define PAGE_SIZE_SHIFT (8 )
11
11
12
12
/* *
13
13
* @brief If value is false the device does not support native read. This
37
37
* <SectorSize> = 2 ^ Shift. Shift = 12 => <SectorSize> = 2 ^ 12 = 4096 bytes
38
38
*
39
39
*/
40
- #define SECTOR_SIZE_SHIFT (2 )
40
+ #define SECTOR_SIZE_SHIFT (12 )
41
+
42
+ /* *
43
+ * @brief Use a custom verify. Is optional. Speeds up verifying
44
+ *
45
+ */
46
+ #define CUSTOM_VERIFY (false )
41
47
42
48
/* *
43
49
* @brief Device specific infomation
44
50
*
45
51
*/
46
52
extern " C" {
47
- const __attribute__ ((section(" DevDscr" ), __used__)) flash_device FlashDevice = {
48
- flash_drv_version, // driver version
49
- " test device" , // device name
50
- device_type::on_chip, // device type
51
- 0xA0000000 , // base address
52
- 0x00000400 , // flash size
53
- 4 , // page size
54
- 0 , // reserved
55
- 0xff , // blank value
56
- 100 , // page program timeout
57
- 3000 , // sector erase timeout
58
-
59
- // flash sectors
60
- {
61
- {0x00000400 , 0x00000000 },
62
- end_of_sectors
63
- }
64
- };
53
+ // declaration for the flash device. If we initialize it here we get
54
+ // a wrong name in the symbol table
55
+ extern const struct flash_device FlashDevice;
56
+
57
+ // Mark start of <PrgData> segment. Non-static to make sure linker can keep this
58
+ // symbol. Dummy needed to make sure that <PrgData> section in resulting ELF file
59
+ // is present. Needed by open flash loader logic on PC side
60
+ volatile int PRGDATA_StartMarker __attribute__ ((section (" PrgData" ), __used__));
65
61
}
66
62
63
+ // definition for the flash device
64
+ const __attribute__ ((section(" DevDscr" ), __used__)) flash_device FlashDevice = {
65
+ flash_drv_version, // driver version
66
+ " test device" , // device name
67
+ device_type::on_chip, // device type
68
+ 0xA0000000 , // base address
69
+ 0x00000400 , // flash size
70
+ 4 , // page size
71
+ 0 , // reserved
72
+ 0xff , // blank value
73
+ 100 , // page program timeout
74
+ 3000 , // sector erase timeout
75
+
76
+ // flash sectors
77
+ {
78
+ {0x00000400 , 0x00000000 },
79
+ end_of_sectors
80
+ }
81
+ };
82
+
67
83
// function overrides when parts are not in use
68
84
#if NATIVE_READ
69
- #define VERIFY_FUNC nullptr
70
85
#define BLANK_CHECK_FUNC nullptr
71
86
#define OPEN_READ_FUNC nullptr
72
87
#else
73
- #define VERIFY_FUNC Verify
74
88
#define BLANK_CHECK_FUNC BlankCheck
75
89
#define OPEN_READ_FUNC SEGGER_OPEN_Read
76
90
#endif
77
91
92
+ #if CUSTOM_VERIFY
93
+ #define VERIFY_FUNC Verify
94
+ #else
95
+ #define VERIFY_FUNC nullptr
96
+ #endif
97
+
78
98
#if CHIP_ERASE
79
99
#define CHIP_ERASE_FUNC EraseChip
80
100
#else
@@ -92,23 +112,28 @@ extern "C" {
92
112
*
93
113
*/
94
114
extern " C" {
95
- const uint32_t SEGGER_OFL_Api[13 ] __attribute__ ((section (" PrgCode" ), __used__)) = {
96
- reinterpret_cast <uint32_t >(FeedWatchdog),
97
- reinterpret_cast <uint32_t >(Init),
98
- reinterpret_cast <uint32_t >(UnInit),
99
- reinterpret_cast <uint32_t >(EraseSector),
100
- reinterpret_cast <uint32_t >(ProgramPage),
101
- reinterpret_cast <uint32_t >(BLANK_CHECK_FUNC),
102
- reinterpret_cast <uint32_t >(CHIP_ERASE_FUNC),
103
- reinterpret_cast <uint32_t >(VERIFY_FUNC),
104
- reinterpret_cast <uint32_t >(nullptr ), // SEGGER_OPEN_CalcCRC
105
- reinterpret_cast <uint32_t >(OPEN_READ_FUNC),
106
- reinterpret_cast <uint32_t >(SEGGER_OPEN_Program),
107
- reinterpret_cast <uint32_t >(UNIFORM_ERASE_FUNC),
108
- reinterpret_cast <uint32_t >(nullptr ), // SEGGER_OPEN_Start for turbo mode
109
- };
115
+ // declaration for the OFL Api. If we initialize it here we get
116
+ // a wrong name in the symbol table
117
+ extern const uint32_t SEGGER_OFL_Api[13 ];
110
118
}
111
119
120
+ // definition of OFL Api
121
+ const uint32_t SEGGER_OFL_Api[13 ] __attribute__ ((section (" PrgCode" ), __used__)) = {
122
+ reinterpret_cast <uint32_t >(FeedWatchdog),
123
+ reinterpret_cast <uint32_t >(Init),
124
+ reinterpret_cast <uint32_t >(UnInit),
125
+ reinterpret_cast <uint32_t >(EraseSector),
126
+ reinterpret_cast <uint32_t >(ProgramPage),
127
+ reinterpret_cast <uint32_t >(BLANK_CHECK_FUNC),
128
+ reinterpret_cast <uint32_t >(CHIP_ERASE_FUNC),
129
+ reinterpret_cast <uint32_t >(VERIFY_FUNC),
130
+ reinterpret_cast <uint32_t >(nullptr ), // SEGGER_OPEN_CalcCRC
131
+ reinterpret_cast <uint32_t >(OPEN_READ_FUNC),
132
+ reinterpret_cast <uint32_t >(SEGGER_OPEN_Program),
133
+ reinterpret_cast <uint32_t >(UNIFORM_ERASE_FUNC),
134
+ reinterpret_cast <uint32_t >(nullptr ), // SEGGER_OPEN_Start for turbo mode
135
+ };
136
+
112
137
void __attribute__ ((noinline)) FeedWatchdog(void ) {
113
138
// TODO: implement something to keep the watchdog happy
114
139
return ;
@@ -185,20 +210,22 @@ int __attribute__ ((noinline)) SEGGER_OPEN_Program(uint32_t address, uint32_t si
185
210
}
186
211
#endif
187
212
188
- #if !NATIVE_READ
189
- uint32_t __attribute__ ((noinline)) Verify(uint32_t Addr, uint32_t NumBytes, uint8_t *pBuff) {
213
+ #if CUSTOM_VERIFY
214
+ uint32_t __attribute__ ((noinline, __used__ )) Verify(uint32_t Addr, uint32_t NumBytes, uint8_t *pBuff) {
190
215
// TODO: implement verify
191
216
192
- return 0 ;
217
+ return (Addr + NumBytes) ;
193
218
}
219
+ #endif
194
220
195
- int __attribute__ ((noinline)) BlankCheck(const uint32_t address, const uint32_t size, const uint8_t blank_value) {
196
- // TODO: implement blankcheck
221
+ #if !NATIVE_READ
222
+ int __attribute__ ((noinline, __used__)) BlankCheck(const uint32_t address, const uint32_t size, const uint8_t blank_value) {
223
+ // TODO: implement verify
197
224
198
225
return 0 ;
199
226
}
200
227
201
- int __attribute__ ((noinline)) SEGGER_OPEN_Read(const uint32_t address, const uint32_t size, uint8_t *const data) {
228
+ int __attribute__ ((noinline, __used__ )) SEGGER_OPEN_Read(const uint32_t address, const uint32_t size, uint8_t *const data) {
202
229
// TODO: add read implementation
203
230
204
231
return size;
0 commit comments