Skip to content

Commit 2e5743e

Browse files
committed
Fix enable Update partition
1 parent 1d4973a commit 2e5743e

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

cores/esp32/esp32-hal-uart.c

+31-9
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ static uart_t _uart_bus_array[3] = {
5656
{(volatile uart_dev_t *)(DR_REG_UART2_BASE), 2, NULL}
5757
};
5858
#else
59-
#define UART_MUTEX_LOCK() do {} while (xSemaphoreTake(uart->lock, portMAX_DELAY) != pdPASS)
60-
#define UART_MUTEX_UNLOCK() xSemaphoreGive(uart->lock)
59+
static BaseType_t _pxHigherPriorityTaskWoken_ = pdFALSE;
60+
#define UART_MUTEX_LOCK() do {} while (xSemaphoreTakeFromISR(uart->lock, &_pxHigherPriorityTaskWoken_) != pdPASS)
61+
#define UART_MUTEX_UNLOCK() xSemaphoreGiveFromISR(uart->lock, &_pxHigherPriorityTaskWoken_)
6162

6263
static uart_t _uart_bus_array[3] = {
6364
{(volatile uart_dev_t *)(DR_REG_UART_BASE), NULL, 0, NULL},
@@ -377,9 +378,10 @@ int log_printf(const char *format, ...)
377378
if(s_uart_debug_nr < 0){
378379
return 0;
379380
}
380-
static char loc_buf[64];
381+
char loc_buf[64];
381382
char * temp = loc_buf;
382-
int len;
383+
int len, i;
384+
void (* put_char)(char) = NULL;
383385
va_list arg;
384386
va_list copy;
385387
va_start(arg, format);
@@ -392,17 +394,37 @@ int log_printf(const char *format, ...)
392394
return 0;
393395
}
394396
}
397+
398+
switch(s_uart_debug_nr) {
399+
case 0:
400+
put_char = &uart0_write_char;
401+
break;
402+
case 1:
403+
put_char = &uart1_write_char;
404+
break;
405+
case 2:
406+
put_char = &uart2_write_char;
407+
break;
408+
default:
409+
return 0;
410+
}
395411
vsnprintf(temp, len+1, format, arg);
396412
#if !CONFIG_DISABLE_HAL_LOCKS
397413
if(_uart_bus_array[s_uart_debug_nr].lock){
398-
while (xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY) != pdPASS);
399-
ets_printf("%s", temp);
400-
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
414+
while (xSemaphoreTakeFromISR(_uart_bus_array[s_uart_debug_nr].lock, &_pxHigherPriorityTaskWoken_) != pdPASS);
415+
for(i=0;i<len;i++){
416+
put_char(temp[i]);
417+
}
418+
xSemaphoreGiveFromISR(_uart_bus_array[s_uart_debug_nr].lock, &_pxHigherPriorityTaskWoken_);
401419
} else {
402-
ets_printf("%s", temp);
420+
for(i=0;i<len;i++){
421+
put_char(temp[i]);
422+
}
403423
}
404424
#else
405-
ets_printf("%s", temp);
425+
for(i=0;i<len;i++){
426+
put_char(temp[i]);
427+
}
406428
#endif
407429
va_end(arg);
408430
if(len > 64){

libraries/Update/src/Updater.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ bool UpdateClass::_verifyHeader(uint8_t data) {
209209

210210
bool UpdateClass::_verifyEnd() {
211211
if(_command == U_FLASH) {
212-
if(!_enablePartition || !_partitionIsBootable(_partition)) {
212+
if(!_enablePartition(_partition) || !_partitionIsBootable(_partition)) {
213213
_abort(UPDATE_ERROR_READ);
214214
return false;
215215
}

0 commit comments

Comments
 (0)