adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
MIT License
3.97k stars 1.16k forks source link

SPI Flash Issue - MX25R1635F CIRCUITPY drive not showing #3548

Closed StackRduino closed 3 years ago

StackRduino commented 3 years ago

Hello There!

I am trying to make a custom board for CircuitPython my design is based around the feather M0 (Pin configurations). i have done with the hardware testing and everything is working as it should be. except for the SPI flash (which uses the same pins as ITSYBITSY M0 Express.

I have tested the board using no SPI flash configuration and the CIRCUITPY device shows up on my win 10 and Mac, but when configuration the CircuitPython firmware to use external flash the drive won't show up on mac nor windows 10, but the serial communication through putty is working fine and i can control the onboard D13 led as well as new pixel via putty.

The SPI Chip I used is supported in your supervisor/shared/external_flash/devices.h file Please help as I am very frustrated

I have attached the 4 files i used to create the CircuitPython firmware stackrduino.zip

Thanks

Putty welcome screen:- Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Press any key to enter the REPL. Use CTRL-D to reload. Adafruit CircuitPython 6.0.0-beta.2-58-g40a3d11d6 on 2020-10-12; StackRduino M0 with samd21g18

StackRduino commented 3 years ago

one more thing... Using the example flash_info from Adafruit_SPIFlash give this results in the serial monitor

Unknown flash device 0xC22815 (i have googled and found out that this is the correct value for my SPI flash) Adafruit Serial Flash Info example JEDEC ID: FFFFFF Flash size: 0

tannewt commented 3 years ago

Unfortunately, it doesn't look like that flash is actually used by any boards. It's hard to say it will work if it isn't used.

It should be usable with a corrected config. I find the best way to debug new flash is by sniffing the SPI lines with a logic analyzer and/or setting a breakpoint, via a debugger, here: https://github.com/adafruit/circuitpython/blob/main/supervisor/shared/external_flash/external_flash.c#L224

StackRduino commented 3 years ago

Thank you for your response, i guess am gonna have to replace the spi flash with W25Q16JV-IQ, is it supported? its my only option as for debugging i am not sure i can do it without your help!

tannewt commented 3 years ago

It is used on a number of non-Adafruit boards so it may work better. Since you are creating your own board, I suggest you learn to debug this issue. Feel free to ask for help in the #circuitpython channel on the Adafruit Discord https://adafru.it/discord.

$ ag -Q W25Q16JV_IQ
supervisor/shared/external_flash/devices.h
282:#define W25Q16JV_IQ {\

ports/nrf/boards/hiibot_bluefi/mpconfigboard.mk
10:EXTERNAL_FLASH_DEVICES = "W25Q16JV_IQ"

ports/nrf/boards/hiibot_bluefi/pins.c
117:    // P28~P33/D28~D33 connecte into QSPI FlashROM (W25Q16JV_IQ)

ports/stm/boards/meowbit_v121/mpconfigboard.mk
8:EXTERNAL_FLASH_DEVICES = W25Q16JV_IQ

ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk
11:EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JV_IQ"

ports/atmel-samd/boards/snekboard/mpconfigboard.mk
11:EXTERNAL_FLASH_DEVICES = "W25Q16JV_IQ"

ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk
11:EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JV_IQ, W25Q16JV_IM"

ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk
11:EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM, W25Q16JV_IQ"
bd34n commented 3 years ago

According to the data sheet for the MX25R1635F, the JDEC should be 0xc2, 0x28, 0x15. In the devices.h file, the capacity parameter is specified as 0x18 for that chip. So I think the value may be incorrect in devices.h - thus it is not being recoginized.

Updating the entry to:

/ Settings for the Macronix MX25R1635F 8MiB SPI flash. // Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7595/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf // In low power mode, quad operations can only run at 8 MHz.

define MX25R1635F {\

.total_size = (1 << 21), /* 2 MiB */ \
.start_up_time_us = 800, \
.manufacturer_id = 0xc2, \
.memory_type = 0x28, \

Should make it work. Note - I don’t have anything with that chip on it so I can’t test. I recommend making the update to your local repo, rebuild, and give it a try.

-Brian

— Brian Dean bsd@bdmicro.com BDMICRO, LLC https://www.bdmicro.com

On Oct 13, 2020, at 10:19 AM, hanyelkomy notifications@github.com wrote:

one more thing... Using the example flash_info from Adafruit_SPIFlash give this results in the serial monitor

Unknown flash device 0xC22815 (i have googled and found out that this is the correct value for my SPI flash) Adafruit Serial Flash Info example JEDEC ID: FFFFFF Flash size: 0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/circuitpython/issues/3548#issuecomment-707771317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMIB3E3MKZ34O777ADAMTCTSKROYJANCNFSM4SO6LTZA.

StackRduino commented 3 years ago

According to the data sheet for the MX25R1635F, the JDEC should be 0xc2, 0x28, 0x15. In the devices.h file, the capacity parameter is specified as 0x18 for that chip. So I think the value may be incorrect in devices.h - thus it is not being recoginized. Updating the entry to: / Settings for the Macronix MX25R1635F 8MiB SPI flash. // Datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/7595/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf // In low power mode, quad operations can only run at 8 MHz. #define MX25R1635F {\ .total_size = (1 << 21), / 2 MiB / \ .start_up_time_us = 800, \ .manufacturer_id = 0xc2, \ .memory_type = 0x28, \ - .capacity = 0x18, \ + .capacity = 0x15, \ .max_clock_speed_mhz = 33, / 8 mhz for dual/quad / \ .quad_enable_bit_mask = 0x80, \ .has_sector_protection = false, \ .supports_fast_read = true, \ .supports_qspi = true, \ .supports_qspi_writes = true, \ .write_status_register_split = false, \ .single_status_byte = true, \ } Should make it work. Note - I don’t have anything with that chip on it so I can’t test. I recommend making the update to your local repo, rebuild, and give it a try. -Brian — Brian Dean bsd@bdmicro.com BDMICRO, LLC https://www.bdmicro.com On Oct 13, 2020, at 10:19 AM, hanyelkomy @.***> wrote: one more thing... Using the example flash_info from Adafruit_SPIFlash give this results in the serial monitor Unknown flash device 0xC22815 (i have googled and found out that this is the correct value for my SPI flash) Adafruit Serial Flash Info example JEDEC ID: FFFFFF Flash size: 0 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#3548 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMIB3E3MKZ34O777ADAMTCTSKROYJANCNFSM4SO6LTZA.

Thank you very much, it works now..:)