Skip to content

Commit 01aceaa

Browse files
committed
Support all boards and remove erase and page sizes because they never change.
1 parent 2ab9238 commit 01aceaa

12 files changed

Lines changed: 157 additions & 94 deletions

File tree

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@
4747

4848
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4949

50-
#define EXTERNAL_FLASH_DEVICES 25FL216K, \
50+
#include "external_flash/devices.h"
51+
52+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
53+
#define EXTERNAL_FLASH_DEVICES S25FL216K, \
5154
GD25Q16C
5255

56+
#include "external_flash/external_flash.h"
57+
5358
#define CALIBRATE_CRYSTALLESS 1
5459

5560
// Explanation of how a user got into safe mode.

ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,10 @@
4040

4141
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4242

43-
#include "external_flash/devices/S25FL216K.h"
44-
#include "external_flash/devices/GD25Q16C.h"
43+
#include "external_flash/devices.h"
44+
45+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
46+
#define EXTERNAL_FLASH_DEVICES S25FL216K, \
47+
GD25Q16C
48+
49+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@
4242

4343
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4444

45-
#include "external_flash/devices/S25FL064L.h"
45+
#include "external_flash/devices.h"
46+
47+
#define EXTERNAL_FLASH_DEVICE_COUNT 1
48+
#define EXTERNAL_FLASH_DEVICES S25FL064L
49+
50+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
#define MICROPY_PORT_B (PORT_PB22 | PORT_PB23 | PORT_PB03 )
3434
#define MICROPY_PORT_C (0)
3535

36-
#include "external_flash/external_flash.h"
37-
3836
// If you change this, then make sure to update the linker scripts as well to
3937
// make sure you don't overwrite code.
4038
// #define CIRCUITPY_INTERNAL_NVM_SIZE 256
4139
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
4240
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4341

44-
#include "external_flash/devices/GD25Q16C.h"
45-
#include "external_flash/devices/W25Q16FW.h"
42+
#include "external_flash/devices.h"
43+
44+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
45+
#define EXTERNAL_FLASH_DEVICES W25Q16FW, \
46+
GD25Q16C
47+
48+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
#define MICROPY_PORT_B (PORT_PB03 | PORT_PB22 | PORT_PB23)
3535
#define MICROPY_PORT_C (0)
3636

37-
#include "external_flash/external_flash.h"
38-
3937
// If you change this, then make sure to update the linker scripts as well to
4038
// make sure you don't overwrite code.
4139
// #define CIRCUITPY_INTERNAL_NVM_SIZE 256
4240
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
4341

4442
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4543

46-
#include "external_flash/devices/S25FL216K.h"
47-
#include "external_flash/devices/GD25Q16C.h"
44+
#include "external_flash/devices.h"
45+
46+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
47+
#define EXTERNAL_FLASH_DEVICES S25FL216K, \
48+
GD25Q16C
49+
50+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "external_flash/devices.h"
3131

32-
#define EXTERNAL_FLASH_DEVICE_COUNT 2
33-
#define EXTERNAL_FLASH_DEVICES S25FL116K, GD25Q16C
32+
#define EXTERNAL_FLASH_DEVICE_COUNT 3
33+
#define EXTERNAL_FLASH_DEVICES S25FL116K, S25FL216K, GD25Q16C
3434

3535
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/metro_m4_express_revb/mpconfigboard.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,10 @@
5454

5555
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
5656

57-
#include "external_flash/devices/S25FL216K.h"
58-
#include "external_flash/devices/GD25Q16C.h"
57+
#include "external_flash/devices.h"
58+
59+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
60+
#define EXTERNAL_FLASH_DEVICES S25FL216K, \
61+
GD25Q16C
62+
63+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@
4848
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
4949
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
5050

51-
#include "external_flash/devices/W25Q32BV.h"
51+
#include "external_flash/devices.h"
52+
53+
#define EXTERNAL_FLASH_DEVICE_COUNT 1
54+
#define EXTERNAL_FLASH_DEVICES W25Q32BV
55+
56+
#include "external_flash/external_flash.h"

ports/atmel-samd/boards/ugame10/mpconfigboard.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@
4141
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
4242
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4343

44-
//#include "external_flash/devices/W25Q32BV.h"
45-
#include "external_flash/devices/S25FL216K.h"
44+
#include "external_flash/devices.h"
45+
46+
#define EXTERNAL_FLASH_DEVICE_COUNT 1
47+
#define EXTERNAL_FLASH_DEVICES S25FL216K
48+
49+
#include "external_flash/external_flash.h"

ports/atmel-samd/external_flash/devices.h

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,149 +31,173 @@
3131

3232
typedef struct {
3333
uint32_t total_size;
34-
uint16_t erase_size;
35-
uint16_t page_size;
3634
uint16_t start_up_time_us;
35+
36+
// Three response bytes to 0x9f JEDEC ID command.
3737
uint8_t manufacturer_id;
3838
uint8_t memory_type;
3939
uint8_t capacity;
40+
41+
// Max clock speed for all operations and the fastest read mode.
4042
uint8_t max_clock_speed_mhz;
41-
bool has_sector_protection;
42-
bool supports_qspi;
43-
bool supports_qspi_writes;
43+
bool has_sector_protection : 1;
44+
45+
// Supports the 0x0b fast read command with 8 dummy cycles.
46+
bool supports_fast_read : 1;
47+
48+
// Supports the fast read, quad output command 0x6b with 8 dummy cycles.
49+
bool supports_qspi : 1;
50+
51+
// Requires quad enable set in status bit 9.
52+
bool has_quad_enable : 1;
53+
54+
// Supports the quad input page program command 0x32. This is known as 1-1-4 because it only
55+
// uses all four lines for data.
56+
bool supports_qspi_writes: 1;
4457
} external_flash_device;
4558

4659
// Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. Its on the SAMD21
4760
// Xplained board.
4861
// Datasheet: https://www.adestotech.com/wp-content/uploads/doc8715.pdf
4962
#define AT25DF081A {\
5063
.total_size = (1 << 20), /* 1 MiB */ \
51-
.erase_size = (1 << 12), /* 4 KiB */ \
52-
.page_size = 256, /*256 bytes */ \
5364
.start_up_time_us = 10000, \
5465
.manufacturer_id = 0x1f, \
5566
.memory_type = 0x45, \
5667
.capacity = 0x01, \
57-
.max_clock_speed_mhz = 104, \
68+
.max_clock_speed_mhz = 85, \
5869
.has_sector_protection = true, \
59-
.supports_qspi = true, \
70+
.supports_fast_read = true, \
71+
.supports_qspi = false, \
72+
.has_quad_enable = false, \
6073
.supports_qspi_writes = false, \
6174
}
6275

6376
// Settings for the Gigadevice GD25Q16C 2MiB SPI flash.
6477
// Datasheet: http://www.gigadevice.com/wp-content/uploads/2017/12/DS-00086-GD25Q16C-Rev2.6.pdf
65-
6678
#define GD25Q16C {\
6779
.total_size = (1 << 21), /* 2 MiB */ \
68-
.erase_size = (1 << 12), /* 4 KiB */ \
69-
.page_size = 256, /*256 bytes */ \
7080
.start_up_time_us = 5000, \
7181
.manufacturer_id = 0xc8, \
7282
.memory_type = 0x40, \
7383
.capacity = 0x15, \
74-
.max_clock_speed_mhz = 104, \
75-
.has_sector_protection = true, \
84+
.max_clock_speed_mhz = 104, /* if we need 120 then we can turn on high performance mode */ \
85+
.has_sector_protection = false, \
86+
.supports_fast_read = true, \
7687
.supports_qspi = true, \
77-
.supports_qspi_writes = false, \
88+
.has_quad_enable = true, \
89+
.supports_qspi_writes = true, \
7890
}
7991

8092
// Settings for the Cypress (was Spansion) S25FL064L 8MiB SPI flash.
8193
// Datasheet: http://www.cypress.com/file/316661/download
8294
#define S25FL064L {\
8395
.total_size = (1 << 23), /* 8 MiB */ \
84-
.erase_size = (1 << 12), /* 4 KiB */ \
85-
.page_size = 256, /*256 bytes */ \
8696
.start_up_time_us = 300, \
8797
.manufacturer_id = 0x01, \
8898
.memory_type = 0x60, \
8999
.capacity = 0x17, \
90-
.max_clock_speed_mhz = 104, \
91-
.has_sector_protection = true, \
100+
.max_clock_speed_mhz = 108, \
101+
.has_sector_protection = false, \
102+
.supports_fast_read = true, \
92103
.supports_qspi = true, \
93-
.supports_qspi_writes = false, \
104+
.has_quad_enable = true, \
105+
.supports_qspi_writes = true, \
94106
}
95107

96108
// Settings for the Cypress (was Spansion) S25FL116K 2MiB SPI flash.
97109
// Datasheet: http://www.cypress.com/file/196886/download
98110
#define S25FL116K {\
99111
.total_size = (1 << 21), /* 2 MiB */ \
100-
.erase_size = (1 << 12), /* 4 KiB */ \
101-
.page_size = 256, /*256 bytes */ \
102112
.start_up_time_us = 10000, \
103113
.manufacturer_id = 0x01, \
104114
.memory_type = 0x40, \
105115
.capacity = 0x15, \
106-
.max_clock_speed_mhz = 104, \
107-
.has_sector_protection = true, \
116+
.max_clock_speed_mhz = 108, \
117+
.has_sector_protection = false, \
118+
.supports_fast_read = true, \
108119
.supports_qspi = true, \
120+
.has_quad_enable = true, \
109121
.supports_qspi_writes = false, \
110122
}
111123

112-
113124
// Settings for the Cypress (was Spansion) S25FL216K 2MiB SPI flash.
114125
// Datasheet: http://www.cypress.com/file/197346/download
115-
116126
#define S25FL216K {\
117127
.total_size = (1 << 21), /* 2 MiB */ \
118-
.erase_size = (1 << 12), /* 4 KiB */ \
119-
.page_size = 256, /*256 bytes */ \
120128
.start_up_time_us = 10000, \
121129
.manufacturer_id = 0x01, \
122130
.memory_type = 0x40, \
123131
.capacity = 0x15, \
124-
.max_clock_speed_mhz = 104, \
132+
.max_clock_speed_mhz = 65, \
125133
.has_sector_protection = false, \
126-
.supports_qspi = true, \
134+
.supports_fast_read = true, \
135+
.supports_qspi = false, \
136+
.has_quad_enable = false, \
127137
.supports_qspi_writes = false, \
128138
}
129139

130140
// Settings for the Winbond W25Q16FW 2MiB SPI flash.
131141
// Datasheet: https://www.winbond.com/resource-files/w25q16fw%20revj%2005182017%20sfdp.pdf
132-
133142
#define W25Q16FW {\
134143
.total_size = (1 << 21), /* 2 MiB */ \
135-
.erase_size = (1 << 12), /* 4 KiB */ \
136-
.page_size = 256, /*256 bytes */ \
137144
.start_up_time_us = 5000, \
138145
.manufacturer_id = 0xef, \
139146
.memory_type = 0x60, \
140147
.capacity = 0x15, \
141-
.max_clock_speed_mhz = 104, \
148+
.max_clock_speed_mhz = 133, \
142149
.has_sector_protection = false, \
150+
.supports_fast_read = true, \
143151
.supports_qspi = true, \
144-
.supports_qspi_writes = false, \
152+
.has_quad_enable = true, \
153+
.supports_qspi_writes = true, \
154+
}
155+
156+
// Settings for the Winbond W25Q16JV 2MiB SPI flash.
157+
// Datasheet: https://www.winbond.com/resource-files/w25q16jv%20spi%20revf%2005092017.pdf
158+
#define W25Q16JV {\
159+
.total_size = (1 << 21), /* 2 MiB */ \
160+
.start_up_time_us = 5000, \
161+
.manufacturer_id = 0xef, \
162+
.memory_type = 0x40, \
163+
.capacity = 0x15, \
164+
.max_clock_speed_mhz = 133, \
165+
.has_sector_protection = false, \
166+
.supports_fast_read = true, \
167+
.supports_qspi = true, \
168+
.has_quad_enable = true, \
169+
.supports_qspi_writes = true, \
145170
}
146171

147172
// Settings for the Winbond W25Q32BV 2MiB SPI flash.
148173
// Datasheet: https://www.winbond.com/resource-files/w25q32bv_revi_100413_wo_automotive.pdf
149-
150174
#define W25Q32BV {\
151-
.total_size = (1 << 21), /* 2 MiB */ \
152-
.erase_size = (1 << 12), /* 4 KiB */ \
153-
.page_size = 256, /*256 bytes */ \
154-
.start_up_time_us = 5000, \
175+
.total_size = (1 << 22), /* 4 MiB */ \
176+
.start_up_time_us = 10000, \
155177
.manufacturer_id = 0xef, \
156178
.memory_type = 0x60, \
157179
.capacity = 0x16, \
158180
.max_clock_speed_mhz = 104, \
159181
.has_sector_protection = false, \
182+
.supports_fast_read = true, \
160183
.supports_qspi = true, \
184+
.has_quad_enable = true, \
161185
.supports_qspi_writes = false, \
162186
}
163187

164188
// Settings for the Winbond W25Q80DL 1MiB SPI flash.
165189
// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf
166190
#define W25Q80DL {\
167191
.total_size = (1 << 20), /* 1 MiB */ \
168-
.erase_size = (1 << 12), /* 4 KiB */ \
169-
.page_size = 256, /*256 bytes */ \
170192
.start_up_time_us = 5000, \
171193
.manufacturer_id = 0xef, \
172194
.memory_type = 0x60, \
173195
.capacity = 0x14, \
174196
.max_clock_speed_mhz = 104, \
175197
.has_sector_protection = false, \
198+
.supports_fast_read = true, \
176199
.supports_qspi = true, \
200+
.has_quad_enable = true, \
177201
.supports_qspi_writes = false, \
178202
}
179203

0 commit comments

Comments
 (0)