Skip to content

Commit

Permalink
Merge branch 'espressif:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Jan 14, 2024
2 parents ae2f6a9 + b3f7e2c commit 952412a
Show file tree
Hide file tree
Showing 165 changed files with 3,431 additions and 12,481 deletions.
54 changes: 54 additions & 0 deletions .gitlab/ci/target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,60 @@ pytest_components_esp32_psramv0:
artifacts: false
tags: [ esp32, psramv0 ]

pytest_components_esp32_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32
needs:
- job: build_pytest_components_esp32
artifacts: false
tags: [ esp32, twai_std ]

pytest_components_esp32s2_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32s2
needs:
- job: build_pytest_components_esp32s2
artifacts: false
tags: [ esp32s2, twai_std ]

pytest_components_esp32s3_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32s3
needs:
- job: build_pytest_components_esp32s3
artifacts: false
tags: [ esp32s3, twai_std ]

pytest_components_esp32c3_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32c3
needs:
- job: build_pytest_components_esp32c3
artifacts: false
tags: [ esp32c3, twai_std ]

pytest_components_esp32c6_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32c6
needs:
- job: build_pytest_components_esp32c6
artifacts: false
tags: [ esp32c6, twai_std ]

pytest_components_esp32h2_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32h2
needs:
- job: build_pytest_components_esp32h2
artifacts: false
tags: [ esp32h2, twai_std ]

pytest_components_esp32s2_generic:
extends:
- .pytest_components_dir_template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -13,16 +13,21 @@
#include "hal/efuse_ll.h"
#include "hal/efuse_hal.h"

#include "hal/spi_flash_ll.h"
#include "rom/spi_flash.h"
#if CONFIG_IDF_TARGET_ESP32
# include "soc/spi_struct.h"
# include "soc/spi_reg.h"
/* SPI flash controller */
# define SPIFLASH SPI1
# define SPI0 SPI0
#else
# include "hal/spimem_flash_ll.h"
# include "soc/spi_mem_struct.h"
# include "soc/spi_mem_reg.h"
/* SPI flash controller */
# define SPIFLASH SPIMEM1
# define SPI0 SPIMEM0
#endif

// This dependency will be removed in the future. IDF-5025
Expand Down Expand Up @@ -581,10 +586,12 @@ IRAM_ATTR uint32_t bootloader_flash_execute_command_common(
uint32_t old_user_reg = SPIFLASH.user.val;
uint32_t old_user1_reg = SPIFLASH.user1.val;
uint32_t old_user2_reg = SPIFLASH.user2.val;
// Clear ctrl regs.
SPIFLASH.ctrl.val = 0;
#if CONFIG_IDF_TARGET_ESP32
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
spi_flash_ll_set_wp_level(&SPIFLASH, true);
#else
SPIFLASH.ctrl.val = SPI_MEM_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
spimem_flash_ll_set_wp_level(&SPIFLASH, true);
#endif
//command phase
SPIFLASH.user.usr_command = 1;
Expand Down Expand Up @@ -832,8 +839,8 @@ bool IRAM_ATTR bootloader_flash_is_octal_mode_enabled(void)
esp_rom_spiflash_read_mode_t bootloader_flash_get_spi_mode(void)
{
esp_rom_spiflash_read_mode_t spi_mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
uint32_t spi_ctrl = spi_flash_ll_get_ctrl_val(&SPI0);
#if CONFIG_IDF_TARGET_ESP32
uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0));
if (spi_ctrl & SPI_FREAD_QIO) {
spi_mode = ESP_ROM_SPIFLASH_QIO_MODE;
} else if (spi_ctrl & SPI_FREAD_QUAD) {
Expand All @@ -848,7 +855,6 @@ esp_rom_spiflash_read_mode_t bootloader_flash_get_spi_mode(void)
spi_mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
}
#else
uint32_t spi_ctrl = REG_READ(SPI_MEM_CTRL_REG(0));
if (spi_ctrl & SPI_MEM_FREAD_QIO) {
spi_mode = ESP_ROM_SPIFLASH_QIO_MODE;
} else if (spi_ctrl & SPI_MEM_FREAD_QUAD) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -30,9 +30,9 @@ void bootloader_flash_update_id()

void IRAM_ATTR bootloader_flash_cs_timing_config()
{
SET_PERI_REG_MASK(SPI_MEM_USER_REG(0), SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(0), SPI_MEM_CS_HOLD_TIME_V, 0, SPI_MEM_CS_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_MEM_CTRL2_REG(0), SPI_MEM_CS_SETUP_TIME_V, 0, SPI_MEM_CS_SETUP_TIME_S);
SET_PERI_REG_MASK(SPI_MEM_C_USER_REG, SPI_MEM_C_CS_HOLD_M | SPI_MEM_C_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_MEM_C_CTRL2_REG, SPI_MEM_C_CS_HOLD_TIME_V, 0, SPI_MEM_C_CS_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_MEM_C_CTRL2_REG, SPI_MEM_C_CS_SETUP_TIME_V, 0, SPI_MEM_C_CS_SETUP_TIME_S);
}

void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t *pfhdr)
Expand Down
2 changes: 1 addition & 1 deletion components/bt/host/bluedroid/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ config BT_BLUEDROID_PINNED_TO_CORE
config BT_BTU_TASK_STACK_SIZE
int "Bluetooth Bluedroid Host Stack task stack size"
depends on BT_BLUEDROID_ENABLED
default 4096
default 4352
help
This select btu task stack size

Expand Down
10 changes: 9 additions & 1 deletion components/bt/host/bluedroid/stack/btm/btm_ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2090,15 +2090,23 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length)

STREAM_TO_UINT8(length, p);

while ( length && (p - p_adv <= BTM_BLE_CACHE_ADV_DATA_MAX)) {
while ( length && (p - p_adv < BTM_BLE_CACHE_ADV_DATA_MAX)) {
STREAM_TO_UINT8(adv_type, p);

if ( adv_type == type ) {
/* length doesn't include itself */
*p_length = length - 1; /* minus the length of type */
return p;
}

p += length - 1; /* skip the length of data */

/* Break loop if advertising data is in an incorrect format,
as it may lead to memory overflow */
if (p >= p_adv + BTM_BLE_CACHE_ADV_DATA_MAX) {
break;
}

STREAM_TO_UINT8(length, p);
}

Expand Down
2 changes: 1 addition & 1 deletion components/bt/host/nimble/nimble
2 changes: 1 addition & 1 deletion components/console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ idf_component_register(SRCS "commands.c"
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
REQUIRES vfs
PRIV_REQUIRES esp_driver_uart
driver # to be replaced by esp_driver_usj
esp_driver_usb_serial_jtag
)
11 changes: 5 additions & 6 deletions components/console/esp_console_repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
#include "esp_err.h"
#include "esp_log.h"
#include "esp_console.h"
#include "esp_vfs_dev.h"
#include "esp_vfs_cdcacm.h"
#include "esp_vfs_usb_serial_jtag.h"
#include "driver/usb_serial_jtag_vfs.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
Expand Down Expand Up @@ -144,9 +143,9 @@ esp_err_t esp_console_new_repl_usb_serial_jtag(const esp_console_dev_usb_serial_
}

/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */
esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);

/* Enable blocking mode on stdin and stdout */
fcntl(fileno(stdout), F_SETFL, 0);
Expand All @@ -167,7 +166,7 @@ esp_err_t esp_console_new_repl_usb_serial_jtag(const esp_console_dev_usb_serial_
}

/* Tell vfs to use usb-serial-jtag driver */
esp_vfs_usb_serial_jtag_use_driver();
usb_serial_jtag_vfs_use_driver();

// setup history
ret = esp_console_setup_history(repl_config->history_save_path, repl_config->max_history_len, &usb_serial_jtag_repl->repl_com);
Expand Down Expand Up @@ -466,7 +465,7 @@ static esp_err_t esp_console_repl_usb_serial_jtag_delete(esp_console_repl_t *rep
}
repl_com->state = CONSOLE_REPL_STATE_DEINIT;
esp_console_deinit();
esp_vfs_usb_serial_jtag_use_nonblocking();
usb_serial_jtag_vfs_use_nonblocking();
usb_serial_jtag_driver_uninstall();
free(usb_serial_jtag_repl);
_exit:
Expand Down
18 changes: 2 additions & 16 deletions components/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ set(srcs)
set(includes "deprecated"
"i2c/include"
"touch_sensor/include"
"twai/include"
"usb_serial_jtag/include")
"twai/include")

# Always included linker fragments
set(ldfragments "")
Expand Down Expand Up @@ -86,12 +85,6 @@ if(CONFIG_SOC_TWAI_SUPPORTED)
list(APPEND ldfragments "twai/linker.lf")
endif()

# USB Serial JTAG related source files
if(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED)
list(APPEND srcs "usb_serial_jtag/usb_serial_jtag.c"
"usb_serial_jtag/usb_serial_jtag_connection_monitor.c")
endif()

# Other source files
if(${target} STREQUAL "esp32")
list(APPEND srcs "deprecated/adc_i2s_deprecated.c")
Expand All @@ -113,14 +106,7 @@ else()
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio
esp_driver_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm esp_driver_i2c
esp_driver_uart esp_driver_ledc esp_driver_parlio
esp_driver_uart esp_driver_ledc esp_driver_parlio esp_driver_usb_serial_jtag
LDFRAGMENTS ${ldfragments}
)
endif()

# If system needs to monitor USJ connection status, then usb_serial_jtag_connection_monitor object file has to be linked
# to the binary, to allow tick hook to be registered
if(CONFIG_USJ_NO_AUTO_LS_ON_CONNECTION OR
(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORT_LIGHT_SLEEP AND CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED))
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u usb_serial_jtag_connection_monitor_include")
endif()
17 changes: 0 additions & 17 deletions components/driver/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,4 @@ menu "Driver Configurations"

orsource "./twai/Kconfig.twai"

menu "USB Serial/JTAG Configuration"
depends on SOC_USB_SERIAL_JTAG_SUPPORTED
config USJ_NO_AUTO_LS_ON_CONNECTION
bool "Don't enter the automatic light sleep when USB Serial/JTAG port is connected"
depends on PM_ENABLE && ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED && !SOC_USB_SERIAL_JTAG_SUPPORT_LIGHT_SLEEP
default n
help
If enabled, the chip will constantly monitor the connection status of the USB Serial/JTAG port. As long
as the USB Serial/JTAG is connected, a ESP_PM_NO_LIGHT_SLEEP power management lock will be acquired to
prevent the system from entering light sleep.
This option can be useful if serial monitoring is needed via USB Serial/JTAG while power management is
enabled, as the USB Serial/JTAG cannot work under light sleep and after waking up from light sleep.
Note. This option can only control the automatic Light-Sleep behavior. If esp_light_sleep_start() is
called manually from the program, enabling this option will not prevent light sleep entry even if the
USB Serial/JTAG is in use.
endmenu # USB Serial/JTAG Configuration

endmenu # Driver configurations
9 changes: 3 additions & 6 deletions components/driver/deprecated/adc_dma_legacy.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -177,7 +177,7 @@ esp_err_t adc_digi_deinitialize(void)
free(s_adc_digi_ctx);
s_adc_digi_ctx = NULL;

periph_module_disable(PERIPH_SARADC_MODULE);
adc_apb_periph_free();

return ESP_OK;
}
Expand Down Expand Up @@ -321,10 +321,7 @@ esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config)
};
adc_hal_dma_ctx_config(&s_adc_digi_ctx->hal, &config);

//enable ADC digital part
periph_module_enable(PERIPH_SARADC_MODULE);
//reset ADC digital part
periph_module_reset(PERIPH_SARADC_MODULE);
adc_apb_periph_claim();

#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_1);
Expand Down
10 changes: 5 additions & 5 deletions components/driver/deprecated/adc_legacy.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -777,7 +777,7 @@ int adc1_get_raw(adc1_channel_t channel)
return ESP_ERR_TIMEOUT;
}

periph_module_enable(PERIPH_SARADC_MODULE);
adc_apb_periph_claim();
sar_periph_ctrl_adc_oneshot_power_acquire();
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_DEFAULT);

Expand All @@ -792,7 +792,7 @@ int adc1_get_raw(adc1_channel_t channel)
ADC_REG_LOCK_EXIT();

sar_periph_ctrl_adc_oneshot_power_release();
periph_module_disable(PERIPH_SARADC_MODULE);
adc_apb_periph_free();
adc_lock_release(ADC_UNIT_1);

return raw_out;
Expand Down Expand Up @@ -834,7 +834,7 @@ esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *
return ESP_ERR_TIMEOUT;
}

periph_module_enable(PERIPH_SARADC_MODULE);
adc_apb_periph_claim();
sar_periph_ctrl_adc_oneshot_power_acquire();
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_DEFAULT);

Expand All @@ -852,7 +852,7 @@ esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *
ADC_REG_LOCK_EXIT();

sar_periph_ctrl_adc_oneshot_power_release();
periph_module_disable(PERIPH_SARADC_MODULE);
adc_apb_periph_free();
adc_lock_release(ADC_UNIT_2);

return ret;
Expand Down
9 changes: 1 addition & 8 deletions components/driver/test_apps/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,7 @@ components/driver/test_apps/twai:
- if: IDF_TARGET == "esp32p4"
temporary: true
reason: test not pass, should be re-enable # TODO: IDF-8966

components/driver/test_apps/usb_serial_jtag:
disable:
- if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1
depends_filepatterns:
- components/driver/usb_serial_jtag/**/*
- components/driver/twai/**/*
depends_components:
- hal
- esp_hw_support # for clock
- vfs
- esp_driver_gpio
8 changes: 5 additions & 3 deletions components/driver/test_apps/twai/main/test_twai_interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST_CASE("twai_listen_only", "[twai]")
{
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 2, TWAI_MODE_LISTEN_ONLY);
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_LISTEN_ONLY);
#if CONFIG_TWAI_ISR_IN_IRAM
g_config.intr_flags |= ESP_INTR_FLAG_IRAM;
#endif
Expand Down Expand Up @@ -60,8 +60,10 @@ TEST_CASE("twai_remote_request", "[twai]")
twai_handle_t bus_handle;
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 2, TWAI_MODE_NORMAL);
g_config.controller_id = 2;
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_NORMAL);
#if CONFIG_IDF_TARGET_ESP32C6
g_config.controller_id = 1;
#endif
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle));
TEST_ESP_OK(twai_start_v2(bus_handle));

Expand Down
Loading

0 comments on commit 952412a

Please sign in to comment.