Forum Discussion
Altera_Forum
Honored Contributor
16 years agoOkay well the bootloader you are looking at was designed to allow me to have two FPGA images in FLASH (safe and user) along with two software images (safe and user). Basically whenever the board first powers up, the safe image is loaded. What we want to do is get the user image up and running as fast as possible. However, there is the possibility that the user image is corrupt. If the user image is corrupt, we want to stay in safe mode and load the safe software. This provides enough functionality so the user can download a new user image to the board.
Now remember this is a stratix II so the registers are not the same as a cyclone III. Here is what the status register bits are for stratix II: 0x00 - Normal configuration (first boot). 0x01 - Configuration occured due to a CRC error (we tried to configure and failed). 0x02 - nStatus caused the reconfiguration (I don't remember what this means. I think this is the case when it was programmed via JTAG). 0x04 - Core nCONFIG caused the reconfiguration. This is when we triggered the configuration. In other words, I told the FPGA to reconfigure. 0x08 - nConfig caused the reconfiguration. 0x10 - A watchdog timeout caused the reconfiguration. In addition the the status register bits, the Stratix II reconfig core also has a control register with a "AnF" bit that tells whether we're in factory or application mode. So here is the sequence: 1 - boot 2 - Are we in application or factory mode? 2a - If we are in application (user) mode, we go ahead and load the user software. 2b - If we are in factory (safe) mode, we continue on. 3 - Why are we in factory mode? 3a - If we are in factory mode because of a first boot or because we explicitly triggered a reconfig (like new user code was downloaded), we try to reboot using the application (user) image. 3b - If we are in factory image because of a failure (watchdog timeout, CRC error, etc.) then we assume that we must have tried to boot the application image but it failed. So we load the factory software image and we're done. It's up to the user to download a new valid application image and try again. So it looks like there is a typo in my comments and they should read: --- Quote Start --- // If the status word contains a 0x00, or a 0x04, we will load the USER image, --- Quote End --- Jake