Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ti-connected-launchpad
lm4tools_public
Commits
9e2cfa61
Commit
9e2cfa61
authored
Oct 18, 2012
by
Peter Stuge
Browse files
Change file I/O from fd functions to more portable FILE * functions
parent
853932a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
icdiflasher.c
View file @
9e2cfa61
...
...
@@ -362,7 +362,7 @@ static int send_vFlashErase(libusb_device_handle *handle, uint32_t start, uint32
return
retval
;
}
static
int
send_vFlashWrite
(
libusb_device_handle
*
handle
,
uint32_t
addr
,
int
fd
,
int
size
)
static
int
send_vFlashWrite
(
libusb_device_handle
*
handle
,
uint32_t
addr
,
FILE
*
f
,
int
size
)
{
int
retval
;
size_t
idx
;
...
...
@@ -384,7 +384,7 @@ static int send_vFlashWrite(libusb_device_handle *handle, uint32_t addr, int fd,
buffer
[
idx
++
]
=
':'
;
// FIXME: need to check return and size cant be more than 512
rdsize
=
read
(
fd
,
fdbuffer
,
size
);
rdsize
=
f
read
(
fdbuffer
,
1
,
size
,
f
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
uint8_t
by
=
fdbuffer
[
i
];
...
...
@@ -426,7 +426,7 @@ static int send_vFlashWrite(libusb_device_handle *handle, uint32_t addr, int fd,
* traffic between LM Flash Programmer and the Stellaris Launchpad
* when doing a firmware write
*/
static
int
write_firmware
(
libusb_device_handle
*
handle
,
int
fd
)
static
int
write_firmware
(
libusb_device_handle
*
handle
,
FILE
*
f
)
{
int
retval
;
uint32_t
val
=
0
;
...
...
@@ -473,7 +473,7 @@ static int write_firmware(libusb_device_handle *handle, int fd)
retval
=
send_x
(
handle
,
XXX2CTL
,
4
,
&
val
);
for
(
addr
=
0
,
retval
=
512
;
retval
==
512
;
addr
+=
0x200
)
retval
=
send_vFlashWrite
(
handle
,
addr
,
f
d
,
512
);
retval
=
send_vFlashWrite
(
handle
,
addr
,
f
,
512
);
retval
=
send_qRcmd
(
handle
,
cmd_str4
,
sizeof
(
cmd_str4
)
-
1
);
retval
=
send_qRcmd
(
handle
,
cmd_str5
,
sizeof
(
cmd_str5
)
-
1
);
...
...
@@ -491,7 +491,7 @@ int main(int argc, char *argv[])
libusb_device
*
dev
=
NULL
;
libusb_device_handle
*
handle
=
NULL
;
int
retval
=
1
;
int
fd
=
-
1
;
FILE
*
f
=
NULL
;
if
(
argc
<
2
)
{
printf
(
"usage: %s <binary-file>
\n
"
,
argv
[
0
]);
...
...
@@ -519,18 +519,18 @@ int main(int argc, char *argv[])
goto
done
;
}
f
d
=
open
(
argv
[
1
],
O_RDONLY
);
if
(
f
d
==
-
1
)
{
perror
(
"open"
);
f
=
f
open
(
argv
[
1
],
"rb"
);
if
(
!
f
)
{
perror
(
"
f
open"
);
retval
=
1
;
goto
done
;
}
retval
=
write_firmware
(
handle
,
f
d
);
retval
=
write_firmware
(
handle
,
f
);
done:
if
(
f
d
!=
-
1
)
close
(
f
d
);
if
(
f
)
f
close
(
f
);
if
(
handle
)
libusb_close
(
handle
);
if
(
ctx
)
...
...
Write
Preview
Supports
Markdown
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