Skip to content

Fix for #723 Bugfix/fix spi 4 byte alignment error (GIT8266O-397) (GIT8266O-704) #1126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
362d25b
chore(ci): Modify CI image URL
donghengqaz Apr 19, 2021
c2be3ba
Merge branch 'bugfix/check_and_reset_mac_reg_every_2s_when_rx_hang' i…
donghengqaz Mar 30, 2021
abeb1dd
Merge branch 'chore/modify_docs_ci_url_v3.4' into 'release/v3.4'
donghengqaz Apr 20, 2021
e2fe180
Merge branch 'cherry-pick-30a4ba7e' into 'release/v3.4'
donghengqaz Apr 20, 2021
9902931
fix(mbedtls): Fix mbedtls_ssl_send_alert_message crash due to ssl->ou…
ESP-YJM Mar 12, 2021
cf820bf
Merge branch 'bugfix/fix_mbedtls_send_alert_crash_v3.4' into 'release…
donghengqaz Apr 28, 2021
a8be948
tcpip_adapter: fix set static ip fail and remove the dhcp_check timer
ESP-YJM Apr 27, 2021
f9aca5a
fix: potential blocking code when call uart_wait_tx_done()
ustccw Apr 28, 2021
504fa5f
Merge branch 'bugfix/fix_dhcp_set_static_ip_fail_v3.4' into 'release/…
donghengqaz Apr 28, 2021
a60ee4e
Merge branch 'bugfix/uart_tx_done_timeout_check_v3.4' into 'release/v…
donghengqaz Apr 28, 2021
0c9be8d
fix(lib): fix beacon ie error when set to bgn mode
ustccw May 12, 2021
2abe921
Merge branch 'bugfix/beacon_ie_error_when_set_to_bgn_mode_v3.4' into …
donghengqaz May 13, 2021
b54fb1b
freertos: Add queue init overflow check
projectgus May 4, 2021
91163a8
freertos: Add addition overflow check for stream buffer
projectgus May 4, 2021
fc70295
Merge branch 'bugfix/queue_arith_overflow_v3.4' into 'release/v3.4'
donghengqaz May 13, 2021
f46ef19
fix(sc): fix the issue of sending failure and exit
cwespressif May 7, 2021
699b6fd
Merge branch 'bugfix/fix_sc_send_failed_issue_for_v3.4' into 'release…
donghengqaz May 17, 2021
611a942
fix(lib): restart softap when phy mode change (backport v3.4)
ustccw May 18, 2021
bedf68f
Merge branch 'bugfix/restart_softap_when_phy_mode_change_v3.4' into '…
donghengqaz May 18, 2021
5047c3a
fix(wifi): fragment and forge vulnerability detection
May 21, 2021
be11a5a
fix(lib): update lib
May 21, 2021
967752e
Merge branch 'bugfix/fragment_and_forge_vulnerability_detection_v3.4'…
donghengqaz May 24, 2021
1d1b995
fix(smartconfig): add timeout for airkiss sync
Jun 2, 2021
9e3c3c8
Merge branch 'bugfix/add_timeout_for_airkiss_sync_v3.4' into 'release…
donghengqaz Jun 2, 2021
186b244
feat(sc): Support ESP-Touch-V2 to send unicast
cwespressif May 15, 2021
ba8b38b
chore(ci): Modify SSC branch for CI
donghengqaz Jul 26, 2021
60079c9
Merge branch 'chore/modify_ci_ssc_branch_v3.4' into 'release/v3.4'
donghengqaz Jul 26, 2021
97d0c2a
feat(nvs_flash): Bring nvs_flash from esp-idf
donghengqaz Jul 23, 2021
0b85707
feat(nvs_flash): Modify for ESP8266
donghengqaz Jul 23, 2021
85a9f33
Merge branch 'feature/update_nvs_flash_from_esp-idf_v3.4' into 'relea…
donghengqaz Jul 26, 2021
bd5a4c3
fix(lib): fix smartconfig stop error
Jul 23, 2021
2c9b38b
fix(wpa_supplicant): fix pmk error
Jul 23, 2021
3d11cbc
Merge branch 'feature/support_esptouch_v2_send_unicast_for_v3.4' into…
donghengqaz Jul 26, 2021
562e650
Merge branch 'bugfix/fix_smartconfig_stop_error_v3.4' into 'release/v…
donghengqaz Jul 26, 2021
e600fe0
Merge branch 'bugfix/fix_pmk_error_v3.4' into 'release/v3.4'
donghengqaz Jul 26, 2021
86f399a
feat(nvs_flash): Update nvs_flash from esp-idf
donghengqaz Jul 30, 2021
d92d00e
Merge branch 'feature/update_nvs_flash_from_esp-idf_v3.4' into 'relea…
donghengqaz Aug 2, 2021
236ff89
Fix for the SPI communication problem described in "Improve SPI inter…
vargavik Aug 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ variables:

IDF_PATH: "$CI_PROJECT_DIR"

# Versioned esp-idf-doc env image to use for all document building jobs
ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v8"

# before each job, we need to check if this job is filtered by bot stage/job filter
.apply_bot_filter: &apply_bot_filter
python $APPLY_BOT_FILTER_SCRIPT || exit 0
Expand Down Expand Up @@ -45,7 +48,7 @@ build_ssc:
- git clone $GITLAB_SSH_SERVER/yinling/SSC.git
- cd SSC
# try checkout same branch
- git checkout "${CI_BUILD_REF_NAME}_8266" || echo "Using default branch..."
- git checkout "release/v3.4_8266" || echo "Using default branch..."
- ./gen_misc_rtos.sh

push_master_to_github:
Expand Down Expand Up @@ -79,7 +82,7 @@ push_master_to_github:

build_docs:
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
image: $ESP_IDF_DOC_ENV_IMAGE
tags:
- build_docs
artifacts:
Expand Down
15 changes: 6 additions & 9 deletions components/esp8266/driver/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_master_trans(spi_host_t host, spi_
SPI[host]->data_buf[y] = trans->mosi[y];
}
} else {
ESP_LOGW(TAG,"Using unaligned data may reduce transmission efficiency");
memset(spi_object[host]->buf, 0, sizeof(uint32_t) * 16);
memcpy(spi_object[host]->buf, trans->mosi, trans->bits.mosi / 8 + (trans->bits.mosi % 8) ? 1 : 0);
memcpy(spi_object[host]->buf, trans->mosi, trans->bits.mosi / 8 + ((trans->bits.mosi % 8) ? 1 : 0));

for (x = 0; x < trans->bits.mosi; x += 32) {
y = x / 32;
SPI[host]->data_buf[y] = spi_object[host]->buf[y];
Expand Down Expand Up @@ -522,19 +521,17 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_master_trans(spi_host_t host, spi_
if (trans->bits.miso && trans->miso) {
while (SPI[host]->cmd.usr);

if ((uint32_t)(trans->miso) % 4 == 0) {
if ((uint32_t)(trans->miso) % 4 == 0 && trans->bits.miso % 32 == 0) {
for (x = 0; x < trans->bits.miso; x += 32) {
y = x / 32;
trans->miso[y] = SPI[host]->data_buf[y];
}
} else {
ESP_LOGW(TAG,"Using unaligned data may reduce transmission efficiency");
memset(spi_object[host]->buf, 0, sizeof(uint32_t) * 16);
for (x = 0; x < trans->bits.miso; x += 32) {
y = x / 32;
spi_object[host]->buf[y] = SPI[host]->data_buf[y];
}
memcpy(trans->miso, spi_object[host]->buf, trans->bits.miso / 8 + (trans->bits.miso % 8) ? 1 : 0);
memcpy(trans->miso, spi_object[host]->buf, trans->bits.miso / 8 + ((trans->bits.miso % 8) ? 1 : 0));
}
}

Expand Down Expand Up @@ -577,7 +574,7 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_slave_trans(spi_host_t host, spi_t
} else {
ESP_LOGW(TAG,"Using unaligned data may reduce transmission efficiency");
memset(spi_object[host]->buf, 0, sizeof(uint32_t) * 16);
memcpy(spi_object[host]->buf, trans->miso, trans->bits.miso / 8 + (trans->bits.miso % 8) ? 1 : 0);
memcpy(spi_object[host]->buf, trans->miso, trans->bits.miso / 8 + ((trans->bits.miso % 8) ? 1 : 0));
for (x = 0; x < trans->bits.miso; x += 32) {
y = x / 32;
SPI[host]->data_buf[y] = spi_object[host]->buf[y];
Expand All @@ -599,7 +596,7 @@ static esp_err_t SPI_HIGH_THROUGHPUT_ATTR spi_slave_trans(spi_host_t host, spi_t
y = x / 32;
spi_object[host]->buf[y] = SPI[host]->data_buf[y];
}
memcpy(trans->mosi, spi_object[host]->buf, trans->bits.mosi / 8 + (trans->bits.mosi % 8) ? 1 : 0);
memcpy(trans->mosi, spi_object[host]->buf, trans->bits.mosi / 8 + ((trans->bits.mosi % 8) ? 1 : 0));
}
}

Expand Down
25 changes: 24 additions & 1 deletion components/esp8266/driver/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,18 @@ esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait)
uint32_t baudrate;
uint32_t byte_delay_us = 0;
BaseType_t res;
portTickType ticks_cur;
portTickType ticks_start = xTaskGetTickCount();
portTickType ticks_end = xTaskGetTickCount() + ticks_to_wait;
/**
* Considering the overflow of the ticks_end and the ticks_cur (xTaskGetTickCount()),
* the possible tick timestamp is as follows:
* (one start tick timestamp, two end tick timestamps, four current tick timestamps)
*
* ticks: 0 0xFFFFFFFF
* |_______._______._______._______._______._______._______._______|
* cur1 end1 cur2 start cur3 end2 cur4
*/

// Take tx_mux
res = xSemaphoreTake(p_uart_obj[uart_num]->tx_mux, (portTickType)ticks_to_wait);
Expand All @@ -273,10 +284,22 @@ esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait)
uart_get_baudrate(uart_num, &baudrate);
byte_delay_us = (uint32_t)(10000000 / baudrate); // (1/baudrate)*10*1000_000 us

ticks_to_wait = ticks_end - xTaskGetTickCount();
ticks_cur = xTaskGetTickCount();
if (ticks_start <= ticks_cur) {
ticks_to_wait = ticks_to_wait - (ticks_cur - ticks_start);
} else {
ticks_to_wait = ticks_to_wait - (portMAX_DELAY - ticks_start + ticks_cur);
}
// wait for tx done sem.
if (pdTRUE == xSemaphoreTake(p_uart_obj[uart_num]->tx_done_sem, ticks_to_wait)) {
while (1) {
ticks_cur = xTaskGetTickCount();
bool end1_timeout = (ticks_end < ticks_start && ticks_cur < ticks_start && ticks_cur > ticks_end);
bool end2_timeout = (ticks_start < ticks_end && (ticks_cur < ticks_start || ticks_end < ticks_cur));
if (end1_timeout || end2_timeout) {
xSemaphoreGive(p_uart_obj[uart_num]->tx_mux);
return ESP_ERR_TIMEOUT;
}
if (UART[uart_num]->status.txfifo_cnt == 0) {
ets_delay_us(byte_delay_us); // Delay one byte time to guarantee transmission completion
break;
Expand Down
6 changes: 6 additions & 0 deletions components/esp8266/include/esp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@

#define _COUNTER_STRINGIFY(COUNTER) #COUNTER

#ifdef IDF_CI_BUILD
#define IDF_DEPRECATED(REASON) __attribute__((deprecated(REASON)))
#else
#define IDF_DEPRECATED(REASON)
#endif

#endif /* __ESP_ATTR_H__ */
10 changes: 5 additions & 5 deletions components/esp8266/lib/VERSION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
gwen:
core: cebfb0e
net80211: 8114f9c
pp: 52bb147
espnow: 7a93d71
core: db51cd0
net80211: db51cd0
pp: db51cd0
espnow: db51cd0

smartconfig: 3.0.0/5f550c40
smartconfig: 3.0.0/283eacca
phy: 1163.0
Binary file modified components/esp8266/lib/libcore.a
Binary file not shown.
Binary file modified components/esp8266/lib/libcore_dbg.a
Binary file not shown.
Binary file modified components/esp8266/lib/libespnow.a
Binary file not shown.
Binary file modified components/esp8266/lib/libespnow_dbg.a
Binary file not shown.
Binary file modified components/esp8266/lib/libnet80211.a
Binary file not shown.
Binary file modified components/esp8266/lib/libnet80211_dbg.a
Binary file not shown.
Binary file modified components/esp8266/lib/libpp.a
Binary file not shown.
Binary file modified components/esp8266/lib/libpp_dbg.a
Binary file not shown.
Binary file modified components/esp8266/lib/libsmartconfig.a
Binary file not shown.
12 changes: 6 additions & 6 deletions components/esp8266/source/phy_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ static const char* PHY_NAMESPACE = "phy";
static const char* PHY_CAL_DATA_KEY = "cal_data";
static const char* PHY_RX_GAIN_DC_TABLE_KEY = "dc_table";

static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
esp_phy_calibration_data_t* out_cal_data);

static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
const esp_phy_calibration_data_t* cal_data);

esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data)
{
nvs_handle handle;
nvs_handle_t handle;
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READONLY, &handle);

if (err == ESP_ERR_NVS_NOT_INITIALIZED) {
Expand All @@ -230,7 +230,7 @@ esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_dat

esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data)
{
nvs_handle handle;
nvs_handle_t handle;
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);

if (err != ESP_OK) {
Expand All @@ -243,7 +243,7 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da
}
}

static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
esp_phy_calibration_data_t* out_cal_data)
{
esp_err_t err;
Expand Down Expand Up @@ -278,7 +278,7 @@ static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
return ESP_OK;
}

static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
const esp_phy_calibration_data_t* cal_data)
{
esp_err_t err;
Expand Down
52 changes: 30 additions & 22 deletions components/esp8266/source/smartconfig_ack.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "esp_wifi.h"
#include "esp_smartconfig.h"
#include "smartconfig_ack.h"
#include "lwip/inet.h"

#define SC_ACK_TASK_PRIORITY 2 /*!< Priority of sending smartconfig ACK task */
#define SC_ACK_TASK_STACK_SIZE 2048 /*!< Stack size of sending smartconfig ACK task */
Expand All @@ -40,7 +41,7 @@
#define SC_ACK_TOUCH_V2_SERVER_PORT(i) (18266+i*10000) /*!< ESP touch_v2 UDP port of server on cellphone */
#define SC_ACK_AIRKISS_SERVER_PORT 10000 /*!< Airkiss UDP port of server on cellphone */
#define SC_ACK_AIRKISS_DEVICE_PORT 10001 /*!< Airkiss UDP port of server on device */
#define SC_ACK_AIRKISS_TIMEOUT 1500 /*!< Airkiss read data timout millisecond */
#define SC_ACK_TIMEOUT 1500 /*!< Airkiss and ESP touch_v2 read data timout millisecond */

#define SC_ACK_TOUCH_LEN 11 /*!< Length of ESP touch ACK context */
#define SC_ACK_AIRKISS_LEN 7 /*!< Length of Airkiss ACK context */
Expand Down Expand Up @@ -79,7 +80,7 @@ static void sc_ack_send_task(void* pvParameters)
sc_ack_t* ack = (sc_ack_t*)pvParameters;
tcpip_adapter_ip_info_t local_ip;
uint8_t remote_ip[4];
memset(remote_ip, 0xFF, sizeof(remote_ip));
memcpy(remote_ip, ack->ctx.ip, sizeof(remote_ip));
struct sockaddr_in server_addr;
socklen_t sin_size = sizeof(server_addr);
int send_sock = -1;
Expand All @@ -99,6 +100,7 @@ static void sc_ack_send_task(void* pvParameters)
port_bit = 0;
}
remote_port = SC_ACK_TOUCH_V2_SERVER_PORT(port_bit);
memset(remote_ip, 0xFF, sizeof(remote_ip));
} else {
remote_port = SC_ACK_AIRKISS_SERVER_PORT;
}
Expand Down Expand Up @@ -132,21 +134,24 @@ static void sc_ack_send_task(void* pvParameters)

setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int));

if (ack->type == SC_TYPE_AIRKISS) {
if (ack->type == SC_TYPE_AIRKISS || ack->type == SC_TYPE_ESPTOUCH_V2) {
char data = 0;
struct sockaddr_in local_addr, from;
socklen_t sockadd_len = sizeof(struct sockaddr);
struct timeval timeout = {
SC_ACK_AIRKISS_TIMEOUT / 1000,
SC_ACK_AIRKISS_TIMEOUT % 1000 * 1000
SC_ACK_TIMEOUT / 1000,
SC_ACK_TIMEOUT % 1000 * 1000
};

bzero(&local_addr, sizeof(struct sockaddr_in));
bzero(&from, sizeof(struct sockaddr_in));
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = INADDR_ANY;
local_addr.sin_port = htons(SC_ACK_AIRKISS_DEVICE_PORT);

if (ack->type == SC_TYPE_AIRKISS) {
local_addr.sin_port = htons(SC_ACK_AIRKISS_DEVICE_PORT);
} else {
local_addr.sin_port = htons(SC_ACK_TOUCH_DEVICE_PORT);
}
bind(send_sock, (struct sockaddr*)&local_addr, sockadd_len);
setsockopt(send_sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));

Expand All @@ -155,31 +160,34 @@ static void sc_ack_send_task(void* pvParameters)
if (from.sin_addr.s_addr != INADDR_ANY) {
memcpy(remote_ip, &from.sin_addr, 4);
server_addr.sin_addr.s_addr = from.sin_addr.s_addr;
ESP_LOGI(TAG, "cellphone_ip: %s", inet_ntoa(server_addr.sin_addr));
} else {
goto _end;
server_addr.sin_addr.s_addr = INADDR_BROADCAST;
}
}

uint32_t ip_addr = server_addr.sin_addr.s_addr;
while (s_sc_ack_send) {
/* Send smartconfig ACK every 100ms. */
vTaskDelay(100 / portTICK_RATE_MS);
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);

if (sendlen > 0) {
/* Totally send 60 smartconfig ACKs. Then smartconfig is successful. */
if (packet_count++ >= SC_ACK_MAX_COUNT) {
esp_event_post(SC_EVENT, SC_EVENT_SEND_ACK_DONE, NULL, 0, portMAX_DELAY);
goto _end;
}
if (ip_addr != INADDR_BROADCAST) {
sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
server_addr.sin_addr.s_addr = INADDR_BROADCAST;
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
server_addr.sin_addr.s_addr = ip_addr;
} else {
err = sc_ack_send_get_errno(send_sock);

if (err == ENOMEM || err == EAGAIN) {
ESP_LOGD(TAG, "send failed, errno %d", err);
continue;
}
sendlen = sendto(send_sock, &ack->ctx, ack_len, 0, (struct sockaddr*) &server_addr, sin_size);
}

if (sendlen <= 0) {
err = sc_ack_send_get_errno(send_sock);
ESP_LOGE(TAG, "send failed, errno %d", err);
vTaskDelay(200 / portTICK_RATE_MS);
}

/* Send 60 smartconfig ACKs, exit regardless of failure or success. */
if (packet_count++ >= SC_ACK_MAX_COUNT) {
esp_event_post(SC_EVENT, SC_EVENT_SEND_ACK_DONE, NULL, 0, portMAX_DELAY);
goto _end;
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/esp8266/source/system_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static const char *BACKUP_MAC_DATA_KEY = "backup_mac_data";
static esp_err_t load_backup_mac_data(uint8_t *mac)
{
esp_err_t err;
nvs_handle handle;
nvs_handle_t handle;
uint32_t efuse[4];
uint8_t efuse_crc = 0;
uint8_t calc_crc = 0;
Expand Down Expand Up @@ -221,7 +221,7 @@ static esp_err_t load_backup_mac_data(uint8_t *mac)
static esp_err_t store_backup_mac_data()
{
esp_err_t err;
nvs_handle handle;
nvs_handle_t handle;
uint32_t efuse[4];
efuse[0] = REG_READ(EFUSE_DATA0_REG);
efuse[1] = REG_READ(EFUSE_DATA1_REG);
Expand Down
25 changes: 24 additions & 1 deletion components/freertos/freertos/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
Queue_t *pxNewQueue;
size_t xQueueSizeInBytes;
uint8_t *pucQueueStorage;
BaseType_t overflow;

configASSERT( uxQueueLength > ( UBaseType_t ) 0 );

Expand All @@ -375,7 +376,29 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
}

pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );
/* Check for multiplication overflow. */
overflow = ( uxItemSize != 0 ) && ( uxQueueLength != ( xQueueSizeInBytes / uxItemSize ) );

/* Check for addition overflow. */
overflow = overflow || ( ( sizeof( Queue_t ) + xQueueSizeInBytes ) < xQueueSizeInBytes );

if ( overflow == (BaseType_t) 0 )
{
/* Allocate the queue and storage area. Justification for MISRA
deviation as follows: pvPortMalloc() always ensures returned memory
blocks are aligned per the requirements of the MCU stack. In this case
pvPortMalloc() must return a pointer that is guaranteed to meet the
alignment requirements of the Queue_t structure - which in this case
is an int8_t *. Therefore, whenever the stack alignment requirements
are greater than or equal to the pointer to char requirements the cast
is safe. In other cases alignment requirements are not strict (one or
two bytes). */
pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */
}
else
{
pxNewQueue = NULL;
}

if( pxNewQueue != NULL )
{
Expand Down
11 changes: 9 additions & 2 deletions components/freertos/freertos/stream_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,15 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
this is a quirk of the implementation that means otherwise the free
space would be reported as one byte smaller than would be logically
expected. */
xBufferSizeBytes++;
pucAllocatedMemory = ( uint8_t * ) pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); /*lint !e9079 malloc() only returns void*. */
if( xBufferSizeBytes < ( xBufferSizeBytes + 1 + sizeof( StreamBuffer_t ) ) )
{
xBufferSizeBytes++;
pucAllocatedMemory = ( uint8_t * ) pvPortMalloc( xBufferSizeBytes + sizeof( StreamBuffer_t ) ); /*lint !e9079 malloc() only returns void*. */
}
else
{
pucAllocatedMemory = NULL;
}

if( pucAllocatedMemory != NULL )
{
Expand Down
1 change: 0 additions & 1 deletion components/lwip/port/esp8266/netif/dhcp_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ static const char *interface_key[] = {"IF_STA", "IF_AP", "IF_ETH", "IF_TEST"};
_Static_assert(sizeof(interface_key) / sizeof(char*) == TCPIP_ADAPTER_IF_MAX,
"Number interface keys differs from number of interfaces");

typedef nvs_handle nvs_handle_t;
bool dhcp_ip_addr_restore(void *netif)
{
nvs_handle_t nvs;
Expand Down
Loading