Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
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
White Rabbit Switch - Software
Commits
a498862e
Commit
a498862e
authored
Sep 04, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/tools: trivial: propagate back errors
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
44cbb691
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
lm32-loader.c
userspace/tools/lm32-loader.c
+18
-10
load-fpga.c
userspace/tools/load-fpga.c
+2
-1
No files found.
userspace/tools/lm32-loader.c
View file @
a498862e
...
...
@@ -50,13 +50,13 @@ int conv_endian(int x)
+
((
x
&
0x000000ff
)
<<
24
);
}
void
rst_lm32
(
int
rst
)
static
void
rst_lm32
(
int
rst
)
{
fpga_writel
(
1
<<
LM32_RESET_PIN
,
GPIO_BASE
+
(
rst
?
GPIO_SOR
:
GPIO_COR
));
}
void
copy_lm32
(
uint32_t
*
buf
,
int
buf_nwords
,
uint32_t
base_addr
)
static
int
copy_lm32
(
uint32_t
*
buf
,
int
buf_nwords
,
uint32_t
base_addr
)
{
int
i
;
printf
(
"Writing memory: "
);
...
...
@@ -64,7 +64,8 @@ void copy_lm32(uint32_t *buf, int buf_nwords, uint32_t base_addr)
for
(
i
=
0
;
i
<
buf_nwords
;
i
++
)
{
fpga_writel
(
conv_endian
(
buf
[
i
]),
base_addr
+
i
*
4
);
if
(
!
(
i
&
0xfff
))
{
printf
(
"."
);
fflush
(
stdout
);
}
if
(
!
(
i
&
0xfff
))
printf
(
"."
);
}
printf
(
"
\n
Verifing memory: "
);
...
...
@@ -75,15 +76,18 @@ void copy_lm32(uint32_t *buf, int buf_nwords, uint32_t base_addr)
if
(
conv_endian
(
buf
[
i
])
!=
x
)
{
printf
(
"Verify failed (%x vs %x)
\n
"
,
conv_endian
(
buf
[
i
]),
x
);
return
;
return
-
1
;
}
if
(
!
(
i
&
0xfff
))
{
printf
(
"."
);
fflush
(
stdout
);
}
if
(
!
(
i
&
0xfff
))
printf
(
"."
);
}
printf
(
"OK.
\n
"
)
;
printf
(
" OK.
\n
"
);
return
0
;
}
/* being a lazy bastard, I fork a process to avoid free, munmap etc */
int
load_lm32_child
(
char
*
fname
)
{
...
...
@@ -91,6 +95,7 @@ int load_lm32_child(char *fname)
FILE
*
f
;
int
fdmem
;
setbuffer
(
stdout
,
NULL
,
0
);
if
((
fdmem
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
))
<
0
)
{
fprintf
(
stderr
,
"%s: /dev/mem: %s
\n
"
,
__func__
,
strerror
(
errno
));
...
...
@@ -111,7 +116,8 @@ int load_lm32_child(char *fname)
f
=
fopen
(
fname
,
"rb"
);
if
(
!
f
)
{
fprintf
(
stderr
,
"Input file not found.
\n
"
);
fprintf
(
stderr
,
"%s: %s: %s
\n
"
,
__func__
,
fname
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -124,7 +130,8 @@ int load_lm32_child(char *fname)
fclose
(
f
);
rst_lm32
(
1
);
copy_lm32
(
buf
,
(
size
+
3
)
/
4
,
0
);
if
(
copy_lm32
(
buf
,
(
size
+
3
)
/
4
,
0
))
return
-
1
;
rst_lm32
(
0
);
return
0
;
...
...
@@ -140,7 +147,8 @@ int load_lm32_main(char *fname)
fprintf
(
stderr
,
"fork(): %s
\n
"
,
strerror
(
errno
));
return
-
1
;
case
0
:
/* child */
load_lm32_child
(
fname
);
if
(
load_lm32_child
(
fname
))
exit
(
1
);
exit
(
0
);
default:
/* parent */
waitpid
(
pid
,
&
status
,
0
);
...
...
userspace/tools/load-fpga.c
View file @
a498862e
...
...
@@ -313,7 +313,8 @@ int load_fpga_main(char *fname)
fprintf
(
stderr
,
"fork(): %s
\n
"
,
strerror
(
errno
));
return
-
1
;
case
0
:
/* child */
load_fpga_child
(
fname
);
if
(
load_fpga_child
(
fname
))
exit
(
1
);
exit
(
0
);
default:
/* parent */
waitpid
(
pid
,
&
status
,
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