Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #16455
    jhrg
    Participant

    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 bytes

    Is this expected or should I see 2MB?

    Thanks,
    James

    Hardware: 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);
    }

    #16456
    LIM PHANG MOH
    Keymaster

    Hi,

    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.

    #16460
    jhrg
    Participant

    I’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?

    #16461
    jhrg
    Participant

    Yes, 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.

    #16462
    LIM PHANG MOH
    Keymaster

    What are the markings on the chip?
    I’m not that familiar with Platform.io unfortunately.

    #16464
    jhrg
    Participant

    The chip number/markings are:
    Winbond
    25Q16JVSIQ
    1931

    Thanks

    #16465
    LIM PHANG MOH
    Keymaster

    It 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.

    #16466
    jhrg
    Participant

    So I did various things and found two solutions to this problem.
    #1 I modified SPI.cc in void 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 call SPI.setClockDivider(SPI_CLOCK_DIV64); after bool status = SerialFlash.begin(SPI, FLASH_CS);

    Since #2 works, I’ll go with that.
    NB: I tried other values for SPI_CLOCK_DIV64 and down to SPI_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.

    #16531
    andrew.cunningham
    Participant

    I’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.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.