Forum Discussion
Altera_Forum
Honored Contributor
15 years agoI did it by including the remote-update component in my main design and using it in my reset function to trigger the reconfiguration from the beginning of the EPCS where my factory image lies.
g_EncoderBox.CycloneIII_Reconfig(REMOTE_UPDATE_CYCLONEIII_0_BASE, // Remote Update Controller Base
EPCS0_BASE, // Flash Base
0x00000000, // offset in Flash where the factory image is
0, // Watchdog Timout
8);
CycloneIII_Reconfig(int remote_update_base, int flash_base, int reconfig_offset, int watchdog_timeout, int width_of_flash )
{
//close and umount sdcard
printf("closing log\r\n");
g_SDCard.closeLog();
int offset_shift;
// Obtain upper 12 bits of 29-bit watchdog timeout value
watchdog_timeout = watchdog_timeout >> 17;
// Only enable the watchdog timer if its timeout value is greater than 0.
if( watchdog_timeout > 0 )
{
// Set the watchdog timeout value
IOWR( remote_update_base, 0x2, watchdog_timeout );
}
else
{
// Disable the watchdog timer
IOWR( remote_update_base, 0x3, 0 );
}
// Calculate how much to shift the reconfig offset location:
// width_of_flash == 8->offset_shift = 2.
// width_of_flash == 16->offset_shift = 3
offset_shift = (( width_of_flash / 8 ) + 1 );
// Write the offset of the desired reconfiguration image in flash
IOWR( remote_update_base, 0x4, reconfig_offset >> offset_shift );
// Perform the reconfiguration by setting bit 0 in the
// control/status register
printf("Get ready for some cool magic!\r\n");
printf("Wait for it...........\r\n");
usleep(100000);
printf("3\r\n");
usleep(100000);
printf("2\r\n");
usleep(100000);
printf("1\r\n");
IOWR( remote_update_base, 0x20, 0x1 );
return( 0 );
-mitch