Merge branch 'master' of ssh://gitlab.espressif.cn:27227/idf/esp-idf

This commit is contained in:
Liu Zhi Fu
2017-02-13 17:39:53 +08:00
16 changed files with 142 additions and 67 deletions

View File

@@ -291,8 +291,7 @@ check_doc_links:
allow_failure: true allow_failure: true
variables: variables:
# LOCAL_ENV_CONFIG_PATH: define in template and jobs can overwrite if required LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
LOCAL_ENV_CONFIG_PATH: /home/gitlab-runner/LocalConfig/ESP32_IDF
BIN_PATH: "$CI_PROJECT_DIR/SSC/ssc_bin/SSC" BIN_PATH: "$CI_PROJECT_DIR/SSC/ssc_bin/SSC"
APP_NAME: "ssc" APP_NAME: "ssc"
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF" LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
@@ -317,6 +316,8 @@ check_doc_links:
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# clone local test env configs
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
# clone test bench # clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git - git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script - cd auto_test_script
@@ -342,6 +343,8 @@ check_doc_links:
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# clone local test env configs
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
# clone test bench # clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git - git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script - cd auto_test_script
@@ -355,8 +358,7 @@ check_doc_links:
stage: unit_test stage: unit_test
variables: variables:
# jobs MUST set CONFIG_FILE in before_script, and overwrite the variables above if necessary LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
LOCAL_ENV_CONFIG_PATH: /home/gitlab-runner/LocalConfig/ESP32_IDF
BIN_PATH: "$CI_PROJECT_DIR/tools/unit-test-app/build/" BIN_PATH: "$CI_PROJECT_DIR/tools/unit-test-app/build/"
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF" LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
APP_NAME: "ut" APP_NAME: "ut"

View File

@@ -177,6 +177,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
blufi_env.prepare_buf = NULL; blufi_env.prepare_buf = NULL;
} }
break;
case BTA_GATTS_MTU_EVT:
LOG_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
break; break;
case BTA_GATTS_CONF_EVT: case BTA_GATTS_CONF_EVT:
LOG_DEBUG("CONIRM EVT\n"); LOG_DEBUG("CONIRM EVT\n");
@@ -294,6 +298,7 @@ static tGATT_STATUS btc_blufi_profile_init(void)
memset(&blufi_env, 0x0, sizeof(blufi_env)); memset(&blufi_env, 0x0, sizeof(blufi_env));
blufi_env.cbs = store_p; /* if set callback prior, restore the point */ blufi_env.cbs = store_p; /* if set callback prior, restore the point */
blufi_env.frag_size = BLUFI_FRAG_DATA_DEFAULT_LEN;
/* register the BLUFI profile to the BTA_GATTS module*/ /* register the BLUFI profile to the BTA_GATTS module*/
BTA_GATTS_AppRegister(&blufi_app_uuid, blufi_profile_cb); BTA_GATTS_AppRegister(&blufi_app_uuid, blufi_profile_cb);
@@ -406,16 +411,16 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
int ret; int ret;
while (remain_len > 0) { while (remain_len > 0) {
if (remain_len > BLUFI_FRAG_DATA_MAX_LEN) { if (remain_len > blufi_env.frag_size) {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + 2 + BLUFI_FRAG_DATA_MAX_LEN + 2); hdr = GKI_getbuf(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
if (hdr == NULL) { if (hdr == NULL) {
LOG_ERROR("%s no mem\n", __func__); LOG_ERROR("%s no mem\n", __func__);
return; return;
} }
hdr->fc = 0x0; hdr->fc = 0x0;
hdr->data_len = BLUFI_FRAG_DATA_MAX_LEN + 2; hdr->data_len = blufi_env.frag_size + 2;
*(uint16_t *)hdr->data = remain_len; *(uint16_t *)hdr->data = remain_len;
memcpy(hdr->data + 2, &data[total_data_len - remain_len], BLUFI_FRAG_DATA_MAX_LEN); //copy first, easy for check sum memcpy(hdr->data + 2, &data[total_data_len - remain_len], blufi_env.frag_size); //copy first, easy for check sum
hdr->fc |= BLUFI_FC_FRAG; hdr->fc |= BLUFI_FC_FRAG;
} else { } else {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + remain_len + 2); hdr = GKI_getbuf(sizeof(struct blufi_hdr) + remain_len + 2);

View File

@@ -33,6 +33,7 @@ typedef struct {
BD_ADDR remote_bda; BD_ADDR remote_bda;
UINT32 trans_id; UINT32 trans_id;
UINT8 congest; UINT8 congest;
UINT16 frag_size;
#define BLUFI_PREPAIR_BUF_MAX_SIZE 1024 #define BLUFI_PREPAIR_BUF_MAX_SIZE 1024
uint8_t *prepare_buf; uint8_t *prepare_buf;
int prepare_len; int prepare_len;
@@ -160,7 +161,9 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
#define BLUFI_FC_IS_REQ_ACK(fc) ((fc) & BLUFI_FC_REQ_ACK_MASK) #define BLUFI_FC_IS_REQ_ACK(fc) ((fc) & BLUFI_FC_REQ_ACK_MASK)
#define BLUFI_FC_IS_FRAG(fc) ((fc) & BLUFI_FC_FRAG_MASK) #define BLUFI_FC_IS_FRAG(fc) ((fc) & BLUFI_FC_FRAG_MASK)
#define BLUFI_FRAG_DATA_MAX_LEN 50 /* BLUFI HEADER + TOTAL(REMAIN) LENGTH + CRC + L2CAP RESERVED */
#define BLUFI_MTU_RESERVED_SIZE (sizeof(struct blufi_hdr) + 2 + 2 + 3)
#define BLUFI_FRAG_DATA_DEFAULT_LEN (GATT_DEF_BLE_MTU_SIZE - BLUFI_MTU_RESERVED_SIZE)
//function declare //function declare
void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len); void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len);

View File

@@ -1162,6 +1162,10 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
} else if (reason == GATT_SUCCESS || reason == GATT_STACK_RSP) { } else if (reason == GATT_SUCCESS || reason == GATT_STACK_RSP) {
attp_send_sr_msg(p_tcb, p_msg); attp_send_sr_msg(p_tcb, p_msg);
gatt_dequeue_sr_cmd(p_tcb); gatt_dequeue_sr_cmd(p_tcb);
} else {
if (p_msg) {
GKI_freebuf(p_msg);
}
} }
} }

View File

@@ -26,16 +26,17 @@
#if CONFIG_ESP32_ENABLE_COREDUMP #if CONFIG_ESP32_ENABLE_COREDUMP
#define LOG_LOCAL_LEVEL CONFIG_ESP32_CORE_DUMP_LOG_LEVEL #define LOG_LOCAL_LEVEL CONFIG_ESP32_CORE_DUMP_LOG_LEVEL
#include "esp_log.h" #include "esp_log.h"
const static char *TAG = "esp_core_dump"; const static DRAM_ATTR char TAG[] = "esp_core_dump";
#define ESP_COREDUMP_LOGE( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { ets_printf(LOG_FORMAT(E, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOG( level, format, ... ) if (LOG_LOCAL_LEVEL >= level) { ets_printf(DRAM_STR(format), esp_log_early_timestamp(), (const char *)TAG, ##__VA_ARGS__); }
#define ESP_COREDUMP_LOGW( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { ets_printf(LOG_FORMAT(W, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOGE( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_ERROR, LOG_FORMAT(E, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGI( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { ets_printf(LOG_FORMAT(I, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOGW( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_WARN, LOG_FORMAT(W, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGD( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOGI( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_INFO, LOG_FORMAT(I, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGV( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { ets_printf(LOG_FORMAT(V, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOGD( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_DEBUG, LOG_FORMAT(D, format), ##__VA_ARGS__)
#define ESP_COREDUMP_LOGV( format, ... ) ESP_COREDUMP_LOG(ESP_LOG_VERBOSE, LOG_FORMAT(V, format), ##__VA_ARGS__)
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
#define ESP_COREDUMP_LOG_PROCESS( format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_early_timestamp(), TAG, ##__VA_ARGS__); } #define ESP_COREDUMP_LOG_PROCESS( format, ... ) ESP_COREDUMP_LOGD(format, ##__VA_ARGS__)
#else #else
#define ESP_COREDUMP_LOG_PROCESS( format, ... ) do{/*(__VA_ARGS__);*/}while(0) #define ESP_COREDUMP_LOG_PROCESS( format, ... ) do{/*(__VA_ARGS__);*/}while(0)
#endif #endif
@@ -345,8 +346,9 @@ void esp_core_dump_to_flash(XtExcFrame *frame)
#endif #endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART #if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART
static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8_t *dst) { static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8_t *dst) {
static const char *b64 = const static DRAM_ATTR char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int i, j, a, b, c; int i, j, a, b, c;
@@ -373,14 +375,14 @@ static void esp_core_dump_b64_encode(const uint8_t *src, uint32_t src_len, uint8
static esp_err_t esp_core_dump_uart_write_start(void *priv) static esp_err_t esp_core_dump_uart_write_start(void *priv)
{ {
esp_err_t err = ESP_OK; esp_err_t err = ESP_OK;
ets_printf("================= CORE DUMP START =================\r\n"); ets_printf(DRAM_STR("================= CORE DUMP START =================\r\n"));
return err; return err;
} }
static esp_err_t esp_core_dump_uart_write_end(void *priv) static esp_err_t esp_core_dump_uart_write_end(void *priv)
{ {
esp_err_t err = ESP_OK; esp_err_t err = ESP_OK;
ets_printf("================= CORE DUMP END =================\r\n"); ets_printf(DRAM_STR("================= CORE DUMP END =================\r\n"));
return err; return err;
} }
@@ -398,7 +400,7 @@ static esp_err_t esp_core_dump_uart_write_data(void *priv, void * data, uint32_t
memcpy(tmp, addr, len); memcpy(tmp, addr, len);
esp_core_dump_b64_encode((const uint8_t *)tmp, len, (uint8_t *)buf); esp_core_dump_b64_encode((const uint8_t *)tmp, len, (uint8_t *)buf);
addr += len; addr += len;
ets_printf("%s\r\n", buf); ets_printf(DRAM_STR("%s\r\n"), buf);
} }
return err; return err;
@@ -427,7 +429,8 @@ void esp_core_dump_to_uart(XtExcFrame *frame)
wr_cfg.priv = NULL; wr_cfg.priv = NULL;
//Make sure txd/rxd are enabled //Make sure txd/rxd are enabled
gpio_pullup_dis(1); // use direct reg access instead of gpio_pullup_dis which can cause exception when flash cache is disabled
REG_CLR_BIT(GPIO_PIN_REG_1, FUN_PU);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
@@ -438,10 +441,6 @@ void esp_core_dump_to_uart(XtExcFrame *frame)
tm_cur = xthal_get_ccount() / (XT_CLOCK_FREQ / 1000); tm_cur = xthal_get_ccount() / (XT_CLOCK_FREQ / 1000);
if (tm_cur >= tm_end) if (tm_cur >= tm_end)
break; break;
/* Feed the Cerberus. */
TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
TIMERG0.wdt_feed = 1;
TIMERG0.wdt_wprotect = 0;
ch = esp_core_dump_uart_get_char(); ch = esp_core_dump_uart_get_char();
} }
ESP_COREDUMP_LOGI("Print core dump to uart..."); ESP_COREDUMP_LOGI("Print core dump to uart...");
@@ -455,18 +454,18 @@ void esp_core_dump_init()
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
const esp_partition_t *core_part; const esp_partition_t *core_part;
ESP_LOGI(TAG, "Init core dump to flash"); ESP_COREDUMP_LOGI("Init core dump to flash");
core_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, NULL); core_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_COREDUMP, NULL);
if (!core_part) { if (!core_part) {
ESP_LOGE(TAG, "No core dump partition found!"); ESP_COREDUMP_LOGE("No core dump partition found!");
return; return;
} }
ESP_LOGI(TAG, "Found partition '%s' @ %x %d bytes", core_part->label, core_part->address, core_part->size); ESP_COREDUMP_LOGI("Found partition '%s' @ %x %d bytes", core_part->label, core_part->address, core_part->size);
s_core_part_start = core_part->address; s_core_part_start = core_part->address;
s_core_part_size = core_part->size; s_core_part_size = core_part->size;
#endif #endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART #if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART
ESP_LOGI(TAG, "Init core dump to UART"); ESP_COREDUMP_LOGI("Init core dump to UART");
#endif #endif
} }

View File

@@ -210,6 +210,10 @@ void start_cpu0_default(void)
/* init default OS-aware flash access critical section */ /* init default OS-aware flash access critical section */
spi_flash_guard_set(&g_flash_guard_default_ops); spi_flash_guard_set(&g_flash_guard_default_ops);
#if CONFIG_ESP32_ENABLE_COREDUMP
esp_core_dump_init();
#endif
#if CONFIG_ESP32_PHY_AUTO_INIT #if CONFIG_ESP32_PHY_AUTO_INIT
nvs_flash_init(); nvs_flash_init();
do_phy_init(); do_phy_init();
@@ -221,10 +225,6 @@ void start_cpu0_default(void)
} }
#endif #endif
#if CONFIG_ESP32_ENABLE_COREDUMP
esp_core_dump_init();
#endif
xTaskCreatePinnedToCore(&main_task, "main", xTaskCreatePinnedToCore(&main_task, "main",
ESP_TASK_MAIN_STACK, NULL, ESP_TASK_MAIN_STACK, NULL,
ESP_TASK_MAIN_PRIO, NULL, 0); ESP_TASK_MAIN_PRIO, NULL, 0);

View File

@@ -686,7 +686,7 @@ esp_err_t IRAM_ATTR esp_intr_disable(intr_handle_t handle)
} }
void esp_intr_noniram_disable() void IRAM_ATTR esp_intr_noniram_disable()
{ {
int oldint; int oldint;
int cpu=xPortGetCoreID(); int cpu=xPortGetCoreID();
@@ -705,7 +705,7 @@ void esp_intr_noniram_disable()
non_iram_int_disabled[cpu]=oldint&non_iram_int_mask[cpu]; non_iram_int_disabled[cpu]=oldint&non_iram_int_mask[cpu];
} }
void esp_intr_noniram_enable() void IRAM_ATTR esp_intr_noniram_enable()
{ {
int cpu=xPortGetCoreID(); int cpu=xPortGetCoreID();
int intmask=non_iram_int_disabled[cpu]; int intmask=non_iram_int_disabled[cpu];

View File

@@ -80,6 +80,7 @@ SECTIONS
*(.iram1 .iram1.*) *(.iram1 .iram1.*)
*libfreertos.a:(.literal .text .literal.* .text.*) *libfreertos.a:(.literal .text .literal.* .text.*)
*libesp32.a:panic.o(.literal .text .literal.* .text.*) *libesp32.a:panic.o(.literal .text .literal.* .text.*)
*libesp32.a:core_dump.o(.literal .text .literal.* .text.*)
*libphy.a:(.literal .text .literal.* .text.*) *libphy.a:(.literal .text .literal.* .text.*)
*librtc.a:(.literal .text .literal.* .text.*) *librtc.a:(.literal .text .literal.* .text.*)
*libpp.a:(.literal .text .literal.* .text.*) *libpp.a:(.literal .text .literal.* .text.*)

View File

@@ -267,7 +267,7 @@ static void reconfigureAllWdts()
TIMERG1.wdt_wprotect = 0; TIMERG1.wdt_wprotect = 0;
} }
#if CONFIG_ESP32_PANIC_GDBSTUB || CONFIG_ESP32_PANIC_PRINT_HALT #if CONFIG_ESP32_PANIC_GDBSTUB || CONFIG_ESP32_PANIC_PRINT_HALT || CONFIG_ESP32_ENABLE_COREDUMP
/* /*
This disables all the watchdogs for when we call the gdbstub. This disables all the watchdogs for when we call the gdbstub.
*/ */
@@ -367,11 +367,15 @@ static void commonErrorHandler(XtExcFrame *frame)
panicPutStr("Entering gdb stub now.\r\n"); panicPutStr("Entering gdb stub now.\r\n");
esp_gdbstub_panic_handler(frame); esp_gdbstub_panic_handler(frame);
#else #else
#if CONFIG_ESP32_ENABLE_COREDUMP
disableAllWdts();
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
esp_core_dump_to_flash(frame); esp_core_dump_to_flash(frame);
#endif #endif
#if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART && !CONFIG_ESP32_PANIC_SILENT_REBOOT #if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART && !CONFIG_ESP32_PANIC_SILENT_REBOOT
esp_core_dump_to_uart(frame); esp_core_dump_to_uart(frame);
#endif
reconfigureAllWdts();
#endif #endif
#if CONFIG_ESP32_PANIC_PRINT_REBOOT || CONFIG_ESP32_PANIC_SILENT_REBOOT #if CONFIG_ESP32_PANIC_PRINT_REBOOT || CONFIG_ESP32_PANIC_SILENT_REBOOT
panicPutStr("Rebooting...\r\n"); panicPutStr("Rebooting...\r\n");

View File

@@ -537,6 +537,10 @@ static void emac_check_phy_init(void)
} else { } else {
REG_CLR_BIT(EMAC_GMACCONFIG_REG, EMAC_GMACFESPEED); REG_CLR_BIT(EMAC_GMACCONFIG_REG, EMAC_GMACFESPEED);
} }
#if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
emac_disable_flowctrl();
emac_config.emac_flow_ctrl_partner_support = false;
#else
if (emac_config.emac_flow_ctrl_enable == true) { if (emac_config.emac_flow_ctrl_enable == true) {
if (emac_config.emac_phy_get_partner_pause_enable() == true && emac_config.emac_phy_get_duplex_mode() == ETH_MDOE_FULLDUPLEX) { if (emac_config.emac_phy_get_partner_pause_enable() == true && emac_config.emac_phy_get_duplex_mode() == ETH_MDOE_FULLDUPLEX) {
emac_enable_flowctrl(); emac_enable_flowctrl();
@@ -549,6 +553,7 @@ static void emac_check_phy_init(void)
emac_disable_flowctrl(); emac_disable_flowctrl();
emac_config.emac_flow_ctrl_partner_support = false; emac_config.emac_flow_ctrl_partner_support = false;
} }
#endif
emac_mac_enable_txrx(); emac_mac_enable_txrx();
} }
static void emac_process_link_updown(bool link_status) static void emac_process_link_updown(bool link_status)

View File

@@ -632,7 +632,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
*/ */
void taskYIELD_OTHER_CORE( BaseType_t xCoreID, UBaseType_t uxPriority ) void taskYIELD_OTHER_CORE( BaseType_t xCoreID, UBaseType_t uxPriority )
{ {
TCB_t *curTCB = xTaskGetCurrentTaskHandle(); TCB_t *curTCB = pxCurrentTCB[xCoreID];
BaseType_t i; BaseType_t i;
if (xCoreID != tskNO_AFFINITY) { if (xCoreID != tskNO_AFFINITY) {

View File

@@ -62,12 +62,16 @@ static esp_err_t spi_flash_translate_rc(SpiFlashOpResult rc);
const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_default_ops = { const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_default_ops = {
.start = spi_flash_disable_interrupts_caches_and_other_cpu, .start = spi_flash_disable_interrupts_caches_and_other_cpu,
.end = spi_flash_enable_interrupts_caches_and_other_cpu .end = spi_flash_enable_interrupts_caches_and_other_cpu,
.op_lock = spi_flash_op_lock,
.op_unlock = spi_flash_op_unlock
}; };
const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_no_os_ops = { const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_no_os_ops = {
.start = spi_flash_disable_interrupts_caches_and_other_cpu_no_os, .start = spi_flash_disable_interrupts_caches_and_other_cpu_no_os,
.end = spi_flash_enable_interrupts_caches_no_os .end = spi_flash_enable_interrupts_caches_no_os,
.op_lock = 0,
.op_unlock = 0
}; };
static const spi_flash_guard_funcs_t *s_flash_guard_ops; static const spi_flash_guard_funcs_t *s_flash_guard_ops;
@@ -80,12 +84,12 @@ void spi_flash_init()
#endif #endif
} }
void spi_flash_guard_set(const spi_flash_guard_funcs_t* funcs) void IRAM_ATTR spi_flash_guard_set(const spi_flash_guard_funcs_t* funcs)
{ {
s_flash_guard_ops = funcs; s_flash_guard_ops = funcs;
} }
size_t spi_flash_get_chip_size() size_t IRAM_ATTR spi_flash_get_chip_size()
{ {
return g_rom_flashchip.chip_size; return g_rom_flashchip.chip_size;
} }
@@ -105,18 +109,32 @@ static SpiFlashOpResult IRAM_ATTR spi_flash_unlock()
static inline void IRAM_ATTR spi_flash_guard_start() static inline void IRAM_ATTR spi_flash_guard_start()
{ {
if (s_flash_guard_ops) { if (s_flash_guard_ops && s_flash_guard_ops->start) {
s_flash_guard_ops->start(); s_flash_guard_ops->start();
} }
} }
static inline void IRAM_ATTR spi_flash_guard_end() static inline void IRAM_ATTR spi_flash_guard_end()
{ {
if (s_flash_guard_ops) { if (s_flash_guard_ops && s_flash_guard_ops->end) {
s_flash_guard_ops->end(); s_flash_guard_ops->end();
} }
} }
static inline void IRAM_ATTR spi_flash_guard_op_lock()
{
if (s_flash_guard_ops && s_flash_guard_ops->op_lock) {
s_flash_guard_ops->op_lock();
}
}
static inline void IRAM_ATTR spi_flash_guard_op_unlock()
{
if (s_flash_guard_ops && s_flash_guard_ops->op_unlock) {
s_flash_guard_ops->op_unlock();
}
}
esp_err_t IRAM_ATTR spi_flash_erase_sector(size_t sec) esp_err_t IRAM_ATTR spi_flash_erase_sector(size_t sec)
{ {
return spi_flash_erase_range(sec * SPI_FLASH_SEC_SIZE, SPI_FLASH_SEC_SIZE); return spi_flash_erase_range(sec * SPI_FLASH_SEC_SIZE, SPI_FLASH_SEC_SIZE);
@@ -251,9 +269,9 @@ esp_err_t IRAM_ATTR spi_flash_write(size_t dst, const void *srcv, size_t size)
out: out:
COUNTER_STOP(write); COUNTER_STOP(write);
spi_flash_op_lock(); spi_flash_guard_op_lock();
spi_flash_mark_modified_region(dst, size); spi_flash_mark_modified_region(dst, size);
spi_flash_op_unlock(); spi_flash_guard_op_unlock();
return spi_flash_translate_rc(rc); return spi_flash_translate_rc(rc);
} }
@@ -320,9 +338,9 @@ esp_err_t IRAM_ATTR spi_flash_write_encrypted(size_t dest_addr, const void *src,
} }
COUNTER_ADD_BYTES(write, size); COUNTER_ADD_BYTES(write, size);
spi_flash_op_lock(); spi_flash_guard_op_lock();
spi_flash_mark_modified_region(dest_addr, size); spi_flash_mark_modified_region(dest_addr, size);
spi_flash_op_unlock(); spi_flash_guard_op_unlock();
return spi_flash_translate_rc(rc); return spi_flash_translate_rc(rc);
} }
@@ -444,7 +462,7 @@ esp_err_t IRAM_ATTR spi_flash_read_encrypted(size_t src, void *dstv, size_t size
} }
static esp_err_t spi_flash_translate_rc(SpiFlashOpResult rc) static esp_err_t IRAM_ATTR spi_flash_translate_rc(SpiFlashOpResult rc)
{ {
switch (rc) { switch (rc) {
case SPI_FLASH_RESULT_OK: case SPI_FLASH_RESULT_OK:

View File

@@ -205,9 +205,35 @@ typedef void (*spi_flash_guard_start_func_t)(void);
* @brief SPI flash critical section exit function. * @brief SPI flash critical section exit function.
*/ */
typedef void (*spi_flash_guard_end_func_t)(void); typedef void (*spi_flash_guard_end_func_t)(void);
/**
* @brief SPI flash operation lock function.
*/
typedef void (*spi_flash_op_lock_func_t)(void);
/**
* @brief SPI flash operation unlock function.
*/
typedef void (*spi_flash_op_unlock_func_t)(void);
/** /**
* Structure holding SPI flash access critical section management functions * Structure holding SPI flash access critical sections management functions.
*
* Flash API uses two types of flash access management functions:
* 1) Functions which prepare/restore flash cache and interrupts before calling
* appropriate ROM functions (SPIWrite, SPIRead and SPIEraseBlock):
* - 'start' function should disables flash cache and non-IRAM interrupts and
* is invoked before the call to one of ROM function above.
* - 'end' function should restore state of flash cache and non-IRAM interrupts and
* is invoked after the call to one of ROM function above.
* 2) Functions which synchronizes access to internal data used by flash API.
* This functions are mostly intended to synchronize access to flash API internal data
* in multithreaded environment and use OS primitives:
* - 'op_lock' locks access to flash API internal data.
* - 'op_unlock' unlocks access to flash API internal data.
* Different versions of the guarding functions should be used depending on the context of
* execution (with or without functional OS). In normal conditions when flash API is called
* from task the functions use OS primitives. When there is no OS at all or when
* it is not guaranteed that OS is functional (accessing flash from exception handler) these
* functions cannot use OS primitives or even does not need them (multithreaded access is not possible).
* *
* @note Structure and corresponding guard functions should not reside in flash. * @note Structure and corresponding guard functions should not reside in flash.
* For example structure can be placed in DRAM and functions in IRAM sections. * For example structure can be placed in DRAM and functions in IRAM sections.
@@ -215,6 +241,8 @@ typedef void (*spi_flash_guard_end_func_t)(void);
typedef struct { typedef struct {
spi_flash_guard_start_func_t start; /**< critical section start func */ spi_flash_guard_start_func_t start; /**< critical section start func */
spi_flash_guard_end_func_t end; /**< critical section end func */ spi_flash_guard_end_func_t end; /**< critical section end func */
spi_flash_op_lock_func_t op_lock; /**< flash access API lock func */
spi_flash_op_unlock_func_t op_unlock; /**< flash access API unlock func */
} spi_flash_guard_funcs_t; } spi_flash_guard_funcs_t;
/** /**

View File

@@ -1,10 +1,12 @@
menu "Example 'GATT SERVER' Config" menu "Example 'GATT SERVER' Config"
config SET_RAW_ADV_DATA config SET_RAW_ADV_DATA
bool "adv data or scan_rsp data use raw data or structure" bool "Use raw data for advertising packets and scan response data"
default "y"
help help
Set raw advertising data/scan response data by self or use adv_data/scan_rsp_data structure to If this config item is set, raw binary data will be used to generate advertising & scan response data.
set advertising data/scan response data. If use structure, lower layer will encapsulate the packets. This option uses the esp_ble_gap_config_adv_data_raw() and esp_ble_gap_config_scan_rsp_data_raw() functions.
If this config item is unset, advertising & scan response data is provided via a higher-level esp_ble_adv_data_t structure.
The lower layer will generate the BLE packets. This option has higher overhead at runtime.
endmenu endmenu

View File

@@ -62,10 +62,14 @@ esp_attr_value_t gatts_demo_char1_val =
}; };
#ifdef CONFIG_SET_RAW_ADV_DATA #ifdef CONFIG_SET_RAW_ADV_DATA
static uint8_t raw_adv_data[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, static uint8_t raw_adv_data[] = {
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe}; 0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
static uint8_t raw_scan_rsp_data[] = {0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa, 0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
0xb, 0xb, 0xb, 0xb, 0xc, 0xc, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xe, 0xe, 0xe}; };
static uint8_t raw_scan_rsp_data[] = {
0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
};
#else #else
static uint8_t test_service_uuid128[32] = { static uint8_t test_service_uuid128[32] = {
/* LSB <--------------------------------------------------------------------------------> MSB */ /* LSB <--------------------------------------------------------------------------------> MSB */