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 Dec 22, 2024
2 parents 97756d6 + b5ac4fb commit a2c4cd1
Show file tree
Hide file tree
Showing 477 changed files with 37,190 additions and 7,023 deletions.
2 changes: 1 addition & 1 deletion .gitlab/ci/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ stages:
- pre_check
- build
- assign_test
- build_doc
- target_test
- host_test
- build_doc
- test_deploy
- deploy
- post_deploy
Expand Down
82 changes: 16 additions & 66 deletions .gitlab/ci/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,16 @@
.if-dev-push: &if-dev-push
if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_COMMIT_TAG !~ /^qa-test/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'

.if-schedule: &if-schedule
if: '$CI_PIPELINE_SOURCE == "schedule"'

.doc-rules:build:docs-full:
rules:
- <<: *if-qa-test-tag
when: never
- <<: *if-schedule
- <<: *if-protected
- <<: *if-label-build_docs
- <<: *if-label-docs_full
- <<: *if-dev-push
changes: *patterns-docs-full

.doc-rules:build:docs-full-prod:
rules:
- <<: *if-qa-test-tag
when: never
- <<: *if-protected-no_label

.doc-rules:build:docs-partial:
rules:
- <<: *if-qa-test-tag
Expand Down Expand Up @@ -92,13 +83,14 @@ check_docs_lang_sync:
stage: build_doc
tags:
- build_docs
needs:
- job: fast_template_app
artifacts: false
optional: true
script:
- if [ -n "${BREATHE_ALT_INSTALL_URL}" ]; then pip uninstall -y breathe && pip install -U ${BREATHE_ALT_INSTALL_URL}; fi
- cd docs
- build-docs -t $DOCTGT -bs $DOC_BUILDERS -l $DOCLANG build
artifacts:
expire_in: 4 days
when: always
parallel:
matrix:
- DOCLANG: ["en", "zh_CN"]
Expand All @@ -119,41 +111,25 @@ build_docs_html_full:
extends:
- .build_docs_template
- .doc-rules:build:docs-full
needs:
- job: fast_template_app
artifacts: false
optional: true
artifacts:
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
variables:
DOC_BUILDERS: "html"

build_docs_html_full_prod:
extends:
- .build_docs_template
- .doc-rules:build:docs-full-prod
dependencies: [] # Stop build_docs jobs from downloading all previous job's artifacts
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
variables:
DOC_BUILDERS: "html"

build_docs_html_partial:
extends:
- .build_docs_template
- .doc-rules:build:docs-partial
needs:
- job: fast_template_app
artifacts: false
optional: true
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
variables:
DOC_BUILDERS: "html"
parallel:
Expand All @@ -163,33 +139,6 @@ build_docs_html_partial:
- DOCLANG: "zh_CN"
DOCTGT: "esp32p4"

build_docs_pdf:
extends:
- .build_docs_template
- .doc-rules:build:docs-full
needs:
- job: fast_template_app
artifacts: false
optional: true
allow_failure: true # TODO IDFCI-2216
artifacts:
paths:
- docs/_build/*/*/latex/*
variables:
DOC_BUILDERS: "latex"

build_docs_pdf_prod:
extends:
- .build_docs_template
- .doc-rules:build:docs-full-prod
dependencies: [] # Stop build_docs jobs from downloading all previous job's artifacts
allow_failure: true # TODO IDFCI-2216
artifacts:
paths:
- docs/_build/*/*/latex/*
variables:
DOC_BUILDERS: "latex"

.deploy_docs_template:
image: $ESP_IDF_DOC_ENV_IMAGE
variables:
Expand Down Expand Up @@ -218,8 +167,6 @@ deploy_docs_preview:
optional: true
- job: build_docs_html_full
optional: true
- job: build_docs_pdf
optional: true
variables:
TYPE: "preview"
# older branches use DOCS_DEPLOY_KEY, DOCS_SERVER, DOCS_SERVER_USER, DOCS_PATH for preview server so we keep these names for 'preview'
Expand All @@ -234,12 +181,12 @@ deploy_docs_production:
# The DOCS_PROD_* variables used by this job are "Protected" so these branches must all be marked "Protected" in Gitlab settings
extends:
- .deploy_docs_template
- .doc-rules:build:docs-full-prod
rules:
- <<: *if-protected-no_label
stage: post_deploy
dependencies: # set dependencies to null to avoid missing artifacts issue
needs: # ensure runs after push_to_github succeeded
- build_docs_html_full_prod
- build_docs_pdf_prod
- build_docs_html_full
- job: push_to_github
artifacts: false
variables:
Expand All @@ -254,16 +201,19 @@ deploy_docs_production:
check_doc_links:
extends:
- .build_docs_template
- .doc-rules:build:docs-full-prod
rules:
- <<: *if-protected-no_label
stage: post_deploy
needs:
- job: deploy_docs_production
artifacts: false
tags: ["build", "amd64", "internet"]
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/linkcheck/*.txt
expire_in: 1 week
allow_failure: true
script:
- cd docs
Expand Down
1 change: 1 addition & 0 deletions .gitlab/ci/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test_cli_installer_win:
expire_in: 1 week
variables:
IDF_PATH: "$CI_PROJECT_DIR"
timeout: 3h
script:
# Tools must be downloaded for testing
- python ${IDF_PATH}\tools\idf_tools.py download required qemu-riscv32 qemu-xtensa cmake
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,6 @@ repos:
name: Lint rST files in docs folder using Sphinx Lint
files: ^(docs/en|docs/zh_CN)/.*\.(rst|inc)$
- repo: https://github.com/espressif/esp-idf-kconfig.git
rev: v2.3.0
rev: v2.4.1
hooks:
- id: check-kconfig-files
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void IRAM_ATTR bootloader_init_mspi_clock(void)
// Set source mspi pll clock as 80M in bootloader stage.
// SPLL clock on C5 is 480MHz , and mspi_pll needs 80MHz
// in this stage, set divider as 6
mspi_ll_clock_src_sel(MSPI_CLK_SRC_SPLL);
_mspi_timing_ll_set_flash_clk_src(0, FLASH_CLK_SRC_SPLL);
mspi_ll_fast_set_hs_divider(6);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void IRAM_ATTR bootloader_init_mspi_clock(void)
// Set source mspi pll clock as 80M in bootloader stage.
// SPLL clock on C61 is 480MHz , and mspi_pll needs 80MHz
// in this stage, set divider as 6
mspi_ll_clock_src_sel(MSPI_CLK_SRC_SPLL);
_mspi_timing_ll_set_flash_clk_src(0, FLASH_CLK_SRC_DEFAULT);
mspi_ll_fast_set_hs_divider(6);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "bootloader_init.h"
#include "hal/mmu_hal.h"
#include "hal/mmu_ll.h"
#include "hal/spimem_flash_ll.h"
#include "hal/mspi_timing_tuning_ll.h"
#include "hal/cache_hal.h"
#include "hal/cache_ll.h"
#include "esp_private/bootloader_flash_internal.h"
Expand All @@ -44,8 +44,8 @@ void IRAM_ATTR bootloader_flash_cs_timing_config(void)

void IRAM_ATTR bootloader_init_mspi_clock(void)
{
_spimem_flash_ll_select_clk_source(0, FLASH_CLK_SRC_SPLL);
_spimem_ctrlr_ll_set_core_clock(0, 6);
_mspi_timing_ll_set_flash_clk_src(0, FLASH_CLK_SRC_SPLL);
_mspi_timing_ll_set_flash_core_clock(0, 80);
}

void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t *pfhdr)
Expand Down
24 changes: 22 additions & 2 deletions components/bootloader_support/include/bootloader_memory_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ extern "C" {
*/
__attribute__((always_inline))
inline static bool esp_dram_match_iram(void) {
return (SOC_DRAM_LOW == SOC_IRAM_LOW && SOC_DRAM_HIGH == SOC_IRAM_HIGH);
bool dram_match_iram = (SOC_DRAM_LOW == SOC_IRAM_LOW) &&
(SOC_DRAM_HIGH == SOC_IRAM_HIGH);
#if SOC_RTC_FAST_MEM_SUPPORTED
dram_match_iram &= (SOC_RTC_IRAM_LOW == SOC_RTC_DRAM_LOW);
#endif
return dram_match_iram;
}

/**
Expand Down Expand Up @@ -97,7 +102,7 @@ inline static bool esp_ptr_in_diram_iram(const void *p) {
*/
__attribute__((always_inline))
inline static bool esp_ptr_in_rtc_iram_fast(const void *p) {
#if SOC_RTC_FAST_MEM_SUPPORTED
#if SOC_RTC_FAST_MEM_SUPPORTED && (SOC_RTC_IRAM_LOW != SOC_RTC_DRAM_LOW)
return ((intptr_t)p >= SOC_RTC_IRAM_LOW && (intptr_t)p < SOC_RTC_IRAM_HIGH);
#else
return false;
Expand Down Expand Up @@ -151,6 +156,21 @@ inline static void * esp_ptr_diram_dram_to_iram(const void *p) {
#endif
}

/* Convert a RTC DRAM pointer to equivalent word address in RTC IRAM
- Address must be word aligned
- Address must pass esp_ptr_in_rtc_dram_fast() test, or result will be invalid pointer
*/
__attribute__((always_inline))
inline static void * esp_ptr_rtc_dram_to_iram(const void *p) {
intptr_t ptr = (intptr_t)p;
#if SOC_RTC_FAST_MEM_SUPPORTED && (SOC_RTC_IRAM_LOW != SOC_RTC_DRAM_LOW)
return (void *) ( SOC_RTC_IRAM_LOW + (ptr - SOC_RTC_DRAM_LOW) );
#else
return (void *) ptr;
#endif
}

/* Convert a D/IRAM IRAM pointer to equivalent word address in DRAM
- Address must be word aligned
Expand Down
11 changes: 10 additions & 1 deletion components/bootloader_support/src/bootloader_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,16 @@ esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len,

while (len > 0) {
uint32_t mmu_page_offset = ((flash_offset & MMAP_ALIGNED_MASK) != 0) ? 1 : 0; /* Skip 1st MMU Page if it is already populated */
uint32_t partial_image_len = MIN(len, ((mmu_free_pages_count - mmu_page_offset) * SPI_FLASH_MMU_PAGE_SIZE)); /* Read the image that fits in the free MMU pages */
uint32_t max_pages = (mmu_free_pages_count > mmu_page_offset) ? (mmu_free_pages_count - mmu_page_offset) : 0;
if (max_pages == 0) {
ESP_LOGE(TAG, "No free MMU pages are available");
return ESP_ERR_NO_MEM;
}
uint32_t max_image_len;
if (__builtin_mul_overflow(max_pages, SPI_FLASH_MMU_PAGE_SIZE, &max_image_len)) {
max_image_len = UINT32_MAX;
}
uint32_t partial_image_len = MIN(len, max_image_len); /* Read the image that fits in the free MMU pages */

const void * image = bootloader_mmap(flash_offset, partial_image_len);
if (image == NULL) {
Expand Down
11 changes: 10 additions & 1 deletion components/bootloader_support/src/esp_image_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,16 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
#endif
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
uint32_t max_pages = (free_page_count > offset_page) ? (free_page_count - offset_page) : 0;
if (max_pages == 0) {
ESP_LOGE(TAG, "No free MMU pages are available");
return ESP_ERR_NO_MEM;
}
uint32_t max_image_len;
if (__builtin_mul_overflow(max_pages, SPI_FLASH_MMU_PAGE_SIZE, &max_image_len)) {
max_image_len = UINT32_MAX;
}
data_len = MIN(data_len_remain, max_image_len);
CHECK_ERR(process_segment_data(index, load_addr, data_addr, data_len, do_load, sha_handle, checksum, metadata));
data_addr += data_len;
data_len_remain -= data_len;
Expand Down
4 changes: 4 additions & 0 deletions components/bootloader_support/test_apps/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ components/bootloader_support/test_apps/rtc_custom_section:
enable:
- if: SOC_RTC_MEM_SUPPORTED == 1
reason: this feature is supported on chips that have RTC memory
disable:
- if: IDF_TARGET == "esp32h21"
temporary: true
reason: IDF-11534
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -160,20 +160,31 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
if (p_data->req_data.p_data->write_req.is_prep) {
tBTA_GATT_STATUS status = GATT_SUCCESS;

if (blufi_env.prepare_buf == NULL) {
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE);
blufi_env.prepare_len = 0;
if (blufi_env.prepare_buf == NULL) {
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
status = GATT_NO_RESOURCES;
do {
if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPARE_BUF_MAX_SIZE) {
status = ESP_GATT_INVALID_OFFSET;
break;
}
} else {
if (p_data->req_data.p_data->write_req.offset > BLUFI_PREPAIR_BUF_MAX_SIZE) {
status = GATT_INVALID_OFFSET;
} else if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPAIR_BUF_MAX_SIZE) {
status = GATT_INVALID_ATTR_LEN;

if ((p_data->req_data.p_data->write_req.offset + p_data->req_data.p_data->write_req.len) > BLUFI_PREPARE_BUF_MAX_SIZE) {
status = ESP_GATT_INVALID_ATTR_LEN;
break;
}
}

if (blufi_env.prepare_buf == NULL) {
if (p_data->req_data.p_data->write_req.offset != 0) {
status = GATT_INVALID_OFFSET;
break;
}
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPARE_BUF_MAX_SIZE);
blufi_env.prepare_len = 0;
if (blufi_env.prepare_buf == NULL) {
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
status = GATT_NO_RESOURCES;
break;
}
}
} while (0);

memset(&rsp, 0, sizeof(tGATTS_RSP));
rsp.attr_value.handle = p_data->req_data.p_data->write_req.handle;
Expand Down
Loading

0 comments on commit a2c4cd1

Please sign in to comment.