Forum Discussion
Altera_Forum
Honored Contributor
20 years agoUpgrading Nios Software - external flash
Dear all,
I would like to upgrade my NIOS code by RS232. The NIOS runs from external memory. This is my procedure: - I transfer the .elf file to the .flash file by the instruction elf2bin. (bin file for dowloading to the flash) - I have a RS232 GUI from which I can send the bin file to the flash. I have written a procedure which is stored in FPGA internal memory. This procedure receives the bin file from the UART and writes the data to flash. (byte by byte) Now, what is the problem: my problem is that my NIOS stops working from the moment I erase the flash sector in which the original NIOS code is stored. Nevertheless, the procedure that erases this sector is placed internal. And I keep running my code from internal memory untill the new nios bin file is stored in the flash. The nios core is placed from 0x00000. When I declare an instruction to be placed in internal memory. ex following function is placed in internal memory void test (void) { } Will the instruction always be in internal memory or will it be placed in internal memory from the moment this instruction is called? Has someone an idea what the problem is? Has someone experience with how to upgrade a NIOS that is running from external memory. Regards28 Replies
- Altera_Forum
Honored Contributor
Hi Karel,
> So, I still do'nt know why my program stops after erasing the flash. Where is your exception address? In flash? Regards, --Scott - Altera_Forum
Honored Contributor
Hi Scott
My exception stack is also placed in the onchipmemory and has a size of 0x200. Karel - Altera_Forum
Honored Contributor
> My exception stack is also placed in the onchipmemory and has a size of 0x200.
I'm referring to your exception _address_, the address where your core vectors when an exception occurs ... not the stack that's used during exception processing. --Scott - Altera_Forum
Honored Contributor
3 .exceptions 00000328 01000020 00009c00 00009cd4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE - Altera_Forum
Honored Contributor
Info about the sections
Sections: Idx Name Size VMA LMA File off Algn 0 .entry 00000020 00000000 00000000 000000d4 2**5 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .text 0000961c 00000020 00000020 000000f4 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .rodata 000005c4 0000963c 0000963c 00009710 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .exceptions 00000328 01000020 00009c00 00009cd4 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 4 .rwdata 00001cdc 01000348 00009f28 00009ffc 2**2 CONTENTS, ALLOC, LOAD, DATA, SMALL_DATA 5 .bss 0000216c 01002024 01002024 0000c01c 2**2 ALLOC, SMALL_DATA 6 .FLASHCtrl 00000000 0000bc04 0000bc04 0000c01c 2**0 CONTENTS 7 .OnChipMem 00000344 01004190 0000bc04 0000bcd8 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 8 .comment 000007ba 00000000 00000000 0000c01c 2**0 CONTENTS, READONLY 9 .debug_aranges 00000618 00000000 00000000 0000c7d8 2**3 CONTENTS, READONLY, DEBUGGING 10 .debug_pubnames 00000df8 00000000 00000000 0000cdf0 2**0 CONTENTS, READONLY, DEBUGGING 11 .debug_info 0000ef78 00000000 00000000 0000dbe8 2**0 CONTENTS, READONLY, DEBUGGING 12 .debug_abbrev 00002e88 00000000 00000000 0001cb60 2**0 CONTENTS, READONLY, DEBUGGING 13 .debug_line 0000ba73 00000000 00000000 0001f9e8 2**0 CONTENTS, READONLY, DEBUGGING 14 .debug_frame 00000e74 00000000 00000000 0002b45c 2**2 CONTENTS, READONLY, DEBUGGING 15 .debug_str 00000d7c 00000000 00000000 0002c2d0 2**0 CONTENTS, READONLY, DEBUGGING 16 .debug_alt_sim_info 00000010 00000000 00000000 0002d04c 2**2 CONTENTS, READONLY, DEBUGGING 17 .debug_ranges 00000030 00000010 00000010 0002d05c 2**0 CONTENTS, READONLY, DEBUGGING - Altera_Forum
Honored Contributor
> 3 .exceptions 00000328 01000020 00009c00 00009cd4 2**2
> CONTENTS, ALLOC, LOAD, READONLY, CODE Ok, so I'll assume this is in flash memory. Next question: Do you have a system timer and do you disable interrupts when you are programming the flash? --Scott - Altera_Forum
Honored Contributor
I have a system timer
Indeed, I disable interrupts when writting to the flash - Altera_Forum
Honored Contributor
Hi Karol,
where do you declare the variable FlashAd? void UpdateSoftware(void) { alt_irq_context count3; count3 = alt_irq_disable_all(); for(FlashAd = 0x0000000; FlashAd < 0x0140000; FlashAd += 0x0020000) { EraseFlashSector(FlashAd); } ... - Altera_Forum
Honored Contributor
FlashAd is declared external and in on chip memory
- Altera_Forum
Honored Contributor
Hi Karel,
Does the nios hang _after_ EraseFlashSector returns, or within EraseFlashSector? Could you post the the code for EraseFlashSector? --Scott