- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
#include "system.h"# include "string.h"# include "stdio.h"# include "sys/alt_irq.h"# include "unistd.h"# include "alt_types.h"# include "flashtest.h"
int main(void) { unsigned char buf[100]; unsigned short *flash_test_address; int i; int result; int fail_count = 0; flash_test_address = (unsigned short *)EXT_FLASH_BASE; // | // | Erase the flash. Report result. // | printf("(1) erasing flash at 0x%08x\n",flash_test_address); result = nr_flash_erase_sector((unsigned short *)EXT_FLASH_BASE, flash_test_address); printf(" result = %d\n",result); // | // | Fill the buffer with random (but repeatable) values. // | for (i = 0; i < 100; ++i) // buf = rand();buf = i; // test value // | // | Write that stuff to flash... // | printf("(2) writing flash...\n"); result = nr_flash_write_buffer((unsigned short *)EXT_FLASH_BASE, flash_test_address, buf, 100); // api wants number of short words printf(" result = %d\n",result); // | // | Read that stuff back, and report if it matches, or what. // | printf("(3) reading flash.\n"); for (i = 0; i < 100; ++i) { unsigned short a,b; a = buf;
b = flash_test_address; if(a != http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif { printf("verify failure at location 0x%08x (expected 0x%04x, got 0x%04x)\n", &flash_test_address[i], a,http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif ; fail_count++; if(fail_count >= 10) goto no_more_verifying; } } no_more_verifying: } EXT_FLASH_BASE 0x00000000 ONCHIP_RAM_BASE 0x00200000 complile error: Kind Status Priority Description Resource In Folder Location Error /cygdrive/e/EDA/Altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc-lib/nios2-elf/3.3.3/../../../../nios2-elf/bin/ld region onchip_ram is full (flash.elf section .text) flash line 0 Error /cygdrive/e/EDA/Altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc-lib/nios2-elf/3.3.3/../../../../nios2-elf/bin/ld section .rodata [00000020 -> 000005db] overlaps section .exceptions [00000020 -> 00000327] flash line 0 Error /cygdrive/e/EDA/Altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc-lib/nios2-elf/3.3.3/../../../../nios2-elf/bin/ld section .rwdata [000005e0 -> 000020e3] overlaps section .text [00000328 -> 0000e37f] flash line 0 I want to ask why appear the errors? the rountine is no problem,because I have used them in niosI. Thank you!
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
From your memory map I gather you have a 2MB flash. The error messages are saying you don't have room to fit the code into onchip memory though. So my question is how big is your onchip memory? From the warnings it looks like you need more than 64kB of on chip memory. Since this worked on Nios I, I suggest performing optimizations to make it fit (see pages 4-23 to 4-28 of the "Developing Programs using the HAL" doc).
Also that code with a little bit of modification could use the HAL 100% (i.e. full upgrade to Nios II). nr_flash_erase_sector and other function calls starting in "nr_" are legacy SDK calls, and there are HAL equivalents for these.- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
To BadOmen
I have met the same problem.I want to ask if I can use the programme to test flash ?- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I would use the HAL to communicate with the flash device for starters. Or better yet if you want to test flash try the memory test software template in the IDE (it has a flash test).

- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla