Initial commit of sources from @fpistm

This commit is contained in:
Roger Clark 2016-09-16 20:39:24 +10:00
parent 117ab64b20
commit 3070f73f67
5 changed files with 154 additions and 0 deletions

BIN
nucleoFlasher/nucleoFlasher Normal file

Binary file not shown.

View file

@ -0,0 +1,16 @@
@ECHO off
SET SOURCE=%2
SET SRC_PARSE=%SOURCE:/=\%
SET TARGET=%4
FOR %%I IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
VOL %%I: 2>NUL | FIND "%TARGET%" >NUL && SET DEST=%%I:
)
IF DEFINED DEST (
XCOPY %SRC_PARSE% %DEST% /Y /Q >NUL
) ELSE (
ECHO %TARGET% not found. Please ensure the device is correctly connected
EXIT /B 1
)

View file

@ -0,0 +1,69 @@
#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.

View file

@ -0,0 +1,69 @@
#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;
}