Rename nucleoFlasher to massStorageCopy
Harden massStorageCopy to avoid issue. Create a linux 32 bits version. Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
This commit is contained in:
parent
4963647c4a
commit
1ba6db25b6
16 changed files with 116 additions and 278 deletions
BIN
linux/massStorageCopy
Executable file
BIN
linux/massStorageCopy
Executable file
Binary file not shown.
Binary file not shown.
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <mntent.h>
|
||||
|
||||
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;
|
||||
}
|
||||
BIN
linux64/massStorageCopy
Executable file
BIN
linux64/massStorageCopy
Executable file
Binary file not shown.
Binary file not shown.
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <mntent.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <mntent.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
22
src/massStorageCopy/Makefile
Normal file
22
src/massStorageCopy/Makefile
Normal file
|
|
@ -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
|
||||
92
src/massStorageCopy/massStorageCopy.c
Normal file
92
src/massStorageCopy/massStorageCopy.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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)
|
||||
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)
|
||||
Loading…
Reference in a new issue