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
I use the main.c in attachment. Very simple.
Is there any point I miss?? Disabling the reduced driver option has no effect. Greets - Altera_Forum
Honored Contributor
Did you try placing the breakpoint within alt_sys_init()?
- Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
I suppose that at least it breaks at all other timer init... Anyway you can place also a breakpoint at jtag uart init and see if it stops also there.
Just a hint: I see a watchdog, did you disabled it when you debug your device? Because if for example you reset your device if it not refreshed correctly, probably your debugging is fake. Anyway initialization of device is required. As a last option, you could call ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE and ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INIT within your main()... :cry: Ciao - Altera_Forum
Honored Contributor
Now I set also breakpoints in function static int alt_epcs_flash_query(alt_flash_epcs_dev* flash)... But it never reaches one of them.
Any ideas?? - Altera_Forum
Honored Contributor
--- Quote Start --- I suppose that at least it breaks at all other timer init... Anyway you can place also a breakpoint at jtag uart init and see if it stops also there. Just a hint: I see a watchdog, did you disabled it when you debug your device? Because if for example you reset your device if it not refreshed correctly, probably your debugging is fake. Anyway initialization of device is required. As a last option, you could call ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE and ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INIT within your main()... :cry: Ciao --- Quote End --- Yes I disabled it. I did so, an you see the result in attachment... it stops, but not at the bp. Strange!? What is ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE? I've never read it. - 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(). - 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
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 :)