-
AuthorPosts
-
February 13, 2022 at 8:37 AM #16455jhrgParticipant
When I run some simple diagnostics on the flash chip, I get a reported size of 1MB, not 2MB as I was expecting. The tests are taken from the RawHardwareTest of the PaulStoffregen SerialFlash library. Here’s the output:
JEDEC ID: F7 20 A
Memory Size: 1048576 bytes
Block Size: 65536 bytesIs this expected or should I see 2MB?
Thanks,
JamesHardware: Mini Ultra Pro 2
Code:
uint32_t space_on_flash()
{
uint8_t buf[256];// Read the chip identification
Serial.println();
Serial.println(F(“Read Chip Identification:”));
SerialFlash.readID(buf);
Serial.print(F(” JEDEC ID: “));
Serial.print(buf[0], HEX);
Serial.print(‘ ‘);
Serial.print(buf[1], HEX);
Serial.print(‘ ‘);
Serial.println(buf[2], HEX);
#if 0
Serial.print(F(” Part Number: “));
Serial.println(id2chip(buf));
#endif
Serial.print(F(” Memory Size: “));
uint32_t chipsize = SerialFlash.capacity(buf);
Serial.print(chipsize);
Serial.println(F(” bytes”));
if (chipsize == 0) return 0;Serial.print(F(” Block Size: “));
uint32_t blocksize = SerialFlash.blockSize();
Serial.print(blocksize);
Serial.println(F(” bytes”));return chipsize;
}Which is called from within:
void setup()
{
pinMode(STATUS_LED, OUTPUT);
digitalWrite(STATUS_LED, HIGH);
pinMode(LORA_CS, OUTPUT);
digitalWrite(LORA_CS, HIGH);Serial.begin(BAUD);
// Wait for serial port to be available
while(!Serial);Serial.println(“Start Flash Write Tester”);
bool status = SerialFlash.begin(FLASH_CS);
if (!status) {
Serial.print(“Flash memory initialization error, error code: “);
Serial.println();
stop();
}Serial.print(“Space on the flash chip: “);
uint32_t capacity = space_on_flash();
Serial.println(capacity);
}February 13, 2022 at 11:21 AM #16456LIM PHANG MOHKeymasterHi,
I do run the raw hardware test for every board and it all must return 2 MB (16 Mbit) to pass.
If you are not running the latest SAMD Arduino package, you might into this issue.February 15, 2022 at 2:15 AM #16460jhrgParticipantI’ll check when I’m at that machine, but I’m using platformio at it’s latest version, so it may well be the problem. If so, will this limit the memory available or just the reported value of capaity?
February 15, 2022 at 1:51 PM #16461jhrgParticipantYes, I do have version 1.8.11 of the SAMD Arduino Core. I’m not sure how to roll back to 1.8.10 on/with platformio.
February 15, 2022 at 1:52 PM #16462LIM PHANG MOHKeymasterWhat are the markings on the chip?
I’m not that familiar with Platform.io unfortunately.February 17, 2022 at 12:01 PM #16464jhrgParticipantThe chip number/markings are:
Winbond
25Q16JVSIQ
1931Thanks
February 17, 2022 at 12:17 PM #16465LIM PHANG MOHKeymasterIt should be 2Mbyte then. It worth playing with the SPI bus speed. I know at 1 point, even the SerialFlash library couldn’t work with the SAMD package. I tested every chip to ensure they are the correct size even though these are bought directly from Winbond Semiconductor.
February 18, 2022 at 10:33 AM #16466jhrgParticipantSo I did various things and found two solutions to this problem.
#1 I modified SPI.cc invoid SPIClass::config(SPISettings settings)
so it used the behavior from version 1.8.10 of the Arduino core code. That worked, but it’s an ugly hack. Specifically I changed_p_sercom->initSPIClock(getDataMode(settings), clock_freq);
to_p_sercom->initSPIClock(getDataMode(settings), settings.getClockFreq());
#2 I modified my code (after backing #1 out of SPI.cc) so that I callSPI.setClockDivider(SPI_CLOCK_DIV64);
afterbool status = SerialFlash.begin(SPI, FLASH_CS);
Since #2 works, I’ll go with that.
NB: I tried other values forSPI_CLOCK_DIV64
and down toSPI_CLOCK_DIV2
they fixed the problem. I went with the slower speed because my needs are pretty paltry – 13 bytes/hour.Can anyone point me toward a good resource on the Arduino SPI bus code. I’m also using LoRa and SdFat and it seems the SPI bus is a source of (ahem) contention.
Thanks.
June 20, 2022 at 3:16 PM #16531andrew.cunninghamParticipantI’m running a pretty old core (1.6.21) but can confirm I can use the full flash chip with both v2 and v3 boards. I’m also using a fairly heavily modified version of Paul’s code, incorporating things like 4k erase, timeouts, write boundary searches etc. I could share it if you like but I haven’t been great on the doc front.
Regarding the ‘sharing the SPI bus’ issue, if using the radioHead lib make sure the radio is idle or asleep when using other peripherals. The radio also has a habit of slipping out of ‘LoRa’ mode on occasion too. I’ve fixed that in a modified version of the radioHead libs. Again, if you’re interested I can share that too.
-
AuthorPosts
- You must be logged in to reply to this topic.