Forum Discussion

Jacob11's avatar
Jacob11
Icon for Occasional Contributor rankOccasional Contributor
3 years ago
Solved

Max10 programming external flash

Hello guys. I am trying to figure out how to write to an external flash. Micron mt25QL02 is what is on the board. I don't want to use Nios, or the flash memory programming tool. I am trying to use...
  • Jacob11's avatar
    3 years ago

    After much trial and error, I have it working. Now I can write to and read from/erase the memory. Basically, I found and error in the Intel example design. Once I corrected it, everything works.

    For anyone else who might try it using Nios.

    First you have to do a write enable like this:

    IOWR(EXT_FLASH_AVL_CSR_BASE,0x7,0x00000006);
    IOWR(EXT_FLASH_AVL_CSR_BASE,0x8,0x1);

    then you can write 0xabcd1234 into the memory like this(this is where the example design had mistakes):
    IOWR(EXT_FLASH_AVL_MEM_BASE,0x00000000,0xabcd1234);

    Then to read it back, do it like this:

    IOWR(EXT_FLASH_AVL_CSR_BASE,0x4,0x00000000);
    IOWR(EXT_FLASH_AVL_CSR_BASE,0x0,0x00000101);
    IOWR(EXT_FLASH_AVL_CSR_BASE,0x5,0x00000003);
    return IORD(EXT_FLASH_AVL_MEM_BASE,0x00000000);

    The most confusing parts are these offsets 0x4, 0x5....etc. I have figured out what most of them are, so I will list them below:

    0x0 control register

    0x4 operating protocols

    0x5 read instructions

    0x6 write instructions

    0x7 flash command setting

    0x8 flash command control(basically always write 0x1 here when writing into the status registers to begin the operation)

    0x9 flash command address register

    0xA flash command write data

    0xC flash command read data

    Why this isnt included in any documentation I have no idea. Basically, once I understood what these offsets were doing I had it up and running in just a few minutes. Hopefully these short notes help the next person.