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.
Regarding the fact you need to perform those calls in main, please note this remark I found in altera_avalon_epcs_flash_controller.h header file just before
ALTERA_AVALON_EPCS_FLASH_CONTROLLER_INSTANCE/_INIT definitions :
/*
* Macros used by alt_sys_init.c
*
* By default this driver is initialised in alt_sys_init. However if the
* "small driver" feature has been selected, or if fast simulation has been requested
* no initialisation is performed.
*
* This causes the driver to be excluded from the system (unless explicitly
* initialised by the user from main()), and therefore reduces code footprint.
*
*/