Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Jun 2, 2018
2 parents f49965f + 9edb0cb commit 4eb919f
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
hex
*.vscode
ftest
platform/compilation/fota/unix
42 changes: 31 additions & 11 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ if "%1%"x =="demo"x (
if "%1%"x =="clean"x (
goto clean_project
) else (
if exist "%1%" (
set PROJ_NAME=%1%
if "%2%"x =="release"x (
set compileMode=release
)
sed -i "15d" Makefile
sed -i "15i\LOCAL_MODULE_DEPENDS += %1%" Makefile
goto compile
REM goto end_exit
if "%1%"x =="fota"x (
goto run_fota
) else (
echo param %1% is not illege
goto usage_help
if exist "%1%" (
set PROJ_NAME=%1%
if "%2%"x =="release"x (
set compileMode=release
)
sed -i "15d" Makefile
sed -i "15i\LOCAL_MODULE_DEPENDS += %1%" Makefile
goto compile
REM goto end_exit
) else (
echo param %1% is not illege
goto usage_help
)
)
)
)
Expand Down Expand Up @@ -100,8 +104,24 @@ if "%1%"x =="demo"x (
echo clean complete
goto end_exit

:run_fota
if exist "%2%" (
if exist "%3%" (
echo waiting for making fota pack...
echo this will take a few minutes
REM platform\compilation\fota\fotacreate.exe 4194304 65536 0.lod 1.lod 0.pack
platform\compilation\fota\fotacreate.exe 4194304 65536 %2% % %3% % %4%
) else (
echo usage: 'build.bat fota old.lod new.lod fota.pack'
)
) else (
echo usage: 'build.bat fota old.lod new.lod fota.pack'
)
goto end_exit

:usage_help
echo usage:
echo use 'build.bat fota old.lod new.lod fota.pack'
echo use 'build.bat PROJECTNAME' to build the project in ./PROJECTNAME
echo eg: build.bat app
echo use 'build.bat demo PROJECTNAME' to build demo in ./demo/PROJECTNAME
Expand Down
14 changes: 14 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
function help()
{
echo "Usage:"
echo "use ./build.bat fota old.lod new.lod fota.pack"
echo "use './build.sh PROJECTNAME' to build the project in ./PROJECTNAME "
echo " eg: ./build.sh app "
echo "use './build.sh demo PROJECTNAME' to build demo in ./demo/PROJECTNAME "
Expand Down Expand Up @@ -131,6 +132,19 @@ elif [[ $paramNum -eq 2 ]]; then
sed -i '15d' Makefile
sed -i "15i\LOCAL_MODULE_DEPENDS += project/$2" Makefile
fi
elif [[ $paramNum -eq 4 ]]; then
if [[ "$1x" == "fotax" ]]; then
if [ -f "$2" ]; then
if [ -f "$3" ]; then
echo "waiting for making fota pack..."
echo "this will take a few minutes"
platform/compilation/fota/fotacreate.exe 4194304 65536 $2 $3 $4
exit 0
fi
fi
fi
help
exit 0
else
help
exit 0
Expand Down
4 changes: 2 additions & 2 deletions demo/fota/src/demo_fota.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

void fota_Main(void)
{
// FOTA_UartTest();
FOTASERVER_Test();
FOTA_UartTest();
// FOTASERVER_Test();
}

4 changes: 2 additions & 2 deletions demo/fota/src/fota_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define MAIN_TASK_NAME "FOTA SERVER Test Task"


#define SOFT_VERSION "V1.0"
#define SOFT_VERSION "V3.0"
#define FOTA_HTTP_SERVER "http://www.vencol.top:8100/fota/%stonew.pack"


Expand Down Expand Up @@ -88,7 +88,7 @@ static void FOTASERVER_TestTask()
while(1)
{
static int times = 0;
Trace(1,"fota server new:%d",++times);
Trace(1,"fota server is new %s:%d", SOFT_VERSION, ++times);
OS_Sleep(5000);
}
}
Expand Down
4 changes: 2 additions & 2 deletions demo/fota/src/fota_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void FOTA_ReceivedData(UINT8 *data, UINT16 len)

upgrade_faile:
Trace(1,"uart fota false");
API_FotaClean();
// API_FotaClean();
return ;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ static void FOTAUART_TestTask()
};
OS_Sleep(1000);//no task
API_Event_t* event=NULL;
Trace(1,"uart2 init is ");
Trace(1,"uart2 init is master");
UART_Init(UART1,config);

while(1)
Expand Down
Binary file added doc/assets/fota_success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions demo/fota/fota_readme.md → doc/gprs_fota_zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# FOTA使用说明
## 1.整体流程
* 保留旧固件包
* 生成新的固件包
* 使用脚本生成ota包,old参数是旧包所在位置,new参数是新包所在位置,最后生成两个用于上传的ota包
* 保留旧固件包,如V1_ota.lod
* 生成新的固件包,如V2_ota.lod
* 使用脚本命令生成差异包,如
```
python platform\compilation\lodCombine.py --opt otapack --old fota\fota_B1508_debug-fold.lod --new fota\fota_B1508_debug-fnew.lod
build.bat fota V1_ota.lod V2_ota.lod V1toV2.pack
参数解释:
V1_ota.lod 旧固件所在路径(可相对于build.bat,也可使用绝对路径)
V2_ota.lod 需要更新固件所在路径(可相对于build.bat,也可使用绝对路径)
V1toV2.pack 生成的差异包(放到服务器上的)
```
* 把两个ota包按照相应的位置上传,选择旧包位置,选择新包位置,点击create
```
![](./doc/assets/fota.png)
```
* 保留生成的pack,可以先通过uart进行本地升级测试,再进行fota测试,具体参考代码GPRS_C_SDK\demo\fota\fota_uart.c
* 如果没有提示出错,![成功如图](./assets/fota_success.png)
* 保留生成的pack,可以先通过uart进行本地升级测试,再进行server测试,具体参考代码GPRS_C_SDK\demo\fota\fota_uart.c
* 把生成的pack包放到http文件服务器上
* 修改GPRS_C_SDK\demo\fota\fota_server.c代码中http的url,实现fota
```
Expand Down
15 changes: 10 additions & 5 deletions platform/compilation/cust_rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ ifeq ($(MAKELEVEL),0)
ifeq "$(strip $(CT_RELEASE))" ""
export CT_RELEASE := debug
endif

export tepath := ${SOFT_WORKDIR}/platform/compilation/

VALID_RELEASE_LIST :=release debug
SELECTED_RELEASE := $(filter $(VALID_RELEASE_LIST), $(CT_RELEASE))
ifeq "$(SELECTED_RELEASE)" ""
Expand Down Expand Up @@ -412,6 +415,7 @@ endif #AM_CONFIG_SUPPORT
ifneq "${AM_PLT_LOD_FILE}" ""
PLT_LOD_VERSION := $(shell echo ${AM_PLT_LOD_FILE} | sed 's/.*SW_V\([0-9]*\).*\.lod$$/B\1/')
WITH_PLT_LOD_FILE := ${BAS_FINAL}_${PLT_LOD_VERSION}_${CT_RELEASE}.lod
WITH_PLT_OTA_FILE := ${BAS_FINAL}_${PLT_LOD_VERSION}_${CT_RELEASE}_ota.lod
CFG_Lod_File_WITH_PLT := `echo ${BAS_FINAL}_\`echo ${AM_PLT_LOD_FILE} | sed 's/.*SW_V\([0-9]*\).*\.lod$$/B\1/'\`.lod | sed 's/.*\(SW_.*\.lod\)$$/\1/'`
endif

Expand Down Expand Up @@ -625,13 +629,14 @@ else
ifneq "${AM_PLT_LOD_FILE}" ""
@${ECHO}
@${ECHO} "LODTOBIN $(LOD_FILE)"
# $(LOD_TO_BIN) ${LOD_FILE} -0
# $(LODCOMBINE_TOOL) openat -l $(AM_PLT_LOD_FILE) -i $(LOD_FILE) -o $(WITH_PLT_LOD_FILE);
# $(LOD_TO_BIN) ${LOD_FILE} -0 \
# python $(LODPYCOMBINE_TOOL) --opt merge --bl $(AM_PLT_LOD_FILE) --lod $(LOD_FILE) --output $(WITH_PLT_LOD_FILE); \
# $(LODCOMBINE_TOOL) openat -l $(tepath)SW_V2000_csdk.lod -i $(tepath)uart_flash_debug.lod -o $(tepath)test.lod -u $(tepath)testota.lod;
${ECHO} "LODTOBIN Sucessful"
@${ECHO} "LODPYCOMBINE Combine user lod with Platform lod"
@${ECHO} "LODCOMBINE Combine user lod with Platform lod"
if [ -f $(LOD_FILE) ]; then \
if [ -f $(AM_PLT_LOD_FILE) ]; then \
python $(LODPYCOMBINE_TOOL) --opt merge --bl $(AM_PLT_LOD_FILE) --lod $(LOD_FILE) --output $(WITH_PLT_LOD_FILE); \
if [ -f $(AM_PLT_LOD_FILE) ]; then \
$(LODCOMBINE_TOOL) openat -l $(AM_PLT_LOD_FILE) -i $(LOD_FILE) -o $(WITH_PLT_LOD_FILE) -u $(WITH_PLT_OTA_FILE); \
if [ $$? -gt 0 ]; then \
${ECHO} "LODCOMBINE Combine failed"; \
exit 1; \
Expand Down
Binary file added platform/compilation/fota/fotacreate.exe
Binary file not shown.
Binary file added platform/compilation/fota/fotasdk.dll
Binary file not shown.
75 changes: 75 additions & 0 deletions platform/compilation/fota/fotasdk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Copyright (C) 2017 RDA Technologies Limited and/or its affiliates("RDA").
* All rights reserved.
*
* This software is supplied "AS IS" without any warranties.
* RDA assumes no responsibility or liability for the use of the software,
* conveys no license or title under any patent, copyright, or mask work
* right to the product. RDA reserves the right to make changes in the
* software without notification. RDA also make no representation or
* warranty that such application will be suitable for the specified use
* without further testing or modification.
*/

#ifndef _FOTA_SDK_H_
#define _FOTA_SDK_H_

#ifdef _WIN32
#ifdef FOTASDK_EXPORTS
#define FOTASDK_CAPI extern "C" __declspec(dllexport)
#else
#define FOTASDK_CAPI extern "C" __declspec(dllimport)
#endif
#else
#ifdef FOTASDK_EXPORTS
#define FOTASDK_CAPI extern "C" __attribute__((__visibility__("default")))
#else
#define FOTASDK_CAPI extern "C"
#endif
#endif

enum
{
ERR_INVALID_SECTOR_SIZE = 1, // must be 2^n
ERR_CODE_BASE_UNALIGNED,
ERR_CODE_SIZE_UNALIGNED,
ERR_FOTA_END_UNAIGNED, // FOTA area end must be block aligned
ERR_FOTA_START_UNALIGNED, // FOTA area start must be sector aligned
ERR_FOTA_INVALID_AREA, // FOTA area not in FLASH range
ERR_FAIL_READ_OLD,
ERR_FAIL_READ_NEW,
ERR_OLD_TOO_MANY_PACKET, // must be contiguous
ERR_OLD_SIZE_UNALIGNED, // must be sector aligned
ERR_OLD_BASE_MISMATCH,
ERR_OLD_SIZE_OVERFLOW,
ERR_NEW_TOO_MANY_PACKET, // must be contiguous
ERR_NEW_SIZE_UNALIGNED, // must be sector aligned
ERR_NEW_BASE_MISMATCH,
ERR_NEW_SIZE_OVERFLOW,
ERR_FAIL_WRITE_PACK,
ERR_FAIL_READ_PACK,
ERR_VERIFY_PACK_INVALID,
ERR_VERIFY_UPGRADE_FAIL,
ERR_VERIFY_UPGRADE_CLEAN_FAIL,
ERR_VERIFY_CMP_FAIL
};

struct FotaFlashParam
{
unsigned pysicalBase; // FLASH physical address, such as 0x08000000
unsigned codeFlashBase; // FLASH base for code (must be sector aligned)
unsigned codeFlashSize; // FLASH size for code (must be sector aligned)
};

// File name strings are encoded as UTF-8

FOTASDK_CAPI int FotaCreatePack(const char *olodfname, // input old LOD file name
const char *nlodfname, // input new LOD file name
const char *patchfname, // output patch file name
unsigned *oldstart, // return old LOD start
unsigned *oldsize, // return old LOD size
unsigned *oldcrc, // return old data CRC
struct FotaFlashParam flash);

FOTASDK_CAPI const char *FotaErrorMsg(int result);

#endif
Binary file added platform/compilation/fota/fotasdk.lib
Binary file not shown.
Binary file added platform/compilation/fota/platforms/qwindows.dll
Binary file not shown.
Loading

0 comments on commit 4eb919f

Please sign in to comment.