The type auto-detection of a SPI memory device connected via SPIMCTRL

Does anyone have experience using the ‘spim’ command ?

In my operation, the auto-detection command is failed.

grmon3> spim flash detect
  Got manufacturer ID 0x00 and device ID 0x0000
  Could not find matching device!

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000008
      0xfff00008  Status register                         0x000000c4
      0xfff0000c  Receive register                        0x00000000
      0xfff00010  Transmit register                       0x00000000

In addition, other commands also failed, such as

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001
      0xfff00008  Status register                         0x000000c4
      0xfff0000c  Receive register                        0x00000000
      0xfff00010  Transmit register                       0x00000000

grmon3> spim tx 0x9F
  Core not initialized!

But I can successfully read the device ID value through direct I/O register operations.

grmon3> spim reset
  SPIM memory controller has been reset

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000008
      0xfff00008  Status register                         0x000000c4
      0xfff0000c  Receive register                        0x00000018
      0xfff00010  Transmit register                       0x00000000

grmon3> wmem 0xfff00004 0x1

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001 --> enable Chip select (CSN) and User control (USRC)
      0xfff00008  Status register                         0x000000c4
      0xfff0000c  Receive register                        0x00000018
      0xfff00010  Transmit register                       0x00000000

grmon3> wmem 0xfff00010 0x9F                                         --> issue read ID command (RDID)

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001
      0xfff00008  Status register                         0x000000c5
      0xfff0000c  Receive register                        0x00000000
      0xfff00010  Transmit register                       0x00000000

grmon3> wmem 0xfff00010 0x00                                         --> issue dummy byte

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001
      0xfff00008  Status register                         0x000000c5
      0xfff0000c  Receive register                        0x00000020 --> 1st Byte, Manufacturer Identification
      0xfff00010  Transmit register                       0x00000000

grmon3> wmem 0xfff00010 0x00

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001
      0xfff00008  Status register                         0x000000c5
      0xfff0000c  Receive register                        0x00000020 --> 2nd Byte, Device Identification: Memory Type
      0xfff00010  Transmit register                       0x00000000

grmon3> wmem 0xfff00010 0x00

grmon3> info reg spim0
  SPI Memory Controller
      0xfff00000  Configuration register                  0x02000003
      0xfff00004  Control register                        0x00000001
      0xfff00008  Status register                         0x000000c5
      0xfff0000c  Receive register                        0x00000018 --> 3rd Byte, Device Identification: Memory Capacity
      0xfff00010  Transmit register                       0x00000000

grmon3>

Hello Wei,

That indeed looks strange.
In particular the Core not initialized! message you are getting for the spim tx command, which should only happen if the init bit in the status register was not set when GRMON tries to read the status register just before starting the command. That bit has however been hardwired to a value of ‘1’ in the SPIMCTRL IP for some time now, so this scenario in GRMON should theoretically never happen if everything in the hardware is working as it should.

The reason to why the spim flash detect command doesn’t work is probably because it encounters the same problem when checking the init bit. For the spim flash detect command there is no printout when this problem occurs, instead it just silently fails.

I see that for your info reg spim0 the init bit is set, which is promising. Can you think of any reason to why GRMON might have not read that bit as ‘1’ earlier? E.g., instabilities in the hardware or local modifications to the SPIMCTRL IP?

Best regards,
Axel

Hi Axel, thank you for your response.

I am using the original IP, the init bit is fixed to ‘1’.

514  when STAT_REG_OFF =>
515    v.rrdata(7) := to_ulogic(allow_writes);
516    v.rrdata(6) := to_ulogic(reconf);
517    v.rrdata(2) := '1';
518    v.rrdata(1) := r.reg.stat.busy;
519    v.rrdata(0) := r.reg.stat.done;

The issue seems to lie in GRMON itself.

We have found an issue in GRMON. It will be fixed in the next release. I will try to make one this week or next.

The new version is working, thanks for your work.

grmon3> spim flash detect
  Got manufacturer ID 0xc2 and device ID 0x201a
  Detected device: Macronix MX25L51245G

grmon3> spim flash show
  Current Flash/EEPROM device config:
    Name                              Macronix MX25L51245G
    Page size                         256 bytes
    Number of bytes in address        3
    Allow erase command               Yes
    Can use FAST READ command         Yes
    FAST READ requires dummy byte     Yes
    Area 0 sector count               16384
    Area 0 bytes per sector           4096

  Command set:
    Write Enable                      0x06
    Write Disable                     0x04
    Read status register              0x05
    Write status register             0x01
    Read data bytes                   0x03
    Read data bytes at higher speed   0x0b
    Page program                      0x02
    Sector erase                      0x20
    Bulk/die erase                    0x60
    Bulk/die erase command bytes      0x01

grmon3>