Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHi pfab,
My NIOS code is running from external flash memory. What I'm doing is the follow. I first of all receive the whole bin file from RS232. I save this file into an free flash sector. This works fine. So, the following thing I have to do is copy this flash sector to the flash sector my nios core is running from. Therefore I have written a routine that is placed in internal memory by the section habdler: extern void UpdataSoftware(void)__attribute__((section(".OnChipMem"))); void UpdateSoftware(void) { alt_irq_context count3; count3 = alt_irq_disable_all(); for(FlashAd = 0x0000000; FlashAd < 0x0140000; FlashAd += 0x0020000) { EraseFlashSector(FlashAd); } /* HERE MY PROGRAM FAILS. I erase the flash sector 0 (sector from which the nios is running from). The instruction "EraseFlashSector" is also placed in internal memory*/ unsigned int FlAdW; unsigned int FlAdR; unsigned char Byte; for(FlAdW = 0x0000000,FlAdR = 0x0640000;FlAdW < 0x0140000; FlAdR++,FlAdW++) { unsigned char * ReadFlashData = (unsigned char*)(FlAdR); Byte = *ReadFlashData; WriteFlash(Byte,FlAdW); } UART1_T('O'); UART1_T('K'); } Regards Karel