diff --git a/linux/massStorageCopy b/linux/massStorageCopy new file mode 100755 index 00000000..7e10d84c Binary files /dev/null and b/linux/massStorageCopy differ diff --git a/linux/nucleoFlasher/nucleoFlasher b/linux/nucleoFlasher/nucleoFlasher deleted file mode 100755 index 4117f94b..00000000 Binary files a/linux/nucleoFlasher/nucleoFlasher and /dev/null differ diff --git a/linux/nucleoFlasher/nucleoFlasher.c b/linux/nucleoFlasher/nucleoFlasher.c deleted file mode 100644 index da654186..00000000 --- a/linux/nucleoFlasher/nucleoFlasher.c +++ /dev/null @@ -1,69 +0,0 @@ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - int 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; - FILE *aFile; - - - for(i = 1; i < argc; i++) { - - if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) { - strcpy(input_path, argv[i+1]); - i++; - } else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) { - strcpy(output_dev, argv[i+1]); - i++; - } else { - printf("unknown option %s\n", argv[i]); - ret = -1; - } - } - - if(ret == 0) { - - - //get thee 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; - } - } - - - return ret; -} diff --git a/linux64/massStorageCopy b/linux64/massStorageCopy new file mode 100755 index 00000000..6373d1cf Binary files /dev/null and b/linux64/massStorageCopy differ diff --git a/linux64/nucleoFlasher/nucleoFlasher b/linux64/nucleoFlasher/nucleoFlasher deleted file mode 100644 index 4117f94b..00000000 Binary files a/linux64/nucleoFlasher/nucleoFlasher and /dev/null differ diff --git a/linux64/nucleoFlasher/nucleoFlasher.c b/linux64/nucleoFlasher/nucleoFlasher.c deleted file mode 100644 index da654186..00000000 --- a/linux64/nucleoFlasher/nucleoFlasher.c +++ /dev/null @@ -1,69 +0,0 @@ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - int 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; - FILE *aFile; - - - for(i = 1; i < argc; i++) { - - if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) { - strcpy(input_path, argv[i+1]); - i++; - } else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) { - strcpy(output_dev, argv[i+1]); - i++; - } else { - printf("unknown option %s\n", argv[i]); - ret = -1; - } - } - - if(ret == 0) { - - - //get thee 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; - } - } - - - return ret; -} diff --git a/macosx/nucleoFlasher/nucleoFlasherMacOsX b/macosx/massStorageCopyMacOsX similarity index 100% rename from macosx/nucleoFlasher/nucleoFlasherMacOsX rename to macosx/massStorageCopyMacOsX diff --git a/nucleoFlasher/nucleoFlasher b/nucleoFlasher/nucleoFlasher deleted file mode 100755 index 4117f94b..00000000 Binary files a/nucleoFlasher/nucleoFlasher and /dev/null differ diff --git a/nucleoFlasher/nucleoFlasher.c b/nucleoFlasher/nucleoFlasher.c deleted file mode 100644 index da654186..00000000 --- a/nucleoFlasher/nucleoFlasher.c +++ /dev/null @@ -1,69 +0,0 @@ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - int 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; - FILE *aFile; - - - for(i = 1; i < argc; i++) { - - if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) { - strcpy(input_path, argv[i+1]); - i++; - } else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) { - strcpy(output_dev, argv[i+1]); - i++; - } else { - printf("unknown option %s\n", argv[i]); - ret = -1; - } - } - - if(ret == 0) { - - - //get thee 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; - } - } - - - return ret; -} diff --git a/nucleoFlasher/nucleoFlasherMacOsX b/nucleoFlasher/nucleoFlasherMacOsX deleted file mode 100644 index 4fa3550f..00000000 Binary files a/nucleoFlasher/nucleoFlasherMacOsX and /dev/null differ diff --git a/nucleoFlasher/nucleoFlasherMacOsX.c b/nucleoFlasher/nucleoFlasherMacOsX.c deleted file mode 100644 index 6ba4f7ab..00000000 --- a/nucleoFlasher/nucleoFlasherMacOsX.c +++ /dev/null @@ -1,69 +0,0 @@ - -#include -#include -#include -#include - -#define MAX_FS 128 - -int main(int argc, char *argv[]) -{ - int i; - int ret = 0; - int device_found = 0; - char input_path[256]; - char output_dev[256]; - char output_path[256]; - char cmd[512]; - struct statfs buf[MAX_FS]; - int fs_count; - - if(argc < 4) { - printf("error: missing parameters\n"); - ret = -1; - } - - for(i = 1; i < argc; i++) { - - if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) { - strcpy(input_path, argv[i+1]); - i++; - } else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) { - strcpy(output_dev, argv[i+1]); - i++; - } else { - printf("error: unknown option %s\n", argv[i]); - ret = -1; - } - } - - if(ret == 0) { - - fs_count = getfsstat(NULL,0,MNT_WAIT); - if(fs_count < 0) { - perror("getfsstat"); - exit(1); - } - - getfsstat(buf,fs_count*sizeof(buf[0]),MNT_WAIT); - - for(i = 0; i < fs_count; i++) { - if(strstr(buf[i].f_mntonname,output_dev)) { - sprintf(output_path, "%s", buf[i].f_mntonname); - device_found = 1; - } - } - - 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; - } - } - - return ret; -} diff --git a/src/massStorageCopy/Makefile b/src/massStorageCopy/Makefile new file mode 100644 index 00000000..a2b6023a --- /dev/null +++ b/src/massStorageCopy/Makefile @@ -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 diff --git a/nucleoFlasher/nucleoFlasher.bat b/src/massStorageCopy/massStorageCopy.bat similarity index 100% rename from nucleoFlasher/nucleoFlasher.bat rename to src/massStorageCopy/massStorageCopy.bat diff --git a/src/massStorageCopy/massStorageCopy.c b/src/massStorageCopy/massStorageCopy.c new file mode 100644 index 00000000..6f7aa5b3 --- /dev/null +++ b/src/massStorageCopy/massStorageCopy.c @@ -0,0 +1,92 @@ + +#include +#include +#include +#include +#include + +void usage(char *name) +{ + printf("Usage: %s [-I ] [-O ]\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; +} diff --git a/macosx/nucleoFlasher/nucleoFlasherMacOsX.c b/src/massStorageCopy/massStorageCopyMacOsX.c similarity index 100% rename from macosx/nucleoFlasher/nucleoFlasherMacOsX.c rename to src/massStorageCopy/massStorageCopyMacOsX.c diff --git a/win/nucleoFlasher/nucleoFlasher.bat b/win/massStorageCopy.bat similarity index 90% rename from win/nucleoFlasher/nucleoFlasher.bat rename to win/massStorageCopy.bat index 746f67a7..8325ff38 100644 --- a/win/nucleoFlasher/nucleoFlasher.bat +++ b/win/massStorageCopy.bat @@ -5,5 +5,5 @@ SET TARGET=%4 setlocal enabledelayedexpansion for /F "skip=1 tokens=*" %%a in ('WMIC LOGICALDISK where "volumename like '%TARGET%%%'" get deviceid') do if not defined id set id=%%a Call Set "deviceid=%%id: =%%" -if not "%deviceid%" == "" (XCOPY %SRC_PARSE% %deviceid% /Y /Q >NUL -echo Upload complete ) else ( echo %TARGET% not found. Please ensure the device is correctly connected) \ No newline at end of file +if not "%deviceid%" == "" (XCOPY %SRC_PARSE% %deviceid% /Y /Q >NUL +echo Upload complete ) else ( echo %TARGET% not found. Please ensure the device is correctly connected)