From cdf15801f4de2e7e1f7ee82c021180e3e1c9ef4b Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Sat, 19 Feb 2022 15:47:15 +0100 Subject: [PATCH] BK7231N OTA support - not tested yet (the OTA address seems different) --- src/httpserver/rest_interface.c | 4 ++-- src/ota/ota.c | 4 +++- src/ota/ota.h | 12 ++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index a460ccbb0..b78b66420 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -533,7 +533,7 @@ static int http_rest_post(http_request_t *request){ return http_rest_post_reboot(request); } if (!strcmp(request->url, "api/ota")){ - return http_rest_post_flash(request, 0x132000); + return http_rest_post_flash(request, START_ADR_OF_BK_PARTITION_OTA); } if (!strncmp(request->url, "api/flash/", 10)){ return http_rest_get_flash_advanced(request); @@ -736,7 +736,7 @@ static int http_rest_post_flash_advanced(http_request_t *request){ int startaddr = 0; int sres; sres = sscanf(params, "%x", &startaddr); - if (sres == 1 && startaddr >= 0x132000){ + if (sres == 1 && startaddr >= START_ADR_OF_BK_PARTITION_OTA){ return http_rest_post_flash(request, startaddr); } return http_rest_error(request, -1, "invalid url"); diff --git a/src/ota/ota.c b/src/ota/ota.c index 2d64919c8..5a663e1a3 100644 --- a/src/ota/ota.c +++ b/src/ota/ota.c @@ -1,4 +1,5 @@ +#include "ota.h" #include "../new_common.h" #include "typedef.h" #include "flash_pub.h" @@ -108,7 +109,8 @@ int myhttpclientcallback(httprequest_t* request){ switch(request->state){ case 0: // start //init_ota(0xff000); - init_ota(0x132000); + + init_ota(START_ADR_OF_BK_PARTITION_OTA); addLog("\r\nmyhttpclientcallback state %d total %d/%d\r\n", request->state, total_bytes, request->client_data.response_content_len); break; case 1: // data diff --git a/src/ota/ota.h b/src/ota/ota.h index 8baf0ebc9..af5072a74 100644 --- a/src/ota/ota.h +++ b/src/ota/ota.h @@ -1,5 +1,17 @@ +// NOTE: this offset was taken from BkDriverFlash.c +// search for BK_PARTITION_OTA + +#if PLATFORM_BK7231T +#define START_ADR_OF_BK_PARTITION_OTA 0x132000 +#elif PLATFORM_BK7231N +#define START_ADR_OF_BK_PARTITION_OTA 0x12A000 +#else +// TODO +#define START_ADR_OF_BK_PARTITION_OTA 0x132000 +#endif + // initialise OTA flash starting at startaddr int init_ota(unsigned int startaddr);