Skip to content

Commit

Permalink
Idf arduino (#24)
Browse files Browse the repository at this point in the history
* timer: propagate isr register failure

Closes espressif#9651

* mcpwm: fix multiplication overflow in converting us to compare ticks

Closes espressif#9648

* heap: remove misleading info about malloc being equivalent to heap_caps_malloc(p, MALLOC_CAP_8BIT)

The actual memory allocated for malloc() depends on a lot of factors, see heap_caps_malloc_default()

Closes espressif#7659

* esp-rom: fixed error in miniz header documention for tdefl_init

Closes espressif#8435

* temperature_sensor: Fix issue that value is not accurate on ESP32-S3

* esp_https_ota: fix bug where `http_client_init_cb` is called after `esp_http_client_perform()` instead of before.

Closes espressif#9581

* Tasmota changes

* Fix linker error for C3

* Avoid bootloop if chip is unknown
   In case the PSIRAM chip is unknown, return an error and disable PSRAM
   instead of calling abort() and causing a bootloop
* Support for xiaomi single core ESP32
* Fix linker error for rom_temp_to_power
* fix linker error r_lld_ext_adv_dynamic_aux_pti_process

* Hide download percent when not interactive

* list(APPEND esptool_elf2image_args --dont-append-digest)

* Use native Apple ARM toolchains

* add package.json

* add submodules

* 8575d75

Co-authored-by: morris <maoshengrong@espressif.com>
Co-authored-by: Marius Vikhammer <marius.vikhammer@espressif.com>
Co-authored-by: Cao Sen Miao <caosenmiao@espressif.com>
Co-authored-by: Harshit Malpani <harshit.malpani@espressif.com>
Co-authored-by: Mahavir Jain <mahavir@espressif.com>
  • Loading branch information
6 people authored Sep 3, 2022
1 parent 016e32e commit 6e3875c
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 22 deletions.
20 changes: 20 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
# For Espressif's public projects please use '../../espressif/proj', not a '../proj'
#

#
# Arduino IDF components
#

[submodule "components/esp32-camera"]
path = components/esp32-camera
url = ../../espressif/esp32-camera.git

[submodule "components/esp_littlefs"]
path = components/esp_littlefs
url = ../../joltwallet/esp_littlefs.git

[submodule "components/esp_dsp"]
path = components/esp_dsp
url = ../../espressif/esp-dsp.git

#
# Standard IDF components
#

[submodule "components/esptool_py/esptool"]
path = components/esptool_py/esptool
url = ../../tasmota/esptool.git
Expand Down
2 changes: 1 addition & 1 deletion components/driver/esp32s3/rtc_tempsensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static float parse_temp_sensor_raw_value(uint32_t tsens_raw, const int dac_offse
if (isnan(s_deltaT)) { //suggests that the value is not initialized
read_delta_t_from_efuse();
}
float result = (TSENS_ADC_FACTOR * (float)tsens_raw - TSENS_DAC_FACTOR * dac_offset - TSENS_SYS_OFFSET) - s_deltaT;
float result = (TSENS_ADC_FACTOR * (float)tsens_raw - TSENS_DAC_FACTOR * dac_offset - TSENS_SYS_OFFSET) - s_deltaT/10.0;
return result;
}

Expand Down
6 changes: 4 additions & 2 deletions components/driver/mcpwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,11 @@ esp_err_t mcpwm_set_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,

mcpwm_critical_enter(mcpwm_num);
int real_group_prescale = mcpwm_ll_group_get_clock_prescale(hal->dev);
unsigned long int real_timer_clk_hz =
// to avid multiplication overflow, use uint64_t here
uint64_t real_timer_clk_hz =
SOC_MCPWM_BASE_CLK_HZ / real_group_prescale / mcpwm_ll_timer_get_clock_prescale(hal->dev, timer_num);
mcpwm_ll_operator_set_compare_value(hal->dev, op, cmp, duty_in_us * real_timer_clk_hz / 1000000);
uint64_t compare_val = real_timer_clk_hz * duty_in_us / 1000000;
mcpwm_ll_operator_set_compare_value(hal->dev, op, cmp, (uint32_t)compare_val);
mcpwm_ll_operator_enable_update_compare_on_tez(hal->dev, op, cmp, true);
mcpwm_critical_exit(mcpwm_num);
return ESP_OK;
Expand Down
8 changes: 5 additions & 3 deletions components/driver/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ esp_err_t timer_isr_callback_add(timer_group_t group_num, timer_idx_t timer_num,
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
esp_err_t ret = ESP_OK;

timer_disable_intr(group_num, timer_num);
p_timer_obj[group_num][timer_num]->timer_isr_fun.fn = isr_handler;
p_timer_obj[group_num][timer_num]->timer_isr_fun.args = args;
p_timer_obj[group_num][timer_num]->timer_isr_fun.isr_timer_group = group_num;
timer_isr_register(group_num, timer_num, timer_isr_default, (void *)p_timer_obj[group_num][timer_num],
intr_alloc_flags, &(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle));
ret = timer_isr_register(group_num, timer_num, timer_isr_default, (void *)p_timer_obj[group_num][timer_num],
intr_alloc_flags, &(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle));
ESP_RETURN_ON_ERROR(ret, TIMER_TAG, "register interrupt service failed");
timer_enable_intr(group_num, timer_num);

return ESP_OK;
return ret;
}

esp_err_t timer_isr_callback_remove(timer_group_t group_num, timer_idx_t timer_num)
Expand Down
1 change: 1 addition & 0 deletions components/esp32-camera
Submodule esp32-camera added at 8575d7
1 change: 1 addition & 0 deletions components/esp_dsp
Submodule esp_dsp added at 401faf
16 changes: 8 additions & 8 deletions components/esp_https_ota/src/esp_https_ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ esp_err_t esp_https_ota_begin(esp_https_ota_config_t *ota_config, esp_https_ota_
goto failure;
}

if (ota_config->http_client_init_cb) {
err = ota_config->http_client_init_cb(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "http_client_init_cb returned 0x%x", err);
goto http_cleanup;
}
}

if (https_ota_handle->partial_http_download) {
esp_http_client_set_method(https_ota_handle->http_client, HTTP_METHOD_HEAD);
err = esp_http_client_perform(https_ota_handle->http_client);
Expand Down Expand Up @@ -252,14 +260,6 @@ esp_err_t esp_https_ota_begin(esp_https_ota_config_t *ota_config, esp_https_ota_
esp_http_client_set_method(https_ota_handle->http_client, HTTP_METHOD_GET);
}

if (ota_config->http_client_init_cb) {
err = ota_config->http_client_init_cb(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "http_client_init_cb returned 0x%x", err);
goto http_cleanup;
}
}

err = _http_connect(https_ota_handle->http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to establish HTTP connection");
Expand Down
1 change: 1 addition & 0 deletions components/esp_littlefs
Submodule esp_littlefs added at 485a03
2 changes: 1 addition & 1 deletion components/esp_rom/include/esp32/rom/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ typedef struct

// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// pBut_buf_func: If **not** NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
Expand Down
2 changes: 1 addition & 1 deletion components/esp_rom/include/esp32c3/rom/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ typedef struct {

// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// pBut_buf_func: If **not** NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
Expand Down
2 changes: 1 addition & 1 deletion components/esp_rom/include/esp32h2/rom/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ typedef struct {

// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// pBut_buf_func: If **not** NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
Expand Down
2 changes: 1 addition & 1 deletion components/esp_rom/include/esp32s2/rom/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ typedef struct

// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// pBut_buf_func: If **not** NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
Expand Down
2 changes: 1 addition & 1 deletion components/esp_rom/include/esp32s3/rom/miniz.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ typedef struct {

// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// pBut_buf_func: If **not** NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
Expand Down
2 changes: 0 additions & 2 deletions components/heap/include/esp_heap_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ esp_err_t heap_caps_register_failed_alloc_callback(esp_alloc_failed_hook_t callb
*
* Equivalent semantics to libc malloc(), for capability-aware memory.
*
* In IDF, ``malloc(p)`` is equivalent to ``heap_caps_malloc(p, MALLOC_CAP_8BIT)``.
*
* @param size Size, in bytes, of the amount of memory to allocate
* @param caps Bitwise OR of MALLOC_CAP_* flags indicating the type
* of memory to be returned
Expand Down
4 changes: 3 additions & 1 deletion docs/en/api-reference/system/mem_alloc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ For more details on these internal memory types, see :ref:`memory-layout`.

It's also possible to connect external SPI RAM to the {IDF_TARGET_NAME} - :doc:`external RAM </api-guides/external-ram>` can be integrated into the {IDF_TARGET_NAME}'s memory map using the flash cache, and accessed similarly to DRAM.

DRAM uses capability ``MALLOC_CAP_8BIT`` (accessible in single byte reads and writes). When calling ``malloc()``, the ESP-IDF ``malloc()`` implementation internally calls ``heap_caps_malloc(size, MALLOC_CAP_8BIT)`` in order to allocate DRAM that is byte-addressable. To test the free DRAM heap size at runtime, call cpp:func:`heap_caps_get_free_size(MALLOC_CAP_8BIT)`.
DRAM uses capability ``MALLOC_CAP_8BIT`` (accessible in single byte reads and writes). To test the free DRAM heap size at runtime, call cpp:func:`heap_caps_get_free_size(MALLOC_CAP_8BIT)`.

When calling ``malloc()``, the ESP-IDF ``malloc()`` implementation internally calls cpp:func:`heap_caps_malloc_default(size)`. This will allocate memory with capability ``MALLOC_CAP_DEFAULT``, which is byte-addressable.

Because malloc uses the capabilities-based allocation system, memory allocated using :cpp:func:`heap_caps_malloc` can be freed by calling
the standard ``free()`` function.
Expand Down

0 comments on commit 6e3875c

Please sign in to comment.