Forum Discussion
Altera_Forum
Honored Contributor
21 years agoFlash Programmer Question
Can anybody explain to me does Altera Flash Programmer places boot loader automatically before main programm at flash for copying main program to sdram or not?
Or I must write my own boot loader and then tell Flash Programmer to program it before my main program?18 Replies
- Altera_Forum
Honored Contributor
The flash programmer does indeed place a bootloader in flash to copy your code out to RAM
- Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by rugbybloke@Dec 2 2004, 10:12 AM the flash programmer does indeed place a bootloader in flash to copy your code out to ram --- Quote End --- Hi, Currently we use the Flash programming Tool to program our custom board (under development). In the operational phase we will not have the JTAG to program the flash. So we will have to download the FPGA codes and our application onto the RAM and then reprogram the entire EPCS flash (thus probably including the bootloader). Do you know if there is documentation about how we can can do this? Maybe you have other tips. Thanks in advance. Regards, Kwok Kwok - Altera_Forum
Honored Contributor
kwokwong
<div class='quotetop'>QUOTE </div> --- Quote Start --- So we will have to download the FPGA codes and our application onto the RAM and then reprogram the entire EPCS flash (thus probably including the bootloader).[/b] --- Quote End --- May be you can use remote system update feature? You need to add to your design any kind of communication with external world (uart or ethernet for example). And than add feature to your programm to write flash at specified address with data recieved via communication interface. In this way, as I understand, you will need to write your own bootloader if you wish to programm flash with code footprint beginning at address 0x00000000. So firstly you programm your bootloader and then you programm your code. In other hand may be you will be able to find how much space occupies Altera Flash Programmer bootloader and write your code footprint right after it. If you discover end address of Altera Flash Programmer bootloader Please post it here - it will be wery usefull to know this. Info about remote update can be found on Altera web server. This feature is applicable to EPC devices too. - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by macshiz@Dec 3 2004, 04:13 AM kwokwong[/b] <div class='quotetop'>QUOTE --- Quote End --- --- Quote Start --- So we will have to download the FPGA codes and our application onto the RAM and then reprogram the entire EPCS flash (thus probably including the bootloader).[/b] --- Quote End --- May be you can use remote system update feature? You need to add to your design any kind of communication with external world (uart or ethernet for example). And than add feature to your programm to write flash at specified address with data recieved via communication interface. In this way, as I understand, you will need to write your own bootloader if you wish to programm flash with code footprint beginning at address 0x00000000. So firstly you programm your bootloader and then you programm your code. In other hand may be you will be able to find how much space occupies Altera Flash Programmer bootloader and write your code footprint right after it. If you discover end address of Altera Flash Programmer bootloader Please post it here - it will be wery usefull to know this. Info about remote update can be found on Altera web server. This feature is applicable to EPC devices too. [/b] --- Quote End --- So far I figure out: 1. You can use elf2flash utility to add the bootloader (boot_loader_epcs.srec) to your own application (output: epcs_controller_boot_rom.flash). 2. You can use sof2flash utility to convert the FPGA to a .flash file (epcs.flash) 3. You can use the HAL EPCS flash api to program the flash . What I DON'T know: 1. To where (flash address) should I write the flash content? Or can I just follow the addresses in the SREC's? - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by macshiz@Dec 3 2004, 04:13 AM kwokwong[/b] <div class='quotetop'>QUOTE --- Quote End --- --- Quote Start --- So we will have to download the FPGA codes and our application onto the RAM and then reprogram the entire EPCS flash (thus probably including the bootloader).[/b] --- Quote End --- May be you can use remote system update feature? You need to add to your design any kind of communication with external world (uart or ethernet for example). And than add feature to your programm to write flash at specified address with data recieved via communication interface. In this way, as I understand, you will need to write your own bootloader if you wish to programm flash with code footprint beginning at address 0x00000000. So firstly you programm your bootloader and then you programm your code. In other hand may be you will be able to find how much space occupies Altera Flash Programmer bootloader and write your code footprint right after it. If you discover end address of Altera Flash Programmer bootloader Please post it here - it will be wery usefull to know this. Info about remote update can be found on Altera web server. This feature is applicable to EPC devices too. [/b] --- Quote End --- So far I figure out: 1. You can use elf2flash utility to add the bootloader (boot_loader_epcs.srec) to your own application (output: epcs_controller_boot_rom.flash). 2. You can use sof2flash utility to convert the FPGA to a .flash file (epcs.flash) 3. You can use the HAL EPCS flash api to program the flash . What I DON'T know: 1. To where (flash address) should I write the flash content? Or can I just follow the addresses in the SREC's? - Altera_Forum
Honored Contributor
I have a similar problem.
In my design a small initialization software is implemented in EPCS and loaded at power on via boot loader. After initialization of all ports and interfaces the programme starts a endless loop in internal RAM while system ram is mapped into PCI space (with shared access from local). From PCI side a new firmware will then be loaded. In the endless loop the processor detects, if reset address at offset 0 is not equal zero and jumps to the new reset start vector. I think this pocedure can be done if the content of the .flash file generated by NIOS II IDE is known. This file is based on the SREC format but differs. The first (S0) record contains in its address field a reference designator of the appropriate flash device (EPCS). The following S3 records contain code but not exactly correlated to the address fields. The last data word is the start address itself and is not stored in a S9-record as specified by motorola. Does anybody have a specification of the .flash file format? If this content is clear it should be no problem, to make a firmware update on-the-fly via any interface to externals. - Altera_Forum
Honored Contributor
<div class='quotetop'>QUOTE </div>
--- Quote Start --- What I DON'T know: 1. To where (flash address) should I write the flash content? Or can I just follow the addresses in the SREC's?[/b] --- Quote End --- May be this will be usefull for you I found this docs and example about remote update on Altera Site. Example deals with EPCS device as i understand http://www.altera.com/literature/hb/stx/ch...ence_design.zip (http://www.altera.com/literature/hb/stx/ch15_reference_design.zip) Also I have 10Meg arch named NiosII_BootCamp.zip I don't remember where I have got it. But it is also Altera produced documentation contains info about remote update features. - Altera_Forum
Honored Contributor
Found another problem.
OK. I have Nios Stratix 1s10 dev board. Configuration scheme is one with MAX device. In such scheme configuration is stored in flash device. I have software to download any file to flash at desired location. So my question is: I produce .flash file with configuration by sof2flash utility. What I must write to flash? .flash file is in motorola srec format so I must write only data fields at specified addresses or I must write entire .flash file with all fields? - Altera_Forum
Honored Contributor
The .flash file should contain initialisation data for only part of the flash. The SREC address records describe offsets from the start of the flash chip. If you write the .flash file to flash using the flash programmer then the contents of locations not described in the .flash file should remain unchanged.
So your software should do the same, if an address is mentioned in the SREC file then write the appropriate data there, if it's not mentioned then leave it unchanged. - Altera_Forum
Honored Contributor
.flash file is not a standard SREC file!
I've realized a secondary bootloader that transfers "epcs_controller_boot_rom.flash" to the nios system ram via PCI-bus. In my design, reset vector is set to epcs-device and exception vector is assigned to system ram. I've figured out that the address field of this .flash file is only a counter which has nothing to do with a storage address. The start address of the different sections are part of the srec data fields. A .flash S3 record starts with a size indicator (two characters just behind "S3") followed by a 8 character number in big endian format (a counter). The following data fields are organized as 8 character of 32bit data words in little endian format. The first Data word is a length indicator, the second data word is the target address. the rest are data words to be placed at target address. The length indicator counts bytes. Every line is terminated with a two character checksum as usual in SREC files. In my design the first data block consists of 12 Bytes (0x0C000000 in little endian) to be placed at address 0x00000000 (the reset start address). The next data block has 68612 Bytes (0x040C0100 in little endian) and has to be stored at address 0x00100020 which is the exception start vector in system ram. The third block in the .flash file has a length of 0 and an address that is the start address of the .text segment e.g. the start of the firmware. The boot loader is only added when 'FLASH PROGRAMMER' is launched. This program generates a new .flash file, named as specified in the custom board design and obviously consists of Bootloader, Firmware and FPGA-Bitstream. I did not figure out how this file is organized.