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
78e6962d
Commit
78e6962d
authored
Oct 24, 2013
by
Theodor-Adrian Stana
Committed by
Grzegorz Daniluk
Jan 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some changes in file formatting and flash-write malloc
Signed-off-by:
Theodor Stana
<
t.stana@cern.ch
>
parent
cb72b87c
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
176 additions
and
221 deletions
+176
-221
flash.c
dev/flash.c
+71
-78
flash.h
include/flash.h
+10
-10
Makefile
tools/Makefile
+1
-1
Makefile
tools/flash-host/Makefile
+1
-1
flash.c
tools/flash-host/flash.c
+68
-73
flash.h
tools/flash-host/flash.h
+9
-9
flash-write.c
tools/flash-write.c
+16
-9
wrc_main.c
wrc_main.c
+0
-40
No files found.
dev/flash.c
View file @
78e6962d
...
...
@@ -51,19 +51,16 @@
/*
* Bit-bang SPI transfer function
*/
static
uint8_t
bbspi_transfer
(
uint8_
t
cspin
,
uint8_t
val
)
static
uint8_t
bbspi_transfer
(
in
t
cspin
,
uint8_t
val
)
{
uint8_
t
i
,
retval
=
0
;
in
t
i
,
retval
=
0
;
gpio_out
(
GPIO_SPI_NCS
,
cspin
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
gpio_out
(
GPIO_SPI_SCLK
,
0
);
if
(
val
&
0x80
)
{
if
(
val
&
0x80
)
{
gpio_out
(
GPIO_SPI_MOSI
,
1
);
}
else
{
else
{
gpio_out
(
GPIO_SPI_MOSI
,
0
);
}
gpio_out
(
GPIO_SPI_SCLK
,
1
);
...
...
@@ -101,8 +98,7 @@ int flash_write(uint32_t addr, uint8_t *buf, int count)
bbspi_transfer
(
0
,(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
bbspi_transfer
(
0
,
buf
[
i
]);
}
bbspi_transfer
(
1
,
0
);
...
...
@@ -122,8 +118,7 @@ int flash_read(uint32_t addr, uint8_t *buf, int count)
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
bbspi_transfer
(
0
,
0
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
bbspi_transfer
(
0
,
0
);
}
bbspi_transfer
(
1
,
0
);
...
...
@@ -225,14 +220,12 @@ int flash_sdb_check()
uint32_t
entry_point
[
6
]
=
{
0x000000
,
0x100
,
0x200
,
0x300
,
0x170000
,
0x2e0000
};
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
entry_point
);
i
++
)
{
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
)
{
if
(
magic
==
SDB_MAGIC
)
{
mprintf
(
"Found SDB magic at address 0x%06X!
\n
"
,
entry_point
[
i
]);
wrc_sdb
.
drvdata
=
NULL
;
wrc_sdb
.
entrypoint
=
entry_point
[
i
];
...
...
include/flash.h
View file @
78e6962d
tools/Makefile
View file @
78e6962d
tools/flash-host/Makefile
View file @
78e6962d
tools/flash-host/flash.c
View file @
78e6962d
...
...
@@ -83,15 +83,12 @@ static uint8_t bbspi_transfer(uint8_t cspin, uint8_t val)
{
uint8_t
i
,
retval
=
0
;
gpio_out
(
GPIO_SPI_NCS
,
cspin
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
gpio_out
(
GPIO_SPI_SCLK
,
0
);
if
(
val
&
0x80
)
{
if
(
val
&
0x80
)
{
gpio_out
(
GPIO_SPI_MOSI
,
1
);
}
else
{
else
{
gpio_out
(
GPIO_SPI_MOSI
,
0
);
}
gpio_out
(
GPIO_SPI_SCLK
,
1
);
...
...
@@ -130,8 +127,7 @@ int flash_write(uint32_t addr, uint8_t *buf, int count)
bbspi_transfer
(
0
,(
addr
&
0xFF0000
)
>>
16
);
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
bbspi_transfer
(
0
,
buf
[
i
]);
}
bbspi_transfer
(
1
,
0
);
...
...
@@ -151,8 +147,7 @@ int flash_read(uint32_t addr, uint8_t *buf, int count)
bbspi_transfer
(
0
,(
addr
&
0xFF00
)
>>
8
);
bbspi_transfer
(
0
,(
addr
&
0xFF
));
bbspi_transfer
(
0
,
0
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
bbspi_transfer
(
0
,
0
);
}
bbspi_transfer
(
1
,
0
);
...
...
tools/flash-host/flash.h
View file @
78e6962d
tools/flash-write.c
View file @
78e6962d
...
...
@@ -82,9 +82,15 @@ extern void *BASE_SYSCON;
static
int
spec_write_flash
(
struct
spec_device
*
spec
,
int
addr
,
int
len
)
{
uint8_t
*
buf
=
malloc
(
len
);
int
i
,
r
,
plen
=
len
;
uint8_t
*
buf
=
malloc
(
len
);
if
(
buf
==
NULL
)
{
fprintf
(
stderr
,
"Memory not available for write buffer!"
);
return
-
1
;
}
BASE_SYSCON
=
spec
->
mapaddr
+
SPEC_SYSCON_OFFSET
;
flash_init
();
...
...
@@ -104,9 +110,8 @@ static int spec_write_flash(struct spec_device *spec, int addr, int len)
return
1
;
}
/* Let's some data to the flash */
while
(
len
)
{
/* Let's send some data to the flash */
while
(
len
)
{
/* Set write length */
i
=
len
;
if
(
len
>
256
)
...
...
@@ -132,15 +137,14 @@ static int spec_write_flash(struct spec_device *spec, int addr, int len)
}
/* Write to flash */
if
(
verbose
)
{
if
(
verbose
)
{
fprintf
(
stderr
,
"Writing %3i bytes at address 0x%06X
\n
"
,
i
,
addr
);
}
flash_write
(
addr
,
buf
,
i
);
sleep
(
1
);
/* FIXME: As above, RSR is a m
i
stery... */
/* FIXME: As above, RSR is a m
y
stery... */
// while (flash_rsr() & 0x01)
// ;
...
...
@@ -156,6 +160,8 @@ static int spec_write_flash(struct spec_device *spec, int addr, int len)
// }
}
free
(
buf
);
return
0
;
}
...
...
@@ -205,6 +211,7 @@ static int spec_scan_pci(struct spec_pci_id *id, struct spec_device *arr,
unsigned
v
,
d
;
n
=
scandir
(
"/sys/bus/pci/devices"
,
&
namelist
,
0
,
0
);
if
(
n
<
0
)
{
fprintf
(
stderr
,
"%s: /sys/bus/pci/devices: %s
\n
"
,
prgname
,
strerror
(
errno
));
...
...
wrc_main.c
View file @
78e6962d
...
...
@@ -28,7 +28,6 @@
#include "shell.h"
#include "lib/ipv4.h"
#include "rxts_calibrator.h"
#include "flash.h"
#include "wrc_ptp.h"
...
...
@@ -225,52 +224,13 @@ static void check_reset(void) {}
#endif
void
w
()
{
uint64_t
i
;
for
(
i
=
0
;
i
<
1024
*
1024
*
100
;
i
++
)
asm
volatile
(
"nop"
);
}
int
main
(
void
)
{
uint8_t
rdat
[
256
];
int
i
;
uint32_t
addr
;
check_reset
();
wrc_ui_mode
=
UI_SHELL_MODE
;
_endram
=
ENDRAM_MAGIC
;
sdb_find_devices
();
uart_init_sw
();
uart_init_hw
();
timer_init
(
0
);
mprintf
(
"preinit
\n
"
);
w
();
mprintf
(
"flash init
\n
"
);
flash_init
();
//#define ADDRSTART 0x100
//#define ADDRMAX 0x600
// addr = 0x100;
// mprintf("reading from 0x%06X to 0x%06X\n", addr, ADDRMAX);
// for (addr = ADDRSTART; addr < ADDRMAX; addr += 256)
// {
// flash_read(addr,rdat,256);
// for (i = 0; i < 256; i++)
// printf("0x%02X ", rdat[i]);
// printf("\n");
// }
// mprintf("done; current address 0x%06X\n", addr);
flash_sdb_check
();
return
0
;
wrc_initialize
();
usleep_init
();
shell_init
();
...
...
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