mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-07 05:25:43 +00:00
ECR6600 (#1553)
* ECR6600 * fix macstr * uart, bl0937 * vbat adc, ota * pwm freq * static ip, change mac * update partitions
This commit is contained in:
committed by
GitHub
parent
a5301939a7
commit
544f48d022
@ -3121,6 +3121,13 @@ void OTA_RequestDownloadFromHTTP(const char* s) {
|
||||
#elif PLATFORM_ESPIDF
|
||||
#elif PLATFORM_TR6260
|
||||
#elif PLATFORM_REALTEK
|
||||
#elif PLATFORM_ECR6600
|
||||
extern int http_client_download_file(const char* url, unsigned int len);
|
||||
extern int ota_done(bool reset);
|
||||
delay_ms(100);
|
||||
int ret = http_client_download_file(s, strlen(s));
|
||||
if(ret != -1) ota_done(1);
|
||||
else ota_done(0);
|
||||
#elif PLATFORM_W600 || PLATFORM_W800
|
||||
t_http_fwup(s);
|
||||
#elif PLATFORM_XR809
|
||||
|
||||
@ -237,10 +237,12 @@ static void tcp_server_thread(beken_thread_arg_t arg)
|
||||
{
|
||||
sock[new_idx].fd = accept(listen_sock, (struct sockaddr*)&source_addr, &addr_len);
|
||||
|
||||
#if LWIP_SO_RCVTIMEO && !PLATFORM_ECR6600
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 30;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(sock[new_idx].fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv));
|
||||
#endif
|
||||
|
||||
if(sock[new_idx].fd < 0)
|
||||
{
|
||||
|
||||
@ -103,6 +103,10 @@ extern uint32_t current_fw_idx;
|
||||
|
||||
#endif
|
||||
|
||||
#elif PLATFORM_ECR6600
|
||||
|
||||
#include "flash.h"
|
||||
|
||||
#else
|
||||
|
||||
extern UINT32 flash_read(char* user_buf, UINT32 count, UINT32 address);
|
||||
@ -303,6 +307,8 @@ static int http_rest_post(http_request_t* request) {
|
||||
return http_rest_post_flash(request, -1, -1);
|
||||
#elif PLATFORM_REALTEK
|
||||
return http_rest_post_flash(request, 0, -1);
|
||||
#elif PLATFORM_ECR6600
|
||||
return http_rest_post_flash(request, -1, -1);
|
||||
#else
|
||||
// TODO
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "No OTA");
|
||||
@ -2865,6 +2871,66 @@ update_ota_exit:
|
||||
return http_rest_error(request, ret, "error");
|
||||
}
|
||||
|
||||
#elif PLATFORM_ECR6600
|
||||
|
||||
extern int ota_init(void);
|
||||
extern int ota_write(unsigned char* data, unsigned int len);
|
||||
extern int ota_done(bool reset);
|
||||
int ret = 0;
|
||||
|
||||
if(request->contentLength > 0)
|
||||
{
|
||||
towrite = request->contentLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -1;
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "Content-length is 0");
|
||||
goto update_ota_exit;
|
||||
}
|
||||
|
||||
if(ota_init() != 0)
|
||||
{
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if(ota_write((unsigned char*)writebuf, writelen) != 0)
|
||||
{
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
delay_ms(10);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "Writelen %i at %i", writelen, total);
|
||||
total += writelen;
|
||||
startaddr += writelen;
|
||||
towrite -= writelen;
|
||||
if(towrite > 0)
|
||||
{
|
||||
writebuf = request->received;
|
||||
writelen = recv(request->fd, writebuf, request->receivedLenmax, 0);
|
||||
if(writelen < 0)
|
||||
{
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "recv returned %d - end of data - remaining %d", writelen, towrite);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
} while((towrite > 0) && (writelen >= 0));
|
||||
|
||||
update_ota_exit:
|
||||
if(ret != -1)
|
||||
{
|
||||
ADDLOG_INFO(LOG_FEATURE_OTA, "OTA is successful");
|
||||
ota_done(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "OTA failed. Reboot to retry");
|
||||
return http_rest_error(request, ret, "error");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
init_ota(startaddr);
|
||||
@ -2967,10 +3033,13 @@ static int http_rest_get_flash(http_request_t* request, int startaddr, int len)
|
||||
#elif PLATFORM_W600 || PLATFORM_W800
|
||||
res = 0;
|
||||
#elif PLATFORM_LN882H
|
||||
// TODO:LN882H flash read?
|
||||
res = hal_flash_read(startaddr, readlen, (uint8_t *)buffer);
|
||||
#elif PLATFORM_ESPIDF || PLATFORM_TR6260
|
||||
#elif PLATFORM_ESPIDF
|
||||
res = 0;
|
||||
#elif PLATFORM_TR6260
|
||||
res = hal_spiflash_read(startaddr, (uint8_t*)buffer, readlen);
|
||||
#elif PLATFORM_ECR6600
|
||||
res = drv_spiflash_read(startaddr, (uint8_t*)buffer, readlen);
|
||||
#elif PLATFORM_REALTEK
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_read(&flash, startaddr, readlen, (uint8_t*)buffer);
|
||||
|
||||
Reference in New Issue
Block a user