Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple VME FMC Carrier SVEC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
14
Issues
14
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple VME FMC Carrier SVEC
Commits
d97d7b17
Commit
d97d7b17
authored
Jan 16, 2014
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/vme-flasher: SPI bugfixes. Extended space for the bitstream to 6MB
parent
751778e7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
29 deletions
+30
-29
svec-flasher.c
software/vme-flasher/svec-flasher.c
+30
-29
No files found.
software/vme-flasher/svec-flasher.c
View file @
d97d7b17
...
...
@@ -15,13 +15,14 @@
#include <unistd.h>
#include <arpa/inet.h>
#include <libvmebus.h>
//#include <libsdbfs.h>
#include "sxldr_regs.h"
#define BOOTLOADER_BASE 0x70000
#define BOOTLOADER_VERSION 2
#define BOOTLOADER_BITSTREAM_BASE 0x100000
#define BOOTLOADER_SDB_BASE 0x
5
00000
#define BOOTLOADER_SDB_BASE 0x
6
00000
#define ID_M25P128 0x202018
...
...
@@ -42,20 +43,24 @@
#define FLASH_BE 0xC7
/* SDB filesystem header. Fixed for the time being, the final version should simply use libsdbfs. */
const
uint8_t
sdb_header
[]
=
{
0x53
,
0x44
,
0x42
,
0x2d
,
0x00
,
0x03
,
0x01
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x50
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x50
,
0x00
,
0xc0
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xce
,
0x42
,
0x00
,
0x00
,
0x5f
,
0xec
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x2e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x4f
,
0xff
,
0xff
,
0x46
,
0x69
,
0x6c
,
0x65
,
0x44
,
0x61
,
0x74
,
0x61
,
0x61
,
0x66
,
0x70
,
0x67
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x61
,
0x66
,
0x70
,
0x67
,
0x61
,
0x2e
,
0x62
,
0x69
,
0x6e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x05
,
0x33
,
0x93
,
0x46
,
0x69
,
0x6c
,
0x65
,
0x44
,
0x61
,
0x74
,
0x61
,
0x73
,
0x66
,
0x70
,
0x67
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x73
,
0x66
,
0x70
,
0x67
,
0x61
,
0x2e
,
0x62
,
0x69
,
0x6e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x01
};
const
uint8_t
sdb_header
[]
=
{
0x53
,
0x44
,
0x42
,
0x2d
,
0x00
,
0x03
,
0x01
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x60
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x60
,
0x00
,
0xc0
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0xce
,
0x42
,
0x00
,
0x00
,
0x5f
,
0xec
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x2e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x2c
,
0x13
,
0xe9
,
0x46
,
0x69
,
0x6c
,
0x65
,
0x44
,
0x61
,
0x74
,
0x61
,
0x61
,
0x66
,
0x70
,
0x67
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x61
,
0x66
,
0x70
,
0x67
,
0x61
,
0x2e
,
0x62
,
0x69
,
0x6e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x05
,
0x33
,
0x93
,
0x46
,
0x69
,
0x6c
,
0x65
,
0x44
,
0x61
,
0x74
,
0x61
,
0x62
,
0x6f
,
0x6f
,
0x74
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x00
,
0x62
,
0x6f
,
0x6f
,
0x74
,
0x6c
,
0x64
,
0x72
,
0x2e
,
0x62
,
0x69
,
0x6e
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x20
,
0x01
};
struct
vme_mapping
map
;
void
*
vme_va
;
...
...
@@ -107,15 +112,6 @@ void enter_bootloader()
Done
\"
LED next to the fuses should be on).
\n
"
);
exit
(
-
1
);
}
uint32_t
cr
=
csr_readl
(
SXLDR_REG_CSR
);
if
(
SXLDR_CSR_VERSION_R
(
cr
)
!=
BOOTLOADER_VERSION
)
{
fprintf
(
stderr
,
"The bootloader is too old. Please update it according to the instructions at:\
http://www.ohwr.org/projects/svec/documents/XXX.
\n
"
);
exit
(
-
1
);
}
}
void
spi_cs
(
int
cs
)
...
...
@@ -207,6 +203,8 @@ void flash_program_page(uint32_t addr, const uint8_t * data, int size)
spi_write8
(
addr
&
0x00ff
);
/* Address to start writing (LSB) */
for
(
i
=
0
;
i
<
size
;
i
++
)
spi_write8
(
data
[
i
]);
for
(;
i
<
FLASH_PAGE_SIZE
;
i
++
)
spi_write8
(
0xff
);
spi_cs
(
0
);
flash_wait_completion
();
}
...
...
@@ -224,6 +222,8 @@ void flash_program(uint32_t addr, const uint8_t * data, int size)
if
(
!
sector_map
[
sector
])
{
flash_write_enable
();
fprintf
(
stderr
,
"Erasing sector 0x%x
\r
"
,
addr
+
n
);
flash_erase_sector
(
addr
+
n
);
sector_map
[
sector
]
=
1
;
}
...
...
@@ -251,11 +251,11 @@ void flash_program(uint32_t addr, const uint8_t * data, int size)
fprintf
(
stderr
,
"Verification failed at offset 0x%06x (is: 0x%02x, should be: 0x%02x)
\n
."
,
addr
+
n
,
d
,
*
p
);
spi_cs
(
1
);
spi_cs
(
0
);
exit
(
-
1
);
}
}
spi_cs
(
1
);
spi_cs
(
0
);
}
...
...
@@ -292,12 +292,13 @@ int main(int argc, char *argv[])
enter_bootloader
();
if
(
flash_read_id
()
!=
ID_M25P128
)
{
fprintf
(
stderr
,
"Flash memory ID invalid.
\n
"
);
fprintf
(
stderr
,
"Flash memory ID invalid. You are probably be running an old version of the bootloader that doesn't support flash programming via VME.
\n
"
);
exit
(
-
1
);
}
flash_program
(
BOOTLOADER_BITSTREAM_BASE
,
buf
,
size
);
flash_program
(
BOOTLOADER_SDB_BASE
,
sdb_header
,
sizeof
(
sdb_header
));
flash_program
(
BOOTLOADER_BITSTREAM_BASE
,
buf
,
size
);
free
(
buf
);
printf
(
"Programming OK.
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment