diff --git a/app/bmc/webserver.c b/app/bmc/webserver.c index 57c2b417..5bbc240e 100755 --- a/app/bmc/webserver.c +++ b/app/bmc/webserver.c @@ -410,6 +410,7 @@ static int get_ubi_num(void) return ret; } +static const char* swupdate_file = "/mnt/sdcard/update.bin"; static int swupdate_cmd(void) { char cmd[256] = {0}; @@ -422,7 +423,7 @@ static int swupdate_cmd(void) printf("error\n"); return -1; } - snprintf(cmd,sizeof(cmd),"swupdate -i %s -e stable,upgrade_ubi%d",updateFilePath,ver); + snprintf(cmd,sizeof(cmd),"swupdate -i %s -e stable,upgrade_ubi%d",swupdate_file,ver); FILE* pp = popen(cmd,"r"); if(pp) { @@ -482,40 +483,61 @@ static int swupdate_cmd(void) printf("--------------UPDATE faild--------------------\n"); } printf("=================system will reboot ====================\n"); + sprintf(cmd,"rm %s",swupdate_file); + system(cmd); sleep(3); system("reboot"); // reboot(); } +static bool isMountSDcard(char* mountPoint) +{ + if(NULL == mountPoint) + return false; + int fd = -1; + char buff[1024]; + if((fd = open("/proc/mounts",O_RDONLY)) < 0) + { + printf("open /proc/mounts error\n"); + return false; + } + while(read(fd,buff,1024)>0) + { + if(strstr(buff,mountPoint)) + { + close(fd); + return true; + } + } + close(fd); + return false; +} + + - //TODO static void uploadFirmware(Webs *wp) { WebsKey *s; WebsUpload *up; + char cmd[128]; char sessionIdBuf[128] = {0}; int sessionIdBufLen = sizeof(sessionIdBuf); -// if (websCheckSession(wp, sessionIdBuf, &sessionIdBufLen) == 0) -// { -// Printf("get wp->session NULL\n"); -// websSetStatus(wp, 401); -// websWriteHeaders(wp, -1, 0); -// websWriteHeader(wp, "Content-Type", "text/plain"); -// websWriteEndHeaders(wp); -// websWrite(wp,"{\"response\":[{\"result\":\"err:login auth\"}]}"); -// websDone(wp); -// return ; -// } - websSetStatus(wp, 200); websWriteHeaders(wp, -1, 0); websWriteHeader(wp, "Content-Type", "text/plain"); -// websWriteEndHeaders(wp); websWriteEndHeaders(wp); + + if(!isMountSDcard("/mnt/sdcard")) + { + websWrite(wp,"{\"response\":[{\"result\":\"err:no sdcard\"}]}"); + websDone(wp); + return ; + } + if (scaselessmatch(wp->method, "POST")) { for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) { up = (WebsUpload*)(s->content.value.symbol); @@ -528,6 +550,8 @@ static void uploadFirmware(Webs *wp) websWrite(wp, "%s=%s\r\n", s->name.value.string, s->content.value.string); } } + sprintf(cmd,"mv %s %s;sync",updateFilePath,swupdate_file); + system(cmd); websWrite(wp,"{\"response\":[{\"result\":\"ok\"}]}"); websDone(wp); printf("upload Filename=%s\n",up->clientFilename); diff --git a/br2t113pro/board/100ask/dragon/sys_partition-bak.bin b/br2t113pro/board/100ask/dragon/sys_partition-bak.bin deleted file mode 100644 index 703b7550..00000000 Binary files a/br2t113pro/board/100ask/dragon/sys_partition-bak.bin and /dev/null differ diff --git a/br2t113pro/board/100ask/dragon/sys_partition.bin b/br2t113pro/board/100ask/dragon/sys_partition.bin index b6cd5cfd..b882f11e 100644 Binary files a/br2t113pro/board/100ask/dragon/sys_partition.bin and b/br2t113pro/board/100ask/dragon/sys_partition.bin differ diff --git a/br2t113pro/board/100ask/dragon/sys_partition.fex b/br2t113pro/board/100ask/dragon/sys_partition.fex index 2afc2021..3db72b3d 100644 --- a/br2t113pro/board/100ask/dragon/sys_partition.fex +++ b/br2t113pro/board/100ask/dragon/sys_partition.fex @@ -35,7 +35,7 @@ size = 16384 [partition] name = boot-resource - size = 34438 + size = 8192 downloadfile = "boot-resource.fex" user_type = 0x8000 @@ -54,19 +54,19 @@ size = 16384 [partition] name = boot - size = 35200 + size = 8192 downloadfile = "boot.fex" user_type = 0x8000 [partition] name = rootfs - size = 65536 + size = 81920 downloadfile = "rootfs-ubifs.fex" user_type = 0x8000 [partition] - name = rootfsbak - size = 65536 + name = recovery + size = 81920 downloadfile = "rootfs-ubifs.fex" user_type = 0x8000 @@ -85,4 +85,3 @@ size = 16384 [partition] name = UDISK user_type = 0x8100 -