I found the problem. In the NIOS configuration, I was using the "reduced device drivers" option. Without this option, I get a non-null file descriptor.
Although I made the inclusion presented in the embedded ip user guide to force including the api's for flash controller, it still doesn't work with "reduced device drivers".
At this moment I'm using the following inclusions:
# define ALT_USE_EPCS_FLASH
# include <stdio.h># include <io.h># include "system.h"# include "sys/alt_irq.h"# include "sys/alt_flash.h"# include "sys/alt_flash_dev.h"# include <altera_avalon_epcs_flash_controller.h># include "define.h"
Now, disabling the "reduced device driver" option, I could do more tests for my project. I intend to remotely configure some parameters of the device, so the configuration data stored in the flash will change from time to time, without changes to the FPGA sw and hw (only one page of the flash will change). But, after a change is made and I want to reboot the device (power off/on) the FPGA won't configure itself. I presume this has something to do with the check-sum that the flash programmer calculates and writes on the end of flash.
Is there a possibility to use the same flash for firmware and exchangeable configuration data ?