Skip to content

Commit bf6e42c

Browse files
Split tools by OS (but initially retain the original single NucleoFlasher folder
1 parent 3070f73 commit bf6e42c

File tree

9 files changed

+292
-0
lines changed

9 files changed

+292
-0
lines changed

linux/nucleoFlasher/nucleoFlasher

8.91 KB
Binary file not shown.

linux/nucleoFlasher/nucleoFlasher.c

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include <stdlib.h>
5+
#include <mntent.h>
6+
7+
int main(int argc, char *argv[])
8+
{
9+
int i;
10+
int ret = 0;
11+
int device_found = 0;
12+
char input_path[256];
13+
char output_dev[256];
14+
char output_path[256];
15+
char cmd[512];
16+
struct mntent *ent;
17+
FILE *aFile;
18+
19+
20+
for(i = 1; i < argc; i++) {
21+
22+
if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) {
23+
strcpy(input_path, argv[i+1]);
24+
i++;
25+
} else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) {
26+
strcpy(output_dev, argv[i+1]);
27+
i++;
28+
} else {
29+
printf("unknown option %s\n", argv[i]);
30+
ret = -1;
31+
}
32+
}
33+
34+
if(ret == 0) {
35+
36+
37+
//get thee mounted devives list
38+
aFile = setmntent("/proc/mounts", "r");
39+
if (aFile == NULL) {
40+
perror("setmntent");
41+
exit(1);
42+
}
43+
44+
//now lets read the path of the device
45+
while (NULL != (ent = getmntent(aFile))) {
46+
if (strstr(ent->mnt_dir, output_dev)) {
47+
sprintf(output_path, "%s", ent->mnt_dir);
48+
device_found = 1;
49+
}
50+
}
51+
52+
endmntent(aFile);
53+
54+
if(device_found) {
55+
printf("copying %s to %s\n", input_path, output_path);
56+
57+
sprintf(cmd, "scp %s %s", input_path, output_path);
58+
system(cmd);
59+
60+
} else {
61+
printf("%s not found. please ensure the device is correctly connected\n",
62+
output_dev);
63+
ret = -1;
64+
}
65+
}
66+
67+
68+
return ret;
69+
}
8.76 KB
Binary file not shown.
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include <stdlib.h>
5+
#include <sys/mount.h>
6+
7+
#define MAX_FS 128
8+
9+
int main(int argc, char *argv[])
10+
{
11+
int i;
12+
int ret = 0;
13+
int device_found = 0;
14+
char input_path[256];
15+
char output_dev[256];
16+
char output_path[256];
17+
char cmd[512];
18+
struct statfs buf[MAX_FS];
19+
int fs_count;
20+
21+
if(argc < 4) {
22+
printf("error: missing parameters\n");
23+
ret = -1;
24+
}
25+
26+
for(i = 1; i < argc; i++) {
27+
28+
if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) {
29+
strcpy(input_path, argv[i+1]);
30+
i++;
31+
} else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) {
32+
strcpy(output_dev, argv[i+1]);
33+
i++;
34+
} else {
35+
printf("error: unknown option %s\n", argv[i]);
36+
ret = -1;
37+
}
38+
}
39+
40+
if(ret == 0) {
41+
42+
fs_count = getfsstat(NULL,0,MNT_WAIT);
43+
if(fs_count < 0) {
44+
perror("getfsstat");
45+
exit(1);
46+
}
47+
48+
getfsstat(buf,fs_count*sizeof(buf[0]),MNT_WAIT);
49+
50+
for(i = 0; i < fs_count; i++) {
51+
if(strstr(buf[i].f_mntonname,output_dev)) {
52+
sprintf(output_path, "%s", buf[i].f_mntonname);
53+
device_found = 1;
54+
}
55+
}
56+
57+
if(device_found) {
58+
printf("copying %s to %s\n", input_path, output_path);
59+
sprintf(cmd, "scp %s %s", input_path, output_path);
60+
system(cmd);
61+
} else {
62+
printf("%s not found. please ensure the device is correctly connected\n",
63+
output_dev);
64+
ret = -1;
65+
}
66+
}
67+
68+
return ret;
69+
}

win/nucleoFlasher/nucleoFlasher

8.91 KB
Binary file not shown.

win/nucleoFlasher/nucleoFlasher.bat

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@ECHO off
2+
3+
SET SOURCE=%2
4+
SET SRC_PARSE=%SOURCE:/=\%
5+
SET TARGET=%4
6+
7+
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 (
8+
VOL %%I: 2>NUL | FIND "%TARGET%" >NUL && SET DEST=%%I:
9+
)
10+
11+
IF DEFINED DEST (
12+
XCOPY %SRC_PARSE% %DEST% /Y /Q >NUL
13+
) ELSE (
14+
ECHO %TARGET% not found. Please ensure the device is correctly connected
15+
EXIT /B 1
16+
)

win/nucleoFlasher/nucleoFlasher.c

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include <stdlib.h>
5+
#include <mntent.h>
6+
7+
int main(int argc, char *argv[])
8+
{
9+
int i;
10+
int ret = 0;
11+
int device_found = 0;
12+
char input_path[256];
13+
char output_dev[256];
14+
char output_path[256];
15+
char cmd[512];
16+
struct mntent *ent;
17+
FILE *aFile;
18+
19+
20+
for(i = 1; i < argc; i++) {
21+
22+
if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) {
23+
strcpy(input_path, argv[i+1]);
24+
i++;
25+
} else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) {
26+
strcpy(output_dev, argv[i+1]);
27+
i++;
28+
} else {
29+
printf("unknown option %s\n", argv[i]);
30+
ret = -1;
31+
}
32+
}
33+
34+
if(ret == 0) {
35+
36+
37+
//get thee mounted devives list
38+
aFile = setmntent("/proc/mounts", "r");
39+
if (aFile == NULL) {
40+
perror("setmntent");
41+
exit(1);
42+
}
43+
44+
//now lets read the path of the device
45+
while (NULL != (ent = getmntent(aFile))) {
46+
if (strstr(ent->mnt_dir, output_dev)) {
47+
sprintf(output_path, "%s", ent->mnt_dir);
48+
device_found = 1;
49+
}
50+
}
51+
52+
endmntent(aFile);
53+
54+
if(device_found) {
55+
printf("copying %s to %s\n", input_path, output_path);
56+
57+
sprintf(cmd, "scp %s %s", input_path, output_path);
58+
system(cmd);
59+
60+
} else {
61+
printf("%s not found. please ensure the device is correctly connected\n",
62+
output_dev);
63+
ret = -1;
64+
}
65+
}
66+
67+
68+
return ret;
69+
}

win/nucleoFlasher/nucleoFlasherMacOsX

8.76 KB
Binary file not shown.
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
#include <stdio.h>
3+
#include <string.h>
4+
#include <stdlib.h>
5+
#include <sys/mount.h>
6+
7+
#define MAX_FS 128
8+
9+
int main(int argc, char *argv[])
10+
{
11+
int i;
12+
int ret = 0;
13+
int device_found = 0;
14+
char input_path[256];
15+
char output_dev[256];
16+
char output_path[256];
17+
char cmd[512];
18+
struct statfs buf[MAX_FS];
19+
int fs_count;
20+
21+
if(argc < 4) {
22+
printf("error: missing parameters\n");
23+
ret = -1;
24+
}
25+
26+
for(i = 1; i < argc; i++) {
27+
28+
if((strcmp(argv[i], "-I") == 0)&&(i+1 < argc)) {
29+
strcpy(input_path, argv[i+1]);
30+
i++;
31+
} else if((strcmp(argv[i], "-O") == 0)&&(i+1 < argc)) {
32+
strcpy(output_dev, argv[i+1]);
33+
i++;
34+
} else {
35+
printf("error: unknown option %s\n", argv[i]);
36+
ret = -1;
37+
}
38+
}
39+
40+
if(ret == 0) {
41+
42+
fs_count = getfsstat(NULL,0,MNT_WAIT);
43+
if(fs_count < 0) {
44+
perror("getfsstat");
45+
exit(1);
46+
}
47+
48+
getfsstat(buf,fs_count*sizeof(buf[0]),MNT_WAIT);
49+
50+
for(i = 0; i < fs_count; i++) {
51+
if(strstr(buf[i].f_mntonname,output_dev)) {
52+
sprintf(output_path, "%s", buf[i].f_mntonname);
53+
device_found = 1;
54+
}
55+
}
56+
57+
if(device_found) {
58+
printf("copying %s to %s\n", input_path, output_path);
59+
sprintf(cmd, "scp %s %s", input_path, output_path);
60+
system(cmd);
61+
} else {
62+
printf("%s not found. please ensure the device is correctly connected\n",
63+
output_dev);
64+
ret = -1;
65+
}
66+
}
67+
68+
return ret;
69+
}

0 commit comments

Comments
 (0)