Răsfoiți Sursa

Merge branch 'bugfix/github_issues' into 'master'

Fixes for github issues

This MR contains a bunch of small fixes for issues raised on Github and esp32.com forum:

- vfs doesn't check error code returned by open syscall
- spi_flash doesn't work when built in release mode
- duplicate definition of O_NONBLOCK when combining LwIP socket.h with sys/fcntl.h
- wrong order of creation of standard streams
- `_times_r` returning incorrect values, causing `clock`to return double of the actual time
- driver/gpio.h: comment fix
- wifi event handlers: fix incorrect MAC address printed by logging statements
- move some functions out of IRAM when compiling for bootloader

Please check commit descriptions for links to issues/forum posts and more details.


See merge request !183

Ivan Grokhotkov 9 ani în urmă
părinte
comite
fcba7e278d

+ 2 - 2
components/bootloader/Makefile.projbuild

@@ -33,7 +33,7 @@ clean: bootloader-clean
 
 bootloader: $(BOOTLOADER_BIN)
 	@echo "Bootloader built. Default flash command is:"
-	@echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $(BOOTLOADER_BIN)"
+	@echo "$(ESPTOOLPY_WRITE_FLASH) 0x1000 $^"
 
 all_binaries: $(BOOTLOADER_BIN)
 
@@ -41,7 +41,7 @@ ESPTOOL_ALL_FLASH_ARGS += 0x1000 $(BOOTLOADER_BIN)
 
 # bootloader-flash calls flash in the bootloader dummy project
 bootloader-flash: $(BOOTLOADER_BIN)
-	$(BOOTLOADER_MAKE) flash
+	$(ESPTOOLPY_WRITE_FLASH) 0x1000 $^
 
 # synchronise the project level config to the bootloader's
 # config

+ 1 - 1
components/driver/include/driver/gpio.h

@@ -313,7 +313,7 @@ esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull);
   *
   * @param gpio_num GPIO number.
   *
-  * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOLEVEL\GPIO_INTR_HILEVEL can be used
+  * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL\GPIO_INTR_HIGH_LEVEL can be used.
   *
   * @return
   *     - ESP_OK Success

+ 1 - 1
components/esp32/cpu_start.c

@@ -177,9 +177,9 @@ void start_cpu0_default(void)
     esp_vfs_dev_uart_register();
     esp_reent_init(_GLOBAL_REENT);
     const char* default_uart_dev = "/dev/uart/0";
+    _GLOBAL_REENT->_stdin  = fopen(default_uart_dev, "r");
     _GLOBAL_REENT->_stdout = fopen(default_uart_dev, "w");
     _GLOBAL_REENT->_stderr = fopen(default_uart_dev, "w");
-    _GLOBAL_REENT->_stdin  = fopen(default_uart_dev, "r");
     do_global_ctors();
 #if !CONFIG_FREERTOS_UNICORE
     esp_crosscore_int_init();

+ 12 - 15
components/esp32/event_default_handlers.c

@@ -22,6 +22,7 @@
 #include "esp_event.h"
 #include "esp_event_loop.h"
 #include "esp_task.h"
+#include "rom/ets_sys.h"
 
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
@@ -196,16 +197,14 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
     }
     case SYSTEM_EVENT_STA_CONNECTED: {
         system_event_sta_connected_t *connected = &event->event_info.connected;
-        ESP_LOGD(TAG, "SYSTEM_EVENT_STA_CONNECTED, ssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, channel:%d, authmode:%d", \
-                   connected->ssid, connected->ssid_len, connected->bssid[0], connected->bssid[0], connected->bssid[1], \
-                   connected->bssid[3], connected->bssid[4], connected->bssid[5], connected->channel, connected->authmode);
+        ESP_LOGD(TAG, "SYSTEM_EVENT_STA_CONNECTED, ssid:%s, ssid_len:%d, bssid:" MACSTR ", channel:%d, authmode:%d", \
+                   connected->ssid, connected->ssid_len, MAC2STR(connected->bssid), connected->channel, connected->authmode);
         break;
     }
     case SYSTEM_EVENT_STA_DISCONNECTED: {
         system_event_sta_disconnected_t *disconnected = &event->event_info.disconnected;
-        ESP_LOGD(TAG, "SYSTEM_EVENT_STA_DISCONNECTED, ssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, reason:%d", \
-                   disconnected->ssid, disconnected->ssid_len, disconnected->bssid[0], disconnected->bssid[0], disconnected->bssid[1], \
-                   disconnected->bssid[3], disconnected->bssid[4], disconnected->bssid[5], disconnected->reason);
+        ESP_LOGD(TAG, "SYSTEM_EVENT_STA_DISCONNECTED, ssid:%s, ssid_len:%d, bssid:" MACSTR ", reason:%d", \
+                   disconnected->ssid, disconnected->ssid_len, MAC2STR(disconnected->bssid), disconnected->reason);
         break;
     }
     case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: {
@@ -231,23 +230,21 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
     }
     case SYSTEM_EVENT_AP_STACONNECTED: {
         system_event_ap_staconnected_t *staconnected = &event->event_info.sta_connected;
-        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STACONNECTED, mac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d", \
-                   staconnected->mac[0], staconnected->mac[0], staconnected->mac[1], \
-                   staconnected->mac[3], staconnected->mac[4], staconnected->mac[5], staconnected->aid);
+        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STACONNECTED, mac:" MACSTR ", aid:%d", \
+                   MAC2STR(staconnected->mac), staconnected->aid);
         break;
     }
     case SYSTEM_EVENT_AP_STADISCONNECTED: {
         system_event_ap_stadisconnected_t *stadisconnected = &event->event_info.sta_disconnected;
-        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STADISCONNECTED, mac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d", \
-                   stadisconnected->mac[0], stadisconnected->mac[0], stadisconnected->mac[1], \
-                   stadisconnected->mac[3], stadisconnected->mac[4], stadisconnected->mac[5], stadisconnected->aid);
+        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STADISCONNECTED, mac:" MACSTR ", aid:%d", \
+                   MAC2STR(stadisconnected->mac), stadisconnected->aid);
         break;
     }
     case SYSTEM_EVENT_AP_PROBEREQRECVED: {
         system_event_ap_probe_req_rx_t *ap_probereqrecved = &event->event_info.ap_probereqrecved;
-        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_PROBEREQRECVED, rssi:%d, mac:%02x:%02x:%02x:%02x:%02x:%02x", \
-                   ap_probereqrecved->rssi, ap_probereqrecved->mac[0], ap_probereqrecved->mac[0], ap_probereqrecved->mac[1], \
-                   ap_probereqrecved->mac[3], ap_probereqrecved->mac[4], ap_probereqrecved->mac[5]);
+        ESP_LOGD(TAG, "SYSTEM_EVENT_AP_PROBEREQRECVED, rssi:%d, mac:" MACSTR, \
+                   ap_probereqrecved->rssi, \
+                   MAC2STR(ap_probereqrecved->mac));
         break;
     }
     default: {

+ 10 - 5
components/log/log.c

@@ -284,7 +284,15 @@ static inline void heap_swap(int i, int j)
 }
 #endif //BOOTLOADER_BUILD
 
-IRAM_ATTR uint32_t esp_log_early_timestamp()
+
+#ifndef BOOTLOADER_BUILD
+#define ATTR IRAM_ATTR
+#else
+#define ATTR
+#endif // BOOTLOADER_BUILD
+
+
+uint32_t ATTR esp_log_early_timestamp()
 {
     return xthal_get_ccount() / (CPU_CLK_FREQ_ROM / 1000);
 }
@@ -305,9 +313,6 @@ uint32_t IRAM_ATTR esp_log_timestamp()
 
 #else
 
-uint32_t IRAM_ATTR esp_log_timestamp()
-{
-    return esp_log_early_timestamp();
-}
+uint32_t esp_log_timestamp() __attribute__((alias("esp_log_early_timestamp")));
 
 #endif //BOOTLOADER_BUILD

+ 1 - 0
components/lwip/include/lwip/port/lwipopts.h

@@ -35,6 +35,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <sys/time.h>
+#include <sys/fcntl.h>
 #include "esp_task.h"
 #include "sdkconfig.h"
 

+ 1 - 1
components/newlib/time.c

@@ -114,7 +114,7 @@ void esp_setup_time_syscalls()
 clock_t IRAM_ATTR _times_r(struct _reent *r, struct tms *ptms)
 {
     clock_t t = xTaskGetTickCount() * (portTICK_PERIOD_MS * CLK_TCK / 1000);
-    ptms->tms_cstime = t;
+    ptms->tms_cstime = 0;
     ptms->tms_cutime = 0;
     ptms->tms_stime = t;
     ptms->tms_utime = 0;

+ 2 - 2
components/spi_flash/cache_utils.c

@@ -38,8 +38,8 @@ static uint32_t s_flash_op_cache_state[2];
 
 #ifndef CONFIG_FREERTOS_UNICORE
 static SemaphoreHandle_t s_flash_op_mutex;
-static bool s_flash_op_can_start = false;
-static bool s_flash_op_complete = false;
+static volatile bool s_flash_op_can_start = false;
+static volatile bool s_flash_op_complete = false;
 
 void spi_flash_init_lock()
 {

+ 8 - 2
components/spi_flash/spi_flash_rom_patch.c

@@ -19,9 +19,15 @@ static const uint32_t STATUS_QIE_BIT = (1 << 9); /* Quad Enable */
 #define SPI_IDX 1
 #define OTH_IDX 0
 
+#ifndef BOOTLOADER_BUILD
+#define ATTR IRAM_ATTR
+#else
+#define ATTR
+#endif // BOOTLOADER_BUILD
+
 extern SpiFlashChip SPI_flashchip_data;
 
-static void IRAM_ATTR Wait_SPI_Idle(void)
+static void ATTR Wait_SPI_Idle(void)
 {
   /* Wait for SPI state machine to be idle */
   while((REG_READ(SPI_EXT2_REG(SPI_IDX)) & SPI_ST)) {
@@ -42,7 +48,7 @@ static void IRAM_ATTR Wait_SPI_Idle(void)
    about interrupts, CPU coordination, flash mapping. However some of
    the functions in esp_spi_flash.c call it.
  */
-SpiFlashOpResult IRAM_ATTR SPIUnlock(void)
+SpiFlashOpResult ATTR SPIUnlock(void)
 {
   uint32_t status;
 

+ 4 - 0
components/vfs/vfs.c

@@ -151,6 +151,10 @@ int esp_vfs_open(struct _reent *r, const char * path, int flags, int mode)
     const char* path_within_vfs = translate_path(vfs, path);
     int ret;
     CHECK_AND_CALL(ret, r, vfs, open, path_within_vfs, flags, mode);
+    if (ret < 0) {
+        return ret;
+    }
+    assert(ret >= vfs->vfs.fd_offset);
     return ret - vfs->vfs.fd_offset + (vfs->offset << VFS_INDEX_S);
 }
 

+ 1 - 0
components/wpa_supplicant/src/crypto/libtommath.h

@@ -668,6 +668,7 @@ mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
   } else {
 #endif
 #ifdef BN_S_MP_EXPTMOD_C
+    (void) dr;
     /* otherwise use the generic Barrett reduction technique */
     return s_mp_exptmod (G, X, P, Y, 0);
 #else