Closed wallarug closed 5 years ago
Page 23 of the datasheet for that chip says that the 0x9F
(9FH
) Read JEDEC ID command responds with0xBF
, 0x26
, and then 0x41
. Datasheets for other chips say that the third byte describes the capacity. The datasheet does not say anywhere that the chip responds with 0x15
for anything, which is what you set the capacity to. So try this:
.capacity = 0x41, \
There may be other issues, but that's what I see at first glance.
Thanks @dhalbert . I'll give it a go tomorrow (It's very late down in Oz right now) and report back.
No luck there. Is there any other reason that CircuitPython would work perfectly over serial but not show the USB Drive?
If it's not able to talk the SPI flash chip, then there'll be no CIRCUITPY. So I think there is still debugging to do there. You'll probably need to set some breakpoints and single step to see if it's working. And you can add print statements (since the serial is working).
@wallarug What do you mean by works perfectly? Are you doing file system manipulations from the REPL? They usually fail as well as the mass storage.
Hi @tannewt ,
When I say "working perfectly" it is probably an overstatement.
I can connect to CircuitPython using Putty (on WIndows) over the Serial COM port and make the LED on the board flash. File manipulations fail. I tried running the filesystem_erase and it said "incorrect pins".
REPL does not work since it relays on the USB drive appearing.
I am doing some more testing today to see if this chip can work or not.
Ok, sounds like the issue is the flash chip initialization. One of the first steps is to make sure your chip's id is being recognized here: https://github.com/adafruit/circuitpython/blob/master/supervisor/shared/external_flash/external_flash.c#L194
I use a debugger to read the values that we're read and to make them match.
A logic analyzer can be helpful too to see how far the flash code gets.
Hey @tannewt ,
Thank you for your helpful insight.
Please excuse my inexperience here: If the flash is mounted to the board and attached to the M0 chip, how can I read those JEDEC values? Is there a way that I can get the code you linked (which I believe is run on the M0) to output some information somewhere without needing any special equipment? -- I'm thinking quick and dirty print statements or something onto the M0 console (stdout).
At the moment I only really have access to the serial com port. Happy to burn whatever bootloader is needed and recompile the firmware.
I just need to be pointed in the right direction and then I can find my way :smile:
I usually use gdb. You should be able to use it if you can burn bootloaders over SWD. There are general instructions here: https://learn.adafruit.com/debugging-the-samd21-with-gdb
Hi @tannewt ,
I found a way. It's not clean but confirms values in a similar way to that code you linked to.
Line ~60, main.c
// additional for SPI hack
#include "supervisor/spi_flash_api.h"
#include <stdio.h>
Line ~256, main.c
print_safe_mode_message(safe_mode);
serial_write("\n");
serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload."));
/// @wallarug added this very dodgy hack
serial_write("\n");
serial_write_compressed(translate("** Checking SPI Flash Device. **"));
serial_write("\n");
uint8_t jedec_id_response[3] = {0xff, 0xff, 0xff};
while (jedec_id_response[0] == 0xff) {
spi_flash_read_command(0x9f, jedec_id_response, 3);
}
if(jedec_id_response[0] == 0xbf){
serial_write_compressed(translate("id: correct"));
}
if(jedec_id_response[1] == 0x26){
serial_write_compressed(translate("type: correct"));
}
if(jedec_id_response[2] == 0x41){
serial_write_compressed(translate("capacity: correct"));
}
So the chip is reporting the following values as 'correct':
manufacturer_id: 0xbf memory_type: 0x26 capacity: 0x41
I guess now it is just down to working out the other functionality of the flash chip, then it can be known for the future and others.
I shall report back later.
Thank you for all the support.
I did not have any luck changing the settings of the flash chip to get the CIRCUITPY drive to show up.
I tried a number of different configurations based on the datasheet, however, none worked.
#define ST26VF016B {\
.total_size = (1 << 21), /* 2 MiB */ \
.start_up_time_us = 300, \
.manufacturer_id = 0xbf, \
.memory_type = 0x26, \
.capacity = 0x41, \
.max_clock_speed_mhz = 104, \
.quad_enable_bit_mask = 0x00, \
.has_sector_protection = false, \
.supports_fast_read = true, \
.supports_qspi = true, \
.supports_qspi_writes = true, \
.write_status_register_split = false, \
.single_status_byte = true, \
}
I think I might just use a different flash chip.
@wallarug Any update on this?
Hey Scott,
I gave up on this particular flash chip. The manufacturer could not provide the correct timings to make it work with CircuitPython either.
Maybe if I have a lifetime of spare time I could fix it. But for now, this can be closed as a won't fix.
Hi Adafruit Community!
I have been trying to make a custom CircuitPython package for a new board that I have created based around the M0. I am having issues getting the CIRCUITPY USB drive to show up for CircuitPython when attached to a USB port.
COM port is present and working (can log into CircuitPython and use it).
I am using a flash chip that does not appear to be supported by CircuitPython or I am making a mistake somewhere. It is using the SST26VF016B which should be a drop in replacement for the supported S25FL116K 2MiB flash chip.
I can only get the USB drive to show if I use "internal flash". The pre-compiled firmware for Feather M0 Basic works perfectly. The Feather M0 Express does not (even though I used the same SPI pin out as this board).
I have attached the files that I used to customize the CircuitPython install for my board (MM1 HAT).
I do not normally work with such a low level of commands / hardware. I love CircuitPython though!
Any assistance in identifying why the USB drive does not appear would be greatly appreciated!!
Thank you in advance.
Appendix
modified supervisor/shared/external_flash/devices.h
ports/at-samd/
Build by:
boards/mm1_hat/board.c
boards/mm1_hat/mpconfigboard.h
boards/mm1_hat/mpconfigboard.mk
boards/mm1_hat/pins.c