Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHow 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 Sim47 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- Hi, about the clock activity it is correct because at call of dev->open within alter_flash_open_dev there is no access to device because there is not a open function defined for epcs. The ID I'm talking about is the answer to epcs_read_electronic_signature (command# define epcs_res ABh). The ID form my EPCS16 is 0x14, I suppose that yours should be 0x16. I don't that the option "Disable EPCS id check" could create problem. The electronic signature is answered by device and during initializationthe relative read command is the only one command sent by epcs controller and probably is why your device open fails. I would investigate about it! Ciao --- Quote End --- Ok, I saw it in boot-loader. I had to think about... At the moment I tried simply to change the alt_epcs_flash_query() function. I added my device id in an additional if statement... Unfortunately I never reach this statement. Is there anywhere a copy of the file which is used? I changed the file in the bsp folder... but no effect. - Altera_Forum
Honored Contributor
--- Quote Start --- Hi, about the clock activity it is correct because at call of dev->open within alter_flash_open_dev there is no access to device because there is not a open function defined for epcs. The ID I'm talking about is the answer to epcs_read_electronic_signature (command# define epcs_res ABh). The ID form my EPCS16 is 0x14, I suppose that yours should be 0x16. I don't that the option "Disable EPCS id check" could create problem. The electronic signature is answered by device and during initializationthe relative read command is the only one command sent by epcs controller and probably is why your device open fails. I would investigate about it! Ciao --- Quote End --- But if the read command fails, why could NIOS boot? While booting the same read commands are used? Aren't? - Altera_Forum
Honored Contributor
If you peek into Nios bootloader, you'll see it doesn't check epcs silicon id. That's why Nios can boot.
If the missing entry in alt_epcs_flash_query() is the only issue, maybe you could create a variant of the epcs controller with the changes you need. Otherwise you must change the standard hal driver. Anyway, since ecps controller is nothing else than a spi controller, another smart solution would be adding a generic spi and writing your own functions for epcs reading and programming. Clearly you must also multiplex spi/epcs signals, switching from epcs controller to spi after boot has completed. Altera driver have some big limitations you can overcome with this solution. - Altera_Forum
Honored Contributor
Hi,
about the clock activity it is correct because at call of dev->open within alter_flash_open_dev there is no access to device because there is not a open function defined for epcs. The ID I'm talking about is the answer to epcs_read_electronic_signature (command# define epcs_res ABh). The ID form my EPCS16 is 0x14, I suppose that yours should be 0x16. I don't that the option "Disable EPCS id check" could create problem. The electronic signature is answered by device and during initializationthe relative read command is the only one command sent by epcs controller and probably is why your device open fails. I would investigate about it! Ciao - Altera_Forum
Honored Contributor
Ok, I did so.
Command "flash->silicon_id= epcs_read_electronic_signature(flash->register_base);" reads the id 0xd9800717. It is no option in the following if statement. So it runs to the else statement. The command "flash->silicon_id = epcs_read_device_id(flash->register_base);" returns 0xd9800717 again. So the end is "ret_code = -ENODEV; /* No known device found! */" That tells me what? The controller can not init because the device id is unknown. Right? What's to do? Had I to modify the alt_epcs_flash_query() function? But Altera dehorts about this. And the final question I ask my self, why could NIOS boot its software from the flash?? Greets - Altera_Forum
Honored Contributor
--- Quote Start --- Because I can boot from this flash, it should work principally with this device!? Right? I suggest you to firstly debug init of epcs verifying flash->silicon_id is returned as an EPCS64 (16h); then you should check if alt_flash_device_register is correctly performed with a good ret_code. After this 2 easy check start the difficult debugging of alt_flash_open_dev trying to understand if alt_find_dev is successful and then what is performed at dev->open call. I would do in this way... Good luck :) --- Quote End --- Is 16h the id? What's the id for an EPCS16? With the id there could maybe a problem. Because, to boot from Flash I had to check the "Disable EPCS id check" option while converting the programming file. - Altera_Forum
Honored Contributor
Hi,
here an new interesting information, I checked the SCLK and SDI/SDO pins of the flash with the scope. While programming the flash and while booting from it I can see the clock and the data bits. But when I call my_epcs = alt_flash_open_dev(EPCS_FLASH_CONTROLLER_NAME) there is NO activity one each pin. No clock no data. Is there any new idea about this? - Altera_Forum
Honored Contributor
Because I can boot from this flash, it should work principally with this device!? Right?
I suggest you to firstly debug init of epcs verifying flash->silicon_id is returned as an EPCS64 (16h); then you should check if alt_flash_device_register is correctly performed with a good ret_code. After this 2 easy check start the difficult debugging of alt_flash_open_dev trying to understand if alt_find_dev is successful and then what is performed at dev->open call. I would do in this way... Good luck :) - Altera_Forum
Honored Contributor
--- Quote Start --- ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE is a macro that create static structure v --- Quote Start --- ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE is a macro that create static structure var for epcs device. The behaviour you described is quite strange... I can't explain it... It still seems that all init following last TIMER init are empty... Try calling INSTANCE and INIT macro later in main(). --- Quote End --- Ok, I called the macros in main() and now it stops at the breakpoints. Sadly nothing changed. Maybe it is only a problem of presentment of eclipse, because the JTAG-UART for example (and anything elese which comes after EPCS Controller) works well. And this wouldn't be if the init wasn't called. Right? But with the call of the macros in main() I'm now able to debug the init. sequence. I will try that tomorrowar for epcs device. The behaviour you described is quite strange... I can't explain it... It still seems that all init following last TIMER init are empty... Try calling INSTANCE and INIT macro later in main(). --- Quote End --- Ok, I called the macros in main() and now it stops at the breakpoints. Sadly nothing changed. Maybe it is only a problem of presentment of eclipse, because the JTAG-UART for example (and anything elese which comes after EPCS Controller) works well. And this wouldn't be if the init. wasn't called. Right? But with the call of the macros in main() I'm now able to debug the init. sequence. I will try that tomorrow. Are there any other things to think about? Any other ideas why the open command always returns NULL? Because I can boot from this flash, it should work principally with this device!? Right? - Altera_Forum
Honored Contributor
ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE is a macro that create static structure var for epcs device.
The behaviour you described is quite strange... I can't explain it... It still seems that all init following last TIMER init are empty... :confused: Try calling INSTANCE and INIT macro later in main().