-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename nucleoFlasher to massStorageCopy
Harden massStorageCopy to avoid issue. Create a linux 32 bits version. Signed-off-by: Frederic.Pillon <[email protected]>
- Loading branch information
Showing
16 changed files
with
116 additions
and
278 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
all: massStorageCopy32 massStorageCopy | ||
|
||
|
||
massStorageCopy32: massStorageCopy32.o | ||
gcc -m32 -o $@ $< | ||
|
||
massStorageCopy32.o: massStorageCopy.c | ||
gcc -m32 -c $< | ||
mv massStorageCopy.o massStorageCopy32.o | ||
|
||
massStorageCopy: massStorageCopy.o | ||
gcc -o $@ $< | ||
|
||
massStorageCopy.o: massStorageCopy.c | ||
gcc -c $< | ||
|
||
clean: | ||
rm -f *.o massStorageCopy massStorageCopy32 | ||
|
||
install: | ||
mv massStorageCopy ../../linux64/ | ||
mv massStorageCopy32 ../../linux/massStorageCopy |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <mntent.h> | ||
#include <unistd.h> | ||
|
||
void usage(char *name) | ||
{ | ||
printf("Usage: %s [-I <filepath>] [-O <mountpoint> ]\n\n", name); | ||
printf("Mandatory options:\n"); | ||
printf("\t-I: filepath binary to copy\n"); | ||
printf("\t-O: mountpoint destination name\n"); | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int c, i; | ||
int ret = 0; | ||
int device_found = 0; | ||
char input_path[256] = ""; | ||
char output_dev[256] = ""; | ||
char output_path[256] = ""; | ||
char cmd[512] = ""; | ||
struct mntent *ent = NULL; | ||
FILE *aFile = NULL; | ||
|
||
opterr = 0; | ||
|
||
while ((c = getopt (argc, argv, "I:O:")) != -1) | ||
switch (c) | ||
{ | ||
case 'I': | ||
strcpy(input_path, optarg); | ||
break; | ||
case 'O': | ||
strcpy(output_dev, optarg); | ||
break; | ||
case '?': | ||
if ((optopt == 'I') || (optopt == 'O')) | ||
fprintf (stderr, "Option -%c requires an argument.\n", optopt); | ||
else if (isprint (optopt)) | ||
fprintf (stderr, "Unknown option `-%c'.\n", optopt); | ||
else | ||
fprintf (stderr, | ||
"Unknown option character `\\x%x'.\n", | ||
optopt); | ||
usage(argv[0]); | ||
return 1; | ||
default: | ||
abort (); | ||
} | ||
|
||
if (strlen(input_path) && strlen(output_dev)) | ||
{ | ||
//get the mounted devives list | ||
aFile = setmntent("/proc/mounts", "r"); | ||
if (aFile == NULL) { | ||
perror("setmntent"); | ||
exit(1); | ||
} | ||
|
||
//now lets read the path of the device | ||
while (NULL != (ent = getmntent(aFile))) { | ||
if (strstr(ent->mnt_dir, output_dev)) { | ||
sprintf(output_path, "%s", ent->mnt_dir); | ||
device_found = 1; | ||
} | ||
} | ||
|
||
endmntent(aFile); | ||
|
||
if(device_found) { | ||
printf("copying %s to %s\n", input_path, output_path); | ||
|
||
sprintf(cmd, "scp %s %s", input_path, output_path); | ||
system(cmd); | ||
|
||
} else { | ||
printf("%s not found. please ensure the device is correctly connected\n", | ||
output_dev); | ||
ret = -1; | ||
} | ||
} | ||
else | ||
{ | ||
printf("Missing argument\n"); | ||
usage(argv[0]); | ||
} | ||
|
||
return ret; | ||
} |
File renamed without changes.
Oops, something went wrong.