Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
233a5827
Commit
233a5827
authored
Oct 07, 2013
by
Theodor-Adrian Stana
Committed by
Grzegorz Daniluk
Jan 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added flash SDBFS read to LM32 code
Signed-off-by:
Theodor Stana
<
t.stana@cern.ch
>
parent
6ef8ac88
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
29 deletions
+100
-29
flash.c
dev/flash.c
+90
-6
flash.h
include/flash.h
+2
-1
--SDB-CONFIG--
tools/sdbfs/--SDB-CONFIG--
+1
-1
wrc_main.c
wrc_main.c
+7
-21
No files found.
dev/flash.c
View file @
233a5827
...
...
@@ -40,13 +40,14 @@
#include "types.h"
#include "syscon.h"
static
void
delay
()
{
int
i
;
for
(
i
=
0
;
i
<
1
;
i
++
)
asm
volatile
(
"nop"
);
}
#define SDBFS_BIG_ENDIAN
#include "libsdbfs.h"
#include <wrc.h>
/*****************************************************************************/
/* Flash interface */
/*****************************************************************************/
/*
* Bit-bang SPI transfer function
*/
...
...
@@ -145,6 +146,19 @@ void flash_serase(uint32_t addr)
bbspi_transfer
(
1
,
0
);
}
/*
* Bulk erase
*/
void
flash_berase
()
{
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0x06
);
bbspi_transfer
(
1
,
0
);
bbspi_transfer
(
0
,
0xc7
);
bbspi_transfer
(
1
,
0
);
}
/*
* Read status register
*/
...
...
@@ -157,3 +171,73 @@ uint8_t flash_rsr()
bbspi_transfer
(
1
,
0
);
return
retval
;
}
/*****************************************************************************/
/* SDB */
/*****************************************************************************/
/* The sdb filesystem itself */
static
struct
sdbfs
wrc_sdb
=
{
.
name
=
"wrpc-storage"
,
.
blocksize
=
1
,
/* Not currently used */
/* .read and .write according to device type */
};
/*
* SDB read and write functions
*/
static
int
sdb_flash_read
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
return
flash_read
(
offset
,
buf
,
count
);
}
static
int
sdb_flash_write
(
struct
sdbfs
*
fs
,
int
offset
,
void
*
buf
,
int
count
)
{
return
flash_write
(
offset
,
buf
,
count
);
}
/*
* A trivial dumper, just to show what's up in there
*/
static
void
flash_sdb_list
(
struct
sdbfs
*
fs
)
{
struct
sdb_device
*
d
;
int
new
=
1
;
while
(
(
d
=
sdbfs_scan
(
fs
,
new
))
!=
NULL
)
{
d
->
sdb_component
.
product
.
record_type
=
'\0'
;
mprintf
(
"file 0x%08x @ %4i, name %s
\n
"
,
(
int
)(
d
->
sdb_component
.
product
.
device_id
),
(
int
)(
d
->
sdb_component
.
addr_first
),
(
char
*
)(
d
->
sdb_component
.
product
.
name
));
new
=
0
;
}
}
/*
* Check for SDB presence on flash
*/
int
flash_sdb_check
()
{
uint32_t
magic
=
0
;
int
i
;
uint32_t
entry_point
[
3
]
=
{
0x000000
,
0x170000
,
0x2e0000
};
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_point
);
i
++
)
{
flash_read
(
entry_point
[
i
],
(
uint8_t
*
)
&
magic
,
4
);
if
(
magic
==
SDB_MAGIC
)
break
;
}
if
(
magic
==
SDB_MAGIC
)
{
mprintf
(
"Found SDB magic at address 0x%06X!
\n
"
,
entry_point
[
i
]);
wrc_sdb
.
drvdata
=
NULL
;
wrc_sdb
.
read
=
sdb_flash_read
;
wrc_sdb
.
write
=
sdb_flash_write
;
flash_sdb_list
(
&
wrc_sdb
);
}
return
0
;
}
include/flash.h
View file @
233a5827
...
...
@@ -46,9 +46,10 @@ void flash_init();
int
flash_write
(
uint32_t
addr
,
uint8_t
*
buf
,
int
count
);
int
flash_read
(
uint32_t
addr
,
uint8_t
*
buf
,
int
count
);
void
flash_serase
(
uint32_t
addr
);
void
flash_berase
();
uint8_t
flash_rsr
();
/* SDB flash interface functions */
int
flash_sdb_check
();
#endif // __FLASH_H_
tools/sdbfs/--SDB-CONFIG--
View file @
233a5827
...
...
@@ -3,7 +3,7 @@
# at offset zero at all, we want to start at zero *wihin* our space.
# This is actually the default, but stating it is better.
.
position = 0
position = 0
x170000
# Then, we have a number of writable files. By default (i.e. no config)
# all existing files are created as read-only files with current contents
...
...
wrc_main.c
View file @
233a5827
...
...
@@ -253,30 +253,16 @@ int main(void)
uint8_t
d
[
4
]
=
{
0xaa
,
0xbb
,
0xcc
,
0xdd
};
flash_init
();
flash_read
(
0x00
,
rdat
,
256
);
flash_read
(
0x170000
,
rdat
,
256
);
for
(
i
=
0
;
i
<
256
;
i
++
)
{
mprintf
(
"0x%02x "
,
rdat
[
i
]);
}
mprintf
(
"
\n
"
);
// mprintf("erase\n");
// flash_serase(0x00);
// while (flash_rsr() & 0x01)
// ;
//
// mprintf("write\n");
// flash_write(0x00, d, 4);
// while (flash_rsr() & 0x01)
// ;
flash_read
(
0x100
,
rdat
,
256
);
printf
(
"0x%02X "
,
rdat
[
i
]);
printf
(
"
\n
"
);
flash_read
(
0x170100
,
rdat
,
256
);
for
(
i
=
0
;
i
<
256
;
i
++
)
{
mprintf
(
"0x%02x "
,
rdat
[
i
]);
}
mprintf
(
"
\n
"
);
printf
(
"0x%02X "
,
rdat
[
i
]);
printf
(
"
\n
"
);
// flash_sdb_check();
return
0
;
...
...
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