alt_flash_write() is quite different from the Nios II Flash Programmer. The fact that the programmer works means that your flash _can_ function with a Nios II processor, but it doesn't necessarily mean that the HAL driver/API will work perfectly...or at all.
It could be that your flash requires more "work" to work. Not sure about the error code either, but it might not be something that's defined in the driver itself. It might be more about what the flash device, itself, is returning.
Welcome to the wonderful world of the CFI standard :-)
Cheers and Good Luck!
-- slacker