OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [apps/] [spiflash/] [README] - Blame information for rev 411

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 349 julius
                SPI flash programming application
2
 
3
This software will be compiled and have another application embedded in it,
4
which will then be programmed into a flash memory via the SPI protocol.
5
 
6
At present, only the simple_spi core communicating with the M25P10 serial flash
7
memory via SPI is supported (the config on ORSoC FPGA board)
8
 
9
First, compile the program to be put into flash, and generate a binary image of
10
it.
11
 
12
The bootloader program that loads programs from the SPI flash, at reset, reads
13
out the first 4 bytes (32-bit word) from the flash and expects this to contain
14
the length of the image in bytes. It then enters a loop for this many bytes
15
and copies them to the SDRAM, before jumping to the reset vector in SDRAM.
16
 
17
This means the image programed into the SPI flash must contain its size at the
18
first word, and the remainder of the image must be correctly aligned so that
19
the reset vector is at address 0x100 after being loaded.
20
 
21
Included with this software package is a tool which will take a binary
22
application and embed its size in the first word. The makefile then takes this
23
altered binary image, and convert it into an object file with the appropriate
24
section name, and is linked into the final application by a custom linker
25
script also included in this path.
26
 
27
First the program to be loaded into the flash memory should be compiled. It
28
should be, of course, tested on the board first, before being loaded into the
29
flash. Once the program is tested on the board, the ELF can be taken and
30
objcopy'd to a binary image. It should be noted that the image should be
31
addressed from 0, and the vectors should be correctly located.
32
 
33
Convert to the ELF to raw binary with:
34
 
35
$ or32-elf-objcopy -O binary myapp.elf myapp.bin
36
 
37
Now, the spiflash-program.elf program should be compiled, and the environment
38
variable PROGRAMMINGFILE should be set to point to myapp.bin, the binary
39
version of the program we are to load into the flash memory.
40
 
41
# make spiflash-program.elf PROGRAMMINGFILE=/path/to/myapp.bin
42
 
43
The steps to embed the size of the program in the binary and then link it
44
into the final executable are all done automatically by the Makefile.
45
 
46
Finally, spiflash-program.elf should be loaded onto the board and executed. A
47
small prompt should come up, pressing 'h' will explain the options, 'p' will
48
do the programming (and verification of the image) and 'v' will verify the
49
image again.
50
 
51
Note that in the flash on the ORSoC dev board, there appears to be 3 pages,
52
either pages 130-132 or pages 180-182 which do not provide reliable data when
53
read from. The cause of this is unknown. If this is a big problem, be sure that
54
no vital information is stored on those pages.
55
 
56
And of course, be sure that the program being loaded fits into the SPI flash.
57
 
58
Once the flash memory is programmed, and if the design is configured with the
59
SPI flash bootloader, resetting the target should cause the new application to
60
be executed.
61
 
62
Author: Julius Baxter, julius.baxter@orsoc.se
63
 
64
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.