Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion hex2dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main (int argc, char **argv) {
int targen_number = 0;
int i, c, vid =0x0483, pid = 0xdf11, ver = 0xffff;
char *tar0 = NULL, *tar0_lab = NULL, *out_fn = NULL;
FILE *inFile, *outFile;
FILE *inFile = NULL, *outFile = NULL;
unsigned char json_output = 0;
unsigned int max_address = 0x08200000;

Expand Down Expand Up @@ -149,6 +149,10 @@ int main (int argc, char **argv) {
#endif

inFile = fopen ( tar0, "r");
if (!inFile) {
perror("error: open input file");
return 1;
}
tar0_buf = ihex2bin_buf(&tar0_start_address, &tar0_len, inFile, max_address);
tar0_len = tar0_len + ((tar0_len & 0x07) ? (8 - (tar0_len & 0x07)) : 0);
fclose (inFile);
Expand Down Expand Up @@ -253,6 +257,11 @@ int main (int argc, char **argv) {

//write DFU to file
outFile = fopen (out_fn, "wb");
if (!outFile) {
perror("error: open output file");
return 1;
}

c = fwrite (dfu, dfu_len, 1, outFile);
fclose(outFile);
if (c != 1) {
Expand Down