URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [apps/] [spiflash/] [README] - Rev 505
Compare with Previous | Blame | View Log
SPI flash programming applicationThis software will be compiled and have another application embedded in it,which will then be programmed into a flash memory via the SPI protocol.At present, only the simple_spi core communicating with the M25P10 serial flashmemory via SPI is supported (the config on ORSoC FPGA board)First, compile the program to be put into flash, and generate a binary image ofit.The bootloader program that loads programs from the SPI flash, at reset, readsout the first 4 bytes (32-bit word) from the flash and expects this to containthe length of the image in bytes. It then enters a loop for this many bytesand copies them to the SDRAM, before jumping to the reset vector in SDRAM.This means the image programed into the SPI flash must contain its size at thefirst word, and the remainder of the image must be correctly aligned so thatthe reset vector is at address 0x100 after being loaded.Included with this software package is a tool which will take a binaryapplication and embed its size in the first word. The makefile then takes thisaltered binary image, and convert it into an object file with the appropriatesection name, and is linked into the final application by a custom linkerscript also included in this path.First the program to be loaded into the flash memory should be compiled. Itshould be, of course, tested on the board first, before being loaded into theflash. Once the program is tested on the board, the ELF can be taken andobjcopy'd to a binary image. It should be noted that the image should beaddressed from 0, and the vectors should be correctly located.Convert to the ELF to raw binary with:$ or32-elf-objcopy -O binary myapp.elf myapp.binNow, the spiflash-program.elf program should be compiled, and the environmentvariable PROGRAMMINGFILE should be set to point to myapp.bin, the binaryversion of the program we are to load into the flash memory.To ensure the correct settings for UART and other peripherals are picked upensure the BOARD_PATH variable is set correctly, too.make spiflash-program.elf PROGRAMMINGFILE=/path/to/myapp.bin \BOARD=actel/ordb1a3pe1500It's advisable to do a "make distclean" first, to clear out any previouslycompiled software for other boards.The steps to embed the size of the program in the binary and then link itinto the final executable are all done automatically by the Makefile.Finally, spiflash-program.elf should be loaded onto the board and executed. Asmall prompt should come up, pressing 'h' will explain the options, 'p' willdo the programming (and verification of the image) and 'v' will verify theimage again.Warning:Note that in the flash on the ORSoC dev board, there appears to be 3 pages,either pages 130-132 or pages 180-182 which do not provide reliable data whenread from. The cause of this is unknown. If this is a big problem, be sure thatno vital information is stored on those pages.And of course, be sure that the program being loaded fits into the SPI flash.Once the flash memory is programmed, and if the design is configured with theSPI flash bootloader, resetting the target should cause the new application tobe executed.Author: Julius Baxter, julius.baxter@orsoc.se
