From e335f19a4d8efacdaca45e269cf4a8d5c9a9c415 Mon Sep 17 00:00:00 2001 From: "rudi ;-)" Date: Sun, 26 Feb 2017 04:13:39 +0100 Subject: [PATCH 01/17] examples/ethernet: typo, better named Merges #382 https://github.com/espressif/esp-idf/pull/382 --- examples/ethernet/ethernet/main/ethernet_main.c | 2 +- examples/ethernet/ethernet/main/tlk110_phy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ethernet/ethernet/main/ethernet_main.c b/examples/ethernet/ethernet/main/ethernet_main.c index 6419c41843..d406ab4dc7 100644 --- a/examples/ethernet/ethernet/main/ethernet_main.c +++ b/examples/ethernet/ethernet/main/ethernet_main.c @@ -45,7 +45,7 @@ void phy_tlk110_check_phy_init(void) { while((esp_eth_smi_read(BASIC_MODE_STATUS_REG) & AUTO_NEGOTIATION_COMPLETE ) != AUTO_NEGOTIATION_COMPLETE) {}; - while((esp_eth_smi_read(PHY_STATUS_REG) & AUTO_NEGTIATION_STATUS ) != AUTO_NEGTIATION_STATUS) + while((esp_eth_smi_read(PHY_STATUS_REG) & AUTO_NEGOTIATION_STATUS ) != AUTO_NEGOTIATION_STATUS) {}; while((esp_eth_smi_read(CABLE_DIAGNOSTIC_CONTROL_REG) & DIAGNOSTIC_DONE ) != DIAGNOSTIC_DONE) {}; diff --git a/examples/ethernet/ethernet/main/tlk110_phy.h b/examples/ethernet/ethernet/main/tlk110_phy.h index a21bc57aea..87d512c42b 100644 --- a/examples/ethernet/ethernet/main/tlk110_phy.h +++ b/examples/ethernet/ethernet/main/tlk110_phy.h @@ -23,7 +23,7 @@ #define RMII_ENHANCED_MODE BIT(9) #define PHY_STATUS_REG (0x10) -#define AUTO_NEGTIATION_STATUS BIT(4) +#define AUTO_NEGOTIATION_STATUS BIT(4) #define DUPLEX_STATUS BIT(2) #define SPEED_STATUS BIT(1) From f4c47872816c5cb73d1315ab5a004cc640c2ddcb Mon Sep 17 00:00:00 2001 From: "rudi ;-)" Date: Tue, 21 Feb 2017 02:52:27 +0100 Subject: [PATCH 02/17] examples/ethernet: Same sense of meaning SW_STRAP Merges #366 #367 https://github.com/espressif/esp-idf/pull/366 https://github.com/espressif/esp-idf/pull/367 --- examples/ethernet/ethernet/main/ethernet_main.c | 2 +- examples/ethernet/ethernet/main/tlk110_phy.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ethernet/ethernet/main/ethernet_main.c b/examples/ethernet/ethernet/main/ethernet_main.c index d406ab4dc7..f76bd1d76e 100644 --- a/examples/ethernet/ethernet/main/ethernet_main.c +++ b/examples/ethernet/ethernet/main/ethernet_main.c @@ -108,7 +108,7 @@ void phy_tlk110_init(void) while (esp_eth_smi_read(PHY_IDENTIFIER_REG) != OUI_MSB_21TO6_DEF) { } - esp_eth_smi_write(SOFTWARE_STRAP_CONTROL_REG, DEFAULT_PHY_CONFIG |SW_STRAP_CONFIG_DONE); + esp_eth_smi_write(SW_STRAP_CONTROL_REG, DEFAULT_PHY_CONFIG | SW_STRAP_CONFIG_DONE); ets_delay_us(300); diff --git a/examples/ethernet/ethernet/main/tlk110_phy.h b/examples/ethernet/ethernet/main/tlk110_phy.h index 87d512c42b..63236edebd 100644 --- a/examples/ethernet/ethernet/main/tlk110_phy.h +++ b/examples/ethernet/ethernet/main/tlk110_phy.h @@ -13,7 +13,7 @@ #define PARTNER_ASM_DIR BIT(11) #define PARTNER_PAUSE BIT(10) -#define SOFTWARE_STRAP_CONTROL_REG (0x9) +#define SW_STRAP_CONTROL_REG (0x9) #define SW_STRAP_CONFIG_DONE BIT(15) #define AUTO_MDIX_ENABLE BIT(14) #define AUTO_NEGOTIATION_ENABLE BIT(13) From c08a2871e67ee7003fabee6332a1326d7a4c7368 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Mon, 20 Feb 2017 00:42:58 +0000 Subject: [PATCH 03/17] sdmmc: Add width field to the slot config. Therefore if the width is set to 1, you can choose to only configure the CLK, DAT0 and CMD pins. Merges #361 https://github.com/espressif/esp-idf/pull/361 --- components/driver/include/driver/sdmmc_host.h | 2 ++ components/driver/sdmmc_host.c | 23 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/driver/include/driver/sdmmc_host.h b/components/driver/include/driver/sdmmc_host.h index 0f56c266a8..f9f4f7d377 100644 --- a/components/driver/include/driver/sdmmc_host.h +++ b/components/driver/include/driver/sdmmc_host.h @@ -50,6 +50,7 @@ extern "C" { typedef struct { gpio_num_t gpio_cd; ///< GPIO number of card detect signal gpio_num_t gpio_wp; ///< GPIO number of write protect signal + uint8_t width; ///< Bus width used by the slot (might be less than the max width supported) } sdmmc_slot_config_t; #define SDMMC_SLOT_NO_CD ((gpio_num_t) -1) ///< indicates that card detect line is not used @@ -61,6 +62,7 @@ typedef struct { #define SDMMC_SLOT_CONFIG_DEFAULT() {\ .gpio_cd = SDMMC_SLOT_NO_CD, \ .gpio_wp = SDMMC_SLOT_NO_WP, \ + .width = 4, \ } /** diff --git a/components/driver/sdmmc_host.c b/components/driver/sdmmc_host.c index 400c85b889..54c7997b0a 100644 --- a/components/driver/sdmmc_host.c +++ b/components/driver/sdmmc_host.c @@ -302,17 +302,24 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config) // Configure pins const sdmmc_slot_info_t* pslot = &s_slot_info[slot]; + + if (slot_config->width > pslot->width) { + return ESP_ERR_INVALID_ARG; + } + configure_pin(pslot->clk); configure_pin(pslot->cmd); configure_pin(pslot->d0); - configure_pin(pslot->d1); - configure_pin(pslot->d2); - configure_pin(pslot->d3); - if (pslot->width == 8) { - configure_pin(pslot->d4); - configure_pin(pslot->d5); - configure_pin(pslot->d6); - configure_pin(pslot->d7); + if (slot_config->width >= 4) { + configure_pin(pslot->d1); + configure_pin(pslot->d2); + configure_pin(pslot->d3); + if (slot_config->width == 8) { + configure_pin(pslot->d4); + configure_pin(pslot->d5); + configure_pin(pslot->d6); + configure_pin(pslot->d7); + } } if (gpio_cd != -1) { gpio_set_direction(gpio_cd, GPIO_MODE_INPUT); From 7bb4c8521a1cda1f0ec0dd0ded139888d8c7c24b Mon Sep 17 00:00:00 2001 From: gbcwbz Date: Sun, 19 Feb 2017 19:33:08 +0800 Subject: [PATCH 04/17] docs: Fix typo in build-system.rst Merges #355 https://github.com/espressif/esp-idf/pull/355 --- docs/build-system.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build-system.rst b/docs/build-system.rst index b3abbd28f5..ea4925f74e 100644 --- a/docs/build-system.rst +++ b/docs/build-system.rst @@ -144,7 +144,7 @@ The minimal ``component.mk`` file is an empty file(!). If the file is empty, the See `example component makefiles` for more complete component makefile examples. -Note that there is a different between an empty ``component.mk`` file (which invokes default component build behaviour) and no ``component.mk`` file (which means no default component build behaviour will occur.) It is possible for a component to have no `component.mk` file, if it only contains other files which influence the project configuration or build process. +Note that there is a difference between an empty ``component.mk`` file (which invokes default component build behaviour) and no ``component.mk`` file (which means no default component build behaviour will occur.) It is possible for a component to have no `component.mk` file, if it only contains other files which influence the project configuration or build process. .. component variables: From 3119f936abac87e522fc03a947e087528aeaa955 Mon Sep 17 00:00:00 2001 From: alarruskain Date: Fri, 17 Feb 2017 11:02:00 +0100 Subject: [PATCH 05/17] lwip: Fix hostname set in tcpip_adapter_lwip Hostname for each interface is not correctly stored in "hostinfo" variable. Merges #350 https://github.com/espressif/esp-idf/pull/350 --- components/tcpip_adapter/tcpip_adapter_lwip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 40f235d545..6e16617547 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -713,7 +713,7 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho { #if LWIP_NETIF_HOSTNAME struct netif *p_netif; - static char hostinfo[TCPIP_HOSTNAME_MAX_SIZE + 1][TCPIP_ADAPTER_IF_MAX]; + static char hostinfo[TCPIP_ADAPTER_IF_MAX][TCPIP_HOSTNAME_MAX_SIZE + 1]; if (tcpip_if >= TCPIP_ADAPTER_IF_MAX || hostname == NULL) { return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS; From da723ca11d331c160da2a941fd0036ffef2ad658 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 14:50:58 +1100 Subject: [PATCH 06/17] lwip: Use strlcpy() instead of memcpy() to copy hostname to static buffer --- components/tcpip_adapter/tcpip_adapter_lwip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 6e16617547..c98825ec6b 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -726,7 +726,7 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho p_netif = esp_netif[tcpip_if]; if (p_netif != NULL) { memset(hostinfo[tcpip_if], 0, sizeof(hostinfo[tcpip_if])); - memcpy(hostinfo[tcpip_if], hostname, strlen(hostname)); + strlcpy(hostinfo[tcpip_if], hostname, sizeof(hostinfo[tcpip_if])); p_netif->hostname = hostinfo[tcpip_if]; return ESP_OK; } else { From ec31b39989cae74d8322840b933cea432e1d59b7 Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Fri, 17 Feb 2017 01:58:44 +0100 Subject: [PATCH 07/17] Added missing platform.h to mbedtls ssl.h There was a missing definition of mbedtls_time_t See for example: https://travis-ci.org/SHA2017-badge/Firmware/jobs/202459377 Merges #348 https://github.com/espressif/esp-idf/pull/348 --- components/mbedtls/include/mbedtls/ssl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/mbedtls/include/mbedtls/ssl.h b/components/mbedtls/include/mbedtls/ssl.h index 82c07607f5..7e1a17c813 100644 --- a/components/mbedtls/include/mbedtls/ssl.h +++ b/components/mbedtls/include/mbedtls/ssl.h @@ -29,6 +29,7 @@ #include MBEDTLS_CONFIG_FILE #endif +#include "platform.h" #include "bignum.h" #include "ecp.h" From e14d65d7047c9fdce08eea1e7aba67db91197695 Mon Sep 17 00:00:00 2001 From: Neil Kolban Date: Mon, 13 Feb 2017 23:03:04 -0600 Subject: [PATCH 08/17] Update to ESP_ERROR_CHECK See request from ESP_Angus here: https://esp32.com/viewtopic.php?f=18&t=1179 Merges #339 https://github.com/espressif/esp-idf/pull/339 --- components/esp32/include/esp_err.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/include/esp_err.h b/components/esp32/include/esp_err.h index b6a1e8b421..059b597351 100644 --- a/components/esp32/include/esp_err.h +++ b/components/esp32/include/esp_err.h @@ -45,7 +45,7 @@ typedef int32_t esp_err_t; * and terminate the program in case the code is not ESP_OK. * Prints the failed statement to serial output. */ -#define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { assert(0 && #x);} } while(0); +#define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0); #ifdef __cplusplus } From e08cf27b8afd78bb9c9054edc813c964fbf67a30 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 15:40:49 +1100 Subject: [PATCH 09/17] esp_err: add NDEBUG guard, comment about flash cache Follow-up to 316b040 --- components/esp32/include/esp_err.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/esp32/include/esp_err.h b/components/esp32/include/esp_err.h index 059b597351..fe8c004fac 100644 --- a/components/esp32/include/esp_err.h +++ b/components/esp32/include/esp_err.h @@ -44,8 +44,15 @@ typedef int32_t esp_err_t; * Macro which can be used to check the error code, * and terminate the program in case the code is not ESP_OK. * Prints the failed statement to serial output. + * + * Note: this macro is not safe to use if flash cache + * may be disabled. */ +#ifdef NDEBUG +#define ESP_ERROR_CHECK(x) +#else #define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0); +#endif #ifdef __cplusplus } From 41e29d7384e1280dd54c55b8199f5150c4e9bf4d Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Fri, 7 Oct 2016 23:31:24 +0800 Subject: [PATCH 10/17] docs/linux-setup: Install dependencies for Ubuntu 16.04 Not sure which Ubuntu is used in the installation guide but for the latest LTS release 16.04 we need libtool-bin for compiling crosstool-NG proper Merges #46 https://github.com/espressif/esp-idf/pull/46 --- docs/linux-setup.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/linux-setup.rst b/docs/linux-setup.rst index 94d77f3605..50c1609a31 100644 --- a/docs/linux-setup.rst +++ b/docs/linux-setup.rst @@ -83,6 +83,10 @@ In any case, here are the steps to compile the toolchain yourself. sudo apt-get install gawk gperf grep gettext libncurses-dev python python-dev automake bison flex texinfo help2man libtool + - Ubuntu 16.04:: + + sudo apt-get install gawk gperf grep gettext python python-dev automake bison flex texinfo help2man libtool libtool-bin + - Debian:: TODO From 2575d1dd70a1082f10d15fe021c1020dfef8be7a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 16:07:28 +1100 Subject: [PATCH 11/17] docs/*-setup: Use --enable-local instead of --prefix=$PWD for ct-ng --- docs/linux-setup.rst | 8 +++++--- docs/macos-setup.rst | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/linux-setup.rst b/docs/linux-setup.rst index 50c1609a31..d3b8597cd4 100644 --- a/docs/linux-setup.rst +++ b/docs/linux-setup.rst @@ -77,14 +77,16 @@ If you can't think of a reason why you need to build it yourself, then probably In any case, here are the steps to compile the toolchain yourself. +(Note: You will also need the prerequisite packages mentioned in step 0, above.) + - Install dependencies: - - Ubuntu:: + - Ubuntu pre-16.04:: sudo apt-get install gawk gperf grep gettext libncurses-dev python python-dev automake bison flex texinfo help2man libtool - Ubuntu 16.04:: - + sudo apt-get install gawk gperf grep gettext python python-dev automake bison flex texinfo help2man libtool libtool-bin - Debian:: @@ -100,7 +102,7 @@ Download ``crosstool-NG`` and build it:: cd ~/esp git clone -b xtensa-1.22.x https://github.com/espressif/crosstool-NG.git cd crosstool-NG - ./bootstrap && ./configure --prefix=$PWD && make install + ./bootstrap && ./configure --enable-local && make install Build the toolchain:: diff --git a/docs/macos-setup.rst b/docs/macos-setup.rst index eeed9e4e26..e8f8257b28 100644 --- a/docs/macos-setup.rst +++ b/docs/macos-setup.rst @@ -89,7 +89,7 @@ Download ``crosstool-NG`` and build it:: cd ~/esp git clone -b xtensa-1.22.x https://github.com/espressif/crosstool-NG.git cd crosstool-NG - ./bootstrap && ./configure --prefix=$PWD && make install + ./bootstrap && ./configure --enable-local && make install Build the toolchain:: From 8ce94d5bd3765c0f7973cf4c0f2335d67e69891b Mon Sep 17 00:00:00 2001 From: lucashutchinson Date: Thu, 2 Mar 2017 16:41:03 +1300 Subject: [PATCH 12/17] ble: Fix ble_adv data truncation Fixed issue with ble_adv data being truncated after the 31st octet due to an incorrect length passed in a memcpy. Merges #389 https://github.com/espressif/esp-idf/pull/389 --- components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 8fea801b0a..9e158c592e 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -476,8 +476,7 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data param.scan_rst.ble_addr_type = p_data->inq_res.ble_addr_type; param.scan_rst.ble_evt_type = p_data->inq_res.ble_evt_type; param.scan_rst.flag = p_data->inq_res.flag; - memcpy(param.scan_rst.ble_adv, p_data->inq_res.p_eir, - ESP_BLE_ADV_DATA_LEN_MAX); + memcpy(param.scan_rst.ble_adv, p_data->inq_res.p_eir, sizeof(param.scan_rst.ble_adv)); break; } case BTA_DM_INQ_CMPL_EVT: { From a4a790030d5d3783b74ac804b05bf954c711621d Mon Sep 17 00:00:00 2001 From: Derek Gregory Date: Sat, 28 Jan 2017 00:47:09 -0800 Subject: [PATCH 13/17] component/bt: fix bug where uuid was not reset in btc_gatts_act_create_attr_tab. Merges #307 https://github.com/espressif/esp-idf/pull/307 --- components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c index 2ba3ec0f14..da8d4d5f68 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c @@ -182,13 +182,16 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db, future_t *future_p; esp_ble_gatts_cb_param_t param; - //set the attribute table create service flag to ture + //set the attribute table create service flag to true btc_creat_tab_env.is_tab_creat_svc = true; btc_creat_tab_env.num_handle = max_nb_attr; for(int i = 0; i < max_nb_attr; i++){ if(gatts_attr_db[i].att_desc.uuid_length== ESP_UUID_LEN_16){ uuid = (gatts_attr_db[i].att_desc.uuid_p[1] << 8) + (gatts_attr_db[i].att_desc.uuid_p[0]); } + else{ + continue; + } future_p = future_new(); if (future_p == NULL) { LOG_ERROR("%s failed:no mem\n", __func__); From 6ee5a1e49267a70e6fede6e2f9b8bc276be3f8f8 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 17:18:44 +1100 Subject: [PATCH 14/17] sdmmc: Use slot width as default slot_config width parameter, instead of 4 Ref #361 https://github.com/espressif/esp-idf/pull/361 --- components/driver/include/driver/sdmmc_host.h | 3 ++- components/driver/sdmmc_host.c | 10 +++++++--- docs/api/storage/sdmmc.rst | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/driver/include/driver/sdmmc_host.h b/components/driver/include/driver/sdmmc_host.h index f9f4f7d377..dc3e9ef6bf 100644 --- a/components/driver/include/driver/sdmmc_host.h +++ b/components/driver/include/driver/sdmmc_host.h @@ -55,6 +55,7 @@ typedef struct { #define SDMMC_SLOT_NO_CD ((gpio_num_t) -1) ///< indicates that card detect line is not used #define SDMMC_SLOT_NO_WP ((gpio_num_t) -1) ///< indicates that write protect line is not used +#define SDMMC_SLOT_WIDTH_DEFAULT 0 ///< use the default width for the slot (8 for slot 0, 4 for slot 1) /** * Macro defining default configuration of SDMMC host slot @@ -62,7 +63,7 @@ typedef struct { #define SDMMC_SLOT_CONFIG_DEFAULT() {\ .gpio_cd = SDMMC_SLOT_NO_CD, \ .gpio_wp = SDMMC_SLOT_NO_WP, \ - .width = 4, \ + .width = SDMMC_SLOT_WIDTH_DEFAULT, \ } /** diff --git a/components/driver/sdmmc_host.c b/components/driver/sdmmc_host.c index 54c7997b0a..706a1e3fef 100644 --- a/components/driver/sdmmc_host.c +++ b/components/driver/sdmmc_host.c @@ -299,22 +299,26 @@ esp_err_t sdmmc_host_init_slot(int slot, const sdmmc_slot_config_t* slot_config) } int gpio_cd = slot_config->gpio_cd; int gpio_wp = slot_config->gpio_wp; + uint8_t slot_width = slot_config->width; // Configure pins const sdmmc_slot_info_t* pslot = &s_slot_info[slot]; - if (slot_config->width > pslot->width) { + if (slot_width == SDMMC_SLOT_WIDTH_DEFAULT) { + slot_width = pslot->width; + } + else if (slot_width > pslot->width) { return ESP_ERR_INVALID_ARG; } configure_pin(pslot->clk); configure_pin(pslot->cmd); configure_pin(pslot->d0); - if (slot_config->width >= 4) { + if (slot_width >= 4) { configure_pin(pslot->d1); configure_pin(pslot->d2); configure_pin(pslot->d3); - if (slot_config->width == 8) { + if (slot_width == 8) { configure_pin(pslot->d4); configure_pin(pslot->d5); configure_pin(pslot->d6); diff --git a/docs/api/storage/sdmmc.rst b/docs/api/storage/sdmmc.rst index fe2e5c27f8..4ea2f62606 100644 --- a/docs/api/storage/sdmmc.rst +++ b/docs/api/storage/sdmmc.rst @@ -79,6 +79,7 @@ Of all the funtions listed below, only ``sdmmc_host_init``, ``sdmmc_host_init_sl .. doxygendefine:: SDMMC_HOST_SLOT_0 .. doxygendefine:: SDMMC_HOST_SLOT_1 .. doxygendefine:: SDMMC_HOST_DEFAULT +.. doxygendefine:: SDMMC_SLOT_WIDTH_DEFAULT .. doxygenfunction:: sdmmc_host_init_slot From 3442d4d463b9c94fdfbeaac39349f7ad30e16ee6 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 15:21:03 +1100 Subject: [PATCH 15/17] spi_flash: Add spi_flash_cache_enabled() test function --- components/spi_flash/cache_utils.c | 6 +++ components/spi_flash/include/esp_spi_flash.h | 6 +++ .../spi_flash/test/test_cache_disabled.c | 53 +++++++++++++++++++ docs/api/storage/spi_flash.rst | 1 + 4 files changed, 66 insertions(+) create mode 100644 components/spi_flash/test/test_cache_disabled.c diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index 5e880ab493..6d0dd91845 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -275,3 +275,9 @@ static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_sta } } + +IRAM_ATTR bool spi_flash_cache_enabled() +{ + return REG_GET_BIT(DPORT_PRO_CACHE_CTRL_REG, DPORT_PRO_CACHE_ENABLE) + && REG_GET_BIT(DPORT_APP_CACHE_CTRL_REG, DPORT_APP_CACHE_ENABLE); +} diff --git a/components/spi_flash/include/esp_spi_flash.h b/components/spi_flash/include/esp_spi_flash.h index 40720af38b..00797b8df2 100644 --- a/components/spi_flash/include/esp_spi_flash.h +++ b/components/spi_flash/include/esp_spi_flash.h @@ -233,6 +233,12 @@ size_t spi_flash_cache2phys(const void *cached); */ const void *spi_flash_phys2cache(size_t phys_offs, spi_flash_mmap_memory_t memory); +/** @brief Check at runtime if flash cache is enabled on both CPUs + * + * @return true if both CPUs have flash cache enabled, false otherwise. + */ +bool spi_flash_cache_enabled(); + /** * @brief SPI flash critical section enter function. */ diff --git a/components/spi_flash/test/test_cache_disabled.c b/components/spi_flash/test/test_cache_disabled.c new file mode 100644 index 0000000000..8caa7e83f9 --- /dev/null +++ b/components/spi_flash/test/test_cache_disabled.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../cache_utils.h" + +static QueueHandle_t result_queue; + +static IRAM_ATTR void cache_test_task(void *arg) +{ + bool do_disable = (bool)arg; + bool result; + if(do_disable) { + spi_flash_disable_interrupts_caches_and_other_cpu(); + } + result = spi_flash_cache_enabled(); + if (do_disable) { + spi_flash_enable_interrupts_caches_and_other_cpu(); + } + + TEST_ASSERT( xQueueSendToBack(result_queue, &result, 0) ); + vTaskDelete(NULL); +} + +TEST_CASE("spi_flash_cache_enabled() works on both CPUs", "[spi_flash]") +{ + result_queue = xQueueCreate(1, sizeof(bool)); + + for(int cpu = 0; cpu < portNUM_PROCESSORS; cpu++) { + for(int disable = 0; disable <= 1; disable++) { + bool do_disable = disable; + bool result; + printf("Testing cpu %d disabled %d\n", cpu, do_disable); + + xTaskCreatePinnedToCore(cache_test_task, "cache_check_task", + 2048, (void *)do_disable, configMAX_PRIORITIES-1, NULL, cpu); + + TEST_ASSERT( xQueueReceive(result_queue, &result, 2) ); + TEST_ASSERT_EQUAL(!do_disable, result); + } + } + + vQueueDelete(result_queue); +} + diff --git a/docs/api/storage/spi_flash.rst b/docs/api/storage/spi_flash.rst index 4bf5e37a99..c42aedb4b0 100644 --- a/docs/api/storage/spi_flash.rst +++ b/docs/api/storage/spi_flash.rst @@ -62,6 +62,7 @@ Functions .. doxygenfunction:: spi_flash_mmap_dump .. doxygenfunction:: spi_flash_cache2phys .. doxygenfunction:: spi_flash_phys2cache +.. doxygenfunction:: spi_flash_cache_enabled .. doxygenfunction:: esp_partition_find .. doxygenfunction:: esp_partition_find_first .. doxygenfunction:: esp_partition_get From d6f183fbb9c3ceec82b37a527fad00e1754ecbe5 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 2 Mar 2017 17:22:22 +1100 Subject: [PATCH 16/17] esp_err: Use separate code path for ESP_ERROR_CHECK assertion * Minimum code size overhead * Makes function safe to use when flash cache is disabled Builds on #339 https://github.com/espressif/esp-idf/pull/339 --- components/esp32/include/esp_err.h | 34 ++++++++++++++----- components/esp32/panic.c | 23 ++++++++++--- components/nvs_flash/test_nvs_host/Makefile | 1 + .../test_nvs_host/esp_error_check_stub.cpp | 9 +++++ 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp diff --git a/components/esp32/include/esp_err.h b/components/esp32/include/esp_err.h index fe8c004fac..c7beafd375 100644 --- a/components/esp32/include/esp_err.h +++ b/components/esp32/include/esp_err.h @@ -11,10 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef __ESP_ERR_H__ -#define __ESP_ERR_H__ +#pragma once #include +#include #include #ifdef __cplusplus @@ -40,22 +40,38 @@ typedef int32_t esp_err_t; #define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */ +void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn)); + +#ifndef __ASSERT_FUNC +/* This won't happen on IDF, which defines __ASSERT_FUNC in assert.h, but it does happen when building on the host which + uses /usr/include/assert.h or equivalent. +*/ +#ifdef __ASSERT_FUNCTION +#define __ASSERT_FUNC __ASSERT_FUNCTION /* used in glibc assert.h */ +#else +#define __ASSERT_FUNC "??" +#endif +#endif + /** * Macro which can be used to check the error code, * and terminate the program in case the code is not ESP_OK. - * Prints the failed statement to serial output. + * Prints the error code, error location, and the failed statement to serial output. * - * Note: this macro is not safe to use if flash cache - * may be disabled. + * Disabled if assertions are disabled. */ #ifdef NDEBUG -#define ESP_ERROR_CHECK(x) +#define ESP_ERROR_CHECK(x) do { (x); } while (0) #else -#define ESP_ERROR_CHECK(x) do { esp_err_t rc = (x); if (rc != ESP_OK) { ESP_LOGE("err", "esp_err_t = %d", rc); assert(0 && #x);} } while(0); +#define ESP_ERROR_CHECK(x) do { \ + esp_err_t rc = (x); \ + if (rc != ESP_OK) { \ + _esp_error_check_failed(rc, __FILE__, __LINE__, \ + __ASSERT_FUNC, #x); \ + } \ + } while(0); #endif #ifdef __cplusplus } #endif - -#endif /* __ESP_ERR_H__ */ diff --git a/components/esp32/panic.c b/components/esp32/panic.c index 4f0497d6ea..cd426344e1 100644 --- a/components/esp32/panic.c +++ b/components/esp32/panic.c @@ -34,6 +34,7 @@ #include "esp_attr.h" #include "esp_err.h" #include "esp_core_dump.h" +#include "esp_spi_flash.h" /* Panic handlers; these get called when an unhandled exception occurs or the assembly-level @@ -107,11 +108,8 @@ void __attribute__((weak)) vApplicationStackOverflowHook( TaskHandle_t xTask, s static bool abort_called; -void abort() +static __attribute__((noreturn)) inline void invoke_abort() { -#if !CONFIG_ESP32_PANIC_SILENT_REBOOT - ets_printf("abort() was called at PC 0x%08x\n", (intptr_t)__builtin_return_address(0) - 3); -#endif abort_called = true; while(1) { __asm__ ("break 0,0"); @@ -119,6 +117,14 @@ void abort() } } +void abort() +{ +#if !CONFIG_ESP32_PANIC_SILENT_REBOOT + ets_printf("abort() was called at PC 0x%08x\n", (intptr_t)__builtin_return_address(0) - 3); +#endif + invoke_abort(); +} + static const char *edesc[] = { "IllegalInstruction", "Syscall", "InstructionFetchError", "LoadStoreError", @@ -441,4 +447,11 @@ void esp_clear_watchpoint(int no) } } - +void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) +{ + ets_printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at 0x%08x\n", rc, (intptr_t)__builtin_return_address(0) - 3); + if (spi_flash_cache_enabled()) { // strings may be in flash cache + ets_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); + } + invoke_abort(); +} diff --git a/components/nvs_flash/test_nvs_host/Makefile b/components/nvs_flash/test_nvs_host/Makefile index 6006213961..133762992d 100644 --- a/components/nvs_flash/test_nvs_host/Makefile +++ b/components/nvs_flash/test_nvs_host/Makefile @@ -2,6 +2,7 @@ TEST_PROGRAM=test_nvs all: $(TEST_PROGRAM) SOURCE_FILES = \ + esp_error_check_stub.cpp \ $(addprefix ../src/, \ nvs_types.cpp \ nvs_api.cpp \ diff --git a/components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp b/components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp new file mode 100644 index 0000000000..9cff4af310 --- /dev/null +++ b/components/nvs_flash/test_nvs_host/esp_error_check_stub.cpp @@ -0,0 +1,9 @@ +#include "catch.hpp" +#include "esp_err.h" + +void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) +{ + printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at %p\n", rc, __builtin_return_address(0)); + printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression); + abort(); +} From 5f82322ffad4ab3fcb21ba27424c9e508704af3e Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 3 Mar 2017 12:19:24 +1100 Subject: [PATCH 17/17] docs/eclipse: Add considerations for PATH, PYTHONPATH Thanks to @motla who mentioned these on github: https://github.com/espressif/esp-idf/pull/157#issuecomment-271109920 --- docs/eclipse-setup.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/eclipse-setup.rst b/docs/eclipse-setup.rst index 140e81e173..aa53d171eb 100644 --- a/docs/eclipse-setup.rst +++ b/docs/eclipse-setup.rst @@ -49,7 +49,9 @@ Project Properties * Click "Add..." again, and enter name ``IDF_PATH``. The value should be the full path where ESP-IDF is installed. -*All users, continue with these steps:* +* Edit the ``PATH`` environment variable. Keep the current value, and append the path to the Xtensa toolchain that will installed as part of IDF setup (``something/xtensa-esp32-elf/bin``) if this is not already listed on the PATH. + +* On macOS, add a ``PYTHONPATH`` environment variable and set it to ``/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages``. This is so that the system Python, which has pyserial installed as part of the setup steps, overrides any built-in Eclipse Python. Navigate to "C/C++ General" -> "Preprocessor Include Paths" property page: