It is not so simple how you write or i have some error on my design or program. I have design, where i have altremote_update0 megafunction connect to NIOS2/f to LED_BASE led[15] to reconfig pin and led[14] to reset pin and i have this part of program:
-----------------------------------
printf("Restart altremote_update.\n");
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x4000);
usleep(10000);
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x0);
// open flash
printf("Oteviram flash EPROM.\n");
fd = alt_flash_open_dev("/dev/epcs_flash_controller_0");
if (fd!=NULL)
{
printf("Info flash EPROM.\n");
ret_code = alt_get_flash_info(fd, ®ions, &number_of_regions);
if (!ret_code)
{
printf("Flash EPROM obsahuje %d sektoru.\n", regions->number_of_blocks);
for(n=0;n<regions->number_of_blocks;n++)
{ printf("Erase %d.sector.\n",n);
if (fd!=NULL) alt_erase_flash_block(fd, n*65536, 65536);
}
printf("Wait on data in UART.\n");
}
}
init_uarts();
// main cycle
while (1)
{
// write uarts data to flash eprom
if (rx_lan_flag1==1)
{ alt_printf("%x ",blok_cnt);
// reverzuj bity
ReverseBitsInBytes(data_written, 256);
// write block
if (fd!=NULL) ret_code = alt_write_flash_block(fd, 0, blok_cnt*256, data_written, 256);
rx_lan1=0;
rx_lan_flag1=0;
blok_cnt++;
}
// read data
if (blok_cnt==16*256)
{ printf("Reading flash EPROM.\n");
for(m=0;m<blok_cnt;m++)
{ ret_code = alt_read_flash(fd, m*256, data_read, 256);
// reverzuj bity
ReverseBitsInBytes(data_read, 256);
// list only 16 bytes from 256-bytes block
printf("%04X:",m);
for(n=0;n<16;n++)
{ printf("%02X",data_read[n]);
}
printf("\n");
}
printf("Close flash EPROM.\n");
alt_flash_close_dev(fd);
blok_cnt=0;
printf("Perform reconfiguration - write 1 to config.pin.\n");
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x8000);
usleep(10000);
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x0);
}
------------------------------
Everything is ok, but reconfiguration does not start after
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x8000);
usleep(10000);
IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE,0x0);
When i turn off and turn on power supply of the board, it takes the bitstream which i programed to flash and it work well.
Is possible to set some registers on altremote megafunction or something else ?
Clock for NIOS is 120MHz and for altremote megafunction 20MHz. In NIOS is not any timer ...
Thank you for your answer.
Jan