Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

How to use an EPCS Flash

Hallo together,

I'm actually trying to save data from NIOS II into an EPCS64 device. My system contains an EPCS controller. But now the confusion is complete, there are so many files for using an flash... and I'm not sure which to use. There are:

- altera_avalon_epcs_flash_controller.h

- sys\alt_flash.h

- epcs_commands.h

And all these headers include different read/write functions.

Then I tried an example from the Internet to start.


static alt_flash_fd* epcs16_dev_ptr;
static flash_region *p_epcs_reg_info;
static int num_epcs_regs;
void epcs_open(void)
{
    epcs16_dev_ptr = alt_flash_open_dev(EPCS_FLASH_CONTROLLER_NAME);                         
    if (epcs16_dev_ptr == NULL)
    {
        alt_printf("** Can't open flash device **\n\n");
        return;
    }
    alt_epcs_flash_get_info(epcs16_dev_ptr, &p_epcs_reg_info, &num_epcs_regs);               
    return;
}

But to open the EPCS flash always fails. Is there something else to configure in the EPCS controller before start?

Which header and functions are the right?

Greets

Sim

47 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    id=0xff is definitely an error, since this means the data rx line is stuck to high level, namely the undriven state or, equivalent, the epcs_controller rx register contains invalid data.

    Then read and write operations will probably not work.

    --- Quote End ---

    I agree with you...

    --- Quote Start ---

    "small driver" feature has been selected, or if fast simulation has been requested

    --- Quote End ---

    Sim already posted that small driver are selected but he enabled ALT_USE_EPCS_FLASH; from an image he posted yesterday correct epcs init function is enabled.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hallo,

    I know about the fact that small driver will exclude the flash drivers. But like paolobbi said, I thought that# define ALT_USE_EPCS_FLASH will solve that problem. This is described in the embedded software development user guide in that way.

    Or had I misunderstood this??

    Ok, 0xFF is an error. This brings me to the beginning of this thread :(. Any ideas how to find the problem?

    Greets Sim
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    As I said in one of yesterday's posts M25PE16 and EPCS commands are faily compatible but the read indentification commands are different

    Since you are not willing to look at the datasheet (at least in order to know what the expected id should be), I'll explain here.

    EPCS use the command code 0xAB to read the silicon id (e.g. 0x14 for EPCS16)

    while on M25PE16 the same code is used for the release from power down command.

    Then, the hal driver function will get no id but only invalid data; actually they are all 1s, since the RDP command is not supposed to send any answer.

    The read-id command code for M25PE16 is instead 0x9F

    In conclusion, I guess I have to correct my previous statement: you can't get the silicon id but you probably will be able to read/write the flash device, since all other relevant commands are pretty compatible.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    EPCS use the command code 0xAB to read the silicon id (e.g. 0x14 for EPCS16)

    while on M25PE16 the same code is used for the release from power down command.

    --- Quote End ---

    Probably you would be right, but from a Micron datasheet of M25P16, the "READ ELECTRONIC SIGNATURE and

    RELEASE from DEEP POWER-DOWN" command is exactly the one that epcs_read_electronic_signature function within original HAL driver use (i.e. res_cmd[] = {epcs_res, 0, 0, 0})

    --- Quote Start ---

    The read-id command code for M25PE16 is instead 0x9F

    --- Quote End ---

    Exactly... that (epcs_read_device_id) is in fact the command issued by original EPCS HAL driver if previous epcs_read_electronic_signature command (ABh) fails answering something not foreseen.

    I think (again) that debugging you should be able to retrieve the answer to both command. If the second command is issued because the answer to first one is FFh, you will have to possibilities: 1) if the answer is still FFh you have to check you signal

    2) if the answer is not FFh, you have to modify your HAL driver adding the support of M25PE64 because the original HAL driver only support EPCS128 (18h) as possible answer to epcs_read_device_id command.

    Ciao
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    As I said in one of yesterday's posts M25PE16 and EPCS commands are faily compatible but the read indentification commands are different

    Since you are not willing to look at the datasheet (at least in order to know what the expected id should be), I'll explain here.

    EPCS use the command code 0xAB to read the silicon id (e.g. 0x14 for EPCS16)

    while on M25PE16 the same code is used for the release from power down command.

    Then, the hal driver function will get no id but only invalid data; actually they are all 1s, since the RDP command is not supposed to send any answer.

    The read-id command code for M25PE16 is instead 0x9F

    In conclusion, I guess I have to correct my previous statement: you can't get the silicon id but you probably will be able to read/write the flash device, since all other relevant commands are pretty compatible.

    --- Quote End ---

    Ok, I'm sorry if you are right. I maybe overlooked this in your last post. But I will investigate in this way the next days. If I have any news I will give a report here.

    Thanks!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hallo,

    I'm already working on this problem. I could not get any data out of this flash. I recently tried to access the flash over a simple spi after booting.

    So I multiplexed the signals. I boot over EPCS controller and the the NIOS switches the the signal to a spi.

    Then I try to send an RDID command over the spi interface.

    With the oscilloscope I see, that the clock is right. Also the CSn and the Data signal seems to be right. But the Flash never answers...

    I tried the same withe a READ command -> no answer!

    Has anybody an idea about this behavior?

    Greets

    Sim
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok, I couldn't really explain, but I recompiled the whole design, loaded it and it works!

    Maybe there was some strange behavior anywhere...

    Thanks to all!

    Greets

    Sim