bk7231n flash vars hals fixes

This commit is contained in:
openshwprojects
2022-04-17 18:13:33 +02:00
parent 997c1eeaee
commit 9a7d59ec3d
7 changed files with 139 additions and 157 deletions

View File

@@ -11,6 +11,7 @@
#include "../hal/hal_wifi.h"
#include "../hal/hal_pins.h"
#include "../hal/hal_flashConfig.h"
#include "../logging/logging.h"
#ifdef WINDOWS
// nothing
@@ -19,18 +20,14 @@
#elif PLATFORM_XR809
#include <image/flash.h>
#elif defined(PLATFORM_BK7231N)
#include "../logging/logging.h"
// tuya-iotos-embeded-sdk-wifi-ble-bk7231n/sdk/include/tuya_hal_storage.h
#include "tuya_hal_storage.h"
#include "BkDriverFlash.h"
#include "../flash_config/flash_config.h"
#else
// REALLY? A typo in Tuya SDK? Storge?
// tuya-iotos-embeded-sdk-wifi-ble-bk7231t/platforms/bk7231t/tuya_os_adapter/include/driver/tuya_hal_storge.h
#include "../logging/logging.h"
#include "tuya_hal_storge.h"
#include "BkDriverFlash.h"
#include "../flash_config/flash_config.h"
#endif
@@ -207,9 +204,7 @@ int http_fn_index(http_request_t *request) {
#ifndef OBK_DISABLE_ALL_DRIVERS
DRV_AppendInformationToHTTPIndexPage(request);
#endif
// strcat(outbuf,"<button type=\"button\">Click Me!</button>");
if(http_getArg(request->url,"restart",tmpA,sizeof(tmpA))) {
poststr(request,"<h5> Module will restart soon</h5>");
RESET_ScheduleModuleReset(3);
@@ -224,7 +219,7 @@ int http_fn_index(http_request_t *request) {
poststr(request,"<form action=\"about\"><input type=\"submit\" value=\"About\"/></form>");
hprintf128(request,"<h3>Cfg size: %i, change counter: %i, ota counter: %i, boot fails %i!</h3>",
hprintf128(request,"<h5>Cfg size: %i, change counter: %i, ota counter: %i, boot incompletes %i (might change to 0 if you wait to 30 sec)!</h5>",
sizeof(g_cfg),g_cfg.changeCounter,g_cfg.otaCounter,Main_GetLastRebootBootFailures());
poststr(request,htmlReturnToMenu);
@@ -239,7 +234,7 @@ int http_fn_about(http_request_t *request){
http_setup(request, httpMimeTypeHTML);
poststr(request,htmlHeader);
poststr(request,g_header);
poststr(request,"About us page.");
poststr(request,"<h2>Open source firmware for BK7231N, BK7231T, XR809 and BL602 by OpenSHWProjects</h2>");
poststr(request,htmlReturnToMenu);
HTTP_AddBuildFooter(request);
poststr(request,htmlEnd);

View File

@@ -928,49 +928,47 @@ static int http_rest_get_testconfig(http_request_t *request){
}
static int http_rest_get_flash_vars_test(http_request_t *request){
#if PLATFORM_XR809
return http_rest_error(request, 400, "flash vars unsupported");
#elif PLATFORM_BL602
return http_rest_error(request, 400, "flash vars unsupported");
#else
#ifndef DISABLE_FLASH_VARS_VARS
char *params = request->url + 17;
int increment = 0;
int len = 0;
int sres;
int i;
char tmp[128];
FLASH_VARS_STRUCTURE data, *p;
p = &flash_vars;
sres = sscanf(params, "%x-%x", &increment, &len);
ADDLOG_DEBUG(LOG_FEATURE_API, "http_rest_get_flash_vars_test %d %d returned %d", increment, len, sres);
if (increment == 10){
flash_vars_read(&data);
p = &data;
} else {
for (i = 0; i < increment; i++){
HAL_FlashVars_IncreaseBootCount();
}
for (i = 0; i < len; i++){
HAL_FlashVars_SaveBootComplete();
}
}
sprintf(tmp, "offset %d, boot count %d, boot success %d, bootfailures %d",
flash_vars_offset,
p->boot_count,
p->boot_success_count,
p->boot_count - p->boot_success_count );
return http_rest_error(request, 200, tmp);
#else
return http_rest_error(request, 400, "flash vars unsupported");
#endif
#endif
//#if PLATFORM_XR809
// return http_rest_error(request, 400, "flash vars unsupported");
//#elif PLATFORM_BL602
// return http_rest_error(request, 400, "flash vars unsupported");
//#else
//#ifndef DISABLE_FLASH_VARS_VARS
// char *params = request->url + 17;
// int increment = 0;
// int len = 0;
// int sres;
// int i;
// char tmp[128];
// FLASH_VARS_STRUCTURE data, *p;
//
// p = &flash_vars;
//
// sres = sscanf(params, "%x-%x", &increment, &len);
//
// ADDLOG_DEBUG(LOG_FEATURE_API, "http_rest_get_flash_vars_test %d %d returned %d", increment, len, sres);
//
// if (increment == 10){
// flash_vars_read(&data);
// p = &data;
// } else {
// for (i = 0; i < increment; i++){
// HAL_FlashVars_IncreaseBootCount();
// }
// for (i = 0; i < len; i++){
// HAL_FlashVars_SaveBootComplete();
// }
// }
//
// sprintf(tmp, "offset %d, boot count %d, boot success %d, bootfailures %d",
// flash_vars_offset,
// p->boot_count,
// p->boot_success_count,
// p->boot_count - p->boot_success_count );
//
// return http_rest_error(request, 200, tmp);
//#else
return http_rest_error(request, 400, "flash test unsupported");
}