Forum Discussion

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

Help:Cann't read or write EPCS in Nios II,why?

my system includes Flash,EPCS,etc,and has a EPCS controller.i want to read and write the EPCS in the nios.i tried to open the device using "alt_flash_open_dev()",but it's alway wrong--"can not open the device".so i used IORD()/IOWR(),and found Flash could be read/writen correctly,but EPCS couldn't be read/writen.Why?is anybody help me?

7 Replies

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

    i can't even do that can you help me with that. when i measure with the scope on the ports there is no activity on any port

    //*****************

    while(1)

    {

    IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(EPCS_FLASH_CONTROLLER_0_BASE, 1 << 0);

    IOWR_ALTERA_AVALON_SPI_TXDATA(EPCS_FLASH_CONTROLLER_0_BASE, 0xAA);

    IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(EPCS_FLASH_CONTROLLER_0_BASE, 0 << 0);

    }

    //*******************

    I think that your problem is that you need to NOT, enable the small device drivers in the system library.

    i have the same problem and from the reading i figured that is the problem. I'm a newbe so i might be wrong.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    WDB is correct that enabling "small device drivers" for your system library will essentially disable the EPCS controller and it will fail to open. You can however still use the "small device drivers" option if you add the following macro to your system library build:

    "-DALT_USE_EPCS_FLASH"

    To understand why, simply look at the file:

    C:\altera\81\ip\altera\sopc_builder_ip\altera_avalon_epcs_flash_controller\HAL\inc\altera_avalon_epcs_flash_controller.h

    You'll see the line:

    # if (!defined(ALT_USE_SMALL_DRIVERS) && !defined(ALT_SIM_OPTIMIZE)) || defined ALT_USE_EPCS_FLASH

    Good luck,

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

    Simply add it to the compiler options for your system library or BSP.

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

    1 - In the NIOS II IDE right click on your system library project.

    2 - On the left hand side of the window that pops up, click on "C/C++ Build".

    3 - Click on the "Tool Settings" tab.

    4 - Click on the Preprocessor section of the NIOS II Compiler.

    5 - Add the "ALT_USE_EPCS_FLASH" to the list of defined symbols.

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

    --- Quote Start ---

    1 - In the NIOS II IDE right click on your system library project.

    2 - On the left hand side of the window that pops up, click on "C/C++ Build".

    3 - Click on the "Tool Settings" tab.

    4 - Click on the Preprocessor section of the NIOS II Compiler.

    5 - Add the "ALT_USE_EPCS_FLASH" to the list of defined symbols.

    Jake

    --- Quote End ---

    Hi Jake,

    I am using Nios 12.SP2 web edition. But I can't find "tool setting" in this version. Do you have any idea?

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

    Hi,

    I have the same problem, when i try to open the device using "alt_flash_open_dev()". I use hello_world_small model, because i have only 48kB on chip memory. Is possible to use this model for alt_flash functions ?

    I am not able to find "tool setting" too, and i have NIOS 13.1.

    Any idea ?

    Jan