You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • I did not add pull up resistors to WP and HOLD but seems to work without it (did not try writing yet).

    Just a followup - I found out that I bought W25Q16JVUXIQ where the last Q means it is permanently in Quad SPI mode after reset and this mode cannot be cleared. However normal SPI commands still work in this mode so it is OK, the only difference is that /WP and /HOLD pins are data pins and its classic functionality is disabled which is actually good for me as those pins are floating (in theory it is even possible to wire them from unpopulated pull up resistor pads to some nrf pins to have quad mode working but it is not worth it)

    So everything should work as floating WP or HOLD would not interfere with writes however I could not make writes work with software SPI! All other SPI commands worked - getting ids , putting in and out of sleep, reading unique 64bit id, reading all 3 status registers, write enable (0x6) (the WE bit in status register is set), even the writing or erase command (0x2, 0x20) would clear the WE bit in status register but the data did not change. Checked various flash protection bits and everything was disabled as it should be by default according to datasheet but still nothing.

    So I built 2MB SPI flash storage area into the firmware by adding

      'NFC': { 'pin_a':'D9', 'pin_b':'D10' },
      'SPIFLASH' : {
                'pin_cs' : 'D19',
                'pin_sck' : 'D12',
                'pin_mosi' : 'D11',
                'pin_miso' : 'D18',
                'size' : 2048*1024, # 2MB
                'memmap_base' : 0x60000000,

    and the espruino code did not work too

    >var f=require("Flash")
    =function () { [native code] }
      { addr: 364544, length: 4096 },
      { addr: 1610612736, length: 2097152 }
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255])
    FW addr 0x00000000 fail
    Status 0
    FW addr 0x00010000 fail
    Status 0
    FW addr 0x00100000 fail
    Status 0
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255])

    So I enabled hardware SPI in the build and tried that

    var sf=SPI1;//new SPI();
    var FCS=D19;FCS.write(1);

    and suddenly everything worked. The very same lines now started to work, I even saw for the first time the busy bit set in status register when erasing

    =new Uint8Array([255, 3, 3, 3])
    =new Uint8Array([255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    =new Uint8Array([255, 0, 0, 0])
    =new Uint8Array([0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8])

    And what is interesting is that since then also the software serial and the builtin espruino flash storage started to work - I could erase again and write different data and it all works now.

    So not sure what really happened. Did not try removing battery yet if it breaks again, will try.


Avatar for fanoush @fanoush started