commit
A => ameba_tools_linux/amebasize +0 -0

        
A => ameba_tools_linux/bsp/image/ram_1.p.bin +0 -0

        
A => ameba_tools_linux/bsp/image/ram_1.r.bin +0 -0

        
A => ameba_tools_linux/postbuild_img2_arduino_linux +0 -0

        
A => ameba_tools_linux/tools/linux/checksum +0 -0

        
A => ameba_tools_linux/tools/linux/padding +0 -0

        
A => ameba_tools_linux/tools/linux/pick +0 -0

        
A => ameba_tools_linux/tools/linux/src/amebasize.c +47 -0
@@ 0,0 1,47 @@ 
+/*
+
+Compile command:
+	gcc -m32 -o amebasize tools/linux/src/amebasize.c -static
+
+*/
+
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+
+	int size;
+	char filename[512];
+
+	if (argc < 2) {
+		return -1;
+	}
+
+	sprintf(filename, "%s/ram_1.p.bin", argv[1]);
+	FILE* fp_bootloader = fopen(filename, "rb");
+	if (fp_bootloader != NULL) {
+		fseek(fp_bootloader, 0L, SEEK_END);
+		size = ftell(fp_bootloader);
+		fclose(fp_bootloader);
+		printf("bootloader %d\n", size);
+	}
+
+	sprintf(filename, "%s/ram_2.p.bin", argv[1]);
+	FILE* fp_img2 = fopen(filename, "rb");
+	if (fp_img2 != NULL) {
+		fseek(fp_img2, 0L, SEEK_END);
+		size = ftell(fp_img2);
+		fclose(fp_img2);
+		printf("image2 %d\n", size);
+	}
+
+	sprintf(filename, "%s/ram_3.p.bin", argv[1]);
+	FILE* fp_img3 = fopen(filename, "rb");
+	if (fp_img3 != NULL) {
+		fseek(fp_img3, 0L, SEEK_END);
+		size = ftell(fp_img3);
+		fclose(fp_img3);
+		printf("image3 %d\n", size);
+	}
+
+	return 0;
+}

          
A => ameba_tools_linux/tools/linux/src/checksum.c +107 -0
@@ 0,0 1,107 @@ 
+// checksum.cpp : Defines the entry point for the console application.
+
+/*
+
+Compile command:
+	gcc -m32 -o tools/linux/checksum tools/linux/src/checksum.c -static
+
+*/
+
+#if 1
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+	FILE *fp;
+	unsigned int checksum = 0;
+	//unsigned char buf[502000]; //MAX FW Size = 512K-44K/2 = 501760
+	unsigned char *buf;
+	int i;
+	int size = 0;
+
+	if(argc != 2)	return -1;
+
+	fp = fopen(argv[1], "rb+");
+	if(!fp)	return -2;
+
+
+	fseek(fp,0L,SEEK_END);
+	size = ftell(fp);
+	fseek(fp,0L,SEEK_SET);
+	
+	buf = malloc(size+100);
+	if(!buf){
+		fclose(fp);
+		return -3;
+	}
+	
+	printf("size = %d \n\r", size);
+
+	memset(buf, 0, size+100);
+
+	fread(buf, 1, size, fp);
+
+	for(i=0;i<size;i++){
+		checksum += buf[i];
+	}
+	
+	fseek(fp,0L,SEEK_END);
+	
+	fwrite(&checksum, sizeof(int), 1, fp);
+
+	printf("checksum %x\n\r", checksum);
+
+	free(buf);
+	fclose(fp);
+}
+
+#else
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int main(int argc, char *argv[])
+{
+	//FILE *fp;
+	int fd;	
+	unsigned int checksum = 0;
+	
+	if(argc != 2)	return -1;
+
+	//fp = fopen(argv[1], "r+");
+	//if(!fp)	return -2;
+	fd = open(argv[1], O_RDWR);
+	if(fd<0) return -2;
+
+	//fseek(fp, 0, SEEK_SET);
+	lseek(fd, 0, SEEK_SET);
+	int size = lseek(fd, 0, SEEK_END);
+	lseek(fd, 0, SEEK_SET);
+
+	printf("size = %d \n\r", size);
+
+	unsigned char buf[size+100];
+
+	memset(buf, 0, size+100);
+
+	read(fd, buf, size);
+
+	for(int i=0;i<size;i++){
+		checksum += buf[i];
+	}
+	
+	lseek(fd, 0, SEEK_END);
+	
+	write(fd, &checksum, sizeof(int));
+
+	printf("checksum %x\n\r", checksum);
+	close(fd);
+}
+#endif

          
A => ameba_tools_linux/tools/linux/src/padding.c +44 -0
@@ 0,0 1,44 @@ 
+/*
+
+Compile command:
+	gcc -m32 -o tools/linux/padding tools/linux/src/padding.c -static
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void main(int argc, char *argv[])
+{
+	FILE* fp;
+
+	// argv[1] -> length
+	// argv[2] -> data
+	// argv[3] -> output file name
+	char	*unit;
+	int 	length = strtod(argv[1], &unit);
+	char	data = strtod(argv[2], NULL);
+	char	*buf;
+
+	printf("total %d %s, padding data %x, name %s\n", length, unit, data&0xFF, argv[3]);
+	if(unit[0]==0)	length*=1;
+	else if(unit[0]=='K'||unit[0]=='k')	length*=1024;
+	else if(unit[0]=='M'||unit[0]=='m')	length*=(1024*1024);
+	else if(unit[0]=='G'||unit[0]=='g')	length*=(1024*1024);
+	else {
+		printf("unit %s is Not valid\n", unit);
+		return;
+	}
+	fp = fopen(argv[3], "r+b");
+	if(!fp)	return;
+
+	buf = malloc(length);
+	memset(buf, data, length);
+	printf("Original size %zd\n", fread(buf, 1, length, fp));
+	fseek(fp, 0, SEEK_SET);
+	printf("Padding  size %zd\n", fwrite(buf, 1, length, fp));
+	
+	free(buf);
+	fclose(fp);
+}

          
A => ameba_tools_linux/tools/linux/src/pick.c +126 -0
@@ 0,0 1,126 @@ 
+/*
+
+Compile command:
+	gcc -m32 -o tools/linux/pick tools/linux/src/pick.c -static
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h> 
+#include <fcntl.h>
+#include <sys/types.h>
+
+#define PATTERN_1 0x96969999
+#define PATTERN_2 0xFC66CC3F
+#define PATTERN_3 0x03CC33C0
+#define PATTERN_4 0x6231DCE5
+
+unsigned int fw_head[4] = {PATTERN_1, PATTERN_2, PATTERN_3, PATTERN_4};
+unsigned int seg_head[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
+
+int main(int argc, char* argv[])
+{
+	int arg_num = 6;
+
+	if(strstr(argv[5],"head"))	arg_num++;
+
+	if(argc!=arg_num){
+			printf("Usage: pick.exe <start addr> <end addr> <input name> <output name> <body[+offset] , head [image2_start]>\n");
+			return -1;
+	}
+
+	unsigned char *buf;
+
+	unsigned int start;//=atoi(argv[1]);
+	unsigned int end;// = atoi(argv[2]);
+	unsigned int base;
+
+	int is_raw = 0;
+	int is_sig = 0;
+
+	char *inf = argv[3];
+	char *outf = argv[4];
+
+	int size;
+	FILE *ifp, *ofp;
+	
+	//if(argv[1][0]=='0'&&(argv[1][1]=='x'||argv[1][1]=='X'))
+	//	sscanf(argv[1], "0x%x", &start);
+	//else
+	//	start=atoi(argv[1]);
+	start = strtol(argv[1], NULL, 0);
+
+	//if(argv[2][0]=='0'&&(argv[2][1]=='x'||argv[2][1]=='X'))
+	//	sscanf(argv[2], "0x%x", &end);
+	//else
+	//	end=atoi(argv[2]);
+	end = strtol(argv[2], NULL, 0);
+
+	base = start&0xFFFF0000;
+
+	if(strstr(argv[5],"reset_offset")){
+		base = start;
+	}
+
+	if(strstr(argv[5],"raw")){
+		is_raw = 1;
+	}else
+		is_raw = 0;
+
+	if(strstr(argv[5],"sig")){
+		is_sig = 1;
+	}else
+		is_sig = 0;
+
+	printf("b:%d s:%d e:%d\n", base, start, end);
+	//printf("%s %s\n", inf, outf);	
+
+	ifp = fopen(inf, "rb");
+	if(!ifp)	return -2;
+	ofp = fopen(outf, "wb");
+	if(!ofp)	return -3;
+
+	fseek(ifp, 0, SEEK_END);
+	size = ftell(ifp);
+	
+	printf("size %d\n", size);
+	buf = malloc(size);
+	if(!buf)	return -4;
+
+	if(end==0)	end = base+size;
+
+	if( end-start+1 > 0){	
+		fseek(ifp, start-base, SEEK_SET);
+		fread(buf, end-start, 1, ifp);
+		if(is_raw==0){
+			if(strcmp(argv[5],"head")==0){
+				int offset = strtol(argv[6], NULL, 0);
+				printf("append fw head %x\n", offset);
+				fwrite(fw_head, 4, sizeof(unsigned int), ofp);
+				seg_head[2] = (0xFFFF0000|(offset/1024));
+			}else{
+				if(is_sig){
+					seg_head[2] = 0x35393138;
+					seg_head[3] = 0x31313738;
+				}else{
+					seg_head[2] = 0xFFFFFFFF;
+					seg_head[3] = 0xFFFFFFFF;
+				}
+			}
+			seg_head[0] = end-start;
+			seg_head[1] = start;
+			fwrite(seg_head, 4, sizeof(unsigned int), ofp);
+		}
+		fwrite(buf, end-start, 1, ofp);
+			
+	}	
+	printf("copy size %d\n", end-start);
+	fclose(ifp);
+	fclose(ofp);
+	free(buf);
+
+	return 0;
+}

          
A => ameba_tools_linux/tools/linux/src/postbuild_img2_arduino_linux.cpp +209 -0
@@ 0,0 1,209 @@ 
+/*
+
+compile command:
+    g++ -m32 -o postbuild_img2_arduino_linux tools/linux/src/postbuild_img2_arduino_linux.cpp -static
+
+*/
+
+#include <iostream>
+#include <sstream>
+#include <cstring>
+#include <cstdlib>
+#include <fstream>
+#include <unistd.h>
+#include <vector>
+
+using namespace std;
+
+int main(int argc, char *argv[]) {
+
+	int ret = 0;
+    stringstream cmdss;
+    string cmd, line, msg;
+	vector<string> lines;
+	vector<string>::iterator iter;
+    string path_tool;
+    string path_arm_none_eabi_gcc;
+	string path_symbol_black_list;
+	string bksym;
+    ifstream fin;
+
+    bool has_sdram = false;
+    string sram_start_st = "", sram_end_st = "", sdram_start_st = "", sdram_end_st = "";
+    unsigned int sram_start = 0, sram_end = 0, sdram_start = 0, sdram_end = 0;
+
+    size_t pos;
+
+    // 0. change work folder
+    chdir(argv[1]);
+
+    // 1. copy elf application.axf to current folder
+    cmdss.clear();
+    cmdss << "cp " << argv[2] << " ./";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    // 2. remove previous files
+    cmd = "rm -f application.map";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    cmd = "rm -f application.asm";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    cmd = "rm -f *.bin";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    // 3. generate information files
+    path_arm_none_eabi_gcc.assign(argv[3]);
+
+    cmdss.clear();
+    cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-nm --numeric-sort application.axf > application.map";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    fin.open("application.map");
+    while( getline(fin, line) ) {
+        lines.push_back(line);
+    }
+    fin.close();
+
+    cmdss.clear();
+    cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objdump -d application.axf > application.asm";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+	// 3.1 check if any forbidden symbols
+	path_symbol_black_list.assign(argv[4]);
+	fin.open(path_symbol_black_list.c_str(), ifstream::in);
+	cout << path_symbol_black_list << endl;
+	ret = 0;
+	if (fin) {
+		while ( !fin.eof() && ret == 0) {
+			fin >> bksym;
+			getline(fin, msg);
+
+			// check if this symbole appears in the map file
+			for (iter = lines.begin(); iter != lines.end(); ++iter) {
+				if ( (iter->find(bksym)) != string::npos ) {
+					cerr << endl << "ERROR: " << msg << endl << endl;
+					ret = -1;
+					break;
+				}
+			}
+		}
+	}
+	fin.close();
+
+	if (ret != 0) {
+		return -1;
+	}
+
+    // 4. grep sram and sdram information
+    for (iter = lines.begin(); iter != lines.end(); ++iter) {
+        line = *iter;
+        pos = line.find("__ram_image2_text_start__");
+        if ( pos != string::npos ) {
+            sram_start_st = line.substr(0, pos-3);
+            sram_start = strtol(sram_start_st.c_str(), NULL, 16);
+        }
+        pos = line.find("__ram_image2_text_end__");
+        if ( pos != string::npos ) {
+            sram_end_st = line.substr(0, pos-3);
+            sram_end = strtol(sram_end_st.c_str(), NULL, 16);
+        }
+        pos = line.find("__sdram_data_start__");
+        if ( pos != string::npos ) {
+            sdram_start_st = line.substr(0, pos-3);
+            sdram_start = strtol(sdram_start_st.c_str(), NULL, 16);
+        }
+        pos = line.find("__sdram_data_end__");
+        if ( pos != string::npos ) {
+            sdram_end_st = line.substr(0, pos-3);
+            sdram_end = strtol(sdram_end_st.c_str(), NULL, 16);
+        }
+    }
+
+    if (sdram_start > 0 && sdram_end > 0) {
+        has_sdram = true;
+    }
+
+    cout << "sram  " << sram_start_st << " ~ " << sram_end_st << endl;
+    if (has_sdram) {
+        cout << "sdram " << sdram_start_st << " ~ " << sdram_end_st << endl;
+    }
+
+    // 5. generate image 2 and image 3
+    cmdss.clear();
+    cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objcopy -j .image2.start.table -j .ram_image2.text -j .ram.data -Obinary ./application.axf ./ram_2.bin";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    if (has_sdram) {
+        cmdss.clear();
+        cmdss << path_arm_none_eabi_gcc << "arm-none-eabi-objcopy -j .image3 -j .ARM.exidx -j .sdr_data -Obinary ./application.axf ./sdram.bin";
+        getline(cmdss, cmd);
+        cout << cmd << endl;
+        system(cmd.c_str());
+    }
+
+    // 6. fulfill header
+    cmdss.clear();
+    cmdss << "./tools/linux/pick " << sram_start << " " << sram_end << " ram_2.bin ram_2.p.bin body+reset_offset+sig";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    cmdss.clear();
+    cmdss << "./tools/linux/pick " << sram_start << " " << sram_end << " ram_2.bin ram_2.ns.bin body+reset_offset";
+    getline(cmdss, cmd);
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    if (has_sdram) {
+        cmdss.clear();
+        cmdss << "./tools/linux/pick " << sdram_start << " " << sdram_end << " sdram.bin ram_3.p.bin body+reset_offset";
+        getline(cmdss, cmd);
+        cout << cmd << endl;
+        system(cmd.c_str());
+    }
+
+    // 7. prepare image 1
+    cmd = "cp bsp/image/ram_1.p.bin ./";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    cmd = "./tools/linux/padding 44k 0xFF ram_1.p.bin";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    // 8. generate ram_all.bin
+    if (has_sdram) {
+        cmd = "cat ram_1.p.bin ram_2.p.bin ram_3.p.bin > ram_all.bin";
+        cout << cmd << endl;
+        system(cmd.c_str());
+        cmd = "cat ram_2.ns.bin ram_3.p.bin > ota.bin";
+        cout << cmd << endl;
+        system(cmd.c_str());
+    } else {
+        cmd = "cat ram_1.p.bin ram_2.p.bin > ram_all.bin";
+        cout << cmd << endl;
+        system(cmd.c_str());
+        cmd = "cat ram_2.ns.bin > ota.bin";
+        cout << cmd << endl;
+        system(cmd.c_str());
+    }
+
+    // 9. add checksum
+    cmd = "./tools/linux/checksum ota.bin";
+    cout << cmd << endl;
+    system(cmd.c_str());
+
+    return 0;
+}

          
A => ameba_tools_linux/tools/linux/src/upload_dap_linux.cpp +87 -0
@@ 0,0 1,87 @@ 
+/*
+
+Compile command:
+	g++ -m32 -o upload_dap_linux tools/linux/src/upload_dap_linux.cpp -static
+
+*/
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <cstring>
+#include <cstdlib>
+#include <string>
+#include <cstdio>
+#include <sys/stat.h>
+
+using namespace std;
+
+bool isFileExist(string path) {
+	bool ret = false;
+	struct stat info;
+
+	do {
+		if (stat(path.c_str(), &info) != 0) {
+			break;
+		}
+
+		ret = true;
+	} while (0);
+
+	return ret;
+}
+
+int main(int argc, char *argv[]) {
+
+	int i;
+	bool mbed_disk_found = false;
+
+	string cmd;
+	vector<string> lines;
+	vector<string>::iterator iter;
+
+	stringstream ss;
+	string disk_caption;
+	string disk_volumename;
+	string filepath;
+
+	string filepath_ram_all;
+	if (argc >= 2) {
+		// the path of ram_all.bin is feed from arg
+		filepath_ram_all.assign(argv[1]);
+	} else {
+		// assume ram_all.bin is in current path
+		filepath_ram_all.assign("ram_all.bin");
+	}
+
+	do {
+		// 2. check if MBED disk is accessable
+		char *puser = getenv("USER");
+		filepath = "/media/";
+		filepath.append(puser);
+		filepath.append("/MBED/mbed.htm");
+		if (!isFileExist(filepath)) {
+			cout << "ERR: Cannot access mbed driver!" << endl;
+			break;
+		}
+
+		// 3. check if ram_all.bin exist
+		if (!isFileExist(filepath_ram_all)) {
+			cout << "ERR: Cannot find ram_all.bin!" << endl;
+			break;
+		}
+
+		// 4. copy ram_all.bin into mbed device
+		cout << "uploading..." << endl;
+		cmd = "cp \"" + filepath_ram_all;
+		cmd.append("\" /media/");
+		cmd.append(puser);
+		cmd.append("/MBED/;sync");
+		cout << cmd << endl;
+		system(cmd.c_str());
+
+		cout << "upload finish" << endl;
+	} while (0);
+
+	return 0;
+}

          
A => ameba_tools_linux/tools/linux/src/upload_ota_linux.c +187 -0
@@ 0,0 1,187 @@ 
+/*
+
+Compile command:
+	gcc -m32 -o upload_ota_linux tools/linux/src/upload_ota_linux.c -static
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include "getopt.h"
+
+#define BUF_SIZE 256
+
+#define CMD_FILENAME    0x01
+#define CMD_IP          0x02
+#define CMD_PORT        0x04
+#define CMD_HELP        0x08
+
+#define CHUNK_SIZE 1460
+
+static struct option long_options[] = {
+    {"file",      required_argument, 0, 'f'},
+    {"interface", required_argument, 0, 'i'},
+    {"port",      required_argument, 0, 'p'},
+    {"help",      no_argument,       0, 'h'},
+    {0,           0,                 0,  0 }
+};
+
+void dumpMenu() {
+    printf("Usage: upload_ota\r\n");
+    printf("  -f  --file       the OTA image to be uploaded\r\n");
+    printf("  -i  --interface  the network ip address\r\n");
+    printf("  -p  --port       the network port\r\n");
+    printf("  -h  --help\r\n");
+}
+
+void ota_process(char *filename, char *ipstring, int port) {
+
+    FILE *pFile;
+    struct stat info;
+    uint32_t ota_description[3];
+    long filesize;
+    unsigned char *ota_buf = NULL;
+
+    uint32_t checksum = 0;
+
+    int s;
+    struct sockaddr_in server;
+    int i, n;
+    int processed_size;
+
+    printf("file: %s\r\n", filename);
+    printf("ip: %s\r\n", ipstring);
+    printf("port: %d\r\n", port);
+
+    do {
+        pFile = fopen(filename, "rb");
+        if ( pFile == NULL ) {
+            printf("ERR: Fail to open file: %s\r\n", filename);
+            break;
+        }
+
+        // get file size;
+        fseek(pFile, 0L, SEEK_END);
+        filesize = ftell(pFile);
+        fseek(pFile, 0, SEEK_SET);
+
+        ota_buf = (unsigned char *) malloc (filesize);
+        if (ota_buf == NULL) {
+            printf("ERR: no enough memory\r\n");
+            break;
+        }
+        fread(ota_buf, 1, filesize, pFile);
+        fclose(pFile);
+
+        checksum = 0;
+        for (i=0; i<filesize; i++) {
+            checksum += (ota_buf[i] & 0xff);
+        }
+
+        s = socket(AF_INET, SOCK_STREAM, 0);
+        if (s < 0) {
+            printf("ERR: Could not create socket\r\n");
+            break;
+        }
+
+        server.sin_addr.s_addr = inet_addr(ipstring);
+        server.sin_family = AF_INET;
+        server.sin_port = htons( port );
+
+        printf("Try to connect...\r\n");
+        if ( connect(s, (struct sockaddr *)&server, sizeof(server)) < 0 ) {
+            printf("ERR: Connect error\r\n");
+            break;
+        }
+
+        ota_description[0] = checksum;
+        ota_description[1] = 0;
+        ota_description[2] = (uint32_t) filesize;
+
+        printf("Send OTA info...\r\n");
+        n = send(s, (unsigned char *)ota_description, sizeof(ota_description), 0);
+        if (n < 0) {
+            printf("ERR: fail to send OTA description\r\n");
+            break;
+        }
+
+        printf("String uploading...\r\n");
+        n = send(s, (const char *)ota_buf, filesize, 0);
+        if (n < 0) {
+            printf("ERR: fail to send OTA image\r\n");
+            break;
+        }
+
+        close(s);
+
+        printf("Upload success\r\n");
+
+    } while (0);
+
+    if (ota_buf != NULL) {
+        free(ota_buf);
+        ota_buf = NULL;
+    }
+}
+
+int main(int argc, char *argv[]) {
+
+    int c;
+    int opt_idx = 0;
+
+    unsigned char cmd = 0;
+
+    char filename[BUF_SIZE];
+    char ipstring[16];
+    char portstring[10];
+    int port;
+
+    while (1) {
+        c = getopt_long(argc, argv, "f:i:p:h?", long_options, &opt_idx);
+
+        if (c== -1) break;
+
+        switch (c) {
+            case 'f':
+                sprintf(filename, "%s", optarg);
+                cmd |= CMD_FILENAME;
+                break;
+            case 'i':
+                if (strlen(optarg) < 16) {
+                    sprintf(ipstring, "%s", optarg);
+                    cmd |= CMD_IP;
+                }
+                break;
+            case 'p':
+                if (strlen(optarg) < 10) {
+                    sprintf(portstring, "%s", optarg);
+                    cmd |= CMD_PORT;
+                }
+                break;
+            case 'h':
+            case '?':
+            default:
+                cmd |= CMD_HELP;
+                break;
+        }
+    }
+
+    if (cmd & CMD_HELP) {
+        dumpMenu();
+    } else if (cmd & (CMD_FILENAME | CMD_IP | CMD_PORT)) {
+        port = atoi(portstring);
+        ota_process(filename, ipstring, port);
+    } else {
+        dumpMenu();
+    }
+
+    return 0;
+}
+

          
A => ameba_tools_linux/upload_dap_linux +0 -0

        
A => ameba_tools_linux/upload_ota_linux +0 -0