Skip to content

Commit 2af166a

Browse files
tyethpeterharperuk
authored andcommitted
Update nuke.c to auto-detect flash size
Fixes #642 Thanks to @Gadgetoid for the work "Making A Thing" - Support [PiMoRoNi by buying stuff](https://shop.pimoroni.com/)!
1 parent aed0867 commit 2af166a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

flash/nuke/nuke.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
int main() {
2929
uint flash_size_bytes;
30-
#ifndef PICO_FLASH_SIZE_BYTES
31-
#warning PICO_FLASH_SIZE_BYTES not set, assuming 16M
32-
flash_size_bytes = 16 * 1024 * 1024;
33-
#else
34-
flash_size_bytes = PICO_FLASH_SIZE_BYTES;
35-
#endif
30+
uint8_t txbuf[4];
31+
uint8_t rxbuf[4];
32+
txbuf[0] = 0x9f;
33+
flash_do_cmd(txbuf, rxbuf, 4);
34+
flash_size_bytes = 1u << rxbuf[3];
3635
flash_range_erase(0, flash_size_bytes);
3736
// Leave an eyecatcher pattern in the first page of flash so picotool can
3837
// more easily check the size:

0 commit comments

Comments
 (0)