diff --git a/platform.txt b/platform.txt index e9ee9375..5fdc6e2b 100644 --- a/platform.txt +++ b/platform.txt @@ -21,7 +21,7 @@ compiler.warning_flags.all=-Wall -Werror=all -Wextra compiler.path={runtime.tools.xtensa-esp32-elf-gcc.path}/bin/ compiler.sdk.path={runtime.platform.path}/tools/sdk -compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bluedroid" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mbedtls_port" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip" +compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/bluedroid" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mbedtls_port" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/lwip" compiler.c.cmd=xtensa-esp32-elf-gcc compiler.c.flags=-std=gnu99 -Os -g3 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c @@ -33,8 +33,8 @@ compiler.S.cmd=xtensa-esp32-elf-gcc compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls compiler.c.elf.cmd=xtensa-esp32-elf-gcc -compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -compiler.c.elf.libs=-lgcc -lstdc++ -lapp_trace -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lcore -lcxx -ldriver -lesp32 -lethernet -lexpat -lfatfs -lfreertos -lhal -lheap -ljsmn -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lrtc -lsdmmc -lsmartconfig -lsoc -lspi_flash -ltcpip_adapter -lulp -lvfs -lwear_levelling -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module +compiler.c.elf.flags=-nostdlib "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority +compiler.c.elf.libs=-lgcc -lstdc++ -lapp_trace -lapp_update -lbootloader_support -lbt -lbtdm_app -lc -lc_nano -lcoap -lcoexist -lconsole -lcore -lcxx -ldriver -lesp32 -lesp_adc_cal -lethernet -lexpat -lfatfs -lfreertos -lhal -lheap -ljsmn -ljson -llog -llwip -lm -lmbedtls -lmdns -lmicro-ecc -lnet80211 -lnewlib -lnghttp -lnvs_flash -lopenssl -lphy -lpp -lpthread -lrtc -lsdmmc -lsmartconfig -lsoc -lspi_flash -lspiffs -ltcpip_adapter -lulp -lvfs -lwear_levelling -lwpa -lwpa2 -lwpa_supplicant -lwps -lxtensa-debug-module compiler.as.cmd=xtensa-esp32-elf-as diff --git a/tools/esptool.py b/tools/esptool.py index 86e5ab19..c65c6bfa 100755 --- a/tools/esptool.py +++ b/tools/esptool.py @@ -32,7 +32,7 @@ import shlex import copy import io -__version__ = "2.1-beta1" +__version__ = "2.1" MAX_UINT32 = 0xffffffff MAX_UINT24 = 0xffffff @@ -1315,7 +1315,7 @@ class ESP32FirmwareImage(BaseFirmwareImage): if self.append_digest: end = load_file.tell() - self.stored_digest = load_file.read(16) + self.stored_digest = load_file.read(32) load_file.seek(start) calc_digest = hashlib.sha256() calc_digest.update(load_file.read(end - start)) @@ -1864,6 +1864,15 @@ def image_info(args): calc_checksum = image.calculate_checksum() print('Checksum: %02x (%s)' % (image.checksum, 'valid' if image.checksum == calc_checksum else 'invalid - calculated %02x' % calc_checksum)) + try: + digest_msg = 'Not appended' + if image.append_digest: + is_valid = image.stored_digest == image.calc_digest + digest_msg = "%s (%s)" % (hexify(image.calc_digest).lower(), + "valid" if is_valid else "invalid") + print('Validation Hash: %s' % digest_msg) + except AttributeError: + pass # ESP8266 image has no append_digest field def make_image(args): diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 21174a51..5f9cc99f 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -57,6 +57,7 @@ env.Prepend( join(FRAMEWORK_DIR, "tools", "sdk", "include", "bt"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "driver"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp32"), + join(FRAMEWORK_DIR, "tools", "sdk", "include", "esp_adc_cal"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "ethernet"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "fatfs"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "freertos"), @@ -72,11 +73,13 @@ env.Prepend( join(FRAMEWORK_DIR, "tools", "sdk", "include", "soc"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "spi_flash"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "sdmmc"), + join(FRAMEWORK_DIR, "tools", "sdk", "include", "spiffs"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "tcpip_adapter"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "ulp"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "vfs"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "wear_levelling"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "xtensa-debug-module"), + join(FRAMEWORK_DIR, "tools", "sdk", "include", "console"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "newlib"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "coap"), join(FRAMEWORK_DIR, "tools", "sdk", "include", "wpa_supplicant"), @@ -91,7 +94,7 @@ env.Prepend( join(FRAMEWORK_DIR, "tools", "sdk", "ld") ], LIBS=[ - "gcc", "stdc++", "app_trace", "app_update", "bootloader_support", "bt", "btdm_app", "c", "c_nano", "coap", "coexist", "core", "cxx", "driver", "esp32", "ethernet", "expat", "fatfs", "freertos", "hal", "heap", "jsmn", "json", "log", "lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib", "nghttp", "nvs_flash", "openssl", "phy", "pp", "rtc", "sdmmc", "smartconfig", "soc", "spi_flash", "tcpip_adapter", "ulp", "vfs", "wear_levelling", "wpa", "wpa2", "wpa_supplicant", "wps", "xtensa-debug-module" + "gcc", "stdc++", "app_trace", "app_update", "bootloader_support", "bt", "btdm_app", "c", "c_nano", "coap", "coexist", "console", "core", "cxx", "driver", "esp32", "esp_adc_cal", "ethernet", "expat", "fatfs", "freertos", "hal", "heap", "jsmn", "json", "log", "lwip", "m", "mbedtls", "mdns", "micro-ecc", "net80211", "newlib", "nghttp", "nvs_flash", "openssl", "phy", "pp", "pthread", "rtc", "sdmmc", "smartconfig", "soc", "spi_flash", "spiffs", "tcpip_adapter", "ulp", "vfs", "wear_levelling", "wpa", "wpa2", "wpa_supplicant", "wps", "xtensa-debug-module" ], UPLOADERFLAGS=[ @@ -110,6 +113,7 @@ env.Append( "-T", "esp32.common.ld", "-T", "esp32.rom.ld", "-T", "esp32.peripherals.ld", + "-T", "esp32.rom.spiram_incompatible_fns.ld", "-u", "ld_include_panic_highint_hdl" ], diff --git a/tools/sdk/bin/bootloader.bin b/tools/sdk/bin/bootloader.bin index cba63819..e4e682bc 100644 Binary files a/tools/sdk/bin/bootloader.bin and b/tools/sdk/bin/bootloader.bin differ diff --git a/tools/sdk/bin/bootloader_qio.bin b/tools/sdk/bin/bootloader_qio.bin index 7d524f9f..e4769d7c 100644 Binary files a/tools/sdk/bin/bootloader_qio.bin and b/tools/sdk/bin/bootloader_qio.bin differ diff --git a/tools/sdk/include/app_trace/esp_ota_ops.h b/tools/sdk/include/app_trace/esp_ota_ops.h index 9bc8798e..a089a92b 100755 --- a/tools/sdk/include/app_trace/esp_ota_ops.h +++ b/tools/sdk/include/app_trace/esp_ota_ops.h @@ -126,13 +126,17 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition); * * If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned. * - * If esp_ota_set_boot_partition() has not been called, the result is - * equivalent to esp_ota_get_running_partition(). + * If esp_ota_set_boot_partition() has not been called, the result is usually the same as esp_ota_get_running_partition(). + * The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition + * will be an app that the bootloader chose via fallback). + * + * If the OTA data partition is not present or not valid then the result is the first app partition found in the + * partition table. In priority order, this means: the factory app, the first OTA app slot, or the test app partition. * * Note that there is no guarantee the returned partition is a valid app. Use esp_image_load(ESP_IMAGE_VERIFY, ...) to verify if the - * partition contains a bootable image. + * returned partition contains a bootable image. * - * @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application. + * @return Pointer to info for partition structure, or NULL if partition table is invalid or a flash read operation failed. Any returned pointer is valid for the lifetime of the application. */ const esp_partition_t* esp_ota_get_boot_partition(void); diff --git a/tools/sdk/include/app_update/esp_ota_ops.h b/tools/sdk/include/app_update/esp_ota_ops.h index 9bc8798e..a089a92b 100755 --- a/tools/sdk/include/app_update/esp_ota_ops.h +++ b/tools/sdk/include/app_update/esp_ota_ops.h @@ -126,13 +126,17 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition); * * If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned. * - * If esp_ota_set_boot_partition() has not been called, the result is - * equivalent to esp_ota_get_running_partition(). + * If esp_ota_set_boot_partition() has not been called, the result is usually the same as esp_ota_get_running_partition(). + * The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition + * will be an app that the bootloader chose via fallback). + * + * If the OTA data partition is not present or not valid then the result is the first app partition found in the + * partition table. In priority order, this means: the factory app, the first OTA app slot, or the test app partition. * * Note that there is no guarantee the returned partition is a valid app. Use esp_image_load(ESP_IMAGE_VERIFY, ...) to verify if the - * partition contains a bootable image. + * returned partition contains a bootable image. * - * @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application. + * @return Pointer to info for partition structure, or NULL if partition table is invalid or a flash read operation failed. Any returned pointer is valid for the lifetime of the application. */ const esp_partition_t* esp_ota_get_boot_partition(void); diff --git a/tools/sdk/include/bluedroid/alarm.h b/tools/sdk/include/bluedroid/alarm.h index 937874f2..07efbc5a 100644 --- a/tools/sdk/include/bluedroid/alarm.h +++ b/tools/sdk/include/bluedroid/alarm.h @@ -76,4 +76,6 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm); // t1 and t2 should be no greater than the time of MAX ticks period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2); +uint32_t osi_time_get_os_boottime_ms(void); + #endif /*_ALARM_H_*/ diff --git a/tools/sdk/include/bluedroid/allocator.h b/tools/sdk/include/bluedroid/allocator.h index 82ef5b0e..b217cef9 100644 --- a/tools/sdk/include/bluedroid/allocator.h +++ b/tools/sdk/include/bluedroid/allocator.h @@ -20,7 +20,7 @@ #define _ALLOCATOR_H_ #include -//#include +#include #include "sdkconfig.h" typedef void *(*alloc_fn)(size_t size); @@ -52,7 +52,7 @@ void osi_mem_dbg_show(void); ({ \ void *p; \ \ - p = calloc(1, (size)); \ + p = malloc((size)); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) @@ -67,14 +67,15 @@ void osi_mem_dbg_show(void); }) #define osi_free(ptr) \ -({ \ - osi_mem_dbg_clean(ptr, __func__, __LINE__); \ - free((ptr)); \ -}) +do { \ + void *tmp_point = (void *)(ptr); \ + osi_mem_dbg_clean(tmp_point, __func__, __LINE__); \ + free(tmp_point); \ +} while (0) #else -#define osi_malloc(size) calloc(1, (size)) +#define osi_malloc(size) malloc((size)) #define osi_calloc(size) calloc(1, (size)) #define osi_free(p) free((p)) diff --git a/tools/sdk/include/bluedroid/avct_int.h b/tools/sdk/include/bluedroid/avct_int.h index c922fe11..f70f516c 100644 --- a/tools/sdk/include/bluedroid/avct_int.h +++ b/tools/sdk/include/bluedroid/avct_int.h @@ -24,10 +24,10 @@ #ifndef AVCT_INT_H #define AVCT_INT_H -#include "gki.h" #include "avct_api.h" #include "avct_defs.h" #include "l2c_api.h" +#include "fixed_queue.h" /***************************************************************************** ** constants @@ -81,7 +81,7 @@ typedef struct { BT_HDR *p_rx_msg; /* Message being reassembled */ UINT16 conflict_lcid; /* L2CAP channel LCID */ BD_ADDR peer_addr; /* BD address of peer */ - BUFFER_Q tx_q; /* Transmit data buffer queue */ + fixed_queue_t *tx_q; /* Transmit data buffer queue */ BOOLEAN cong; /* TRUE, if congested */ } tAVCT_LCB; diff --git a/tools/sdk/include/bluedroid/avdt_int.h b/tools/sdk/include/bluedroid/avdt_int.h index 5050f066..6555152a 100644 --- a/tools/sdk/include/bluedroid/avdt_int.h +++ b/tools/sdk/include/bluedroid/avdt_int.h @@ -24,12 +24,12 @@ #ifndef AVDT_INT_H #define AVDT_INT_H -#include "gki.h" #include "avdt_api.h" #include "avdtc_api.h" #include "avdt_defs.h" #include "l2c_api.h" #include "btm_api.h" +#include "fixed_queue.h" #if (AVRC_INCLUDED == TRUE) @@ -425,8 +425,8 @@ typedef union { typedef struct { BD_ADDR peer_addr; /* BD address of peer */ TIMER_LIST_ENT timer_entry; /* CCB timer list entry */ - BUFFER_Q cmd_q; /* Queue for outgoing command messages */ - BUFFER_Q rsp_q; /* Queue for outgoing response and reject messages */ + fixed_queue_t *cmd_q; /* Queue for outgoing command messages */ + fixed_queue_t *rsp_q; /* Queue for outgoing response and reject messages */ tAVDT_CTRL_CBACK *proc_cback; /* Procedure callback function */ tAVDT_CTRL_CBACK *p_conn_cback; /* Connection/disconnection callback function */ void *p_proc_data; /* Pointer to data storage for procedure */ @@ -453,7 +453,7 @@ typedef struct { BT_HDR *p_buf; UINT32 time_stamp; #if AVDT_MULTIPLEXING == TRUE - BUFFER_Q frag_q; /* Queue for outgoing media fragments. p_buf should be 0 */ + fixed_queue_t *frag_q; /* Queue for outgoing media fragments. p_buf should be 0 */ UINT8 *p_data; UINT32 data_len; #endif @@ -500,7 +500,7 @@ typedef struct { BOOLEAN cong; /* Whether media transport channel is congested */ UINT8 close_code; /* Error code received in close response */ #if AVDT_MULTIPLEXING == TRUE - BUFFER_Q frag_q; /* Queue for outgoing media fragments */ + fixed_queue_t *frag_q; /* Queue for outgoing media fragments */ UINT32 frag_off; /* length of already received media fragments */ UINT32 frag_org_len; /* original length before fragmentation of receiving media packet */ UINT8 *p_next_frag; /* next fragment to send */ @@ -673,7 +673,7 @@ extern void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data); extern void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data); extern void avdt_scb_tc_timer(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data); extern void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data); -extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, BUFFER_Q *pq); +extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, fixed_queue_t *pq); /* msg function declarations */ extern BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg); diff --git a/tools/sdk/include/bluedroid/bt_defs.h b/tools/sdk/include/bluedroid/bt_defs.h index 5d0dd3d9..bb0ca6de 100644 --- a/tools/sdk/include/bluedroid/bt_defs.h +++ b/tools/sdk/include/bluedroid/bt_defs.h @@ -22,8 +22,7 @@ #include #include #include "bt_trace.h" - -#include "osi_arch.h" +#include "bt_target.h" #define UNUSED(x) (void)(x) @@ -32,6 +31,20 @@ #endif /*Timer Related Defination*/ +//by Snake.T +typedef void (TIMER_CBACK)(void *p_tle); +typedef struct _tle { + struct _tle *p_next; + struct _tle *p_prev; + TIMER_CBACK *p_cback; + INT32 ticks; + INT32 ticks_initial; + TIMER_PARAM_TYPE param; + TIMER_PARAM_TYPE data; + UINT16 event; + UINT8 in_use; +} TIMER_LIST_ENT; + #define alarm_timer_t uint32_t #define alarm_timer_setfn(timer, cb, data) \ do { \ @@ -45,23 +58,6 @@ do { \ #define alarm_timer_now() (0) -/*Thread and locker related defination*/ -#define RTOS_SUPPORT -#ifdef RTOS_SUPPORT -#define pthread_mutex_t osi_mutex_t -#define pthread_mutex_init(mutex, a) osi_mutex_new(mutex) -#define pthread_mutex_destroy(mutex) osi_mutex_free(mutex) -#define pthread_mutex_lock osi_mutex_lock -#define pthread_mutex_unlock osi_mutex_unlock -#else -#define pthread_mutex_t uint8_t -#define pthread_mutex_init(x1, x2) -#define pthread_mutex_destroy(mutex) -#define pthread_mutex_lock(mutex) -#define pthread_mutex_unlock(mutex) -#endif - - /*Bluetooth Address*/ typedef struct { uint8_t address[6]; diff --git a/tools/sdk/include/bluedroid/bt_target.h b/tools/sdk/include/bluedroid/bt_target.h index a426d69f..34b8c194 100644 --- a/tools/sdk/include/bluedroid/bt_target.h +++ b/tools/sdk/include/bluedroid/bt_target.h @@ -37,8 +37,6 @@ #include "sdkconfig.h" #include "bt_types.h" /* This must be defined AFTER buildcfg.h */ -/* Include common GKI definitions used by this platform */ -#include "gki_target.h" #include "dyn_mem.h" /* defines static and/or dynamic memory for components */ #if CONFIG_CLASSIC_BT_ENABLED @@ -177,15 +175,6 @@ #define BTA_DISABLE_DELAY 200 /* in milliseconds */ #endif -// If the next wakeup time is less than this threshold, we should acquire -// a wakelock instead of setting a wake alarm so we're not bouncing in -// and out of suspend frequently. -// in millisecond -// TODO(zachoverflow): reinstate in alarm code -#ifndef GKI_TIMER_INTERVAL_FOR_WAKELOCK -#define GKI_TIMER_INTERVAL_FOR_WAKELOCK 3000 -#endif - #ifndef BTA_SYS_TIMER_PERIOD #define BTA_SYS_TIMER_PERIOD 100 #endif @@ -266,66 +255,63 @@ /****************************************************************************** ** -** GKI Buffer Pools +** Buffer Size ** ******************************************************************************/ +#ifndef BT_DEFAULT_BUFFER_SIZE +#define BT_DEFAULT_BUFFER_SIZE (4096 + 16) +#endif + +#ifndef BT_SMALL_BUFFER_SIZE +#define BT_SMALL_BUFFER_SIZE 660 +#endif + /* Receives HCI events from the lower-layer. */ -#ifndef HCI_CMD_POOL_ID -#define HCI_CMD_POOL_ID GKI_POOL_ID_2 -#endif - -#ifndef HCI_CMD_POOL_BUF_SIZE -#define HCI_CMD_POOL_BUF_SIZE GKI_BUF2_SIZE -#endif - -/* Receives ACL data packets from thelower-layer. */ -#ifndef HCI_ACL_POOL_ID -#define HCI_ACL_POOL_ID GKI_POOL_ID_3 -#endif - -/* Maximum number of buffers available for ACL receive data. */ -#ifndef HCI_ACL_BUF_MAX -#define HCI_ACL_BUF_MAX GKI_BUF3_MAX -#endif - -/* Receives SCO data packets from the lower-layer. */ -#ifndef HCI_SCO_POOL_ID -#define HCI_SCO_POOL_ID GKI_POOL_ID_6 +#ifndef HCI_CMD_BUF_SIZE +#define HCI_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif /* Sends SDP data packets. */ -#ifndef SDP_POOL_ID -#define SDP_POOL_ID 3 +#ifndef SDP_DATA_BUF_SIZE +#define SDP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* Sends RFCOMM command packets. */ -#ifndef RFCOMM_CMD_POOL_ID -#define RFCOMM_CMD_POOL_ID GKI_POOL_ID_2 +#ifndef RFCOMM_CMD_BUF_SIZE +#define RFCOMM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif /* Sends RFCOMM data packets. */ -#ifndef RFCOMM_DATA_POOL_ID -#define RFCOMM_DATA_POOL_ID GKI_POOL_ID_3 -#endif - -#ifndef RFCOMM_DATA_POOL_BUF_SIZE -#define RFCOMM_DATA_POOL_BUF_SIZE GKI_BUF3_SIZE +#ifndef RFCOMM_DATA_BUF_SIZE +#define RFCOMM_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* Sends L2CAP packets to the peer and HCI messages to the controller. */ -#ifndef L2CAP_CMD_POOL_ID -#define L2CAP_CMD_POOL_ID GKI_POOL_ID_2 +#ifndef L2CAP_CMD_BUF_SIZE +#define L2CAP_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE +#endif + +#ifndef L2CAP_USER_TX_BUF_SIZE +#define L2CAP_USER_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE +#endif + +#ifndef L2CAP_USER_RX_BUF_SIZE +#define L2CAP_USER_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* Sends L2CAP segmented packets in ERTM mode */ -#ifndef L2CAP_FCR_TX_POOL_ID -#define L2CAP_FCR_TX_POOL_ID HCI_ACL_POOL_ID +#ifndef L2CAP_FCR_TX_BUF_SIZE +#define L2CAP_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* Receives L2CAP segmented packets in ERTM mode */ -#ifndef L2CAP_FCR_RX_POOL_ID -#define L2CAP_FCR_RX_POOL_ID HCI_ACL_POOL_ID +#ifndef L2CAP_FCR_RX_BUF_SIZE +#define L2CAP_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE +#endif + +#ifndef L2CAP_FCR_ERTM_BUF_SIZE +#define L2CAP_FCR_ERTM_BUF_SIZE (10240 + 24) #endif /* Number of ACL buffers to assign to LE @@ -335,114 +321,72 @@ #endif /* Used by BTM when it sends HCI commands to the controller. */ -#ifndef BTM_CMD_POOL_ID -#define BTM_CMD_POOL_ID GKI_POOL_ID_2 +#ifndef BTM_CMD_BUF_SIZE +#define BTM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif -#ifndef OBX_LRG_DATA_POOL_SIZE -#define OBX_LRG_DATA_POOL_SIZE GKI_BUF4_SIZE +#ifndef OBX_LRG_DATA_BUF_SIZE +#define OBX_LRG_DATA_BUF_SIZE (8080 + 26) #endif -#ifndef OBX_LRG_DATA_POOL_ID -#define OBX_LRG_DATA_POOL_ID GKI_POOL_ID_4 -#endif /* Used to send data to L2CAP. */ -#ifndef GAP_DATA_POOL_ID -#define GAP_DATA_POOL_ID GKI_POOL_ID_3 -#endif - -#ifndef SPP_DB_SIZE -#define SPP_DB_SIZE GKI_BUF3_SIZE +#ifndef GAP_DATA_BUF_SIZE +#define GAP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* BNEP data and protocol messages. */ -#ifndef BNEP_POOL_ID -#define BNEP_POOL_ID GKI_POOL_ID_3 +#ifndef BNEP_BUF_SIZE +#define BNEP_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -/* RPC pool for temporary trace message buffers. */ -#ifndef RPC_SCRATCH_POOL_ID -#define RPC_SCRATCH_POOL_ID GKI_POOL_ID_2 +/* AVDTP buffer size for protocol messages */ +#ifndef AVDT_CMD_BUF_SIZE +#define AVDT_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif -/* AVDTP pool for protocol messages */ -#ifndef AVDT_CMD_POOL_ID -#define AVDT_CMD_POOL_ID GKI_POOL_ID_2 +/* AVDTP buffer size for media packets in case of fragmentation */ +#ifndef AVDT_DATA_BUF_SIZE +#define AVDT_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -/* AVDTP pool size for media packets in case of fragmentation */ -#ifndef AVDT_DATA_POOL_SIZE -#define AVDT_DATA_POOL_SIZE GKI_BUF3_SIZE +#ifndef PAN_BUF_SIZE +#define PAN_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -#ifndef PAN_POOL_ID -#define PAN_POOL_ID GKI_POOL_ID_3 -/* Maximum amount of the shared buffer to allocate for PAN */ -#define PAN_POOL_MAX (GKI_BUF3_MAX / 4) +/* Maximum number of buffers to allocate for PAN */ +#ifndef PAN_BUF_MAX +#define PAN_BUF_MAX 100 #endif -/* AVCTP pool for protocol messages */ -#ifndef AVCT_CMD_POOL_ID -#define AVCT_CMD_POOL_ID GKI_POOL_ID_1 +/* AVCTP buffer size for protocol messages */ +#ifndef AVCT_CMD_BUF_SIZE +#define AVCT_CMD_BUF_SIZE 288 #endif -/* AVRCP pool for protocol messages */ -#ifndef AVRC_CMD_POOL_ID -#define AVRC_CMD_POOL_ID GKI_POOL_ID_1 +/* AVRCP buffer size for protocol messages */ +#ifndef AVRC_CMD_BUF_SIZE +#define AVRC_CMD_BUF_SIZE 288 #endif -/* AVRCP pool size for protocol messages */ -#ifndef AVRC_CMD_POOL_SIZE -#define AVRC_CMD_POOL_SIZE GKI_BUF1_SIZE +/* AVRCP Metadata buffer size for protocol messages */ +#ifndef AVRC_META_CMD_BUF_SIZE +#define AVRC_META_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE #endif -/* AVRCP Metadata pool for protocol messages */ -#ifndef AVRC_META_CMD_POOL_ID -#define AVRC_META_CMD_POOL_ID GKI_POOL_ID_2 +#ifndef BTA_HL_LRG_DATA_BUF_SIZE +#define BTA_HL_LRG_DATA_BUF_SIZE (10240 + 24) #endif -/* AVRCP Metadata pool size for protocol messages */ -#ifndef AVRC_META_CMD_POOL_SIZE -#define AVRC_META_CMD_POOL_SIZE GKI_BUF2_SIZE +/* GATT Server Database buffer size */ +#ifndef GATT_DB_BUF_SIZE +#define GATT_DB_BUF_SIZE 128 #endif - -/* AVRCP buffer size for browsing channel messages */ -#ifndef AVRC_BROWSE_POOL_SIZE -#define AVRC_BROWSE_POOL_SIZE GKI_MAX_BUF_SIZE +/* GATT Data sending buffer size */ +#ifndef GATT_DATA_BUF_SIZE +#define GATT_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -#ifndef BTA_HL_LRG_DATA_POOL_ID -#define BTA_HL_LRG_DATA_POOL_ID GKI_POOL_ID_7 -#endif - -/* GATT Server Database pool ID */ -#ifndef GATT_DB_POOL_ID -#define GATT_DB_POOL_ID GKI_POOL_ID_8 -#endif - -/* GATT Data sending buffer pool ID, use default ACL pool for fix channel data */ -#ifndef GATT_BUF_POOL_ID -#define GATT_BUF_POOL_ID HCI_ACL_POOL_ID -#endif - -/****************************************************************************** -** -** Lower Layer Interface -** -******************************************************************************/ - -/* Macro for allocating buffer for HCI commands */ -#ifndef HCI_GET_CMD_BUF -#if (!defined(HCI_USE_VARIABLE_SIZE_CMD_BUF) || (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE)) -/* Allocate fixed-size buffer from HCI_CMD_POOL (default case) */ -#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)GKI_getpoolbuf (HCI_CMD_POOL_ID)) -#else -/* Allocate smallest possible buffer (for platforms with limited RAM) */ -#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)GKI_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen)))) -#endif -#endif /* HCI_GET_CMD_BUF */ - /****************************************************************************** ** ** HCI Services (H4) @@ -1267,68 +1211,41 @@ #define PORT_CREDIT_RX_LOW 8 #endif -/* if application like BTA, Java or script test engine is running on other than BTU thread, */ -/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_lock() or GKI_disable() */ -#ifndef PORT_SCHEDULE_LOCK -#define PORT_SCHEDULE_LOCK GKI_disable() -#endif - -/* if application like BTA, Java or script test engine is running on other than BTU thread, */ -/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_unlock() or GKI_enable() */ -#ifndef PORT_SCHEDULE_UNLOCK -#define PORT_SCHEDULE_UNLOCK GKI_enable() -#endif - /****************************************************************************** ** ** OBEX ** ******************************************************************************/ -#define OBX_14_INCLUDED FALSE -/* The maximum number of registered servers. */ -#ifndef OBX_NUM_SERVERS -#define OBX_NUM_SERVERS 12 +/* + * Buffer size to reassemble the SDU. + * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU. + */ +#ifndef OBX_USER_RX_BUF_SIZE +#define OBX_USER_RX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE #endif -/* The maximum number of active clients. */ -#ifndef OBX_NUM_CLIENTS -#define OBX_NUM_CLIENTS 8 +/* + * Buffer size to hold the SDU. + * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU. + */ +#ifndef OBX_USER_TX_BUF_SIZE +#define OBX_USER_TX_BUF_SIZE OBX_LRG_DATA_BUF_SIZE #endif -/* This option is application when OBX_14_INCLUDED=TRUE - Pool ID where to reassemble the SDU. - This Pool will allow buffers to be used that are larger than - the L2CAP_MAX_MTU. */ -#ifndef OBX_USER_RX_POOL_ID -#define OBX_USER_RX_POOL_ID OBX_LRG_DATA_POOL_ID +/* Buffer size used to hold MPS segments during SDU reassembly. */ +#ifndef OBX_FCR_RX_BUF_SIZE +#define OBX_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -/* This option is application when OBX_14_INCLUDED=TRUE - Pool ID where to hold the SDU. - This Pool will allow buffers to be used that are larger than - the L2CAP_MAX_MTU. */ -#ifndef OBX_USER_TX_POOL_ID -#define OBX_USER_TX_POOL_ID OBX_LRG_DATA_POOL_ID -#endif - -/* This option is application when OBX_14_INCLUDED=TRUE -GKI Buffer Pool ID used to hold MPS segments during SDU reassembly -*/ -#ifndef OBX_FCR_RX_POOL_ID -#define OBX_FCR_RX_POOL_ID HCI_ACL_POOL_ID -#endif - -/* This option is application when OBX_14_INCLUDED=TRUE -GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions. -L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool. -Note: This pool needs to have enough buffers to hold two times the window size negotiated - in the L2CA_SetFCROptions (2 * tx_win_size) to allow for retransmissions. - The size of each buffer must be able to hold the maximum MPS segment size passed in - L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec). -*/ -#ifndef OBX_FCR_TX_POOL_ID -#define OBX_FCR_TX_POOL_ID HCI_ACL_POOL_ID +/* + * Buffer size used to hold MPS segments used in (re)transmissions. + * The size of each buffer must be able to hold the maximum MPS segment size + * passed in L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) + + * L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec). + */ +#ifndef OBX_FCR_TX_BUF_SIZE +#define OBX_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* This option is application when OBX_14_INCLUDED=TRUE @@ -1623,16 +1540,12 @@ Range: 2 octets ** ******************************************************************************/ -#ifndef HID_DEV_SUBCLASS -#define HID_DEV_SUBCLASS COD_MINOR_POINTING +#ifndef HID_CONTROL_BUF_SIZE +#define HID_CONTROL_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -#ifndef HID_CONTROL_POOL_ID -#define HID_CONTROL_POOL_ID 2 -#endif - -#ifndef HID_INTERRUPT_POOL_ID -#define HID_INTERRUPT_POOL_ID 2 +#ifndef HID_INTERRUPT_BUF_SIZE +#define HID_INTERRUPT_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /************************************************************************* @@ -1767,33 +1680,31 @@ Range: 2 octets #define MCA_NUM_MDLS 4 #endif -/* Pool ID where to reassemble the SDU. */ -#ifndef MCA_USER_RX_POOL_ID -#define MCA_USER_RX_POOL_ID HCI_ACL_POOL_ID +/* Buffer size to reassemble the SDU. */ +#ifndef MCA_USER_RX_BUF_SIZE +#define MCA_USER_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif -/* Pool ID where to hold the SDU. */ -#ifndef MCA_USER_TX_POOL_ID -#define MCA_USER_TX_POOL_ID HCI_ACL_POOL_ID +/* Buffer size to hold the SDU. */ +#ifndef MCA_USER_TX_BUF_SIZE +#define MCA_USER_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* -GKI Buffer Pool ID used to hold MPS segments during SDU reassembly -*/ -#ifndef MCA_FCR_RX_POOL_ID -#define MCA_FCR_RX_POOL_ID HCI_ACL_POOL_ID + * Buffer size used to hold MPS segments during SDU reassembly + */ +#ifndef MCA_FCR_RX_BUF_SIZE +#define MCA_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* -GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions. -L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool. -Note: This pool needs to have enough buffers to hold two times the window size negotiated - in the tL2CAP_FCR_OPTIONS (2 * tx_win_size) to allow for retransmissions. - The size of each buffer must be able to hold the maximum MPS segment size passed in - tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec). -*/ -#ifndef MCA_FCR_TX_POOL_ID -#define MCA_FCR_TX_POOL_ID HCI_ACL_POOL_ID + * Default buffer size used to hold MPS segments used in (re)transmissions. + * The size of each buffer must be able to hold the maximum MPS segment size + * passed in tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) + + * L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec). + */ +#ifndef MCA_FCR_TX_BUF_SIZE +#define MCA_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE #endif /* MCAP control channel FCR Option: diff --git a/tools/sdk/include/bluedroid/bta_api.h b/tools/sdk/include/bluedroid/bta_api.h index f21803b1..fb02175f 100644 --- a/tools/sdk/include/bluedroid/bta_api.h +++ b/tools/sdk/include/bluedroid/bta_api.h @@ -404,6 +404,8 @@ typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status); typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK; +typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK; + /* advertising channel map */ #define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37 #define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38 @@ -2035,11 +2037,11 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr); ** Description Enable/disable privacy on the local device ** ** Parameters: privacy_enable - enable/disabe privacy on remote device. -** +** set_local_privacy_cback -callback to be called with result ** Returns void ** *******************************************************************************/ -extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable); +extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback); /******************************************************************************* ** @@ -2208,7 +2210,7 @@ extern void BTA_BleDisableAdvInstance(UINT8 inst_id); ** *******************************************************************************/ extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, - UINT16 max_int, UINT16 latency, UINT16 timeout, tBTA_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb); + UINT16 max_int, UINT16 latency, UINT16 timeout); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/bta_av_co.h b/tools/sdk/include/bluedroid/bta_av_co.h index c2f94b63..3f7f989d 100644 --- a/tools/sdk/include/bluedroid/bta_av_co.h +++ b/tools/sdk/include/bluedroid/bta_av_co.h @@ -304,7 +304,7 @@ extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type); ** the audio codec ** ** Returns NULL if data is not ready. -** Otherwise, a GKI buffer (BT_HDR*) containing the audio data. +** Otherwise, a buffer (BT_HDR*) containing the audio data. ** *******************************************************************************/ extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, diff --git a/tools/sdk/include/bluedroid/bta_gatt_api.h b/tools/sdk/include/bluedroid/bta_gatt_api.h index 349c7c6a..4b4945aa 100644 --- a/tools/sdk/include/bluedroid/bta_gatt_api.h +++ b/tools/sdk/include/bluedroid/bta_gatt_api.h @@ -1157,12 +1157,12 @@ extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start); ** only once per connection. ** ** Parameters conn_id: connection ID. -** mtu: desired MTU size to use. +** ** ** Returns void ** *******************************************************************************/ -extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu); +extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id); /******************************************************************************* ** BTA GATT Server API @@ -1409,10 +1409,10 @@ extern void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *valu ** length - the value length which has been set to the attribute. ** value - the pointer to the value ** -** Returns None +** Returns tBTA_GATT_STATUS ** *******************************************************************************/ -extern void BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value); +extern tBTA_GATT_STATUS BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/bta_gatt_common.h b/tools/sdk/include/bluedroid/bta_gatt_common.h new file mode 100644 index 00000000..f6bc884b --- /dev/null +++ b/tools/sdk/include/bluedroid/bta_gatt_common.h @@ -0,0 +1,36 @@ +/****************************************************************************** +* Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at + +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + ******************************************************************************/ + +/****************************************************************************** + * + * This file contains the action functions for gatts and gattc. + * + * + ******************************************************************************/ + +#include "bt_types.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern void BTA_GATT_SetLocalMTU(uint16_t mtu); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/include/bluedroid/bta_gattc_int.h b/tools/sdk/include/bluedroid/bta_gattc_int.h index 21cd4259..6ea09ef8 100644 --- a/tools/sdk/include/bluedroid/bta_gattc_int.h +++ b/tools/sdk/include/bluedroid/bta_gattc_int.h @@ -29,7 +29,7 @@ #include "bta_gatt_api.h" #include "bta_gattc_ci.h" #include "bta_gattc_co.h" -#include "gki.h" +#include "fixed_queue.h" /***************************************************************************** ** Constants and data types @@ -184,7 +184,6 @@ typedef struct { typedef struct { BT_HDR hdr; - UINT16 mtu; } tBTA_GATTC_API_CFG_MTU; typedef struct { @@ -302,7 +301,7 @@ typedef struct { tBTA_GATTC_CACHE *p_srvc_cache; tBTA_GATTC_CACHE *p_cur_srvc; - BUFFER_Q cache_buffer; /* buffer queue used for storing the cache data */ + fixed_queue_t *cache_buffer; /* buffer queue used for storing the cache data */ UINT8 *p_free; /* starting point to next available byte */ UINT16 free_byte; /* number of available bytes in server cache buffer */ UINT8 update_count; /* indication received */ diff --git a/tools/sdk/include/bluedroid/bta_gatts_int.h b/tools/sdk/include/bluedroid/bta_gatts_int.h index 0f9e689a..211929f2 100644 --- a/tools/sdk/include/bluedroid/bta_gatts_int.h +++ b/tools/sdk/include/bluedroid/bta_gatts_int.h @@ -29,7 +29,6 @@ #include "bta_gatt_api.h" #include "gatt_api.h" -#include "gki.h" /***************************************************************************** ** Constants and data types @@ -230,7 +229,7 @@ extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); -extern void bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value); +extern tGATT_STATUS bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value); extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg); diff --git a/tools/sdk/include/bluedroid/bta_sys.h b/tools/sdk/include/bluedroid/bta_sys.h index 808edbb4..94ebd805 100644 --- a/tools/sdk/include/bluedroid/bta_sys.h +++ b/tools/sdk/include/bluedroid/bta_sys.h @@ -25,7 +25,7 @@ #define BTA_SYS_H #include "bt_target.h" -#include "gki.h" +#include "bt_defs.h" /***************************************************************************** ** Constants and data types diff --git a/tools/sdk/include/bluedroid/btc_ble_storage.h b/tools/sdk/include/bluedroid/btc_ble_storage.h index cbb6229c..111f1f0a 100644 --- a/tools/sdk/include/bluedroid/btc_ble_storage.h +++ b/tools/sdk/include/bluedroid/btc_ble_storage.h @@ -11,9 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +#ifndef __BTC_BLE_STORAGE_H__ +#define __BTC_BLE_STORAGE_H__ #include "bt_types.h" #include "bt_target.h" +#include "esp_gap_ble_api.h" #if (SMP_INCLUDED == TRUE) #define BTC_LE_LOCAL_KEY_IR (1<<0) @@ -77,9 +79,12 @@ typedef struct extern btc_dm_pairing_cb_t pairing_cb; extern btc_dm_local_key_cb_t ble_local_key_cb; +extern btc_bonded_devices_t bonded_devices; bt_status_t btc_storage_load_bonded_ble_devices(void); +bt_status_t btc_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev); + bt_status_t btc_in_fetch_bonded_ble_devices(int add); void btc_dm_remove_ble_bonding_keys(void); @@ -102,14 +107,16 @@ bt_status_t btc_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr, char *key_value, int key_length); -bool btc_storage_compare_address_key_value(uint8_t key_type, void *key_value, int key_length); - +bool btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr, + uint8_t key_type, void *key_value, int key_length); bt_status_t btc_storage_add_ble_local_key(char *key, uint8_t key_type, uint8_t key_length); bt_status_t btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr); +bt_status_t btc_storage_clear_bond_devices(void); + bt_status_t btc_storage_remove_ble_local_keys(void); bt_status_t btc_storage_get_ble_local_key(uint8_t key_type, @@ -119,6 +126,8 @@ bt_status_t btc_storage_get_ble_local_key(uint8_t key_type, bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr, int *addr_type); +int btc_storage_get_num_ble_bond_devices(void); + bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, uint8_t addr_type); @@ -126,4 +135,5 @@ void btc_dm_load_ble_local_keys(void); void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, tBTA_BLE_LOCAL_ID_KEYS *p_id_keys); -#endif ///SMP_INCLUDED == TRUE \ No newline at end of file +#endif ///SMP_INCLUDED == TRUE +#endif ///__BTC_BLE_STORAGE_H__ \ No newline at end of file diff --git a/tools/sdk/include/bluedroid/btc_config.h b/tools/sdk/include/bluedroid/btc_config.h index e0d6d6ec..2367c53b 100644 --- a/tools/sdk/include/bluedroid/btc_config.h +++ b/tools/sdk/include/bluedroid/btc_config.h @@ -20,6 +20,8 @@ #include "bt_types.h" +#define BTC_LE_DEV_TYPE "DevType" + typedef struct btc_config_section_iter_t btc_config_section_iter_t; bool btc_config_init(void); @@ -35,6 +37,7 @@ bool btc_config_set_str(const char *section, const char *key, const char *value) bool btc_config_get_bin(const char *section, const char *key, uint8_t *value, size_t *length); bool btc_config_set_bin(const char *section, const char *key, const uint8_t *value, size_t length); bool btc_config_remove(const char *section, const char *key); +bool btc_config_remove_section(const char *section); size_t btc_config_get_bin_length(const char *section, const char *key); @@ -49,7 +52,7 @@ int btc_config_clear(void); // TODO(zachoverflow): Eww...we need to move these out. These are peer specific, not config general. bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type); -bool btc_compare_address_key_value(char *key_type, void *key_value, int key_length); +bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length); bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type); #endif diff --git a/tools/sdk/include/bluedroid/btc_gap_ble.h b/tools/sdk/include/bluedroid/btc_gap_ble.h index 78c2db02..b6da5360 100644 --- a/tools/sdk/include/bluedroid/btc_gap_ble.h +++ b/tools/sdk/include/bluedroid/btc_gap_ble.h @@ -40,6 +40,9 @@ typedef enum { BTC_GAP_BLE_PASSKEY_REPLY_EVT, BTC_GAP_BLE_CONFIRM_REPLY_EVT, BTC_GAP_BLE_DISCONNECT_EVT, + BTC_GAP_BLE_REMOVE_BOND_DEV_EVT, + BTC_GAP_BLE_CLEAR_BOND_DEV_EVT, + BTC_GAP_BLE_GET_BOND_DEV_EVT, } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -89,44 +92,50 @@ typedef union { uint8_t *raw_scan_rsp; uint32_t raw_scan_rsp_len; } cfg_scan_rsp_data_raw; - + //BTC_GAP_BLE_SET_ENCRYPTION_EVT struct set_encryption_args { esp_bd_addr_t bd_addr; esp_ble_sec_act_t sec_act; } set_encryption; - + //BTC_GAP_BLE_SET_SECURITY_PARAM_EVT struct set_security_param_args { esp_ble_sm_param_t param_type; uint8_t len; uint8_t *value; } set_security_param; - + //BTC_GAP_BLE_SECURITY_RSP_EVT struct enc_rsp_args { esp_bd_addr_t bd_addr; bool accept; } sec_rsp; - + //BTC_GAP_BLE_PASSKEY_REPLY_EVT struct enc_passkey_reply_args { esp_bd_addr_t bd_addr; bool accept; uint32_t passkey; } enc_passkey_replay; - + //BTC_GAP_BLE_CONFIRM_REPLY_EVT struct enc_comfirm_reply_args { esp_bd_addr_t bd_addr; bool accept; } enc_comfirm_replay; - //BTC_GAP_BLE_DISCONNECT_EVT struct disconnect_args { esp_bd_addr_t remote_device; } disconnect; - + //BTC_GAP_BLE_REMOVE_BOND_DEV_EVT + struct remove_bond_device_args { + esp_bd_addr_t bd_addr; + } remove_bond_device; } btc_ble_gap_args_t; void btc_gap_ble_call_handler(btc_msg_t *msg); void btc_gap_ble_cb_handler(btc_msg_t *msg); void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); +void btc_gap_ble_arg_deep_free(btc_msg_t *msg); +void btc_gap_ble_cb_deep_free(btc_msg_t *msg); +void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); +void btc_gap_callback_init(void); #endif /* __BTC_GAP_BLE_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_gattc.h b/tools/sdk/include/bluedroid/btc_gattc.h index 1374dc0a..d1e0e968 100644 --- a/tools/sdk/include/bluedroid/btc_gattc.h +++ b/tools/sdk/include/bluedroid/btc_gattc.h @@ -68,7 +68,6 @@ typedef union { //BTC_GATTC_ACT_CFG_MTU, struct cfg_mtu_arg { uint16_t conn_id; - uint16_t mtu; } cfg_mtu; //BTC_GATTC_ACT_SEARCH_SERVICE, struct search_srvc_arg { diff --git a/tools/sdk/include/bluedroid/btc_gatts.h b/tools/sdk/include/bluedroid/btc_gatts.h index 35cf84c5..00f73875 100644 --- a/tools/sdk/include/bluedroid/btc_gatts.h +++ b/tools/sdk/include/bluedroid/btc_gatts.h @@ -147,7 +147,7 @@ typedef union { void btc_gatts_call_handler(btc_msg_t *msg); void btc_gatts_cb_handler(btc_msg_t *msg); void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, uint8_t **value); +esp_gatt_status_t btc_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, uint8_t **value); #endif /* __BTC_GATTS_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_main.h b/tools/sdk/include/bluedroid/btc_main.h index b95ae0bb..523e1bb9 100644 --- a/tools/sdk/include/bluedroid/btc_main.h +++ b/tools/sdk/include/bluedroid/btc_main.h @@ -26,6 +26,7 @@ typedef enum { BTC_MAIN_ACT_DEINIT, BTC_MAIN_ACT_ENABLE, BTC_MAIN_ACT_DISABLE, + BTC_GATT_ACT_SET_LOCAL_MTU, } btc_main_act_t; typedef enum { @@ -60,5 +61,13 @@ bt_status_t btc_init_bluetooth(future_t *future); void btc_deinit_bluetooth(future_t *future); #endif +/* btc_ble_gattc_args_t */ +typedef union { + //BTC_GATT_ACT_SET_LOCAL_MTU, + struct set_mtu_arg { + uint16_t mtu; + } set_mtu; +} btc_ble_main_args_t; + void btc_main_call_handler(btc_msg_t *msg); #endif /* __BTC_BT_MAIN_H__ */ diff --git a/tools/sdk/include/bluedroid/btc_media.h b/tools/sdk/include/bluedroid/btc_media.h index a25da987..66ad366f 100644 --- a/tools/sdk/include/bluedroid/btc_media.h +++ b/tools/sdk/include/bluedroid/btc_media.h @@ -25,7 +25,6 @@ #include #include "bta_api.h" -#include "gki.h" #include "btc_av_api.h" #if (BTA_AV_INCLUDED == TRUE) @@ -174,9 +173,9 @@ extern BOOLEAN btc_media_task_aa_tx_flush_req(void); ** ** Function btc_media_aa_readbuf ** - ** Description Read an audio GKI buffer from the BTC media TX queue + ** Description Read an audio buffer from the BTC media TX queue ** - ** Returns pointer on a GKI aa buffer ready to send + ** Returns pointer on a aa buffer ready to send ** *******************************************************************************/ extern BT_HDR *btc_media_aa_readbuf(void); @@ -198,7 +197,7 @@ UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf); ** ** Function btc_media_aa_writebuf ** - ** Description Enqueue a Advance Audio media GKI buffer to be processed by btc media task. + ** Description Enqueue a Advance Audio media buffer to be processed by btc media task. ** ** Returns TRUE is success ** @@ -209,7 +208,7 @@ extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num ** ** Function btc_media_av_writebuf ** - ** Description Enqueue a video media GKI buffer to be processed by btc media task. + ** Description Enqueue a video media buffer to be processed by btc media task. ** ** Returns TRUE is success ** diff --git a/tools/sdk/include/bluedroid/bte.h b/tools/sdk/include/bluedroid/bte.h index 6a3ffe80..171967cf 100644 --- a/tools/sdk/include/bluedroid/bte.h +++ b/tools/sdk/include/bluedroid/bte.h @@ -110,7 +110,6 @@ typedef struct tBAUD_REG_tag { UINT8 ExplicitBaudRate3; } tBAUD_REG; -#include "gki.h" extern const tBAUD_REG baud_rate_regs[]; diff --git a/tools/sdk/include/bluedroid/btm_api.h b/tools/sdk/include/bluedroid/btm_api.h index 2976e497..d4ee7b47 100644 --- a/tools/sdk/include/bluedroid/btm_api.h +++ b/tools/sdk/include/bluedroid/btm_api.h @@ -69,7 +69,9 @@ enum { BTM_REPEATED_ATTEMPTS, /* 19 repeated attempts for LE security requests */ BTM_MODE4_LEVEL4_NOT_SUPPORTED, /* 20 Secure Connections Only Mode can't be supported */ BTM_PEER_LE_DATA_LEN_UNSUPPORTED, /* 21 peer setting data length is unsupported*/ - BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED /* 22 controller setting data length is unsupported*/ + BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/ + BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */ + BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/ }; typedef uint8_t tBTM_STATUS; @@ -175,6 +177,8 @@ typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params); +typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status); + /***************************************************************************** ** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device @@ -1412,6 +1416,7 @@ typedef UINT8 tBTM_IO_CAP; #define BTM_BLE_INITIATOR_KEY_SIZE 15 #define BTM_BLE_RESPONDER_KEY_SIZE 15 #define BTM_BLE_MAX_KEY_SIZE 16 +#define BTM_BLE_MIN_KEY_SIZE 7 typedef UINT8 tBTM_AUTH_REQ; diff --git a/tools/sdk/include/bluedroid/btm_ble_api.h b/tools/sdk/include/bluedroid/btm_ble_api.h index 92781245..d23313cb 100644 --- a/tools/sdk/include/bluedroid/btm_ble_api.h +++ b/tools/sdk/include/bluedroid/btm_ble_api.h @@ -27,7 +27,6 @@ #include "bt_defs.h" #include "btm_api.h" -#include "gki.h" #include "bt_common_types.h" #define CHANNEL_MAP_LEN 5 @@ -164,12 +163,12 @@ typedef UINT8 tBTM_BLE_SFP; /* default connection interval min */ #ifndef BTM_BLE_CONN_INT_MIN_DEF -#define BTM_BLE_CONN_INT_MIN_DEF 24 /* recommended min: 30ms = 24 * 1.25 */ +#define BTM_BLE_CONN_INT_MIN_DEF 10 /* recommended min: 12.5 ms = 10 * 1.25 */ #endif /* default connection interval max */ #ifndef BTM_BLE_CONN_INT_MAX_DEF -#define BTM_BLE_CONN_INT_MAX_DEF 40 /* recommended max: 50 ms = 56 * 1.25 */ +#define BTM_BLE_CONN_INT_MAX_DEF 12 /* recommended max: 15 ms = 12 * 1.25 */ #endif /* default slave latency */ @@ -861,6 +860,20 @@ tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb; extern "C" { #endif */ + +/******************************************************************************* +** +** Function BTM_BleRegiseterConnParamCallback +** +** Description register connection parameters update callback func +** +** Parameters: update_conn_param_cb +** +** Returns void +** +*******************************************************************************/ +void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb); + /******************************************************************************* ** ** Function BTM_SecAddBleDevice @@ -1596,7 +1609,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start); ** *******************************************************************************/ //extern -BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable); +BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/btm_ble_int.h b/tools/sdk/include/bluedroid/btm_ble_int.h index 055591d7..a73a42e7 100644 --- a/tools/sdk/include/bluedroid/btm_ble_int.h +++ b/tools/sdk/include/bluedroid/btm_ble_int.h @@ -27,7 +27,7 @@ #define BTM_BLE_INT_H #include "bt_target.h" -#include "gki.h" +#include "fixed_queue.h" #include "hcidefs.h" #include "btm_ble_api.h" #include "btm_int.h" @@ -185,6 +185,7 @@ typedef struct { tBTM_BLE_ADDR_CBACK *p_generate_cback; void *p; TIMER_LIST_ENT raddr_timer_ent; + tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback; } tBTM_LE_RANDOM_CB; #define BTM_BLE_MAX_BG_CONN_DEV_NUM 10 @@ -315,7 +316,7 @@ typedef struct { UINT8 white_list_avail_size; tBTM_BLE_WL_STATE wl_state; - BUFFER_Q conn_pending_q; + fixed_queue_t *conn_pending_q; tBTM_BLE_CONN_ST conn_state; /* random address management control block */ @@ -362,6 +363,7 @@ BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int, UINT8 scan_filter_policy); void btm_ble_stop_inquiry(void); void btm_ble_init (void); +void btm_ble_free (void); void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched); void btm_ble_read_remote_features_complete(UINT8 *p); void btm_ble_write_adv_enable_complete(UINT8 *p); diff --git a/tools/sdk/include/bluedroid/btm_int.h b/tools/sdk/include/bluedroid/btm_int.h index 4d263d57..42468d95 100644 --- a/tools/sdk/include/bluedroid/btm_int.h +++ b/tools/sdk/include/bluedroid/btm_int.h @@ -27,7 +27,6 @@ #include "bt_defs.h" #include "bt_target.h" -#include "gki.h" #include "hcidefs.h" #include "rfcdefs.h" @@ -115,7 +114,6 @@ UINT8 conn_addr_type; /* local device address type for this co BD_ADDR active_remote_addr; /* remote address used on this connection */ UINT8 active_remote_addr_type; /* local device address type for this connection */ BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */ -tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb; tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback; tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params; #endif @@ -367,7 +365,7 @@ typedef struct { typedef struct { tBTM_ESCO_INFO esco; /* Current settings */ #if BTM_SCO_HCI_INCLUDED == TRUE - BUFFER_Q xmit_data_q; /* SCO data transmitting queue */ + fixed_queue_t *xmit_data_q; /* SCO data transmitting queue */ #endif tBTM_SCO_CB *p_conn_cb; /* Callback for when connected */ tBTM_SCO_CB *p_disc_cb; /* Callback for when disconnect */ @@ -865,15 +863,21 @@ typedef struct { UINT8 busy_level; /* the current busy level */ BOOLEAN is_paging; /* TRUE, if paging is in progess */ BOOLEAN is_inquiry; /* TRUE, if inquiry is in progess */ - BUFFER_Q page_queue; + fixed_queue_t *page_queue; BOOLEAN paging; BOOLEAN discing; - BUFFER_Q sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */ + fixed_queue_t *sec_pending_q; /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */ #if (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE)) char state_temp_buffer[BTM_STATE_BUFFER_SIZE]; #endif } tBTM_CB; +typedef struct{ + //connection parameters update callback + tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb; +}tBTM_CallbackFunc; + +extern tBTM_CallbackFunc conn_param_update_cb; /* #ifdef __cplusplus extern "C" @@ -892,6 +896,7 @@ extern tBTM_CB *btm_cb_ptr; ******************************************** */ void btm_init (void); +void btm_free (void); /* Internal functions provided by btm_inq.c ******************************************* diff --git a/tools/sdk/include/bluedroid/btu.h b/tools/sdk/include/bluedroid/btu.h index b2d72364..cc960c59 100644 --- a/tools/sdk/include/bluedroid/btu.h +++ b/tools/sdk/include/bluedroid/btu.h @@ -28,7 +28,7 @@ #define BTU_H #include "bt_target.h" -#include "gki.h" +#include "bt_defs.h" // HACK(zachoverflow): temporary dark magic #define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing diff --git a/tools/sdk/include/bluedroid/esp_avrc_api.h b/tools/sdk/include/bluedroid/esp_avrc_api.h index 719a19f1..e3074209 100644 --- a/tools/sdk/include/bluedroid/esp_avrc_api.h +++ b/tools/sdk/include/bluedroid/esp_avrc_api.h @@ -136,7 +136,7 @@ esp_err_t esp_avrc_ct_deinit(void); * @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values. * @param[in] key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc. * @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or - * ESP_AVRC_PT_CMD_STATE_PRESSED + * ESP_AVRC_PT_CMD_STATE_RELEASED * * @return * - ESP_OK: success diff --git a/tools/sdk/include/bluedroid/esp_bt_defs.h b/tools/sdk/include/bluedroid/esp_bt_defs.h index e2b9553b..513d37ec 100644 --- a/tools/sdk/include/bluedroid/esp_bt_defs.h +++ b/tools/sdk/include/bluedroid/esp_bt_defs.h @@ -22,6 +22,12 @@ extern "C" { #endif +#define ESP_BLUEDROID_STATUS_CHECK(status) \ + if (esp_bluedroid_get_status() != (status)) { \ + return ESP_ERR_INVALID_STATE; \ + } + + /* relate to BT_STATUS_xxx in bt_def.h */ /// Status Return Value typedef enum { @@ -44,6 +50,7 @@ typedef enum { ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */ ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */ ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */ + ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */ } esp_bt_status_t; @@ -107,6 +114,7 @@ typedef enum { #define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in btm_api.h */ /// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key #define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in btm_api.h */ +typedef uint8_t esp_ble_key_mask_t; /* the key mask type */ /// Minimum of the application id #define ESP_APP_ID_MIN 0x0000 diff --git a/tools/sdk/include/bluedroid/esp_gap_ble_api.h b/tools/sdk/include/bluedroid/esp_gap_ble_api.h index 0492bd5d..a7cafcd3 100644 --- a/tools/sdk/include/bluedroid/esp_gap_ble_api.h +++ b/tools/sdk/include/bluedroid/esp_gap_ble_api.h @@ -93,6 +93,11 @@ typedef enum { ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */ ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */ ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt lenght complete, the event comes */ + ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */ + ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */ + ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */ + ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */ + ESP_GAP_BLE_EVT_MAX, } esp_gap_ble_cb_event_t; /// Advertising data maximum length @@ -293,7 +298,7 @@ typedef struct uint16_t ediv; /*!< The ediv value*/ uint8_t sec_level; /*!< The security level of the security link*/ uint8_t key_size; /*!< The key size(7~16) of the security link*/ -}esp_ble_penc_keys_t; /*!< The key type*/ +} esp_ble_penc_keys_t; /*!< The key type*/ /** * @brief BLE CSRK keys @@ -303,7 +308,7 @@ typedef struct uint32_t counter; /*!< The counter */ esp_bt_octet16_t csrk; /*!< The csrk key */ uint8_t sec_level; /*!< The security level */ -}esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */ +} esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */ /** * @brief BLE pid keys @@ -313,7 +318,7 @@ typedef struct esp_bt_octet16_t irk; /*!< The irk value */ esp_ble_addr_type_t addr_type; /*!< The address type */ esp_bd_addr_t static_addr; /*!< The static address */ -}esp_ble_pid_keys_t; /*!< The pid key type */ +} esp_ble_pid_keys_t; /*!< The pid key type */ /** * @brief BLE Encryption reproduction keys @@ -324,7 +329,7 @@ typedef struct uint16_t div; /*!< The div value */ uint8_t key_size; /*!< The key size of the security link */ uint8_t sec_level; /*!< The security level of the security link */ -}esp_ble_lenc_keys_t; /*!< The key type */ +} esp_ble_lenc_keys_t; /*!< The key type */ /** * @brief BLE SRK keys @@ -334,8 +339,8 @@ typedef struct uint32_t counter; /*!< The counter value */ uint16_t div; /*!< The div value */ uint8_t sec_level; /*!< The security level of the security link */ - esp_bt_octet16_t csrk; /*!< The csrk key value */ -}esp_ble_lcsrk_keys; /*!< The csrk key type */ + esp_bt_octet16_t csrk; /*!< The csrk key value */ +} esp_ble_lcsrk_keys; /*!< The csrk key type */ /** * @brief Structure associated with ESP_KEY_NOTIF_EVT @@ -352,7 +357,7 @@ typedef struct typedef struct { esp_bd_addr_t bd_addr; /*!< peer address */ -}esp_ble_sec_req_t; /*!< BLE security request type*/ +} esp_ble_sec_req_t; /*!< BLE security request type*/ /** * @brief union type of the security key value @@ -364,7 +369,27 @@ typedef union esp_ble_pid_keys_t pid_key; /*!< peer device ID key */ esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/ esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/ -}esp_ble_key_value_t; /*!< ble key value type*/ +} esp_ble_key_value_t; /*!< ble key value type*/ + +/** +* @brief struct type of the bond key informatuon value +*/ +typedef struct +{ + esp_ble_key_mask_t key_mask; /*!< the key mask to indicate witch key is present */ + esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */ + esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */ + esp_ble_pid_keys_t pid_key; /*!< peer device ID key */ +} esp_ble_bond_key_info_t; /*!< ble bond key information value type */ + +/** +* @brief struct type of the bond device value +*/ +typedef struct +{ + esp_bd_addr_t bd_addr; /*!< peer address */ + esp_ble_bond_key_info_t bond_key; /*!< the bond key information */ +} esp_ble_bond_dev_t; /*!< the ble bond device type */ /** @@ -375,7 +400,7 @@ typedef struct esp_bd_addr_t bd_addr; /*!< peer address */ esp_ble_key_type_t key_type; /*!< key type of the security link */ esp_ble_key_value_t p_key_value; /*!< the pointer to the key value */ -}esp_ble_key_t; /*!< the union to the ble key value type*/ +} esp_ble_key_t; /*!< the union to the ble key value type*/ /** * @brief structure type of the ble local id keys value @@ -384,7 +409,7 @@ typedef struct { esp_bt_octet16_t ir; /*!< the 16 bits of the ir value */ esp_bt_octet16_t irk; /*!< the 16 bits of the ir key value */ esp_bt_octet16_t dhk; /*!< the 16 bits of the dh key value */ -}esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/ +} esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/ /** @@ -400,7 +425,7 @@ typedef struct uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */ esp_ble_addr_type_t addr_type; /*!< Peer device address type */ esp_bt_dev_type_t dev_type; /*!< Device type */ -}esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */ +} esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */ /** * @brief union associated with ble security @@ -412,7 +437,7 @@ typedef union esp_ble_key_t ble_key; /*!< BLE SMP keys used when pairing */ esp_ble_local_id_keys_t ble_id_keys; /*!< BLE IR event */ esp_ble_auth_cmpl_t auth_cmpl; /*!< Authentication complete indication. */ -}esp_ble_sec_t; /*!< Ble secutity type */ +} esp_ble_sec_t; /*!< Ble secutity type */ /// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT typedef enum { @@ -539,6 +564,33 @@ typedef union { esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */ esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */ } pkt_data_lenth_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT + */ + struct ble_local_privacy_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */ + } local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT + */ + struct ble_remove_bond_dev_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */ + esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */ + }remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT + */ + struct ble_clear_bond_dev_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate the clear bond device operation success status */ + }clear_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT + */ + struct ble_get_bond_dev_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate the get bond device operation success status */ + uint8_t dev_num; /*!< Indicate the get number device in the bond list */ + esp_ble_bond_dev_t *bond_dev; /*!< the pointer to the bond device Structure */ + }get_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT */ } esp_ble_gap_cb_param_t; /** @@ -814,6 +866,38 @@ esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t pas */ esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept); +/** +* @brief Removes a device from the security database list of +* peer device. It manages unpairing event while connected. +* +* @param[in] bd_addr : BD address of the peer device +* +* @return - ESP_OK : success +* - other : failed +* +*/ +esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr); + +/** +* @brief Removes all of the device from the security database list of +* peer device. It manages unpairing event while connected. +* +* @return - ESP_OK : success +* - other : failed +* +*/ +esp_err_t esp_ble_clear_bond_device_list(void); + +/** +* @brief Get the device from the security database list of peer device. +* It will return the device bonded information from the ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT event. +* +* @return - ESP_OK : success +* - other : failed +* +*/ +esp_err_t esp_ble_get_bond_device_list(void); + /** * @brief This function is to disconnect the physical connection of the peer device * diff --git a/tools/sdk/include/bluedroid/esp_gatt_common_api.h b/tools/sdk/include/bluedroid/esp_gatt_common_api.h new file mode 100644 index 00000000..33bc1125 --- /dev/null +++ b/tools/sdk/include/bluedroid/esp_gatt_common_api.h @@ -0,0 +1,46 @@ +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "esp_err.h" +#include "esp_bt_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Maximum Transmission Unit used in GATT +#define ESP_GATT_DEF_BLE_MTU_SIZE 23 /* relate to GATT_DEF_BLE_MTU_SIZE in gatt_api.h */ + +// Maximum Transmission Unit allowed in GATT +#define ESP_GATT_MAX_MTU_SIZE 517 /* relate to GATT_MAX_MTU_SIZE in gatt_api.h */ + +/** + * @brief This function is called to set local MTU, + * the function is called before BLE connection. + * + * @param[in] mtu: the size of MTU. + * + * @return + * - ESP_OK: success + * - other: failed + * + */ +extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/include/bluedroid/esp_gattc_api.h b/tools/sdk/include/bluedroid/esp_gattc_api.h index 6e6f9396..b950d438 100644 --- a/tools/sdk/include/bluedroid/esp_gattc_api.h +++ b/tools/sdk/include/bluedroid/esp_gattc_api.h @@ -68,11 +68,6 @@ typedef enum { ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */ } esp_gattc_cb_event_t; -/// Maximum Transmission Unit used in GATT -#define ESP_GATT_DEF_BLE_MTU_SIZE 23 - -/// Maximum Transmission Unit allowed in GATT -#define ESP_GATT_MAX_MTU_SIZE 517 /** * @brief Gatt client callback parameters union @@ -355,18 +350,19 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id); /** * @brief Configure the MTU size in the GATT channel. This can be done - * only once per connection. + * only once per connection. Before using, use esp_ble_gatt_set_local_mtu() + * to configure the local MTU size. + * * * @param[in] gattc_if: Gatt client access interface. * @param[in] conn_id: connection ID. - * @param[in] mtu: desired MTU size to use. * * @return * - ESP_OK: success * - other: failed * */ -esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, uint16_t mtu); +esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id); /** @@ -634,7 +630,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id, * - other: failed * */ -esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if, +esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if, esp_bd_addr_t server_bda, esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id); @@ -653,7 +649,7 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if, * - other: failed * */ -esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if, +esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if, esp_bd_addr_t server_bda, esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id); diff --git a/tools/sdk/include/bluedroid/esp_gatts_api.h b/tools/sdk/include/bluedroid/esp_gatts_api.h index 6bbc370a..d964ac9b 100644 --- a/tools/sdk/include/bluedroid/esp_gatts_api.h +++ b/tools/sdk/include/bluedroid/esp_gatts_api.h @@ -514,11 +514,11 @@ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, co * @param[out] value: Pointer to attribute value payload, the value cannot be modified by user * * @return - * - ESP_OK : success + * - ESP_GATT_OK : success * - other : failed * */ -esp_err_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value); +esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value); /** diff --git a/tools/sdk/include/bluedroid/fixed_queue.h b/tools/sdk/include/bluedroid/fixed_queue.h index 9cbb846d..becafea1 100644 --- a/tools/sdk/include/bluedroid/fixed_queue.h +++ b/tools/sdk/include/bluedroid/fixed_queue.h @@ -20,8 +20,10 @@ #define _FIXED_QUEUE_H_ #include +#include "list.h" struct fixed_queue_t; + typedef struct fixed_queue_t fixed_queue_t; //typedef struct reactor_t reactor_t; @@ -38,10 +40,14 @@ fixed_queue_t *fixed_queue_new(size_t capacity); // blocked on it) results in undefined behaviour. void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb); -// Returns a value indicating whether the given |queue| is empty. |queue| may -// not be NULL. +// Returns a value indicating whether the given |queue| is empty. If |queue| +// is NULL, the return value is true. bool fixed_queue_is_empty(fixed_queue_t *queue); +// Returns the length of the |queue|. If |queue| is NULL, the return value +// is 0. +size_t fixed_queue_length(fixed_queue_t *queue); + // Returns the maximum number of elements this queue may hold. |queue| may // not be NULL. size_t fixed_queue_capacity(fixed_queue_t *queue); @@ -66,12 +72,33 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data); // the caller. If the queue is empty, this function returns NULL immediately. // Otherwise, the next element in the queue is returned. |queue| may not be // NULL. -//void *fixed_queue_try_dequeue(fixed_queue_t *queue); +void *fixed_queue_try_dequeue(fixed_queue_t *queue); // Returns the first element from |queue|, if present, without dequeuing it. -// This function will never block the caller. Returns NULL if there are no elements -// in the queue. |queue| may not be NULL. -//void *fixed_queue_try_peek(fixed_queue_t *queue); +// This function will never block the caller. Returns NULL if there are no +// elements in the queue or |queue| is NULL. +void *fixed_queue_try_peek_first(fixed_queue_t *queue); + +// Returns the last element from |queue|, if present, without dequeuing it. +// This function will never block the caller. Returns NULL if there are no +// elements in the queue or |queue| is NULL. +void *fixed_queue_try_peek_last(fixed_queue_t *queue); + +// Tries to remove a |data| element from the middle of the |queue|. This +// function will never block the caller. If the queue is empty or NULL, this +// function returns NULL immediately. |data| may not be NULL. If the |data| +// element is found in the queue, a pointer to the removed data is returned, +// otherwise NULL. +void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data); + +// Returns the iterateable list with all entries in the |queue|. This function +// will never block the caller. |queue| may not be NULL. +// +// NOTE: The return result of this function is not thread safe: the list could +// be modified by another thread, and the result would be unpredictable. +// TODO: The usage of this function should be refactored, and the function +// itself should be removed. +list_t *fixed_queue_get_list(fixed_queue_t *queue); // This function returns a valid file descriptor. Callers may perform one // operation on the fd: select(2). If |select| indicates that the file @@ -99,4 +126,6 @@ void fixed_queue_unregister_dequeue(fixed_queue_t *queue); void fixed_queue_process(fixed_queue_t *queue); +list_t *fixed_queue_get_list(fixed_queue_t *queue); + #endif diff --git a/tools/sdk/include/bluedroid/future.h b/tools/sdk/include/bluedroid/future.h index a89640c2..f001f1f1 100644 --- a/tools/sdk/include/bluedroid/future.h +++ b/tools/sdk/include/bluedroid/future.h @@ -18,9 +18,8 @@ #ifndef __FUTURE_H__ #define __FUTURE_H__ -// #pragma once -#include "osi_arch.h" +#include "semaphore.h" struct future { bool ready_can_be_called; diff --git a/tools/sdk/include/bluedroid/gap_int.h b/tools/sdk/include/bluedroid/gap_int.h index f05b0ce2..e9317a04 100644 --- a/tools/sdk/include/bluedroid/gap_int.h +++ b/tools/sdk/include/bluedroid/gap_int.h @@ -21,8 +21,8 @@ #define GAP_INT_H #include "bt_target.h" +#include "fixed_queue.h" #include "gap_api.h" -#include "gki.h" #include "gatt_api.h" #define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/ /* Define the Generic Access Profile control structure */ @@ -71,8 +71,8 @@ typedef struct { UINT16 rem_mtu_size; BOOLEAN is_congested; - BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */ - BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */ + fixed_queue_t *tx_queue; /* Queue of buffers waiting to be sent */ + fixed_queue_t *rx_queue; /* Queue of buffers waiting to be read */ UINT32 rx_queue_size; /* Total data count in rx_queue */ @@ -119,7 +119,7 @@ typedef struct { UINT16 cl_op_uuid; BOOLEAN in_use; BOOLEAN connected; - BUFFER_Q pending_req_q; + fixed_queue_t *pending_req_q; } tGAP_CLCB; diff --git a/tools/sdk/include/bluedroid/gatt_api.h b/tools/sdk/include/bluedroid/gatt_api.h index 76d8c465..946e5fee 100644 --- a/tools/sdk/include/bluedroid/gatt_api.h +++ b/tools/sdk/include/bluedroid/gatt_api.h @@ -943,7 +943,7 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 * ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ -extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu); +extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id); /******************************************************************************* ** diff --git a/tools/sdk/include/bluedroid/gatt_int.h b/tools/sdk/include/bluedroid/gatt_int.h index b538ed8b..9d836597 100644 --- a/tools/sdk/include/bluedroid/gatt_int.h +++ b/tools/sdk/include/bluedroid/gatt_int.h @@ -20,12 +20,11 @@ #define GATT_INT_H #include "bt_target.h" - - #include "bt_trace.h" #include "gatt_api.h" #include "btm_ble_api.h" #include "btu.h" +#include "fixed_queue.h" #include @@ -222,7 +221,7 @@ typedef struct { typedef struct { void *p_attr_list; /* pointer to the first attribute, either tGATT_ATTR16 or tGATT_ATTR128 */ UINT8 *p_free_mem; /* Pointer to free memory */ - BUFFER_Q svc_buffer; /* buffer queue used for service database */ + fixed_queue_t *svc_buffer; /* buffer queue used for service database */ UINT32 mem_free; /* Memory still available */ UINT16 end_handle; /* Last handle number */ UINT16 next_handle; /* Next usable handle value */ @@ -285,7 +284,7 @@ typedef struct { BT_HDR *p_rsp_msg; UINT32 trans_id; tGATT_READ_MULTI multi_req; - BUFFER_Q multi_rsp_q; + fixed_queue_t *multi_rsp_q; UINT16 handle; UINT8 op_code; UINT8 status; @@ -357,7 +356,7 @@ typedef struct{ typedef struct{ //only store prepare write packets which need //to be responded by stack (not by application) - BUFFER_Q queue; + fixed_queue_t *queue; //store the total number of prepare write packets //including that should be responded by stack or by application @@ -369,7 +368,7 @@ typedef struct{ }tGATT_PREPARE_WRITE_RECORD; typedef struct { - BUFFER_Q pending_enc_clcb; /* pending encryption channel q */ + fixed_queue_t *pending_enc_clcb; /* pending encryption channel q */ tGATT_SEC_ACTION sec_act; BD_ADDR peer_bda; tBT_TRANSPORT transport; @@ -389,7 +388,7 @@ typedef struct { tGATT_SR_CMD sr_cmd; #endif ///GATTS_INCLUDED == TRUE UINT16 indicate_handle; - BUFFER_Q pending_ind_q; + fixed_queue_t *pending_ind_q; TIMER_LIST_ENT conf_timer_ent; /* peer confirm to indication timer */ @@ -498,7 +497,7 @@ typedef struct { typedef struct { tGATT_TCB tcb[GATT_MAX_PHY_CHANNEL]; - BUFFER_Q sign_op_queue; + fixed_queue_t *sign_op_queue; tGATT_SR_REG sr_reg[GATT_MAX_SR_PROFILES]; UINT16 next_handle; /* next available handle */ @@ -510,8 +509,8 @@ typedef struct { tGATT_SRV_LIST_INFO srv_list_info; tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES]; #endif ///GATTS_INCLUDED == TRUE - BUFFER_Q srv_chg_clt_q; /* service change clients queue */ - BUFFER_Q pending_new_srv_start_q; /* pending new service start queue */ + fixed_queue_t *srv_chg_clt_q; /* service change clients queue */ + fixed_queue_t *pending_new_srv_start_q; /* pending new service start queue */ tGATT_REG cl_rcb[GATT_MAX_APPS]; tGATT_CLCB clcb[GATT_CL_MAX_LCB]; /* connection link control block*/ tGATT_SCCB sccb[GATT_MAX_SCCB]; /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */ @@ -538,6 +537,9 @@ typedef struct { } tGATT_CB; +typedef struct{ + UINT16 local_mtu; +} tGATT_DEFAULT; #define GATT_SIZE_OF_SRV_CHG_HNDL_RANGE 4 @@ -545,6 +547,8 @@ typedef struct { extern "C" { #endif +extern tGATT_DEFAULT gatt_default; + /* Global GATT data */ #if GATT_DYNAMIC_MEMORY == FALSE extern tGATT_CB gatt_cb; @@ -742,4 +746,6 @@ extern void gatts_update_srv_list_elem(UINT8 i_sreg, UINT16 handle, BOOLEAN is_p extern tBT_UUID *gatts_get_service_uuid (tGATT_SVC_DB *p_db); extern void gatt_reset_bgdev_list(void); +extern uint16_t gatt_get_local_mtu(void); +extern void gatt_set_local_mtu(uint16_t mtu); #endif diff --git a/tools/sdk/include/bluedroid/gki.h b/tools/sdk/include/bluedroid/gki.h deleted file mode 100644 index 4e5f3c2b..00000000 --- a/tools/sdk/include/bluedroid/gki.h +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 1999-2012 Broadcom Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#ifndef _GKI_H_ -#define _GKI_H_ - -#include "bt_target.h" -#include "bt_types.h" -#include "gki_common.h" -#include "gki_int.h" -#include "allocator.h" - -#define ALIGN_POOL(pl_size) ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32)) -#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T)) /* Offset past header */ -#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */ -#define MAGIC_NO 0xDDBADDBA - -#define BUF_STATUS_FREE 0 -#define BUF_STATUS_UNLINKED 1 -#define BUF_STATUS_QUEUED 2 - -/* Timer list entry callback type -*/ -typedef void (TIMER_CBACK)(void *p_tle); -#ifndef TIMER_PARAM_TYPE -#define TIMER_PARAM_TYPE UINT32 -#endif -/* Define a timer list entry -*/ -typedef struct _tle { - struct _tle *p_next; - struct _tle *p_prev; - TIMER_CBACK *p_cback; - INT32 ticks; - INT32 ticks_initial; - TIMER_PARAM_TYPE param; - TIMER_PARAM_TYPE data; - UINT16 event; - UINT8 in_use; -} TIMER_LIST_ENT; - -/*********************************************************************** -** This queue is a general purpose buffer queue, for application use. -*/ -typedef struct { - void *_p_first; - void *_p_last; - UINT16 _count; -} BUFFER_Q; - -#define GKI_PUBLIC_POOL 0 /* General pool accessible to GKI_getbuf() */ -#define GKI_RESTRICTED_POOL 1 /* Inaccessible pool to GKI_getbuf() */ - -/*********************************************************************** -** Function prototypes -*/ - -/* To get and release buffers, change owner and get size -*/ -void *GKI_getbuf_func(UINT16); -void *GKI_getpoolbuf_func(UINT8); -void GKI_freebuf(void *); -UINT16 GKI_get_buf_size (void *); -void *GKI_getpoolbuf (UINT8); -UINT16 GKI_poolcount (UINT8); -UINT16 GKI_poolfreecount (UINT8); -UINT16 GKI_poolutilization (UINT8); - -#ifdef CONFIG_BLUEDROID_MEM_DEBUG - -#define GKI_getbuf(_size) \ -({ \ - BUFFER_HDR_T *header = osi_malloc((_size) + BUFFER_HDR_SIZE); \ - header->status = BUF_STATUS_UNLINKED; \ - header->p_next = NULL; \ - header->Type = 0; \ - header->size = (_size); \ - (void *)(header + 1); \ -}) - -#define GKI_getpoolbuf(_pool_id) \ -({ \ - (void *)GKI_getbuf(gki_cb.com.pool_size[(_pool_id)]); \ -}) - -#else -#define GKI_getbuf GKI_getbuf_func -#define GKI_getpoolbuf GKI_getpoolbuf_func - -#endif /* CONFIG_BLUEDROID_MEM_DEBUG */ - -/* User buffer queue management -*/ -void *GKI_dequeue (BUFFER_Q *); -void GKI_enqueue (BUFFER_Q *, void *); -void *GKI_getfirst (BUFFER_Q *); -void *GKI_getlast (BUFFER_Q *); -void *GKI_getnext (void *); -void GKI_init_q (BUFFER_Q *); -UINT16 GKI_queue_length(BUFFER_Q *); -BOOLEAN GKI_queue_is_empty(BUFFER_Q *); -void *GKI_remove_from_queue (BUFFER_Q *, void *); -UINT16 GKI_get_pool_bufsize (UINT8); - -/* Timer management -*/ -void GKI_delay(UINT32); - -/* Disable Interrupts, Enable Interrupts -*/ -void GKI_enable(void); -void GKI_disable(void); - -/* os timer operation */ -UINT32 GKI_get_os_tick_count(void); - -#endif /*_GKI_H_*/ diff --git a/tools/sdk/include/bluedroid/gki_common.h b/tools/sdk/include/bluedroid/gki_common.h deleted file mode 100644 index 838896ee..00000000 --- a/tools/sdk/include/bluedroid/gki_common.h +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 1999-2012 Broadcom Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#ifndef _GKI_COMMON_H_ -#define _GKI_COMMON_H_ - -#include "gki.h" - -typedef struct _buffer_hdr { - struct _buffer_hdr *p_next; /* next buffer in the queue */ - UINT8 q_id; /* id of the queue */ - UINT8 status; /* FREE, UNLINKED or QUEUED */ - UINT8 Type; - UINT16 size; -} BUFFER_HDR_T; - -typedef struct _free_queue { - BUFFER_HDR_T *_p_first; /* first buffer in the queue */ - BUFFER_HDR_T *_p_last; /* last buffer in the queue */ - UINT16 size; /* size of the buffers in the pool */ - UINT16 total; /* toatal number of buffers */ - UINT16 cur_cnt; /* number of buffers currently allocated */ - UINT16 max_cnt; /* maximum number of buffers allocated at any time */ -} FREE_QUEUE_T; - -/* Put all GKI variables into one control block -*/ -typedef struct { - /* Define the buffer pool management variables - */ - FREE_QUEUE_T freeq[GKI_NUM_TOTAL_BUF_POOLS]; - - UINT16 pool_buf_size[GKI_NUM_TOTAL_BUF_POOLS]; - - /* Define the buffer pool start addresses - */ - UINT8 *pool_start[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the start of each buffer pool */ - UINT8 *pool_end[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the end of each buffer pool */ - UINT16 pool_size[GKI_NUM_TOTAL_BUF_POOLS]; /* actual size of the buffers in a pool */ - - /* Define the buffer pool access control variables */ - UINT16 pool_access_mask; /* Bits are set if the corresponding buffer pool is a restricted pool */ -} tGKI_COM_CB; - -/* Internal GKI function prototypes -*/ -void gki_buffer_init(void); -void gki_buffer_cleanup(void); - -#endif /*_GKI_COMMON_H_*/ diff --git a/tools/sdk/include/bluedroid/gki_target.h b/tools/sdk/include/bluedroid/gki_target.h deleted file mode 100644 index fc844518..00000000 --- a/tools/sdk/include/bluedroid/gki_target.h +++ /dev/null @@ -1,244 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 1999-2012 Broadcom Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#ifndef _GKI_TARGET_H_ -#define _GKI_TARGET_H_ - -/****************************************************************************** -** -** Buffer configuration -** -******************************************************************************/ - -/* The size of the buffers in pool 0. */ -#ifndef GKI_BUF0_SIZE -#define GKI_BUF0_SIZE 64 -#endif - -/* The number of buffers in buffer pool 0. */ -#ifndef GKI_BUF0_MAX -#define GKI_BUF0_MAX 96 -#endif - -/* The ID of buffer pool 0. */ -#ifndef GKI_POOL_ID_0 -#define GKI_POOL_ID_0 0 -#endif - -/* The size of the buffers in pool 1. */ -#ifndef GKI_BUF1_SIZE -#define GKI_BUF1_SIZE 288 -#endif - -/* The number of buffers in buffer pool 1. */ -#ifndef GKI_BUF1_MAX -#define GKI_BUF1_MAX 52 -#endif - -/* The ID of buffer pool 1. */ -#ifndef GKI_POOL_ID_1 -#define GKI_POOL_ID_1 1 -#endif - -/* The size of the buffers in pool 2. */ -#ifndef GKI_BUF2_SIZE -#define GKI_BUF2_SIZE 660 -#endif - -/* The number of buffers in buffer pool 2. */ -#ifndef GKI_BUF2_MAX -#define GKI_BUF2_MAX 90 -#endif - -/* The ID of buffer pool 2. */ -#ifndef GKI_POOL_ID_2 -#define GKI_POOL_ID_2 2 -#endif - -/* The size of the buffers in pool 3. */ -#ifndef GKI_BUF3_SIZE -#define GKI_BUF3_SIZE (4096+16) -#endif - -/* The number of buffers in buffer pool 3. */ -#ifndef GKI_BUF3_MAX -#define GKI_BUF3_MAX 400 -#endif - -/* The ID of buffer pool 3. */ -#ifndef GKI_POOL_ID_3 -#define GKI_POOL_ID_3 3 -#endif - -/* The size of the largest PUBLIC fixed buffer in system. */ -#ifndef GKI_MAX_BUF_SIZE -#define GKI_MAX_BUF_SIZE GKI_BUF3_SIZE -#endif - -/* The pool ID of the largest PUBLIC fixed buffer in system. */ -#ifndef GKI_MAX_BUF_SIZE_POOL_ID -#define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3 -#endif - -/* Pool 4 is used for BluetoothSocket L2CAP connections */ -/* The size of the buffers in pool 4. */ -#ifndef GKI_BUF4_SIZE -#define GKI_BUF4_SIZE (8080+26) -#endif - -/* The number of buffers in buffer pool 4. */ -#ifndef GKI_BUF4_MAX -#define GKI_BUF4_MAX (OBX_NUM_SERVERS + OBX_NUM_CLIENTS) -#endif - -/* The ID of buffer pool 4. */ -#ifndef GKI_POOL_ID_4 -#define GKI_POOL_ID_4 4 -#endif - -/* The number of fixed GKI buffer pools. -eL2CAP requires Pool ID 5 -If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7 -If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8 -If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9 -POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB -*/ -#ifndef GKI_NUM_FIXED_BUF_POOLS -#define GKI_NUM_FIXED_BUF_POOLS 10 -#endif - -/* The buffer pool usage mask. */ -#ifndef GKI_DEF_BUFPOOL_PERM_MASK -/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */ -#define GKI_DEF_BUFPOOL_PERM_MASK 0xfdf0 -#endif - -/* The following is intended to be a reserved pool for L2CAP -Flow control and retransmissions and intentionally kept out -of order */ - -/* The number of buffers in buffer pool 5. */ -#ifndef GKI_BUF5_MAX -#define GKI_BUF5_MAX 64 -#endif - -/* The ID of buffer pool 5. */ -#ifndef GKI_POOL_ID_5 -#define GKI_POOL_ID_5 5 -#endif - -/* The size of the buffers in pool 5 -** Special pool used by L2CAP retransmissions only. This size based on segment -** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI -** header. 13 bytes of max headers allows us a 339 payload max. (in btui_app.txt) -** Note: 748 used for insight scriptwrapper with CAT-2 scripts. -*/ -#ifndef GKI_BUF5_SIZE -#define GKI_BUF5_SIZE 748 -#endif - -/* The following is intended to be a reserved pool for SCO -over HCI data and intentionally kept out of order */ - -/* The ID of buffer pool 6. */ -#ifndef GKI_POOL_ID_6 -#define GKI_POOL_ID_6 6 -#endif - -/* The size of the buffers in pool 6, - BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */ -#ifndef GKI_BUF6_SIZE -#define GKI_BUF6_SIZE 268 -#endif - -/* The number of buffers in buffer pool 6. */ -#ifndef GKI_BUF6_MAX -#define GKI_BUF6_MAX 60 -#endif - - -/* The following pool is a dedicated pool for HDP - If a shared pool is more desirable then - 1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID - 2. make sure that the shared pool size is larger than 9472 - 3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since - POOL ID 7 is not needed -*/ - -/* The ID of buffer pool 7. */ -#ifndef GKI_POOL_ID_7 -#define GKI_POOL_ID_7 7 -#endif - -/* The size of the buffers in pool 7 */ -#ifndef GKI_BUF7_SIZE -#define GKI_BUF7_SIZE (10240 + 24) -#endif - -/* The number of buffers in buffer pool 7. */ -#ifndef GKI_BUF7_MAX -#define GKI_BUF7_MAX 2 -#endif - -/* The following pool is a dedicated pool for GATT - If a shared pool is more desirable then - 1. set GATT_DB_POOL_ID to the desired Gki Pool ID - 2. make sure that the shared pool size fit a common GATT database needs - 3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since - POOL ID 8 is not needed -*/ - -/* The ID of buffer pool 8. */ -#ifndef GKI_POOL_ID_8 -#define GKI_POOL_ID_8 8 -#endif - -/* The size of the buffers in pool 8 */ -#ifndef GKI_BUF8_SIZE -#define GKI_BUF8_SIZE 128 -#endif - -/* The number of buffers in buffer pool 8. */ -#ifndef GKI_BUF8_MAX -#define GKI_BUF8_MAX 30 -#endif - -/* The following pool is meant for large allocations such as SDP_DB */ -#ifndef GKI_POOL_ID_9 -#define GKI_POOL_ID_9 9 -#endif - -#ifndef GKI_BUF9_SIZE -#define GKI_BUF9_SIZE 8192 -#endif - -#ifndef GKI_BUF9_MAX -#define GKI_BUF9_MAX 5 -#endif - -/* The number of fixed and dynamic buffer pools */ -#ifndef GKI_NUM_TOTAL_BUF_POOLS -#define GKI_NUM_TOTAL_BUF_POOLS 10 -#endif - -int gki_init(void); -void gki_clean_up(void); - -//void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...); - -#endif /*_GKI_TARGET_H_*/ diff --git a/tools/sdk/include/bluedroid/hci_layer.h b/tools/sdk/include/bluedroid/hci_layer.h index caea29f2..76f93638 100644 --- a/tools/sdk/include/bluedroid/hci_layer.h +++ b/tools/sdk/include/bluedroid/hci_layer.h @@ -77,9 +77,6 @@ typedef struct hci_t { // Do the postload sequence (call after the rest of the BT stack initializes). void (*do_postload)(void); - // Set the queue to receive ACL data in - void (*set_data_queue)(fixed_queue_t *queue); - // Send a command through the HCI layer void (*transmit_command)( BT_HDR *command, diff --git a/tools/sdk/include/bluedroid/l2c_api.h b/tools/sdk/include/bluedroid/l2c_api.h index f2a4d7c4..e6e7e44f 100644 --- a/tools/sdk/include/bluedroid/l2c_api.h +++ b/tools/sdk/include/bluedroid/l2c_api.h @@ -306,10 +306,10 @@ typedef struct { typedef struct { UINT8 preferred_mode; UINT8 allowed_modes; - UINT8 user_rx_pool_id; - UINT8 user_tx_pool_id; - UINT8 fcr_rx_pool_id; - UINT8 fcr_tx_pool_id; + UINT16 user_rx_buf_size; + UINT16 user_tx_buf_size; + UINT16 fcr_rx_buf_size; + UINT16 fcr_tx_buf_size; } tL2CAP_ERTM_INFO; diff --git a/tools/sdk/include/bluedroid/l2c_int.h b/tools/sdk/include/bluedroid/l2c_int.h index b8865917..ef31d109 100644 --- a/tools/sdk/include/bluedroid/l2c_int.h +++ b/tools/sdk/include/bluedroid/l2c_int.h @@ -27,10 +27,10 @@ #include #include "btm_api.h" -#include "gki.h" #include "l2c_api.h" #include "l2cdefs.h" #include "list.h" +#include "fixed_queue.h" #define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */ @@ -176,9 +176,9 @@ typedef struct { UINT16 rx_sdu_len; /* Length of the SDU being received */ BT_HDR *p_rx_sdu; /* Buffer holding the SDU being received */ - BUFFER_Q waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */ - BUFFER_Q srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */ - BUFFER_Q retrans_q; /* Buffers being retransmitted */ + fixed_queue_t *waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */ + fixed_queue_t *srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */ + fixed_queue_t *retrans_q; /* Buffers being retransmitted */ TIMER_LIST_ENT ack_timer; /* Timer delaying RR */ TIMER_LIST_ENT mon_retrans_timer; /* Timer Monitor or Retransmission */ @@ -241,6 +241,9 @@ typedef struct { } tL2C_RCB; +#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA +#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100 +#endif /* Define a channel control block (CCB). There may be many channel control blocks ** between the same two Bluetooth devices (i.e. on the same link). ** Each CCB has unique local and remote CIDs. All channel control blocks on @@ -279,7 +282,7 @@ typedef struct t_l2c_ccb { tL2CAP_CH_CFG_BITS peer_cfg_bits; /* Store what peer wants to configure */ tL2CAP_CFG_INFO peer_cfg; /* Peer's saved configuration options */ - BUFFER_Q xmit_hold_q; /* Transmit data hold queue */ + fixed_queue_t *xmit_hold_q; /* Transmit data hold queue */ BOOLEAN cong_sent; /* Set when congested status sent */ UINT16 buff_quota; /* Buffer quota before sending congestion */ @@ -379,8 +382,8 @@ typedef struct t_l2c_linkcb { UINT8 peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE]; #if (L2CAP_UCD_INCLUDED == TRUE) UINT16 ucd_mtu; /* peer MTU on UCD */ - BUFFER_Q ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */ - BUFFER_Q ucd_in_sec_pending_q; /* Security pending incoming UCD packet */ + fixed_queue_t *ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */ + fixed_queue_t *ucd_in_sec_pending_q; /* Security pending incoming UCD packet */ #endif BT_HDR *p_hcit_rcv_acl; /* Current HCIT ACL buf being rcvd */ @@ -402,14 +405,24 @@ typedef struct t_l2c_linkcb { #define L2C_BLE_NEW_CONN_PARAM 0x2 /* new connection parameter to be set */ #define L2C_BLE_UPDATE_PENDING 0x4 /* waiting for connection update finished */ #define L2C_BLE_NOT_DEFAULT_PARAM 0x8 /* not using default connection parameters */ +#define L2C_BLE_UPDATE_PARAM_FULL 0x10 /* update connection parameters full, can not update */ UINT8 conn_update_mask; - - UINT16 min_interval; /* parameters as requested by peripheral */ - UINT16 max_interval; - UINT16 conn_int; - UINT16 latency; - UINT16 timeout; - + /* cache connection parameters that wait to update */ + UINT16 waiting_update_conn_min_interval; + UINT16 waiting_update_conn_max_interval; + UINT16 waiting_update_conn_latency; + UINT16 waiting_update_conn_timeout; + /* cache parameters that is being updated */ + UINT16 updating_conn_min_interval; + UINT16 updating_conn_max_interval; + bool updating_param_flag; + /* current connection parameters that current connection is using */ + UINT16 current_used_conn_interval; + UINT16 current_used_conn_latency; + UINT16 current_used_conn_timeout; + /* connection parameters update order: + waiting_update_conn_xx -> updating_conn_xx -> current_used_conn_xx + */ #endif #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) @@ -706,7 +719,7 @@ extern void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf); extern void l2c_fcr_proc_tout (tL2C_CCB *p_ccb); extern void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb); extern void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit); -extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool); +extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes); extern BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb); extern BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length); extern void l2c_fcr_start_timer (tL2C_CCB *p_ccb); @@ -733,6 +746,7 @@ extern void l2cble_notify_le_connection (BD_ADDR bda); extern void l2c_ble_link_adjust_allocation (void); extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout); +extern void l2cble_get_conn_param_format_err_from_contoller(UINT8 status, UINT16 handle); #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max, @@ -745,6 +759,7 @@ extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 f extern void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status); extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len, UINT16 rx_data_len); +extern UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb); #endif extern void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb); diff --git a/tools/sdk/include/bluedroid/l2cdefs.h b/tools/sdk/include/bluedroid/l2cdefs.h index e31ee24b..db5013a1 100644 --- a/tools/sdk/include/bluedroid/l2cdefs.h +++ b/tools/sdk/include/bluedroid/l2cdefs.h @@ -258,8 +258,9 @@ #define L2CAP_BLE_EXTFEA_MASK 0 #endif -/* Define a value that tells L2CAP to use the default HCI ACL buffer pool */ -#define L2CAP_DEFAULT_ERM_POOL_ID 0xFF +/* Define a value that tells L2CAP to use the default HCI ACL buffer size */ +#define L2CAP_INVALID_ERM_BUF_SIZE 0 + /* Define a value that tells L2CAP to use the default MPS */ #define L2CAP_DEFAULT_ERM_MPS 0x0000 @@ -273,7 +274,8 @@ /* To optimize this, it must be a multiplum of the L2CAP PDU length AND match the 3DH5 air * including the l2cap headers in each packet - to match the latter - the -5 is added */ -#define L2CAP_MAX_SDU_LENGTH (GKI_BUF4_SIZE - (L2CAP_MIN_OFFSET + L2CAP_MAX_HEADER_FCS) -5) +#define L2CAP_MAX_SDU_LENGTH (8080 + 26 - (L2CAP_MIN_OFFSET + 6)) +#define L2CAP_MAX_BUF_SIZE (10240 + 24) /* Part of L2CAP_MIN_OFFSET that is not part of L2CAP */ diff --git a/tools/sdk/include/bluedroid/list.h b/tools/sdk/include/bluedroid/list.h index 77097967..c0abd106 100644 --- a/tools/sdk/include/bluedroid/list.h +++ b/tools/sdk/include/bluedroid/list.h @@ -10,7 +10,7 @@ struct list_t; typedef struct list_t list_t; typedef void (*list_free_cb)(void *data); -typedef bool (*list_iter_cb)(void *data); +typedef bool (*list_iter_cb)(void *data, void *context); // Returns a new, empty list. Returns NULL if not enough memory could be allocated // for the list structure. The returned list must be freed with |list_free|. The @@ -22,7 +22,6 @@ list_t *list_new(list_free_cb callback); list_node_t *list_free_node(list_t *list, list_node_t *node); -//list_node_t *list_free_node(list_t *list, list_node_t *node); // Frees the list. This function accepts NULL as an argument, in which case it // behaves like a no-op. void list_free(list_t *list); @@ -44,7 +43,8 @@ void *list_front(const list_t *list); // Returns the last element in the list without removing it. |list| may not // be NULL or empty. -//void *list_back(const list_t *list); +void *list_back(const list_t *list); +list_node_t *list_back_node(const list_t *list); // Inserts |data| after |prev_node| in |list|. |data|, |list|, and |prev_node| // may not be NULL. This function does not make a copy of |data| so the pointer @@ -84,7 +84,7 @@ void list_clear(list_t *list); // list inside the callback. If an element is added before the node being visited, // there will be no callback for the newly-inserted node. Neither |list| nor // |callback| may be NULL. -void list_foreach(const list_t *list, list_iter_cb callback); +list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *context); // Returns an iterator to the first element in |list|. |list| may not be NULL. // The returned iterator is valid as long as it does not equal the value returned diff --git a/tools/sdk/include/bluedroid/mutex.h b/tools/sdk/include/bluedroid/mutex.h new file mode 100644 index 00000000..65180a78 --- /dev/null +++ b/tools/sdk/include/bluedroid/mutex.h @@ -0,0 +1,53 @@ +/****************************************************************************** + * + * Copyright (C) 2015 Google, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#ifndef __MUTEX_H__ +#define __MUTEX_H__ + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" + + +#define OSI_MUTEX_MAX_TIMEOUT 0xffffffffUL + +#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) +#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL ) + +typedef xSemaphoreHandle osi_mutex_t; + +int osi_mutex_new(osi_mutex_t *mutex); + +int osi_mutex_lock(osi_mutex_t *mutex, uint32_t timeout); + +void osi_mutex_unlock(osi_mutex_t *mutex); + +void osi_mutex_free(osi_mutex_t *mutex); + +/* Just for a global mutex */ +int osi_mutex_global_init(void); + +void osi_mutex_global_deinit(void); + +void osi_mutex_global_lock(void); + +void osi_mutex_global_unlock(void); + +#endif /* __MUTEX_H__ */ + diff --git a/tools/sdk/include/bluedroid/osi.h b/tools/sdk/include/bluedroid/osi.h index 3308255b..3bd217af 100644 --- a/tools/sdk/include/bluedroid/osi.h +++ b/tools/sdk/include/bluedroid/osi.h @@ -6,21 +6,11 @@ #include #define UNUSED_ATTR __attribute__((unused)) -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define INVALID_FD (-1) #define CONCAT(a, b) a##b +#define COMPILE_ASSERT(x) -// Use during compile time to check conditional values -// NOTE: The the failures will present as a generic error -// "error: initialization makes pointer from integer without a cast" -// but the file and line number will present the condition that -// failed. -#define DUMMY_COUNTER(c) CONCAT(__osi_dummy_, c) -#define DUMMY_PTR DUMMY_COUNTER(__COUNTER__) - -#define COMPILE_ASSERT(x) char * DUMMY_PTR = !(x) - -typedef uint32_t timeout_t; +int osi_init(void); +void osi_deinit(void); #endif /*_OSI_H_*/ diff --git a/tools/sdk/include/bluedroid/osi_arch.h b/tools/sdk/include/bluedroid/osi_arch.h deleted file mode 100644 index 491d4829..00000000 --- a/tools/sdk/include/bluedroid/osi_arch.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __os_ARCH_H__ -#define __os_ARCH_H__ - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "freertos/semphr.h" - -#define OSI_ARCH_TIMEOUT 0xffffffffUL - -typedef xSemaphoreHandle osi_sem_t; -typedef xSemaphoreHandle osi_mutex_t; - -#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) -#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL ) -#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) -#define osi_sem_set_invalid( x ) ( ( *x ) = NULL ) - -int osi_mutex_new(osi_mutex_t *pxMutex); - -void osi_mutex_lock(osi_mutex_t *pxMutex); - -int osi_mutex_trylock(osi_mutex_t *pxMutex); - -void osi_mutex_unlock(osi_mutex_t *pxMutex); - -void osi_mutex_free(osi_mutex_t *pxMutex); - -int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count); - -void osi_sem_signal(osi_sem_t *sem); - -uint32_t osi_sem_wait(osi_sem_t *sem, uint32_t timeout); - -void osi_sem_free(osi_sem_t *sem); - -void osi_arch_init(void); - -uint32_t osi_now(void); - -void osi_delay_ms(uint32_t ms); - - -#endif /* __os_ARCH_H__ */ - diff --git a/tools/sdk/include/bluedroid/port_ext.h b/tools/sdk/include/bluedroid/port_ext.h index e25b6d94..40cdbfce 100644 --- a/tools/sdk/include/bluedroid/port_ext.h +++ b/tools/sdk/include/bluedroid/port_ext.h @@ -25,7 +25,6 @@ #ifndef PORTEXT_H #define PORTEXT_H -#include "gki.h" /* Port emulation entity Entry Points */ extern void rfcomm_process_timeout (TIMER_LIST_ENT *p_tle); diff --git a/tools/sdk/include/bluedroid/port_int.h b/tools/sdk/include/bluedroid/port_int.h index fb72d503..aa6d48e7 100644 --- a/tools/sdk/include/bluedroid/port_int.h +++ b/tools/sdk/include/bluedroid/port_int.h @@ -26,7 +26,6 @@ #define PORT_INT_H #include "bt_target.h" -#include "gki.h" #include "rfcdefs.h" #include "port_api.h" @@ -52,7 +51,7 @@ ** Define Port Data Transfere control block */ typedef struct { - BUFFER_Q queue; /* Queue of buffers waiting to be sent */ + fixed_queue_t *queue; /* Queue of buffers waiting to be sent */ BOOLEAN peer_fc; /* TRUE if flow control is set based on peer's request */ BOOLEAN user_fc; /* TRUE if flow control is set based on user's request */ UINT32 queue_size; /* Number of data bytes in the queue */ @@ -88,7 +87,7 @@ typedef struct { */ typedef struct { TIMER_LIST_ENT tle; /* Timer list entry */ - BUFFER_Q cmd_q; /* Queue for command messages on this mux */ + fixed_queue_t *cmd_q; /* Queue for command messages on this mux */ UINT8 port_inx[RFCOMM_MAX_DLCI + 1]; /* Array for quick access to */ /* tPORT based on dlci */ BD_ADDR bd_addr; /* BD ADDR of the peer if initiator */ diff --git a/tools/sdk/include/bluedroid/sdpint.h b/tools/sdk/include/bluedroid/sdpint.h index 3e89606f..9e721d9f 100644 --- a/tools/sdk/include/bluedroid/sdpint.h +++ b/tools/sdk/include/bluedroid/sdpint.h @@ -26,6 +26,7 @@ #define SDP_INT_H #include "bt_target.h" +#include "bt_defs.h" #include "sdp_api.h" #include "l2c_api.h" diff --git a/tools/sdk/include/bluedroid/gki_int.h b/tools/sdk/include/bluedroid/semaphore.h similarity index 54% rename from tools/sdk/include/bluedroid/gki_int.h rename to tools/sdk/include/bluedroid/semaphore.h index 3307066e..621d5a2c 100644 --- a/tools/sdk/include/bluedroid/gki_int.h +++ b/tools/sdk/include/bluedroid/semaphore.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright (C) 1999-2012 Broadcom Corporation + * Copyright (C) 2015 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +16,28 @@ * ******************************************************************************/ -#ifndef _GKI_INT_H_ -#define _GKI_INT_H_ +#ifndef __SEMAPHORE_H__ +#define __SEMAPHORE_H__ -//#include -#include "bt_defs.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "freertos/semphr.h" -#include "gki_common.h" +#define OSI_SEM_MAX_TIMEOUT 0xffffffffUL -typedef struct { - pthread_mutex_t lock; - tGKI_COM_CB com; -} tGKI_CB; +typedef xSemaphoreHandle osi_sem_t; -extern tGKI_CB gki_cb; +#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) +#define osi_sem_set_invalid( x ) ( ( *x ) = NULL ) -#endif /*_GKI_INT_H_*/ +int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count); + +void osi_sem_free(osi_sem_t *sem); + +int osi_sem_take(osi_sem_t *sem, uint32_t timeout); + +void osi_sem_give(osi_sem_t *sem); + + +#endif /* __SEMAPHORE_H__ */ diff --git a/tools/sdk/include/bluedroid/thread.h b/tools/sdk/include/bluedroid/thread.h index 4d2b4359..5f023c65 100644 --- a/tools/sdk/include/bluedroid/thread.h +++ b/tools/sdk/include/bluedroid/thread.h @@ -35,12 +35,27 @@ typedef struct bt_task_evt BtTaskEvt_t; typedef bt_status_t (* BtTaskCb_t)(void *arg); -enum { - SIG_PRF_START_UP = 0xfc, - SIG_PRF_WORK = 0xfd, - SIG_BTU_START_UP = 0xfe, - SIG_BTU_WORK = 0xff, -}; +typedef enum { + SIG_HCI_HAL_RECV_PACKET = 0, + SIG_HCI_HAL_NUM, +} SIG_HCI_HAL_t; + + +typedef enum { + SIG_HCI_HOST_SEND_AVAILABLE = 0, + SIG_HCI_HOST_NUM, +} SIG_HCI_HOST_t; + +typedef enum { + SIG_BTU_START_UP = 0, + SIG_BTU_HCI_MSG, + SIG_BTU_BTA_MSG, + SIG_BTU_BTA_ALARM, + SIG_BTU_GENERAL_ALARM, + SIG_BTU_ONESHOT_ALARM, + SIG_BTU_L2CAP_ALARM, + SIG_BTU_NUM, +} SIG_BTU_t; #define HCI_HOST_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE) #define HCI_HOST_TASK_PRIO (configMAX_PRIORITIES - 3) @@ -67,9 +82,13 @@ enum { #define TASK_POST_BLOCKING (portMAX_DELAY) typedef uint32_t task_post_t; /* Timeout of task post return, unit TICK */ -void btu_task_post(uint32_t sig, task_post_t timeout); -void hci_host_task_post(task_post_t timeout); -void hci_hal_h4_task_post(task_post_t timeout); +typedef enum { + TASK_POST_SUCCESS = 0, + TASK_POST_FAIL, +} task_post_status_t; +task_post_status_t btu_task_post(uint32_t sig, void *param, task_post_t timeout); +task_post_status_t hci_host_task_post(task_post_t timeout); +task_post_status_t hci_hal_h4_task_post(task_post_t timeout); #endif /* __THREAD_H__ */ diff --git a/tools/sdk/include/bluedroid/utl.h b/tools/sdk/include/bluedroid/utl.h index 39dbe297..eab971e7 100644 --- a/tools/sdk/include/bluedroid/utl.h +++ b/tools/sdk/include/bluedroid/utl.h @@ -105,7 +105,7 @@ extern UINT8 utl_itoa(UINT16 i, char *p_s); ** ** Function utl_freebuf ** -** Description This function calls GKI_freebuf to free the buffer passed +** Description This function calls osi_free to free the buffer passed ** in, if buffer pointer is not NULL, and also initializes ** buffer pointer to NULL. ** diff --git a/tools/sdk/include/bootloader_support/esp_efuse.h b/tools/sdk/include/bootloader_support/esp_efuse.h index 41588396..2f33b05a 100644 --- a/tools/sdk/include/bootloader_support/esp_efuse.h +++ b/tools/sdk/include/bootloader_support/esp_efuse.h @@ -48,6 +48,16 @@ void esp_efuse_burn_new_values(void); */ void esp_efuse_reset(void); +/* @brief Disable BASIC ROM Console via efuse + * + * By default, if booting from flash fails the ESP32 will boot a + * BASIC console in ROM. + * + * Call this function (from bootloader or app) to permanently + * disable the console on this chip. + */ +void esp_efuse_disable_basic_rom_console(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/config/sdkconfig.h b/tools/sdk/include/config/sdkconfig.h index 8a7dc7f1..e3d97fab 100644 --- a/tools/sdk/include/config/sdkconfig.h +++ b/tools/sdk/include/config/sdkconfig.h @@ -6,45 +6,60 @@ */ #define CONFIG_GATTC_ENABLE 1 #define CONFIG_ESP32_PHY_MAX_TX_POWER 20 -#define CONFIG_PHY_ENABLED 1 #define CONFIG_TRACEMEM_RESERVE_DRAM 0x0 #define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16 #define CONFIG_BLE_SMP_ENABLE 1 #define CONFIG_TCP_RECVMBOX_SIZE 6 #define CONFIG_TCP_WND_DEFAULT 5744 #define CONFIG_SW_COEXIST_ENABLE 1 +#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1 #define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1 #define CONFIG_IPC_TASK_STACK_SIZE 1024 #define CONFIG_ESPTOOLPY_FLASHFREQ "40m" -#define CONFIG_NEWLIB_STDOUT_ADDCR 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1 #define CONFIG_UDP_RECVMBOX_SIZE 6 #define CONFIG_TASK_WDT_CHECK_IDLE_TASK 1 +#define CONFIG_MBEDTLS_AES_C 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1 +#define CONFIG_MBEDTLS_GCM_C 1 #define CONFIG_ESPTOOLPY_FLASHSIZE "4MB" +#define CONFIG_SPIFFS_CACHE_WR 1 #define CONFIG_BROWNOUT_DET_LVL_SEL_0 1 #define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 -#define CONFIG_ETHERNET 1 #define CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE 1 +#define CONFIG_SPIFFS_CACHE 1 #define CONFIG_INT_WDT 1 #define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL 1 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1 +#define CONFIG_MBEDTLS_ECDSA_C 1 #define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1 #define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 +#define CONFIG_MBEDTLS_ECDH_C 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1 #define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10 +#define CONFIG_MBEDTLS_SSL_ALPN 1 +#define CONFIG_MBEDTLS_PEM_WRITE_C 1 #define CONFIG_BT_RESERVE_DRAM 0x10000 +#define CONFIG_IP_LOST_TIMER_INTERVAL 120 #define CONFIG_ESP32_PANIC_PRINT_REBOOT 1 +#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1 #define CONFIG_CONSOLE_UART_BAUDRATE 115200 #define CONFIG_LWIP_MAX_SOCKETS 10 #define CONFIG_EMAC_TASK_PRIORITY 20 #define CONFIG_TIMER_TASK_STACK_DEPTH 2048 #define CONFIG_TCP_MSS 1436 +#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1 #define CONFIG_FATFS_CODEPAGE 850 #define CONFIG_ULP_COPROC_RESERVE_MEM 512 #define CONFIG_ESPTOOLPY_BAUD 921600 #define CONFIG_INT_WDT_CHECK_CPU1 1 -#define CONFIG_FLASHMODE_DIO 1 #define CONFIG_ESPTOOLPY_AFTER_RESET 1 #define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED 1 #define CONFIG_TOOLPREFIX "xtensa-esp32-elf-" +#define CONFIG_MBEDTLS_ECP_C 1 #define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1024 +#define CONFIG_MBEDTLS_RC4_DISABLED 1 #define CONFIG_FATFS_LFN_STACK 1 #define CONFIG_ESP32_WIFI_AMPDU_ENABLED 1 #define CONFIG_CONSOLE_UART_NUM 0 @@ -59,44 +74,69 @@ #define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 #define CONFIG_AUTOSTART_ARDUINO 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 +#define CONFIG_TIMER_TASK_STACK_SIZE 4096 #define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE 1 #define CONFIG_BTDM_CONTROLLER_RUN_CPU 0 +#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1 +#define CONFIG_SPIFFS_USE_MAGIC 1 #define CONFIG_TCPIP_TASK_STACK_SIZE 2560 #define CONFIG_FATFS_CODEPAGE_850 1 #define CONFIG_TASK_WDT 1 #define CONFIG_MAIN_TASK_STACK_SIZE 4096 +#define CONFIG_SPIFFS_PAGE_CHECK 1 #define CONFIG_TASK_WDT_TIMEOUT_S 5 #define CONFIG_INT_WDT_TIMEOUT_MS 300 #define CONFIG_ESPTOOLPY_FLASHMODE "dio" #define CONFIG_BTC_TASK_STACK_SIZE 8192 #define CONFIG_BLUEDROID_ENABLED 1 +#define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA 1 #define CONFIG_ESPTOOLPY_BEFORE "default_reset" #define CONFIG_LOG_DEFAULT_LEVEL 1 #define CONFIG_TIMER_QUEUE_LENGTH 10 +#define CONFIG_MAKE_WARN_UNDEFINED_VARIABLES 1 +#define CONFIG_BOOTLOADER_SPI_WP_PIN 7 #define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 0 +#define CONFIG_MBEDTLS_CCM_C 1 #define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 #define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024 #define CONFIG_ESP32_WIFI_TX_BA_WIN 6 #define CONFIG_ESP32_WIFI_NVS_ENABLED 1 #define CONFIG_ULP_COPROC_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1 #define CONFIG_DMA_RX_BUF_NUM 10 +#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1 #define CONFIG_TCP_SYNMAXRTX 6 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1 +#define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_PYTHON "python" +#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1 #define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1 #define CONFIG_ESPTOOLPY_COMPRESSED 1 #define CONFIG_PARTITION_TABLE_FILENAME "partitions_singleapp.csv" #define CONFIG_TCP_SND_BUF_DEFAULT 5744 #define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 +#define CONFIG_TCP_MSL 60000 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1 #define CONFIG_PARTITION_TABLE_SINGLE_APP 1 #define CONFIG_ESP32_WIFI_RX_BA_WIN 6 -#define CONFIG_WIFI_ENABLED 1 +#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1 +#define CONFIG_FLASHMODE_QIO 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1 #define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 #define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000 #define CONFIG_BROWNOUT_DET_LVL 0 +#define CONFIG_MBEDTLS_PEM_PARSE_C 1 +#define CONFIG_SPIFFS_GC_MAX_RUNS 10 #define CONFIG_ESP32_APPTRACE_DEST_NONE 1 #define CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET 0x10000 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1 #define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 +#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1 #define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 +#define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_FREERTOS_HZ 1000 #define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1 #define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 @@ -104,10 +144,16 @@ #define CONFIG_ESP32_XTAL_FREQ 0 #define CONFIG_MONITOR_BAUD_115200B 1 #define CONFIG_LOG_BOOTLOADER_LEVEL 0 +#define CONFIG_MBEDTLS_TLS_ENABLED 1 #define CONFIG_SMP_ENABLE 1 +#define CONFIG_MBEDTLS_SSL_SESSION_TICKETS 1 +#define CONFIG_SPIFFS_MAX_PARTITIONS 3 +#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1 #define CONFIG_ESPTOOLPY_BEFORE_RESET 1 #define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200 #define CONFIG_ENABLE_ARDUINO_DEPENDS 1 +#define CONFIG_SPIFFS_OBJ_NAME_LEN 32 +#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT 5 #define CONFIG_LOG_BOOTLOADER_LEVEL_NONE 1 #define CONFIG_ESP32_DEFAULT_CPU_FREQ_240 1 #define CONFIG_ESP32_XTAL_FREQ_AUTO 1 @@ -115,9 +161,12 @@ #define CONFIG_ESPTOOLPY_AFTER "hard_reset" #define CONFIG_LWIP_SO_REUSE 1 #define CONFIG_DMA_TX_BUF_NUM 10 +#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1 #define CONFIG_WL_SECTOR_SIZE 4096 #define CONFIG_TIMER_TASK_PRIORITY 1 +#define CONFIG_MBEDTLS_TLS_CLIENT 1 #define CONFIG_BT_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1 #define CONFIG_MONITOR_BAUD 115200 #define CONFIG_FREERTOS_CORETIMER_0 1 #define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv" @@ -125,12 +174,17 @@ #define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 #define CONFIG_TCP_QUEUE_OOSEQ 1 #define CONFIG_GATTS_ENABLE 1 +#define CONFIG_MBEDTLS_TLS_SERVER 1 +#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1 #define CONFIG_FREERTOS_ISR_STACKSIZE 1536 #define CONFIG_CLASSIC_BT_ENABLED 1 #define CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK 1 #define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 #define CONFIG_WL_SECTOR_SIZE_4096 1 #define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1 +#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1 +#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA 1 #define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 #define CONFIG_BT_ACL_CONNECTIONS 4 #define CONFIG_FATFS_MAX_LFN 255 @@ -139,7 +193,10 @@ #define CONFIG_APP_OFFSET 0x10000 #define CONFIG_MEMMAP_SMP 1 #define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1 +#define CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED 1 +#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT 2048 #define CONFIG_LWIP_SO_RCVBUF 1 #define CONFIG_MONITOR_BAUD_OTHER_VAL 115200 +#define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1 #define CONFIG_ESPTOOLPY_PORT "/dev/cu.usbserial-DO00EAB0" #define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 1 diff --git a/tools/sdk/include/console/argtable3/argtable3.h b/tools/sdk/include/console/argtable3/argtable3.h new file mode 100644 index 00000000..37a321fb --- /dev/null +++ b/tools/sdk/include/console/argtable3/argtable3.h @@ -0,0 +1,306 @@ +/******************************************************************************* + * This file is part of the argtable3 library. + * + * Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of STEWART HEITMANN nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL STEWART HEITMANN BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ + +#ifndef ARGTABLE3 +#define ARGTABLE3 + +#include /* FILE */ +#include /* struct tm */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ARG_REX_ICASE 1 + +/* bit masks for arg_hdr.flag */ +enum +{ + ARG_TERMINATOR=0x1, + ARG_HASVALUE=0x2, + ARG_HASOPTVALUE=0x4 +}; + +typedef void (arg_resetfn)(void *parent); +typedef int (arg_scanfn)(void *parent, const char *argval); +typedef int (arg_checkfn)(void *parent); +typedef void (arg_errorfn)(void *parent, FILE *fp, int error, const char *argval, const char *progname); + + +/* +* The arg_hdr struct defines properties that are common to all arg_xxx structs. +* The argtable library requires each arg_xxx struct to have an arg_hdr +* struct as its first data member. +* The argtable library functions then use this data to identify the +* properties of the command line option, such as its option tags, +* datatype string, and glossary strings, and so on. +* Moreover, the arg_hdr struct contains pointers to custom functions that +* are provided by each arg_xxx struct which perform the tasks of parsing +* that particular arg_xxx arguments, performing post-parse checks, and +* reporting errors. +* These functions are private to the individual arg_xxx source code +* and are the pointer to them are initiliased by that arg_xxx struct's +* constructor function. The user could alter them after construction +* if desired, but the original intention is for them to be set by the +* constructor and left unaltered. +*/ +struct arg_hdr +{ + char flag; /* Modifier flags: ARG_TERMINATOR, ARG_HASVALUE. */ + const char *shortopts; /* String defining the short options */ + const char *longopts; /* String defiing the long options */ + const char *datatype; /* Description of the argument data type */ + const char *glossary; /* Description of the option as shown by arg_print_glossary function */ + int mincount; /* Minimum number of occurences of this option accepted */ + int maxcount; /* Maximum number of occurences if this option accepted */ + void *parent; /* Pointer to parent arg_xxx struct */ + arg_resetfn *resetfn; /* Pointer to parent arg_xxx reset function */ + arg_scanfn *scanfn; /* Pointer to parent arg_xxx scan function */ + arg_checkfn *checkfn; /* Pointer to parent arg_xxx check function */ + arg_errorfn *errorfn; /* Pointer to parent arg_xxx error function */ + void *priv; /* Pointer to private header data for use by arg_xxx functions */ +}; + +struct arg_rem +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ +}; + +struct arg_lit +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args */ +}; + +struct arg_int +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args */ + int *ival; /* Array of parsed argument values */ +}; + +struct arg_dbl +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args */ + double *dval; /* Array of parsed argument values */ +}; + +struct arg_str +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args */ + const char **sval; /* Array of parsed argument values */ +}; + +struct arg_rex +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args */ + const char **sval; /* Array of parsed argument values */ +}; + +struct arg_file +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of matching command line args*/ + const char **filename; /* Array of parsed filenames (eg: /home/foo.bar) */ + const char **basename; /* Array of parsed basenames (eg: foo.bar) */ + const char **extension; /* Array of parsed extensions (eg: .bar) */ +}; + +struct arg_date +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + const char *format; /* strptime format string used to parse the date */ + int count; /* Number of matching command line args */ + struct tm *tmval; /* Array of parsed time values */ +}; + +enum {ARG_ELIMIT=1, ARG_EMALLOC, ARG_ENOMATCH, ARG_ELONGOPT, ARG_EMISSARG}; +struct arg_end +{ + struct arg_hdr hdr; /* The mandatory argtable header struct */ + int count; /* Number of errors encountered */ + int *error; /* Array of error codes */ + void **parent; /* Array of pointers to offending arg_xxx struct */ + const char **argval; /* Array of pointers to offending argv[] string */ +}; + + +/**** arg_xxx constructor functions *********************************/ + +struct arg_rem* arg_rem(const char* datatype, const char* glossary); + +struct arg_lit* arg_lit0(const char* shortopts, + const char* longopts, + const char* glossary); +struct arg_lit* arg_lit1(const char* shortopts, + const char* longopts, + const char *glossary); +struct arg_lit* arg_litn(const char* shortopts, + const char* longopts, + int mincount, + int maxcount, + const char *glossary); + +struct arg_key* arg_key0(const char* keyword, + int flags, + const char* glossary); +struct arg_key* arg_key1(const char* keyword, + int flags, + const char* glossary); +struct arg_key* arg_keyn(const char* keyword, + int flags, + int mincount, + int maxcount, + const char* glossary); + +struct arg_int* arg_int0(const char* shortopts, + const char* longopts, + const char* datatype, + const char* glossary); +struct arg_int* arg_int1(const char* shortopts, + const char* longopts, + const char* datatype, + const char *glossary); +struct arg_int* arg_intn(const char* shortopts, + const char* longopts, + const char *datatype, + int mincount, + int maxcount, + const char *glossary); + +struct arg_dbl* arg_dbl0(const char* shortopts, + const char* longopts, + const char* datatype, + const char* glossary); +struct arg_dbl* arg_dbl1(const char* shortopts, + const char* longopts, + const char* datatype, + const char *glossary); +struct arg_dbl* arg_dbln(const char* shortopts, + const char* longopts, + const char *datatype, + int mincount, + int maxcount, + const char *glossary); + +struct arg_str* arg_str0(const char* shortopts, + const char* longopts, + const char* datatype, + const char* glossary); +struct arg_str* arg_str1(const char* shortopts, + const char* longopts, + const char* datatype, + const char *glossary); +struct arg_str* arg_strn(const char* shortopts, + const char* longopts, + const char* datatype, + int mincount, + int maxcount, + const char *glossary); + +struct arg_rex* arg_rex0(const char* shortopts, + const char* longopts, + const char* pattern, + const char* datatype, + int flags, + const char* glossary); +struct arg_rex* arg_rex1(const char* shortopts, + const char* longopts, + const char* pattern, + const char* datatype, + int flags, + const char *glossary); +struct arg_rex* arg_rexn(const char* shortopts, + const char* longopts, + const char* pattern, + const char* datatype, + int mincount, + int maxcount, + int flags, + const char *glossary); + +struct arg_file* arg_file0(const char* shortopts, + const char* longopts, + const char* datatype, + const char* glossary); +struct arg_file* arg_file1(const char* shortopts, + const char* longopts, + const char* datatype, + const char *glossary); +struct arg_file* arg_filen(const char* shortopts, + const char* longopts, + const char* datatype, + int mincount, + int maxcount, + const char *glossary); + +struct arg_date* arg_date0(const char* shortopts, + const char* longopts, + const char* format, + const char* datatype, + const char* glossary); +struct arg_date* arg_date1(const char* shortopts, + const char* longopts, + const char* format, + const char* datatype, + const char *glossary); +struct arg_date* arg_daten(const char* shortopts, + const char* longopts, + const char* format, + const char* datatype, + int mincount, + int maxcount, + const char *glossary); + +struct arg_end* arg_end(int maxerrors); + + +/**** other functions *******************************************/ +int arg_nullcheck(void **argtable); +int arg_parse(int argc, char **argv, void **argtable); +void arg_print_option(FILE *fp, const char *shortopts, const char *longopts, const char *datatype, const char *suffix); +void arg_print_syntax(FILE *fp, void **argtable, const char *suffix); +void arg_print_syntaxv(FILE *fp, void **argtable, const char *suffix); +void arg_print_glossary(FILE *fp, void **argtable, const char *format); +void arg_print_glossary_gnu(FILE *fp, void **argtable); +void arg_print_errors(FILE* fp, struct arg_end* end, const char* progname); +void arg_freetable(void **argtable, size_t n); +void arg_print_formatted(FILE *fp, const unsigned lmargin, const unsigned rmargin, const char *text); + +/**** deprecated functions, for back-compatibility only ********/ +void arg_free(void **argtable); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/tools/sdk/include/console/esp_console.h b/tools/sdk/include/console/esp_console.h new file mode 100644 index 00000000..17cf5fe7 --- /dev/null +++ b/tools/sdk/include/console/esp_console.h @@ -0,0 +1,181 @@ +// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once + +#include +#include "esp_err.h" + +// Forward declaration. Definition in linenoise/linenoise.h. +typedef struct linenoiseCompletions linenoiseCompletions; + +/** + * @brief Parameters for console initialization + */ +typedef struct { + size_t max_cmdline_length; //!< length of command line buffer, in bytes + size_t max_cmdline_args; //!< maximum number of command line arguments to parse + int hint_color; //!< ASCII color code of hint text + int hint_bold; //!< Set to 1 to print hint text in bold +} esp_console_config_t; + +/** + * @brief initialize console module + * Call this once before using other console module features + * @return + * - ESP_OK on success + * - ESP_ERR_NO_MEM if out of memory + * - ESP_ERR_INVALID_STATE if already initialized + */ +esp_err_t esp_console_init(const esp_console_config_t* config); + + +/** + * @brief de-initialize console module + * Call this once when done using console module functions + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if not initialized yet + */ +esp_err_t esp_console_deinit(); + + +/** + * @brief Console command main function + * @param argc number of arguments + * @param argv array with argc entries, each pointing to a zero-terminated string argument + * @return console command return code, 0 indicates "success" + */ +typedef int (*esp_console_cmd_func_t)(int argc, char** argv); + +/** + * @brief Console command description + */ +typedef struct { + /** + * Command name. Must not be NULL, must not contain spaces. + * The pointer must be valid until the call to esp_console_deinit. + */ + const char* command; //!< command name + /** + * Help text for the command, shown by help command. + * If set, the pointer must be valid until the call to esp_console_deinit. + * If not set, the command will not be listed in 'help' output. + */ + const char* help; + /** + * Hint text, usually lists possible arguments. + * If set to NULL, and 'argtable' field is non-NULL, hint will be generated + * automatically + */ + const char* hint; + /** + * Pointer to a function which implements the command. + */ + esp_console_cmd_func_t func; + /** + * Array or structure of pointers to arg_xxx structures, may be NULL. + * Used to generate hint text if 'hint' is set to NULL. + * Array/structure which this field points to must end with an arg_end. + * Only used for the duration of esp_console_cmd_register call. + */ + void* argtable; +} esp_console_cmd_t; + +/** + * @brief Register console command + * @param cmd pointer to the command description; can point to a temporary value + * @return + * - ESP_OK on success + * - ESP_ERR_NO_MEM if out of memory + */ +esp_err_t esp_console_cmd_register(const esp_console_cmd_t *cmd); + +/** + * @brief Run command line + * @param cmdline command line (command name followed by a number of arguments) + * @param[out] cmd_ret return code from the command (set if command was run) + * @return + * - ESP_OK, if command was run + * - ESP_ERR_NOT_FOUND, if command with given name wasn't registered + * - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called + */ +esp_err_t esp_console_run(const char* cmdline, int* cmd_ret); + +/** + * @brief Split command line into arguments in place + * + * - This function finds whitespace-separated arguments in the given input line. + * + * 'abc def 1 20 .3' -> [ 'abc', 'def', '1', '20', '.3' ] + * + * - Argument which include spaces may be surrounded with quotes. In this case + * spaces are preserved and quotes are stripped. + * + * 'abc "123 456" def' -> [ 'abc', '123 456', 'def' ] + * + * - Escape sequences may be used to produce backslash, double quote, and space: + * + * 'a\ b\\c\"' -> [ 'a b\c"' ] + * + * Pointers to at most argv_size - 1 arguments are returned in argv array. + * The pointer after the last one (i.e. argv[argc]) is set to NULL. + * + * @param line pointer to buffer to parse; it is modified in place + * @param argv array where the pointers to arguments are written + * @param argv_size number of elements in argv_array (max. number of arguments) + * @return number of arguments found (argc) + */ +size_t esp_console_split_argv(char *line, char **argv, size_t argv_size); + +/** + * @brief Callback which provides command completion for linenoise library + * + * When using linenoise for line editing, command completion support + * can be enabled like this: + * + * linenoiseSetCompletionCallback(&esp_console_get_completion); + * + * @param buf the string typed by the user + * @param lc linenoiseCompletions to be filled in + */ +void esp_console_get_completion(const char *buf, linenoiseCompletions *lc); + +/** + * @brief Callback which provides command hints for linenoise library + * + * When using linenoise for line editing, hints support can be enabled as + * follows: + * + * linenoiseSetHintsCallback((linenoiseHintsCallback*) &esp_console_get_hint); + * + * The extra cast is needed because linenoiseHintsCallback is defined as + * returning a char* instead of const char*. + * + * @param buf line typed by the user + * @param[out] color ANSI color code to be used when displaying the hint + * @param[out] bold set to 1 if hint has to be displayed in bold + * @return string containing the hint text. This string is persistent and should + * not be freed (i.e. linenoiseSetFreeHintsCallback should not be used). + */ +const char *esp_console_get_hint(const char *buf, int *color, int *bold); + +/** + * @brief Register a 'help' command + * Default 'help' command prints the list of registered commands along with + * hints and help strings. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called + */ +esp_err_t esp_console_register_help_command(); diff --git a/tools/sdk/include/console/linenoise/linenoise.h b/tools/sdk/include/console/linenoise/linenoise.h new file mode 100644 index 00000000..a82701f8 --- /dev/null +++ b/tools/sdk/include/console/linenoise/linenoise.h @@ -0,0 +1,76 @@ +/* linenoise.h -- VERSION 1.0 + * + * Guerrilla line editing library against the idea that a line editing lib + * needs to be 20,000 lines of C code. + * + * See linenoise.c for more information. + * + * ------------------------------------------------------------------------ + * + * Copyright (c) 2010-2014, Salvatore Sanfilippo + * Copyright (c) 2010-2013, Pieter Noordhuis + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LINENOISE_H +#define __LINENOISE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct linenoiseCompletions { + size_t len; + char **cvec; +} linenoiseCompletions; + +typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *); +typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold); +typedef void(linenoiseFreeHintsCallback)(void *); +void linenoiseSetCompletionCallback(linenoiseCompletionCallback *); +void linenoiseSetHintsCallback(linenoiseHintsCallback *); +void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *); +void linenoiseAddCompletion(linenoiseCompletions *, const char *); + +int linenoiseProbe(void); +char *linenoise(const char *prompt); +void linenoiseFree(void *ptr); +int linenoiseHistoryAdd(const char *line); +int linenoiseHistorySetMaxLen(int len); +int linenoiseHistorySave(const char *filename); +int linenoiseHistoryLoad(const char *filename); +void linenoiseHistoryFree(); +void linenoiseClearScreen(void); +void linenoiseSetMultiLine(int ml); +void linenoiseSetDumbMode(int set); +void linenoisePrintKeyCodes(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __LINENOISE_H */ diff --git a/tools/sdk/include/driver/driver/adc.h b/tools/sdk/include/driver/driver/adc.h index 19068a23..08d32288 100644 --- a/tools/sdk/include/driver/driver/adc.h +++ b/tools/sdk/include/driver/driver/adc.h @@ -21,6 +21,8 @@ extern "C" { #include #include "esp_err.h" +#include "driver/gpio.h" +#include "soc/adc_channel.h" typedef enum { ADC_ATTEN_0db = 0, /*!0dB signal attenuation for that ADC channel. @@ -107,13 +123,22 @@ esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten); * - -1: Parameter error * - Other: ADC1 channel reading. */ -int adc1_get_voltage(adc1_channel_t channel); +int adc1_get_raw(adc1_channel_t channel); + +/** @cond */ //Doxygen command to hide deprecated function from API Reference +/* + * @deprecated This function returns an ADC1 reading but is deprecated due to + * a misleading name and has been changed to directly call the new function. + * Use the new function adc1_get_raw() instead + */ +int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated)); +/** @endcond */ /** * @brief Configure ADC1 to be usable by the ULP * * This function reconfigures ADC1 to be controlled by the ULP. - * Effect of this function can be reverted using adc1_get_voltage function. + * Effect of this function can be reverted using adc1_get_raw function. * * Note that adc1_config_channel_atten, adc1_config_width functions need * to be called to configure ADC1 channels, before ADC1 is used by the ULP. @@ -136,6 +161,22 @@ void adc1_ulp_enable(); */ int hall_sensor_read(); +/** + * @brief Output ADC2 reference voltage to gpio 25 or 26 or 27 + * + * This function utilizes the testing mux exclusive to ADC 2 to route the + * reference voltage one of ADC2's channels. Supported gpios are gpios + * 25, 26, and 27. This refernce voltage can be manually read from the pin + * and used in the esp_adc_cal component. + * + * @param[in] gpio GPIO number (gpios 25,26,27 supported) + * + * @return + * - ESP_OK: v_ref successfully routed to selected gpio + * - ESP_ERR_INVALID_ARG: Unsupported gpio + */ +esp_err_t adc2_vref_to_gpio(gpio_num_t gpio); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/driver/driver/dac.h b/tools/sdk/include/driver/driver/dac.h index 842894d0..a5563bb8 100644 --- a/tools/sdk/include/driver/driver/dac.h +++ b/tools/sdk/include/driver/driver/dac.h @@ -21,6 +21,7 @@ extern "C" { #include #include "esp_err.h" +#include "soc/dac_channel.h" typedef enum { DAC_CHANNEL_1 = 1, /*!< DAC channel 1 is GPIO25 */ diff --git a/tools/sdk/include/driver/driver/gpio.h b/tools/sdk/include/driver/driver/gpio.h index c68caee7..1b184f60 100644 --- a/tools/sdk/include/driver/driver/gpio.h +++ b/tools/sdk/include/driver/driver/gpio.h @@ -162,7 +162,7 @@ typedef enum { GPIO_NUM_27 = 27, /*!< GPIO27, input and output */ GPIO_NUM_32 = 32, /*!< GPIO32, input and output */ - GPIO_NUM_33 = 33, /*!< GPIO32, input and output */ + GPIO_NUM_33 = 33, /*!< GPIO33, input and output */ GPIO_NUM_34 = 34, /*!< GPIO34, input mode only */ GPIO_NUM_35 = 35, /*!< GPIO35, input mode only */ GPIO_NUM_36 = 36, /*!< GPIO36, input mode only */ diff --git a/tools/sdk/include/driver/driver/periph_ctrl.h b/tools/sdk/include/driver/driver/periph_ctrl.h index 0aab5508..cd09a78f 100644 --- a/tools/sdk/include/driver/driver/periph_ctrl.h +++ b/tools/sdk/include/driver/driver/periph_ctrl.h @@ -44,6 +44,11 @@ typedef enum { PERIPH_SPI_MODULE, PERIPH_HSPI_MODULE, PERIPH_VSPI_MODULE, + PERIPH_SPI_DMA_MODULE, + PERIPH_SDMMC_MODULE, + PERIPH_SDIO_SLAVE_MODULE, + PERIPH_CAN_MODULE, + PERIPH_EMAC_MODULE, } periph_module_t; /** diff --git a/tools/sdk/include/driver/driver/rmt.h b/tools/sdk/include/driver/driver/rmt.h index 0a958688..56c5ed49 100644 --- a/tools/sdk/include/driver/driver/rmt.h +++ b/tools/sdk/include/driver/driver/rmt.h @@ -677,11 +677,15 @@ esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t* rmt_item, i * * @param channel RMT channel (0 - 7) * + * @param wait_time Maximum time to wait for transmission to be complete + * * @return + * - ESP_OK RMT Tx done successfully + * - ESP_ERR_TIMEOUT Crossed the 'wait_time' given * - ESP_ERR_INVALID_ARG Parameter error - * - ESP_OK Success + * - ESP_FAIL Driver not installed */ -esp_err_t rmt_wait_tx_done(rmt_channel_t channel); +esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time); /** * @brief Get ringbuffer from UART. @@ -690,13 +694,13 @@ esp_err_t rmt_wait_tx_done(rmt_channel_t channel); * * @param channel RMT channel (0 - 7) * - * @param buf_handler Pointer to buffer handler to accept RX ringbuffer handler. + * @param buf_handle Pointer to buffer handler to accept RX ringbuffer handler. * * @return * - ESP_ERR_INVALID_ARG Parameter error * - ESP_OK Success */ -esp_err_t rmt_get_ringbuf_handler(rmt_channel_t channel, RingbufHandle_t* buf_handler); +esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t* buf_handle); /***************************EXAMPLE********************************** * diff --git a/tools/sdk/include/driver/driver/rtc_io.h b/tools/sdk/include/driver/driver/rtc_io.h index 5abff188..831a07fd 100644 --- a/tools/sdk/include/driver/driver/rtc_io.h +++ b/tools/sdk/include/driver/driver/rtc_io.h @@ -18,6 +18,7 @@ #include #include "esp_err.h" #include "driver/gpio.h" +#include "soc/rtc_gpio_channel.h" #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/include/driver/driver/sdmmc_defs.h b/tools/sdk/include/driver/driver/sdmmc_defs.h index 455d1c7a..c13df6d1 100644 --- a/tools/sdk/include/driver/driver/sdmmc_defs.h +++ b/tools/sdk/include/driver/driver/sdmmc_defs.h @@ -294,23 +294,67 @@ #define SCR_CMD_SUPPORT_CMD20(scr) MMC_RSP_BITS((scr), 32, 1) #define SCR_RESERVED2(scr) MMC_RSP_BITS((scr), 0, 32) -/* Status of Switch Function */ -#define SFUNC_STATUS_GROUP(status, group) \ - (__bitfield((uint32_t *)(status), 400 + (group - 1) * 16, 16)) +/* Max supply current in SWITCH_FUNC response (in mA) */ +#define SD_SFUNC_I_MAX(status) (MMC_RSP_BITS((uint32_t *)(status), 496, 16)) -#define SD_ACCESS_MODE_SDR12 0 -#define SD_ACCESS_MODE_SDR25 1 -#define SD_ACCESS_MODE_SDR50 2 -#define SD_ACCESS_MODE_SDR104 3 -#define SD_ACCESS_MODE_DDR50 4 +/* Supported flags in SWITCH_FUNC response */ +#define SD_SFUNC_SUPPORTED(status, group) \ + (MMC_RSP_BITS((uint32_t *)(status), 400 + (group - 1) * 16, 16)) +/* Selected function in SWITCH_FUNC response */ +#define SD_SFUNC_SELECTED(status, group) \ + (MMC_RSP_BITS((uint32_t *)(status), 376 + (group - 1) * 4, 4)) + +/* Busy flags in SWITCH_FUNC response */ +#define SD_SFUNC_BUSY(status, group) \ + (MMC_RSP_BITS((uint32_t *)(status), 272 + (group - 1) * 16, 16)) + +/* Version of SWITCH_FUNC response */ +#define SD_SFUNC_VER(status) (MMC_RSP_BITS((uint32_t *)(status), 368, 8)) + +#define SD_SFUNC_GROUP_MAX 6 +#define SD_SFUNC_FUNC_MAX 15 + +#define SD_ACCESS_MODE 1 /* Function group 1, Access Mode */ + +#define SD_ACCESS_MODE_SDR12 0 /* 25 MHz clock */ +#define SD_ACCESS_MODE_SDR25 1 /* 50 MHz clock */ +#define SD_ACCESS_MODE_SDR50 2 /* UHS-I, 100 MHz clock */ +#define SD_ACCESS_MODE_SDR104 3 /* UHS-I, 208 MHz clock */ +#define SD_ACCESS_MODE_DDR50 4 /* UHS-I, 50 MHz clock, DDR */ + +/** + * @brief Extract up to 32 sequential bits from an array of 32-bit words + * + * Bits within the word are numbered in the increasing order from LSB to MSB. + * + * As an example, consider 2 32-bit words: + * + * 0x01234567 0x89abcdef + * + * On a little-endian system, the bytes are stored in memory as follows: + * + * 67 45 23 01 ef cd ab 89 + * + * MMC_RSP_BITS will extact bits as follows: + * + * start=0 len=4 -> result=0x00000007 + * start=0 len=12 -> result=0x00000567 + * start=28 len=8 -> result=0x000000f0 + * start=59 len=5 -> result=0x00000011 + * + * @param src array of words to extract bits from + * @param start index of the first bit to extract + * @param len number of bits to extract, 1 to 32 + * @return 32-bit word where requested bits start from LSB + */ static inline uint32_t MMC_RSP_BITS(uint32_t *src, int start, int len) { uint32_t mask = (len % 32 == 0) ? UINT_MAX : UINT_MAX >> (32 - (len % 32)); - size_t word = 3 - start / 32; + size_t word = start / 32; size_t shift = start % 32; uint32_t right = src[word] >> shift; - uint32_t left = (len + shift <= 32) ? 0 : src[word - 1] << ((32 - shift) % 32); + uint32_t left = (len + shift <= 32) ? 0 : src[word + 1] << ((32 - shift) % 32); return (left | right) & mask; } diff --git a/tools/sdk/include/driver/driver/sdmmc_types.h b/tools/sdk/include/driver/driver/sdmmc_types.h index d9ffde3f..4bc1e05e 100644 --- a/tools/sdk/include/driver/driver/sdmmc_types.h +++ b/tools/sdk/include/driver/driver/sdmmc_types.h @@ -60,6 +60,13 @@ typedef struct { */ typedef uint32_t sdmmc_response_t[4]; +/** + * SD SWITCH_FUNC response buffer + */ +typedef struct { + uint32_t data[512 / 8 / sizeof(uint32_t)]; /*!< response data */ +} sdmmc_switch_func_rsp_t; + /** * SD/MMC command information */ diff --git a/tools/sdk/include/driver/driver/spi_common.h b/tools/sdk/include/driver/driver/spi_common.h index 53cde6ff..6adcc06a 100644 --- a/tools/sdk/include/driver/driver/spi_common.h +++ b/tools/sdk/include/driver/driver/spi_common.h @@ -74,11 +74,30 @@ bool spicommon_periph_claim(spi_host_device_t host); /** * @brief Return the SPI peripheral so another driver can claim it. * - * @param host Peripheral to claim + * @param host Peripheral to return * @return True if peripheral is returned successfully; false if peripheral was free to claim already. */ bool spicommon_periph_free(spi_host_device_t host); +/** + * @brief Try to claim a SPI DMA channel + * + * Call this if your driver wants to use SPI with a DMA channnel. + * + * @param dma_chan channel to claim + * + * @return True if success; false otherwise. + */ +bool spicommon_dma_chan_claim(int dma_chan); + +/** + * @brief Return the SPI DMA channel so other driver can claim it, or just to power down DMA. + * + * @param dma_chan channel to return + * + * @return True if success; false otherwise. + */ +bool spicommon_dma_chan_free(int dma_chan); #define SPICOMMON_BUSFLAG_SLAVE 0 ///< Initialize I/O in slave mode #define SPICOMMON_BUSFLAG_MASTER (1<<0) ///< Initialize I/O in master mode @@ -170,9 +189,6 @@ spi_dev_t *spicommon_hw_for_host(spi_host_device_t host); */ int spicommon_irqsource_for_host(spi_host_device_t host); - - - /** * Callback, to be called when a DMA engine reset is completed */ diff --git a/tools/sdk/include/driver/driver/spi_master.h b/tools/sdk/include/driver/driver/spi_master.h index 79eb52d3..c501998c 100644 --- a/tools/sdk/include/driver/driver/spi_master.h +++ b/tools/sdk/include/driver/driver/spi_master.h @@ -30,7 +30,7 @@ extern "C" #define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first #define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first -#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first +#define SPI_DEVICE_BIT_LSBFIRST (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST); ///< Transmit and receive LSB first #define SPI_DEVICE_3WIRE (1<<2) ///< Use MOSI (=spid) for both sending and receiving data #define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative #define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously @@ -67,24 +67,28 @@ typedef struct { #define SPI_TRANS_USE_TXDATA (1<<3) ///< Transmit tx_data member of spi_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this. /** - * This structure describes one SPI transaction + * This structure describes one SPI transaction. The descriptor should not be modified until the transaction finishes. */ struct spi_transaction_t { uint32_t flags; ///< Bitwise OR of SPI_TRANS_* flags - uint16_t command; ///< Command data. Specific length was given when device was added to the bus. - uint64_t address; ///< Address. Specific length was given when device was added to the bus. + uint16_t cmd; ///< Command data, of which the length is set in the ``command_bits`` of spi_device_interface_config_t. + ///< NOTE: this field, used to be "command" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF 3.0. + ///< - Example: write 0x0123 and command_bits=12 to send command 0x12, 0x3_ (in previous version, you may have to write 0x3_12). + uint64_t addr; ///< Address data, of which the length is set in the ``address_bits`` of spi_device_interface_config_t. + ///< NOTE: this field, used to be "address" in ESP-IDF 2.1 and before, is re-written to be used in a new way in ESP-IDF3.0. + ///< - Example: write 0x123400 and address_bits=24 to send address of 0x12, 0x34, 0x00 (in previous version, you may have to write 0x12340000). size_t length; ///< Total data length, in bits - size_t rxlength; ///< Total data length received, if different from length. (0 defaults this to the value of ``length``) + size_t rxlength; ///< Total data length received, should be not greater than ``length`` in full-duplex mode (0 defaults this to the value of ``length``). void *user; ///< User-defined variable. Can be used to store eg transaction ID. union { const void *tx_buffer; ///< Pointer to transmit buffer, or NULL for no MOSI phase uint8_t tx_data[4]; ///< If SPI_USE_TXDATA is set, data set here is sent directly from this variable. }; union { - void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase + void *rx_buffer; ///< Pointer to receive buffer, or NULL for no MISO phase. Written by 4 bytes-unit if DMA is used. uint8_t rx_data[4]; ///< If SPI_USE_RXDATA is set, data is received directly to this variable }; -}; +} ; //the rx data should start from a 32-bit aligned address to get around dma issue. typedef struct spi_device_t* spi_device_handle_t; ///< Handle for a device on a SPI bus @@ -182,8 +186,9 @@ esp_err_t spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t * * re-use the buffers. * * @param handle Device handle obtained using spi_host_add_dev - * @param trans_desc Pointer to variable able to contain a pointer to the description of the - * transaction that is executed + * @param trans_desc Pointer to variable able to contain a pointer to the description of the transaction + that is executed. The descriptor should not be modified until the descriptor is returned by + spi_device_get_trans_result. * @param ticks_to_wait Ticks to wait until there's a returned item; use portMAX_DELAY to never time out. * @return @@ -201,8 +206,7 @@ esp_err_t spi_device_get_trans_result(spi_device_handle_t handle, spi_transactio * using spi_device_get_trans_result. * * @param handle Device handle obtained using spi_host_add_dev - * @param trans_desc Pointer to variable able to contain a pointer to the description of the - * transaction that is executed + * @param trans_desc Description of transaction to execute * @return * - ESP_ERR_INVALID_ARG if parameter is invalid * - ESP_OK on success diff --git a/tools/sdk/include/driver/driver/touch_pad.h b/tools/sdk/include/driver/driver/touch_pad.h index e880ff61..ce67a7dc 100644 --- a/tools/sdk/include/driver/driver/touch_pad.h +++ b/tools/sdk/include/driver/driver/touch_pad.h @@ -20,150 +20,480 @@ extern "C" { #include "esp_intr.h" #include "esp_err.h" #include "esp_intr_alloc.h" -#define TOUCH_PAD_SLEEP_CYCLE_CONFIG (0x1000)//The Time is 150Khz,the Max value is 0xffff -#define TOUCH_PAD_MEASURE_CYCLE_CONFIG (0xffff)//The Time is 8Mhz,the Max value is 0xffff +#include "soc/touch_channel.h" + typedef enum { TOUCH_PAD_NUM0 = 0, /*!< Touch pad channel 0 is GPIO4 */ - TOUCH_PAD_NUM1, /*!< Touch pad channel 0 is GPIO0 */ - TOUCH_PAD_NUM2, /*!< Touch pad channel 0 is GPIO2 */ - TOUCH_PAD_NUM3, /*!< Touch pad channel 0 is GPIO15 */ - TOUCH_PAD_NUM4, /*!< Touch pad channel 0 is GPIO13 */ - TOUCH_PAD_NUM5, /*!< Touch pad channel 0 is GPIO12 */ - TOUCH_PAD_NUM6, /*!< Touch pad channel 0 is GPIO14 */ - TOUCH_PAD_NUM7, /*!< Touch pad channel 0 is GPIO27*/ - TOUCH_PAD_NUM8, /*!< Touch pad channel 0 is GPIO33*/ - TOUCH_PAD_NUM9, /*!< Touch pad channel 0 is GPIO32*/ + TOUCH_PAD_NUM1, /*!< Touch pad channel 1 is GPIO0 */ + TOUCH_PAD_NUM2, /*!< Touch pad channel 2 is GPIO2 */ + TOUCH_PAD_NUM3, /*!< Touch pad channel 3 is GPIO15*/ + TOUCH_PAD_NUM4, /*!< Touch pad channel 4 is GPIO13*/ + TOUCH_PAD_NUM5, /*!< Touch pad channel 5 is GPIO12*/ + TOUCH_PAD_NUM6, /*!< Touch pad channel 6 is GPIO14*/ + TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27*/ + TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO32*/ + TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO33*/ TOUCH_PAD_MAX, } touch_pad_t; +typedef enum { + TOUCH_HVOLT_KEEP = -1, /*!NumTouch,so you can select a interrupt threshold. - * - * @param[in] touch_num : touch num - * @param[out] touch_value : touch output value - * - * @return - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad error - * - ESP_FAIL Touch pad not initialized + * @brief get touch sensor counter value. + * Each touch sensor has a counter to count the number of charge/discharge cycles. + * When the pad is not 'touched', we can get a number of the counter. + * When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance. + * User can use this function to determine the interrupt trigger threshold. * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad error + * - ESP_FAIL Touch pad not initialized */ esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t * touch_value); /** - * @brief register TouchPad interrupt handler, the handler is an ISR. - * The handler will be attached to the same CPU core that this function is running on. - * - * @param fn Interrupt handler function. - * @param arg Parameter for handler function - * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred) - * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. - * @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will - * be returned here. + * @brief get filtered touch sensor counter value by IIR filter. + * @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered. + * This function can be called from ISR * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad error + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief Register touch-pad ISR, + * @note Deprecated function, users should replace this with touch_pad_isr_register, + * because RTC modules share a same interrupt index. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @param unused Reserved, not used + * @param handle_unused Reserved, not used * @return * - ESP_OK Success ; * - ESP_ERR_INVALID_ARG GPIO error */ -esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int intr_alloc_flags, touch_isr_handle_t *handle); - +esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int unused, intr_handle_t *handle_unused) __attribute__ ((deprecated)); /** - * *************** ATTENTION ********************/ -/** - *@attention - *Touch button is through the body's capacitive characteristics, - *there is a charge discharge circuit inside the. When the hands touch, - *the charge and discharge time will be slow. - *Because of the different hardware, each pad needs to be calibrated at the factory. - *We use touch_pad_read to determine factory parameters. + * @brief Register touch-pad ISR. + * The handler will be attached to the same CPU core that this function is running on. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @return + * - ESP_OK Success ; + * - ESP_ERR_INVALID_ARG GPIO error */ +esp_err_t touch_pad_isr_register(intr_handler_t fn, void* arg); + /** - *----------EXAMPLE TO CONFIGURE GPIO AS OUTPUT ------------ * - * @code{c} - * touch_pad_init(); - * void taskA(void* arg) - * { - * for(;;){ - * vtaskDelay(20/portTICK_PERIOD_MS); - * ets_printf("touch pad value %u\n",touch_pad_read(0));//Take the touched status and untouched status value - * } - * } - * @endcode - **/ -/** - *----------EXAMPLE TO SET ISR HANDLER ---------------------- - * @code{c} - * touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) //hook the isr handler for TouchPad interrupt - * @endcode + * @brief Deregister the handler previously registered using touch_pad_isr_handler_register + * @param fn handler function to call (as passed to touch_pad_isr_handler_register) + * @param arg argument of the handler (as passed to touch_pad_isr_handler_register) + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if a handler matching both fn and + * arg isn't registered */ +esp_err_t touch_pad_isr_deregister(void(*fn)(void *), void *arg); + /** - *----------EXAMPLE TO USE TOUCH_PAD------------ * - * @code{c} - * touch_pad_init();//only init one time - * touch_pad_config(0,300);//set the intr threshold,use touch_pad_read to determine this threshold - * touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) - * #include "esp_attr.h" - * void rtc_intr(void * arg) - * { - * uint32_t pad_intr = READ_PERI_REG(SARADC_SAR_TOUCH_CTRL2_REG) & 0x3ff; - * uint8_t i = 0; - * uint32_t rtc_intr = READ_PERI_REG(RTC_CNTL_INT_ST_REG); - * WRITE_PERI_REG(RTC_CNTL_INT_CLR_REG, rtc_intr); - * SET_PERI_REG_MASK(SARADC_SAR_TOUCH_CTRL2_REG, SARADC_TOUCH_MEAS_EN_CLR); - * if (rtc_intr & RTC_CNTL_TOUCH_INT_ST) { - * for (i = 0; i < TOUCH_PAD_MAX; ++i) { - * if ((pad_intr >> i) & 0x01) { - * ets_printf("touch pad intr %u\n",i); - * } - * } - * } - * } - * @endcode - **/ + * @brief Set touch sensor measurement and sleep time + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_cycle The duration of the touch sensor measurement. + * t_meas = meas_cycle / 8M, the maximum measure time is 0xffff / 8M = 8.19 ms + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle); + +/** + * @brief Get touch sensor measurement and sleep time + * @param sleep_cycle Pointer to accept sleep cycle number + * @param meas_cycle Pointer to accept measurement cycle count. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle); + +/** + * @brief Set touch sensor reference voltage, if the voltage gap between high and low reference voltage get less, + * the charging and discharging time would be faster, accordingly, the counter value would be larger. + * In the case of detecting very slight change of capacitance, we can narrow down the gap so as to increase + * the sensitivity. On the other hand, narrow voltage gap would also introduce more noise, but we can use a + * software filter to pre-process the counter value. + * @param refh the value of DREFH + * @param refl the value of DREFL + * @param atten the attenuation on DREFH + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_voltage(touch_high_volt_t refh, touch_low_volt_t refl, touch_volt_atten_t atten); + +/** + * @brief Get touch sensor reference voltage, + * @param refh pointer to accept DREFH value + * @param refl pointer to accept DREFL value + * @param atten pointer to accept the attenuation on DREFH + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl, touch_volt_atten_t *atten); + +/** + * @brief Set touch sensor charge/discharge speed for each pad. + * If the slope is 0, the counter would always be zero. + * If the slope is 1, the charging and discharging would be slow, accordingly, the counter value would be small. + * If the slope is set 7, which is the maximum value, the charging and discharging would be fast, accordingly, the + * counter value would be larger. + * @param touch_num touch pad index + * @param slope touch pad charge/discharge speed + * @param opt the initial voltage + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt); + +/** + * @brief Get touch sensor charge/discharge speed for each pad + * @param touch_num touch pad index + * @param slope pointer to accept touch pad charge/discharge slope + * @param opt pointer to accept the initial voltage + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt); + +/** + * @brief Initialize touch pad GPIO + * @param touch_num touch pad index + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_io_init(touch_pad_t touch_num); + +/** + * @brief Set touch sensor FSM mode, the test action can be triggered by the timer, + * as well as by the software. + * @param mode FSM mode + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_fsm_mode(touch_fsm_mode_t mode); + +/** + * @brief Get touch sensor FSM mode + * @param mode pointer to accept FSM mode + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode); + +/** + * @brief Trigger a touch sensor measurement, only support in SW mode of FSM + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_sw_start(); + +/** + * @brief Set touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold); + +/** + * @brief Get touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold pointer to accept threshold + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold); + +/** + * @brief Set touch sensor interrupt trigger mode. + * Interrupt can be triggered either when counter result is less than + * threshold or when counter result is more than threshold. + * @param mode touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode); + +/** + * @brief Get touch sensor interrupt trigger mode + * @param mode pointer to accept touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode); + +/** + * @brief Set touch sensor interrupt trigger source. There are two sets of touch signals. + * Set1 and set2 can be mapped to several touch signals. Either set will be triggered + * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated + * if set1 is triggered, or only if both sets are triggered. + * @param src touch sensor interrupt trigger source + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src); + +/** + * @brief Get touch sensor interrupt trigger source + * @param src pointer to accept touch sensor interrupt trigger source + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src); + +/** + * @brief Set touch sensor group mask. + * Touch pad module has two sets of signals, 'Touched' signal is triggered only if + * at least one of touch pad in this group is "touched". + * This function will set the register bits according to the given bitmask. + * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief Get touch sensor group mask. + * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask); + +/** + * @brief Clear touch sensor group mask. + * Touch pad module has two sets of signals, Interrupt is triggered only if + * at least one of touch pad in this group is "touched". + * This function will clear the register bits according to the given bitmask. + * @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief To clear the touch status register, usually use this function in touch ISR to clear status. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_clear_status(); + +/** + * @brief Get the touch sensor status, usually used in ISR to decide which pads are 'touched'. + * @return + * - touch status + */ +uint32_t touch_pad_get_status(); + +/** + * @brief To enable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_enable(); + +/** + * @brief To disable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_disable(); + +/** + * @brief set touch pad filter calibration period, in ms. + * Need to call touch_pad_filter_start before all touch filter APIs + * @param new_period_ms filter period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms); + +/** + * @brief get touch pad filter calibration period, in ms + * Need to call touch_pad_filter_start before all touch filter APIs + * @param p_period_ms pointer to accept period + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_get_filter_period(uint32_t* p_period_ms); + +/** + * @brief start touch pad filter function + * This API will start a filter to process the noise in order to prevent false triggering + * when detecting slight change of capacitance. + * Need to call touch_pad_filter_start before all touch filter APIs + * + * If filter is not initialized, this API will initialize the filter with given period. + * If filter is already initialized, this API will update the filter period. + * @note This filter uses FreeRTOS timer, which is dispatched from a task with + * priority 1 by default on CPU 0. So if some application task with higher priority + * takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected. + * You can adjust FreeRTOS timer task priority in menuconfig. + * @param filter_period_ms filter calibration period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter error + * - ESP_ERR_NO_MEM No memory for driver + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); + +/** + * @brief stop touch pad filter function + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_stop(); + +/** + * @brief delete touch pad filter driver and release the memory + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_delete(); #ifdef __cplusplus } diff --git a/tools/sdk/include/driver/driver/uart.h b/tools/sdk/include/driver/driver/uart.h index 9bd35e43..229685b7 100644 --- a/tools/sdk/include/driver/driver/uart.h +++ b/tools/sdk/include/driver/driver/uart.h @@ -32,6 +32,7 @@ extern "C" { #include "freertos/queue.h" #include "freertos/ringbuf.h" #include +#include "soc/uart_channel.h" #define UART_FIFO_LEN (128) /*!< Length of the hardware FIFO buffers */ #define UART_INTR_MASK 0x1ff /*!< mask of all UART interrupts */ diff --git a/tools/sdk/include/esp32/esp_clk.h b/tools/sdk/include/esp32/esp_clk.h index 7b9c64c6..5c6f5cb8 100644 --- a/tools/sdk/include/esp32/esp_clk.h +++ b/tools/sdk/include/esp32/esp_clk.h @@ -54,3 +54,11 @@ uint32_t esp_clk_slowclk_cal_get(); */ void esp_clk_slowclk_cal_set(uint32_t value); +/** + * @brief Disables clock of some peripherals + * + * Called from cpu_start.c, not intended to be called from other places. + * This function disables clock of useless peripherals when cpu starts. + */ +void esp_perip_clk_init(void); + diff --git a/tools/sdk/include/esp32/esp_deep_sleep.h b/tools/sdk/include/esp32/esp_deep_sleep.h index 61d3642b..ea460181 100644 --- a/tools/sdk/include/esp32/esp_deep_sleep.h +++ b/tools/sdk/include/esp32/esp_deep_sleep.h @@ -1,4 +1,4 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,281 +14,81 @@ #pragma once -#include -#include "esp_err.h" -#include "driver/gpio.h" -#include "driver/touch_pad.h" +/** + * @file esp_deep_sleep.h + * @brief legacy definitions of esp_deep_sleep APIs + * + * This file provides compatibility for applications using esp_deep_sleep_* APIs. + * New applications should use functions defined in "esp_sleep.h" instead. + * These functions and types will be deprecated at some point. + */ + +#warning esp_deep_sleep.h will be deprecated in the next release. Use esp_sleep.h instead. + +#include "esp_sleep.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief Logic function used for EXT1 wakeup mode. - */ -typedef enum { - ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low - ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high -} esp_ext1_wakeup_mode_t; +typedef esp_sleep_pd_domain_t esp_deep_sleep_pd_domain_t; +typedef esp_sleep_pd_option_t esp_deep_sleep_pd_option_t; +typedef esp_sleep_ext1_wakeup_mode_t esp_ext1_wakeup_mode_t; +typedef esp_sleep_wakeup_cause_t esp_deep_sleep_wakeup_cause_t; -/** - * @brief Power domains which can be powered down in deep sleep - */ -typedef enum { - ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor - ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory - ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory - ESP_PD_DOMAIN_MAX //!< Number of domains -} esp_deep_sleep_pd_domain_t; +inline static esp_err_t esp_deep_sleep_enable_ulp_wakeup(void) +{ + return esp_sleep_enable_ulp_wakeup(); +} -/** - * @brief Power down options - */ -typedef enum { - ESP_PD_OPTION_OFF, //!< Power down the power domain in deep sleep - ESP_PD_OPTION_ON, //!< Keep power domain enabled during deep sleep - ESP_PD_OPTION_AUTO //!< Keep power domain enabled in deep sleep, if it is needed by one of the wakeup options. Otherwise power it down. -} esp_deep_sleep_pd_option_t; +inline static esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us) +{ + return esp_sleep_enable_timer_wakeup(time_in_us); +} -/** - * @brief Deep sleep wakeup cause - */ -typedef enum { - ESP_DEEP_SLEEP_WAKEUP_UNDEFINED, //! Wakeup was not caused by deep sleep - ESP_DEEP_SLEEP_WAKEUP_EXT0, //! Wakeup caused by external signal using RTC_IO - ESP_DEEP_SLEEP_WAKEUP_EXT1, //! Wakeup caused by external signal using RTC_CNTL - ESP_DEEP_SLEEP_WAKEUP_TIMER, //! Wakeup caused by timer - ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD, //! Wakeup caused by touchpad - ESP_DEEP_SLEEP_WAKEUP_ULP, //! Wakeup caused by ULP program -} esp_deep_sleep_wakeup_cause_t; +inline static esp_err_t esp_deep_sleep_enable_touchpad_wakeup(void) +{ + return esp_sleep_enable_touchpad_wakeup(); +} +inline static touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status() +{ + return esp_sleep_get_touchpad_wakeup_status(); +} -/** - * @brief Enable wakeup by ULP coprocessor - * @note In revisions 0 and 1 of the ESP32, ULP wakeup source - * can not be used when RTC_PERIPH power domain is forced - * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup - * source is used. - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict - */ -esp_err_t esp_deep_sleep_enable_ulp_wakeup(); +inline static esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level) +{ + return esp_sleep_enable_ext0_wakeup(gpio_num, level); +} -/** - * @brief Enable wakeup by timer - * @param time_in_us time before wakeup, in microseconds - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if value is out of range (TBD) - */ -esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us); +inline static esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode) +{ + return esp_sleep_enable_ext1_wakeup(mask, mode); +} -/** - * @brief Enable wakeup by touch sensor - * - * @note In revisions 0 and 1 of the ESP32, touch wakeup source - * can not be used when RTC_PERIPH power domain is forced - * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup - * source is used. - * - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_STATE if wakeup triggers conflict - */ -esp_err_t esp_deep_sleep_enable_touchpad_wakeup(); +inline static esp_err_t esp_deep_sleep_pd_config( + esp_deep_sleep_pd_domain_t domain, + esp_deep_sleep_pd_option_t option) +{ + return esp_sleep_pd_config(domain, option); +} -/** - * @brief Get the touch pad which caused wakeup - * - * If wakeup was caused by another source, this function will return TOUCH_PAD_MAX; - * - * @return touch pad which caused wakeup - */ -touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status(); +inline static esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause() +{ + return esp_sleep_get_wakeup_cause(); +} -/** - * @brief Enable wakeup using a pin - * - * This function uses external wakeup feature of RTC_IO peripheral. - * It will work only if RTC peripherals are kept on during deep sleep. - * - * This feature can monitor any pin which is an RTC IO. Once the pin transitions - * into the state given by level argument, the chip will be woken up. - * - * @note This function does not modify pin configuration. The pin is - * configured in esp_deep_sleep_start, immediately before - * entering deep sleep. - * - * @note In revisions 0 and 1 of the ESP32, ext0 wakeup source - * can not be used together with touch or ULP wakeup sources. - * - * @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC - * functionality can be used: 0,2,4,12-15,25-27,32-39. - * @param level input level which will trigger wakeup (0=low, 1=high) - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO, - * or the mode is invalid - * - ESP_ERR_INVALID_STATE if wakeup triggers conflict - */ -esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level); +#define ESP_DEEP_SLEEP_WAKEUP_UNDEFINED ESP_SLEEP_WAKEUP_UNDEFINED +#define ESP_DEEP_SLEEP_WAKEUP_EXT0 ESP_SLEEP_WAKEUP_EXT0 +#define ESP_DEEP_SLEEP_WAKEUP_EXT1 ESP_SLEEP_WAKEUP_EXT1 +#define ESP_DEEP_SLEEP_WAKEUP_TIMER ESP_SLEEP_WAKEUP_TIMER +#define ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD ESP_SLEEP_WAKEUP_TOUCHPAD +#define ESP_DEEP_SLEEP_WAKEUP_ULP ESP_SLEEP_WAKEUP_ULP -/** - * @brief Enable wakeup using multiple pins - * - * This function uses external wakeup feature of RTC controller. - * It will work even if RTC peripherals are shut down during deep sleep. - * - * This feature can monitor any number of pins which are in RTC IOs. - * Once any of the selected pins goes into the state given by mode argument, - * the chip will be woken up. - * - * @note This function does not modify pin configuration. The pins are - * configured in esp_deep_sleep_start, immediately before - * entering deep sleep. - * - * @note internal pullups and pulldowns don't work when RTC peripherals are - * shut down. In this case, external resistors need to be added. - * Alternatively, RTC peripherals (and pullups/pulldowns) may be - * kept enabled using esp_deep_sleep_pd_config function. - * - * @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs - * which are have RTC functionality can be used in this bit map: - * 0,2,4,12-15,25-27,32-39. - * @param mode select logic function used to determine wakeup condition: - * - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low - * - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO, - * or mode is invalid - */ -esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode); - - -/** - * @brief Get the bit mask of GPIOs which caused wakeup (ext1) - * - * If wakeup was caused by another source, this function will return 0. - * - * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set - */ -uint64_t esp_deep_sleep_get_ext1_wakeup_status(); - -/** - * @brief Set power down mode for an RTC power domain in deep sleep - * - * If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO. - * - * @param domain power domain to configure - * @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO) - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if either of the arguments is out of range - */ -esp_err_t esp_deep_sleep_pd_config(esp_deep_sleep_pd_domain_t domain, - esp_deep_sleep_pd_option_t option); - -/** - * @brief Enter deep sleep with the configured wakeup options - * - * This function does not return. - */ -void esp_deep_sleep_start() __attribute__((noreturn)); - -/** - * @brief Enter deep-sleep mode - * - * The device will automatically wake up after the deep-sleep time - * Upon waking up, the device calls deep sleep wake stub, and then proceeds - * to load application. - * - * Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup - * followed by a call to esp_deep_sleep_start. - * - * esp_deep_sleep does not shut down WiFi, BT, and higher level protocol - * connections gracefully. - * Make sure relevant WiFi and BT stack functions are called to close any - * connections and deinitialize the peripherals. These include: - * - esp_bluedroid_disable - * - esp_bt_controller_disable - * - esp_wifi_stop - * - * This function does not return. - * - * @param time_in_us deep-sleep time, unit: microsecond - */ -void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); - -/** - * @brief Enter deep-sleep mode - * - * Function has been renamed to esp_deep_sleep. - * This name is deprecated and will be removed in a future version. - * - * @param time_in_us deep-sleep time, unit: microsecond - */ -void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated)); - - -/** - * @brief Get the source which caused deep sleep wakeup - * - * @return wakeup cause, or ESP_DEEP_SLEEP_WAKEUP_UNDEFINED if reset reason is other than deep sleep reset. - */ -esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause(); - - -/** - * @brief Default stub to run on wake from deep sleep. - * - * Allows for executing code immediately on wake from sleep, before - * the software bootloader or ESP-IDF app has started up. - * - * This function is weak-linked, so you can implement your own version - * to run code immediately when the chip wakes from - * sleep. - * - * See docs/deep-sleep-stub.rst for details. - */ -void esp_wake_deep_sleep(void); - -/** - * @brief Function type for stub to run on wake from sleep. - * - */ -typedef void (*esp_deep_sleep_wake_stub_fn_t)(void); - -/** - * @brief Install a new stub at runtime to run on wake from deep sleep - * - * If implementing esp_wake_deep_sleep() then it is not necessary to - * call this function. - * - * However, it is possible to call this function to substitute a - * different deep sleep stub. Any function used as a deep sleep stub - * must be marked RTC_IRAM_ATTR, and must obey the same rules given - * for esp_wake_deep_sleep(). - */ -void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub); - -/** - * @brief Get current wake from deep sleep stub - * @return Return current wake from deep sleep stub, or NULL if - * no stub is installed. - */ -esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void); - -/** - * @brief The default esp-idf-provided esp_wake_deep_sleep() stub. - * - * See docs/deep-sleep-stub.rst for details. - */ -void esp_default_wake_deep_sleep(void); #ifdef __cplusplus } #endif + diff --git a/tools/sdk/include/esp32/esp_deepsleep.h b/tools/sdk/include/esp32/esp_deepsleep.h index fe536499..3f0151b6 100644 --- a/tools/sdk/include/esp32/esp_deepsleep.h +++ b/tools/sdk/include/esp32/esp_deepsleep.h @@ -1,2 +1,2 @@ -#warning esp_deepsleep.h has been renamed to esp_deep_sleep.h, please update include directives -#include "esp_deep_sleep.h" +#warning esp_deepsleep.h has been renamed to esp_sleep.h, please update include directives +#include "esp_sleep.h" diff --git a/tools/sdk/include/esp32/esp_dport_access.h b/tools/sdk/include/esp32/esp_dport_access.h index 8b081c5a..49e15f69 100644 --- a/tools/sdk/include/esp32/esp_dport_access.h +++ b/tools/sdk/include/esp32/esp_dport_access.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #ifndef _ESP_DPORT_ACCESS_H_ #define _ESP_DPORT_ACCESS_H_ @@ -22,7 +24,8 @@ extern "C" { void esp_dport_access_stall_other_cpu_start(void); void esp_dport_access_stall_other_cpu_end(void); void esp_dport_access_int_init(void); -void esp_dport_access_int_deinit(void); +void esp_dport_access_int_pause(void); +void esp_dport_access_int_resume(void); #if defined(BOOTLOADER_BUILD) || defined(CONFIG_FREERTOS_UNICORE) || !defined(ESP_PLATFORM) #define DPORT_STALL_OTHER_CPU_START() diff --git a/tools/sdk/include/esp32/esp_event.h b/tools/sdk/include/esp32/esp_event.h index 7b3a8573..ccffdb81 100644 --- a/tools/sdk/include/esp32/esp_event.h +++ b/tools/sdk/include/esp32/esp_event.h @@ -35,6 +35,7 @@ typedef enum { SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */ SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */ SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */ + SYSTEM_EVENT_STA_LOST_IP, /**< ESP32 station lost IP and the IP is reset to 0 */ SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */ SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */ SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */ @@ -86,6 +87,7 @@ typedef struct { typedef struct { tcpip_adapter_ip_info_t ip_info; + bool ip_changed; } system_event_sta_got_ip_t; typedef struct { @@ -116,7 +118,7 @@ typedef union { system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */ system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */ system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */ - system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP */ + system_event_sta_got_ip_t got_ip; /**< ESP32 station got IP, first time got IP or when IP is changed */ system_event_sta_wps_er_pin_t sta_er_pin; /**< ESP32 station WPS enrollee mode PIN code received */ system_event_sta_wps_fail_reason_t sta_er_fail_reason;/**< ESP32 station WPS enrollee mode failed reason code received */ system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */ @@ -159,6 +161,17 @@ esp_err_t esp_event_send(system_event_t *event); */ esp_err_t esp_event_process_default(system_event_t *event); +/** + * @brief Install default event handlers for Ethernet interface + * + */ +void esp_event_set_default_eth_handlers(); + +/** + * @brief Install default event handlers for Wi-Fi interfaces (station and AP) + * + */ +void esp_event_set_default_wifi_handlers(); #ifdef __cplusplus } diff --git a/tools/sdk/include/esp32/esp_intr_alloc.h b/tools/sdk/include/esp32/esp_intr_alloc.h index 63555c20..ad121abb 100644 --- a/tools/sdk/include/esp32/esp_intr_alloc.h +++ b/tools/sdk/include/esp32/esp_intr_alloc.h @@ -104,7 +104,7 @@ typedef intr_handle_data_t* intr_handle_t ; esp_err_t esp_intr_mark_shared(int intno, int cpu, bool is_in_iram); /** - * @brief Reserve an interrupt to be used outside of this framewoek + * @brief Reserve an interrupt to be used outside of this framework * * This will mark a certain interrupt on the specified CPU as * reserved, not to be allocated for any reason. @@ -197,6 +197,11 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre * Use an interrupt handle to disable the interrupt and release the resources * associated with it. * + * @note + * When the handler shares its source with other handlers, the interrupt status + * bits it's responsible for should be managed properly before freeing it. see + * ``esp_intr_disable`` for more details. + * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus * * @return ESP_ERR_INVALID_ARG if handle is invalid, or esp_intr_free runs on another core than @@ -227,8 +232,13 @@ int esp_intr_get_intno(intr_handle_t handle); /** * @brief Disable the interrupt associated with the handle * - * @note For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the - * CPU the interrupt is allocated on. Other interrupts have no such restriction. + * @note + * 1. For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the + * CPU the interrupt is allocated on. Other interrupts have no such restriction. + * 2. When several handlers sharing a same interrupt source, interrupt status bits, which are + * handled in the handler to be disabled, should be masked before the disabling, or handled + * in other enabled interrupts properly. Miss of interrupt status handling will cause infinite + * interrupt calls and finally system crash. * * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus * diff --git a/tools/sdk/include/esp32/esp_sleep.h b/tools/sdk/include/esp32/esp_sleep.h new file mode 100644 index 00000000..1e3f4efd --- /dev/null +++ b/tools/sdk/include/esp32/esp_sleep.h @@ -0,0 +1,301 @@ +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include "esp_err.h" +#include "driver/gpio.h" +#include "driver/touch_pad.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Logic function used for EXT1 wakeup mode. + */ +typedef enum { + ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low + ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high +} esp_sleep_ext1_wakeup_mode_t; + +/** + * @brief Power domains which can be powered down in sleep mode + */ +typedef enum { + ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor + ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory + ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory + ESP_PD_DOMAIN_MAX //!< Number of domains +} esp_sleep_pd_domain_t; + +/** + * @brief Power down options + */ +typedef enum { + ESP_PD_OPTION_OFF, //!< Power down the power domain in sleep mode + ESP_PD_OPTION_ON, //!< Keep power domain enabled during sleep mode + ESP_PD_OPTION_AUTO //!< Keep power domain enabled in sleep mode, if it is needed by one of the wakeup options. Otherwise power it down. +} esp_sleep_pd_option_t; + +/** + * @brief Sleep wakeup cause + */ +typedef enum { + ESP_SLEEP_WAKEUP_UNDEFINED, //! In case of deep sleep, reset was not caused by exit from deep sleep + ESP_SLEEP_WAKEUP_EXT0, //! Wakeup caused by external signal using RTC_IO + ESP_SLEEP_WAKEUP_EXT1, //! Wakeup caused by external signal using RTC_CNTL + ESP_SLEEP_WAKEUP_TIMER, //! Wakeup caused by timer + ESP_SLEEP_WAKEUP_TOUCHPAD, //! Wakeup caused by touchpad + ESP_SLEEP_WAKEUP_ULP, //! Wakeup caused by ULP program +} esp_sleep_wakeup_cause_t; + + +/** + * @brief Enable wakeup by ULP coprocessor + * @note In revisions 0 and 1 of the ESP32, ULP wakeup source + * can not be used when RTC_PERIPH power domain is forced + * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup + * source is used. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict + */ +esp_err_t esp_sleep_enable_ulp_wakeup(); + +/** + * @brief Enable wakeup by timer + * @param time_in_us time before wakeup, in microseconds + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if value is out of range (TBD) + */ +esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us); + +/** + * @brief Enable wakeup by touch sensor + * + * @note In revisions 0 and 1 of the ESP32, touch wakeup source + * can not be used when RTC_PERIPH power domain is forced + * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup + * source is used. + * + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if wakeup triggers conflict + */ +esp_err_t esp_sleep_enable_touchpad_wakeup(); + +/** + * @brief Get the touch pad which caused wakeup + * + * If wakeup was caused by another source, this function will return TOUCH_PAD_MAX; + * + * @return touch pad which caused wakeup + */ +touch_pad_t esp_sleep_get_touchpad_wakeup_status(); + +/** + * @brief Enable wakeup using a pin + * + * This function uses external wakeup feature of RTC_IO peripheral. + * It will work only if RTC peripherals are kept on during sleep. + * + * This feature can monitor any pin which is an RTC IO. Once the pin transitions + * into the state given by level argument, the chip will be woken up. + * + * @note This function does not modify pin configuration. The pin is + * configured in esp_sleep_start, immediately before entering sleep mode. + * + * @note In revisions 0 and 1 of the ESP32, ext0 wakeup source + * can not be used together with touch or ULP wakeup sources. + * + * @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC + * functionality can be used: 0,2,4,12-15,25-27,32-39. + * @param level input level which will trigger wakeup (0=low, 1=high) + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO, + * or the mode is invalid + * - ESP_ERR_INVALID_STATE if wakeup triggers conflict + */ +esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level); + +/** + * @brief Enable wakeup using multiple pins + * + * This function uses external wakeup feature of RTC controller. + * It will work even if RTC peripherals are shut down during sleep. + * + * This feature can monitor any number of pins which are in RTC IOs. + * Once any of the selected pins goes into the state given by mode argument, + * the chip will be woken up. + * + * @note This function does not modify pin configuration. The pins are + * configured in esp_sleep_start, immediately before + * entering sleep mode. + * + * @note internal pullups and pulldowns don't work when RTC peripherals are + * shut down. In this case, external resistors need to be added. + * Alternatively, RTC peripherals (and pullups/pulldowns) may be + * kept enabled using esp_sleep_pd_config function. + * + * @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs + * which are have RTC functionality can be used in this bit map: + * 0,2,4,12-15,25-27,32-39. + * @param mode select logic function used to determine wakeup condition: + * - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low + * - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO, + * or mode is invalid + */ +esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode_t mode); + + +/** + * @brief Get the bit mask of GPIOs which caused wakeup (ext1) + * + * If wakeup was caused by another source, this function will return 0. + * + * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set + */ +uint64_t esp_sleep_get_ext1_wakeup_status(); + +/** + * @brief Set power down mode for an RTC power domain in sleep mode + * + * If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO. + * + * @param domain power domain to configure + * @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO) + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if either of the arguments is out of range + */ +esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, + esp_sleep_pd_option_t option); + +/** + * @brief Enter deep sleep with the configured wakeup options + * + * This function does not return. + */ +void esp_deep_sleep_start() __attribute__((noreturn)); + +/** + * @brief Enter light sleep with the configured wakeup options + * + * @return + * - ESP_OK on success (returned after wakeup) + * - ESP_ERR_INVALID_STATE if WiFi or BT is not stopped + */ +esp_err_t esp_light_sleep_start(); + +/** + * @brief Enter deep-sleep mode + * + * The device will automatically wake up after the deep-sleep time + * Upon waking up, the device calls deep sleep wake stub, and then proceeds + * to load application. + * + * Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup + * followed by a call to esp_deep_sleep_start. + * + * esp_deep_sleep does not shut down WiFi, BT, and higher level protocol + * connections gracefully. + * Make sure relevant WiFi and BT stack functions are called to close any + * connections and deinitialize the peripherals. These include: + * - esp_bluedroid_disable + * - esp_bt_controller_disable + * - esp_wifi_stop + * + * This function does not return. + * + * @param time_in_us deep-sleep time, unit: microsecond + */ +void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); + +/** + * @brief Enter deep-sleep mode + * + * Function has been renamed to esp_deep_sleep. + * This name is deprecated and will be removed in a future version. + * + * @param time_in_us deep-sleep time, unit: microsecond + */ +void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated)); + + +/** + * @brief Get the source which caused wakeup from sleep + * + * @return wakeup cause, or ESP_DEEP_SLEEP_WAKEUP_UNDEFINED if reset happened for reason other than deep sleep wakeup + */ +esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(); + + +/** + * @brief Default stub to run on wake from deep sleep. + * + * Allows for executing code immediately on wake from sleep, before + * the software bootloader or ESP-IDF app has started up. + * + * This function is weak-linked, so you can implement your own version + * to run code immediately when the chip wakes from + * sleep. + * + * See docs/deep-sleep-stub.rst for details. + */ +void esp_wake_deep_sleep(void); + +/** + * @brief Function type for stub to run on wake from sleep. + * + */ +typedef void (*esp_deep_sleep_wake_stub_fn_t)(void); + +/** + * @brief Install a new stub at runtime to run on wake from deep sleep + * + * If implementing esp_wake_deep_sleep() then it is not necessary to + * call this function. + * + * However, it is possible to call this function to substitute a + * different deep sleep stub. Any function used as a deep sleep stub + * must be marked RTC_IRAM_ATTR, and must obey the same rules given + * for esp_wake_deep_sleep(). + */ +void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub); + +/** + * @brief Get current wake from deep sleep stub + * @return Return current wake from deep sleep stub, or NULL if + * no stub is installed. + */ +esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void); + +/** + * @brief The default esp-idf-provided esp_wake_deep_sleep() stub. + * + * See docs/deep-sleep-stub.rst for details. + */ +void esp_default_wake_deep_sleep(void); + + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/include/esp32/esp_spiram.h b/tools/sdk/include/esp32/esp_spiram.h new file mode 100644 index 00000000..2eb9c08e --- /dev/null +++ b/tools/sdk/include/esp32/esp_spiram.h @@ -0,0 +1,61 @@ +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +#ifndef __ESP_SPIRAM_H +#define __ESP_SPIRAM_H + +#include +#include +#include "esp_err.h" + +/** + * @brief Initialize spiram interface/hardware. Normally called from cpu_start.c. + * + * @return ESP_OK on success + */ +esp_err_t esp_spiram_init(); + + +/** + * @brief Memory test for SPI RAM. Should be called after SPI RAM is initialized and + * (in case of a dual-core system) the app CPU is online. This test overwrites the + * memory with crap, so do not call after e.g. the heap allocator has stored important + * stuff in SPI RAM. + * + * @return true on success, false on failed memory test + */ +bool esp_spiram_test(); + + +/** + * @brief Get the size of the attached SPI RAM chip selected in menuconfig + * + * @return Size in bytes, or 0 if no external RAM chip support compiled in. + */ +size_t esp_spiram_get_size(); + + +/** + * @brief Force a writeback of the data in the SPI RAM cache. This is to be called whenever + * cache is disabled, because disabling cache on the ESP32 discards the data in the SPI + * RAM cache. + * + * This is meant for use from within the SPI flash code. + */ +void esp_spiram_writeback_cache(); + + + +#endif \ No newline at end of file diff --git a/tools/sdk/include/esp32/esp_system.h b/tools/sdk/include/esp32/esp_system.h index 3921dfb8..0d57d84d 100644 --- a/tools/sdk/include/esp32/esp_system.h +++ b/tools/sdk/include/esp32/esp_system.h @@ -18,7 +18,7 @@ #include #include #include "esp_err.h" -#include "esp_deep_sleep.h" +#include "esp_sleep.h" #ifdef __cplusplus extern "C" { @@ -49,6 +49,15 @@ void system_init(void) __attribute__ ((deprecated)); */ void system_restore(void) __attribute__ ((deprecated)); +typedef void (*shutdown_handler_t)(void); +/** + * @brief Register shutdown handler + * + * This function allows you to register a handler that gets invoked before a + * systematic shutdown of the chip. + */ +esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle); + /** * @brief Restart PRO and APP CPUs. * diff --git a/tools/sdk/include/esp32/esp_task.h b/tools/sdk/include/esp32/esp_task.h index aa694d3a..f90e14a0 100644 --- a/tools/sdk/include/esp32/esp_task.h +++ b/tools/sdk/include/esp32/esp_task.h @@ -43,6 +43,8 @@ /* idf task */ +#define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3) +#define ESP_TASK_TIMER_STACK CONFIG_TIMER_TASK_STACK_SIZE #define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5) #define ESP_TASKD_EVENT_STACK CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE #define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7) diff --git a/tools/sdk/include/esp32/esp_wifi.h b/tools/sdk/include/esp32/esp_wifi.h index b6450c7f..7bfa9637 100755 --- a/tools/sdk/include/esp32/esp_wifi.h +++ b/tools/sdk/include/esp32/esp_wifi.h @@ -144,7 +144,15 @@ typedef struct { extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F -#ifdef CONFIG_WIFI_ENABLED + +#ifdef CONFIG_ESP32_WIFI_AMPDU_ENABLED +#define WIFI_DEFAULT_TX_BA_WIN CONFIG_ESP32_WIFI_TX_BA_WIN +#define WIFI_DEFAULT_RX_BA_WIN CONFIG_ESP32_WIFI_RX_BA_WIN +#else +#define WIFI_DEFAULT_TX_BA_WIN 0 /* unused if ampdu_enable == false */ +#define WIFI_DEFAULT_RX_BA_WIN 0 +#endif + #define WIFI_INIT_CONFIG_DEFAULT() { \ .event_handler = &esp_event_send, \ .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \ @@ -156,13 +164,10 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; .ampdu_enable = WIFI_AMPDU_ENABLED,\ .nvs_enable = WIFI_NVS_ENABLED,\ .nano_enable = WIFI_NANO_FORMAT_ENABLED,\ - .tx_ba_win = CONFIG_ESP32_WIFI_TX_BA_WIN,\ - .rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\ + .tx_ba_win = WIFI_DEFAULT_TX_BA_WIN,\ + .rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\ .magic = WIFI_INIT_CONFIG_MAGIC\ }; -#else -#define WIFI_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable wifi in menuconfig to use esp_wifi.h"); -#endif /** * @brief Init WiFi diff --git a/tools/sdk/include/esp32/esp_wifi_internal.h b/tools/sdk/include/esp32/esp_wifi_internal.h index 09813bfa..6627636d 100644 --- a/tools/sdk/include/esp32/esp_wifi_internal.h +++ b/tools/sdk/include/esp32/esp_wifi_internal.h @@ -40,6 +40,26 @@ extern "C" { #endif +/** + * @brief Initialize Wi-Fi Driver + * Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer, + * WiFi NVS structure among others. + * + * For the most part, you need not call this function directly. It gets called + * from esp_wifi_init(). + * + * This function may be called, if you only need to initialize the Wi-Fi driver + * without having to use the network stack on top. + * + * @param config provide WiFi init configuration + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NO_MEM: out of memory + * - others: refer to error code esp_err.h + */ +esp_err_t esp_wifi_init_internal(wifi_init_config_t *config); + /** * @brief get whether the wifi driver is allowed to transmit data or not * diff --git a/tools/sdk/include/esp32/hwcrypto/aes.h b/tools/sdk/include/esp32/hwcrypto/aes.h index b6a632af..0bcd1f49 100644 --- a/tools/sdk/include/esp32/hwcrypto/aes.h +++ b/tools/sdk/include/esp32/hwcrypto/aes.h @@ -38,11 +38,6 @@ extern "C" { #define ERR_ESP_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ #define ERR_ESP_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ -typedef struct { - enum AES_BITS aesbits; - uint8_t key[32]; -} key_context, KEY_CTX; - /** * \brief AES context structure * @@ -52,10 +47,8 @@ typedef struct { * generating an extra round key */ typedef struct { - int nr; /*!< number of rounds */ - uint32_t *rk; /*!< AES round keys */ - KEY_CTX enc; - KEY_CTX dec; + uint8_t key_bytes; + uint8_t key[32]; } esp_aes_context; /** @@ -94,7 +87,7 @@ void esp_aes_init( esp_aes_context *ctx ); void esp_aes_free( esp_aes_context *ctx ); /** - * \brief AES key schedule (encryption) + * \brief AES set key schedule (encryption or decryption) * * \param ctx AES context to be initialized * \param key encryption key @@ -102,18 +95,7 @@ void esp_aes_free( esp_aes_context *ctx ); * * \return 0 if successful, or ERR_AES_INVALID_KEY_LENGTH */ -int esp_aes_setkey_enc( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits ); - -/** - * \brief AES key schedule (decryption) - * - * \param ctx AES context to be initialized - * \param key decryption key - * \param keybits must be 128, 192 or 256 - * - * \return 0 if successful, or ERR_AES_INVALID_KEY_LENGTH - */ -int esp_aes_setkey_dec( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits ); +int esp_aes_setkey( esp_aes_context *ctx, const unsigned char *key, unsigned int keybits ); /** * \brief AES-ECB block encryption/decryption diff --git a/tools/sdk/include/esp32/rom/uart.h b/tools/sdk/include/esp32/rom/uart.h index 81fa26c2..8f075392 100644 --- a/tools/sdk/include/esp32/rom/uart.h +++ b/tools/sdk/include/esp32/rom/uart.h @@ -267,7 +267,7 @@ void uart_tx_flush(uint8_t uart_no); * The function defined in ROM code has a bug, so we define the correct version * here for compatibility. */ -static inline void uart_tx_wait_idle(uint8_t uart_no) { +static inline void IRAM_ATTR uart_tx_wait_idle(uint8_t uart_no) { while(REG_GET_FIELD(UART_STATUS_REG(uart_no), UART_ST_UTX_OUT)) { ; } diff --git a/tools/sdk/include/esp_adc_cal/esp_adc_cal.h b/tools/sdk/include/esp_adc_cal/esp_adc_cal.h new file mode 100644 index 00000000..4a2d06a9 --- /dev/null +++ b/tools/sdk/include/esp_adc_cal/esp_adc_cal.h @@ -0,0 +1,153 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef __ESP_ADC_CAL_H__ +#define __ESP_ADC_CAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "driver/adc.h" + +/** @cond */ +#define ADC_CAL_GAIN_SCALE 16 +#define ADC_CAL_OFFSET_SCALE 10 + +#define ADC_CAL_IDEAL_V_REF 1100 //In mV +#define ADC_CAL_LOW_V_REF 1000 +#define ADC_CAL_HIGH_V_REF 1200 +#define ADC_CAL_MIN 0 +#define ADC_CAL_MAX 4095 +/** @endcond */ + +/** + * @brief Structure storing Lookup Table + * + * The Lookup Tables (LUT) of a given attenuation contains 33 equally spaced + * points. The Gain and Offset curves are used to find the appopriate gain and + * offset factor given a reference voltage v_ref. + * + * @note A seperate LUT is provided for each attenuation and are defined in + * esp_adc_cal_lookup_tables.c + */ +typedef struct { + uint32_t gain_m; /**= ESP_LOG_ERROR) { ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +/// macro to output logs in startup code at ``ESP_LOG_WARN`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` #define ESP_EARLY_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { ets_printf(LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +/// macro to output logs in startup code at ``ESP_LOG_INFO`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` #define ESP_EARLY_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { ets_printf(LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +/// macro to output logs in startup code at ``ESP_LOG_DEBUG`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` #define ESP_EARLY_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { ets_printf(LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +/// macro to output logs in startup code at ``ESP_LOG_VERBOSE`` level. @see ``ESP_EARLY_LOGE``,``ESP_LOGE``, ``printf`` #define ESP_EARLY_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { ets_printf(LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } #ifndef BOOTLOADER_BUILD @@ -167,10 +172,21 @@ void esp_log_buffer_char(const char *tag, const void *buffer, uint16_t buff_len) #define ESP_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } #define ESP_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } #else +/** + * macro to output logs at ESP_LOG_ERROR level. + * + * @param tag tag of the log, which can be used to change the log level by ``esp_log_level_set`` at runtime. + * + * @see ``printf`` + */ #define ESP_LOGE( tag, format, ... ) ESP_EARLY_LOGE(tag, format, ##__VA_ARGS__) +/// macro to output logs at ``ESP_LOG_WARN`` level. @see ``ESP_LOGE`` #define ESP_LOGW( tag, format, ... ) ESP_EARLY_LOGW(tag, format, ##__VA_ARGS__) +/// macro to output logs at ``ESP_LOG_INFO`` level. @see ``ESP_LOGE`` #define ESP_LOGI( tag, format, ... ) ESP_EARLY_LOGI(tag, format, ##__VA_ARGS__) +/// macro to output logs at ``ESP_LOG_DEBUG`` level. @see ``ESP_LOGE`` #define ESP_LOGD( tag, format, ... ) ESP_EARLY_LOGD(tag, format, ##__VA_ARGS__) +/// macro to output logs at ``ESP_LOG_VERBOSE`` level. @see ``ESP_LOGE`` #define ESP_LOGV( tag, format, ... ) ESP_EARLY_LOGV(tag, format, ##__VA_ARGS__) #endif // BOOTLOADER_BUILD diff --git a/tools/sdk/include/lwip/arch/sys_arch.h b/tools/sdk/include/lwip/arch/sys_arch.h index 8d30ef17..716fd9fa 100644 --- a/tools/sdk/include/lwip/arch/sys_arch.h +++ b/tools/sdk/include/lwip/arch/sys_arch.h @@ -67,7 +67,6 @@ typedef struct sys_mbox_s { #define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) #define sys_sem_set_invalid( x ) ( ( *x ) = NULL ) -uint32_t system_get_time(void); void sys_delay_ms(uint32_t ms); sys_sem_t* sys_thread_sem_init(void); void sys_thread_sem_deinit(void); diff --git a/tools/sdk/include/lwip/lwipopts.h b/tools/sdk/include/lwip/lwipopts.h index 61a99382..7bc4021e 100644 --- a/tools/sdk/include/lwip/lwipopts.h +++ b/tools/sdk/include/lwip/lwipopts.h @@ -37,6 +37,7 @@ #include #include #include "esp_task.h" +#include "esp_system.h" #include "sdkconfig.h" /* Enable all Espressif-only options */ @@ -65,7 +66,7 @@ */ #define SMEMCPY(dst,src,len) memcpy(dst,src,len) -#define LWIP_RAND rand +#define LWIP_RAND esp_random /* ------------------------------------ @@ -294,6 +295,11 @@ */ #define TCP_MSS CONFIG_TCP_MSS +/** + * TCP_MSL: The maximum segment lifetime in milliseconds + */ +#define TCP_MSL CONFIG_TCP_MSL + /** * TCP_MAXRTX: Maximum number of retransmissions of data segments. */ diff --git a/tools/sdk/include/lwip/port/arch/sys_arch.h b/tools/sdk/include/lwip/port/arch/sys_arch.h index 8d30ef17..716fd9fa 100644 --- a/tools/sdk/include/lwip/port/arch/sys_arch.h +++ b/tools/sdk/include/lwip/port/arch/sys_arch.h @@ -67,7 +67,6 @@ typedef struct sys_mbox_s { #define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE ) #define sys_sem_set_invalid( x ) ( ( *x ) = NULL ) -uint32_t system_get_time(void); void sys_delay_ms(uint32_t ms); sys_sem_t* sys_thread_sem_init(void); void sys_thread_sem_deinit(void); diff --git a/tools/sdk/include/lwip/port/lwipopts.h b/tools/sdk/include/lwip/port/lwipopts.h index 61a99382..7bc4021e 100644 --- a/tools/sdk/include/lwip/port/lwipopts.h +++ b/tools/sdk/include/lwip/port/lwipopts.h @@ -37,6 +37,7 @@ #include #include #include "esp_task.h" +#include "esp_system.h" #include "sdkconfig.h" /* Enable all Espressif-only options */ @@ -65,7 +66,7 @@ */ #define SMEMCPY(dst,src,len) memcpy(dst,src,len) -#define LWIP_RAND rand +#define LWIP_RAND esp_random /* ------------------------------------ @@ -294,6 +295,11 @@ */ #define TCP_MSS CONFIG_TCP_MSS +/** + * TCP_MSL: The maximum segment lifetime in milliseconds + */ +#define TCP_MSL CONFIG_TCP_MSL + /** * TCP_MAXRTX: Maximum number of retransmissions of data segments. */ diff --git a/tools/sdk/include/mbedtls/mbedtls/aes.h b/tools/sdk/include/mbedtls/mbedtls/aes.h index a36e825a..1829f724 100644 --- a/tools/sdk/include/mbedtls/mbedtls/aes.h +++ b/tools/sdk/include/mbedtls/mbedtls/aes.h @@ -39,6 +39,11 @@ #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + #if !defined(MBEDTLS_AES_ALT) // Regular implementation // @@ -253,10 +258,12 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, * \param ctx AES context * \param input Plaintext block * \param output Output (ciphertext) block + * + * \return 0 if successful */ -void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, - const unsigned char input[16], - unsigned char output[16] ); +int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); /** * \brief Internal AES block decryption function @@ -266,10 +273,49 @@ void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, * \param ctx AES context * \param input Ciphertext block * \param output Output (plaintext) block + * + * \return 0 if successful */ -void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, - const unsigned char input[16], - unsigned char output[16] ); +int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); + +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif +/** + * \brief Deprecated internal AES block encryption function + * without return value. + * + * \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0 + * + * \param ctx AES context + * \param input Plaintext block + * \param output Output (ciphertext) block + */ +MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); + +/** + * \brief Deprecated internal AES block decryption function + * without return value. + * + * \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0 + * + * \param ctx AES context + * \param input Ciphertext block + * \param output Output (plaintext) block + */ +MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, + const unsigned char input[16], + unsigned char output[16] ); + +#undef MBEDTLS_DEPRECATED +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ #ifdef __cplusplus } diff --git a/tools/sdk/include/mbedtls/mbedtls/bignum.h b/tools/sdk/include/mbedtls/mbedtls/bignum.h index 46f25076..2e021c9b 100644 --- a/tools/sdk/include/mbedtls/mbedtls/bignum.h +++ b/tools/sdk/include/mbedtls/mbedtls/bignum.h @@ -105,36 +105,71 @@ /* * Define the base integer type, architecture-wise. * - * 32-bit integers can be forced on 64-bit arches (eg. for testing purposes) - * by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM + * 32 or 64-bit integer types can be forced regardless of the underlying + * architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64 + * respectively and undefining MBEDTLS_HAVE_ASM. + * + * Double-width integers (e.g. 128-bit in 64-bit architectures) can be + * disabled by defining MBEDTLS_NO_UDBL_DIVISION. */ -#if ( ! defined(MBEDTLS_HAVE_INT32) && \ - defined(_MSC_VER) && defined(_M_AMD64) ) - #define MBEDTLS_HAVE_INT64 - typedef int64_t mbedtls_mpi_sint; - typedef uint64_t mbedtls_mpi_uint; -#else - #if ( ! defined(MBEDTLS_HAVE_INT32) && \ - defined(__GNUC__) && ( \ - defined(__amd64__) || defined(__x86_64__) || \ - defined(__ppc64__) || defined(__powerpc64__) || \ - defined(__ia64__) || defined(__alpha__) || \ - (defined(__sparc__) && defined(__arch64__)) || \ - defined(__s390x__) || defined(__mips64) ) ) - #define MBEDTLS_HAVE_INT64 - typedef int64_t mbedtls_mpi_sint; - typedef uint64_t mbedtls_mpi_uint; - /* mbedtls_t_udbl defined as 128-bit unsigned int */ - typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI))); - #define MBEDTLS_HAVE_UDBL - #else - #define MBEDTLS_HAVE_INT32 - typedef int32_t mbedtls_mpi_sint; - typedef uint32_t mbedtls_mpi_uint; - typedef uint64_t mbedtls_t_udbl; - #define MBEDTLS_HAVE_UDBL - #endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */ -#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */ +#if !defined(MBEDTLS_HAVE_INT32) + #if defined(_MSC_VER) && defined(_M_AMD64) + /* Always choose 64-bit when using MSC */ + #if !defined(MBEDTLS_HAVE_INT64) + #define MBEDTLS_HAVE_INT64 + #endif /* !MBEDTLS_HAVE_INT64 */ + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; + #elif defined(__GNUC__) && ( \ + defined(__amd64__) || defined(__x86_64__) || \ + defined(__ppc64__) || defined(__powerpc64__) || \ + defined(__ia64__) || defined(__alpha__) || \ + ( defined(__sparc__) && defined(__arch64__) ) || \ + defined(__s390x__) || defined(__mips64) ) + #if !defined(MBEDTLS_HAVE_INT64) + #define MBEDTLS_HAVE_INT64 + #endif /* MBEDTLS_HAVE_INT64 */ + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; + #if !defined(MBEDTLS_NO_UDBL_DIVISION) + /* mbedtls_t_udbl defined as 128-bit unsigned int */ + typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI))); + #define MBEDTLS_HAVE_UDBL + #endif /* !MBEDTLS_NO_UDBL_DIVISION */ + #elif defined(__ARMCC_VERSION) && defined(__aarch64__) + /* + * __ARMCC_VERSION is defined for both armcc and armclang and + * __aarch64__ is only defined by armclang when compiling 64-bit code + */ + #if !defined(MBEDTLS_HAVE_INT64) + #define MBEDTLS_HAVE_INT64 + #endif /* !MBEDTLS_HAVE_INT64 */ + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; + #if !defined(MBEDTLS_NO_UDBL_DIVISION) + /* mbedtls_t_udbl defined as 128-bit unsigned int */ + typedef __uint128_t mbedtls_t_udbl; + #define MBEDTLS_HAVE_UDBL + #endif /* !MBEDTLS_NO_UDBL_DIVISION */ + #elif defined(MBEDTLS_HAVE_INT64) + /* Force 64-bit integers with unknown compiler */ + typedef int64_t mbedtls_mpi_sint; + typedef uint64_t mbedtls_mpi_uint; + #endif +#endif /* !MBEDTLS_HAVE_INT32 */ + +#if !defined(MBEDTLS_HAVE_INT64) + /* Default to 32-bit compilation */ + #if !defined(MBEDTLS_HAVE_INT32) + #define MBEDTLS_HAVE_INT32 + #endif /* !MBEDTLS_HAVE_INT32 */ + typedef int32_t mbedtls_mpi_sint; + typedef uint32_t mbedtls_mpi_uint; + #if !defined(MBEDTLS_NO_UDBL_DIVISION) + typedef uint64_t mbedtls_t_udbl; + #define MBEDTLS_HAVE_UDBL + #endif /* !MBEDTLS_NO_UDBL_DIVISION */ +#endif /* !MBEDTLS_HAVE_INT64 */ #ifdef __cplusplus extern "C" { @@ -342,7 +377,7 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, #if defined(MBEDTLS_FS_IO) /** - * \brief Read X from an opened file + * \brief Read MPI from a line in an opened file * * \param X Destination MPI * \param radix Input numeric base @@ -351,6 +386,15 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, * \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if * the file read buffer is too small or a * MBEDTLS_ERR_MPI_XXX error code + * + * \note On success, this function advances the file stream + * to the end of the current line or to EOF. + * + * The function returns 0 on an empty line. + * + * Leading whitespaces are ignored, as is a + * '0x' prefix for radix 16. + * */ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ); @@ -667,8 +711,8 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B * * \return 0 if successful, * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or nil - MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N + * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1, + MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N. */ int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ); diff --git a/tools/sdk/include/mbedtls/mbedtls/check_config.h b/tools/sdk/include/mbedtls/mbedtls/check_config.h index a95af6ca..fa72454e 100644 --- a/tools/sdk/include/mbedtls/mbedtls/check_config.h +++ b/tools/sdk/include/mbedtls/mbedtls/check_config.h @@ -77,6 +77,11 @@ #error "MBEDTLS_DHM_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_CMAC_C) && \ + !defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C) +#error "MBEDTLS_CMAC_C defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) #error "MBEDTLS_ECDH_C defined, but not all prerequisites" #endif @@ -145,6 +150,38 @@ #error "MBEDTLS_GCM_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT) +#error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C) #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" #endif @@ -256,6 +293,36 @@ #error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously" #endif +#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ + ( !defined(MBEDTLS_PLATFORM_C) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ + defined(MBEDTLS_PLATFORM_TIME_ALT) ) +#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" +#endif + +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\ + ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\ + defined(MBEDTLS_PLATFORM_TIME_ALT) ) +#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously" +#endif + #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C) #error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites" #endif @@ -352,6 +419,12 @@ #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites" #endif +#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\ + ( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\ + !defined(MBEDTLS_HAVE_TIME) ) +#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\ !defined(MBEDTLS_PLATFORM_FPRINTF_ALT) #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites" @@ -577,6 +650,15 @@ #error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64) +#error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously" +#endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */ + +#if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \ + defined(MBEDTLS_HAVE_ASM) +#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously" +#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */ + /* * Avoid warning from -pedantic. This is a convenient place for this * workaround since this is included by every single file before the diff --git a/tools/sdk/include/mbedtls/mbedtls/cipher.h b/tools/sdk/include/mbedtls/mbedtls/cipher.h index c9675544..b12e3884 100644 --- a/tools/sdk/include/mbedtls/mbedtls/cipher.h +++ b/tools/sdk/include/mbedtls/mbedtls/cipher.h @@ -176,6 +176,11 @@ enum { */ typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t; +/** + * CMAC context (opaque struct). + */ +typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t; + /** * Cipher information. Allows cipher functions to be called in a generic way. */ @@ -241,6 +246,11 @@ typedef struct { /** Cipher-specific context */ void *cipher_ctx; + +#if defined(MBEDTLS_CMAC_C) + /** CMAC Specific context */ + mbedtls_cmac_context_t *cmac_ctx; +#endif } mbedtls_cipher_context_t; /** diff --git a/tools/sdk/include/mbedtls/mbedtls/cmac.h b/tools/sdk/include/mbedtls/mbedtls/cmac.h new file mode 100644 index 00000000..9a2b96bc --- /dev/null +++ b/tools/sdk/include/mbedtls/mbedtls/cmac.h @@ -0,0 +1,170 @@ +/** + * \file cmac.h + * + * \brief Cipher-based Message Authentication Code (CMAC) Mode for + * Authentication + * + * Copyright (C) 2015-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_CMAC_H +#define MBEDTLS_CMAC_H + +#include "mbedtls/cipher.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MBEDTLS_AES_BLOCK_SIZE 16 +#define MBEDTLS_DES3_BLOCK_SIZE 8 + +#if defined(MBEDTLS_AES_C) +#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* longest used by CMAC is AES */ +#else +#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* longest used by CMAC is 3DES */ +#endif + +/** + * CMAC context structure - Contains internal state information only + */ +struct mbedtls_cmac_context_t +{ + /** Internal state of the CMAC algorithm */ + unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + /** Unprocessed data - either data that was not block aligned and is still + * pending to be processed, or the final block */ + unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX]; + + /** Length of data pending to be processed */ + size_t unprocessed_len; +}; + +/** + * \brief Set the CMAC key and prepare to authenticate the input + * data. + * Should be called with an initialized cipher context. + * + * \param ctx Cipher context. This should be a cipher context, + * initialized to be one of the following types: + * MBEDTLS_CIPHER_AES_128_ECB, MBEDTLS_CIPHER_AES_192_ECB, + * MBEDTLS_CIPHER_AES_256_ECB or + * MBEDTLS_CIPHER_DES_EDE3_ECB. + * \param key CMAC key + * \param keybits length of the CMAC key in bits + * (must be acceptable by the cipher) + * + * \return 0 if successful, or a cipher specific error code + */ +int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, + const unsigned char *key, size_t keybits ); + +/** + * \brief Generic CMAC process buffer. + * Called between mbedtls_cipher_cmac_starts() or + * mbedtls_cipher_cmac_reset() and + * mbedtls_cipher_cmac_finish(). + * May be called repeatedly. + * + * \param ctx CMAC context + * \param input buffer holding the data + * \param ilen length of the input data + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, + const unsigned char *input, size_t ilen ); + +/** + * \brief Output CMAC. + * Called after mbedtls_cipher_cmac_update(). + * Usually followed by mbedtls_cipher_cmac_reset(), then + * mbedtls_cipher_cmac_starts(), or mbedtls_cipher_free(). + * + * \param ctx CMAC context + * \param output Generic CMAC checksum result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, + unsigned char *output ); + +/** + * \brief Prepare to authenticate a new message with the same key. + * Called after mbedtls_cipher_cmac_finish() and before + * mbedtls_cipher_cmac_update(). + * + * \param ctx CMAC context to be reset + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ); + +/** + * \brief Output = Generic_CMAC( cmac key, input buffer ) + * + * \param cipher_info message digest info + * \param key CMAC key + * \param keylen length of the CMAC key in bits + * \param input buffer holding the data + * \param ilen length of the input data + * \param output Generic CMAC-result + * + * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter + * verification fails. + */ +int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, + const unsigned char *key, size_t keylen, + const unsigned char *input, size_t ilen, + unsigned char *output ); + +#if defined(MBEDTLS_AES_C) +/** + * \brief AES-CMAC-128-PRF + * Implementation of (AES-CMAC-PRF-128), as defined in RFC 4615 + * + * \param key PRF key + * \param key_len PRF key length in bytes + * \param input buffer holding the input data + * \param in_len length of the input data in bytes + * \param output buffer holding the generated pseudorandom output (16 bytes) + * + * \return 0 if successful + */ +int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len, + const unsigned char *input, size_t in_len, + unsigned char output[16] ); +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) ) +/** + * \brief Checkup routine + * + * \return 0 if successful, or 1 if the test failed + */ +int mbedtls_cmac_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CMAC_H */ diff --git a/tools/sdk/include/mbedtls/mbedtls/compat-1.3.h b/tools/sdk/include/mbedtls/mbedtls/compat-1.3.h index 27abbd97..bba1d2c2 100644 --- a/tools/sdk/include/mbedtls/mbedtls/compat-1.3.h +++ b/tools/sdk/include/mbedtls/mbedtls/compat-1.3.h @@ -207,9 +207,6 @@ #if defined MBEDTLS_ERROR_C #define POLARSSL_ERROR_C MBEDTLS_ERROR_C #endif -#if defined MBEDTLS_ERROR_STRERROR_BC -#define POLARSSL_ERROR_STRERROR_BC MBEDTLS_ERROR_STRERROR_BC -#endif #if defined MBEDTLS_ERROR_STRERROR_DUMMY #define POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY #endif @@ -318,9 +315,6 @@ #if defined MBEDTLS_MEMORY_BUFFER_ALLOC_C #define POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C #endif -#if defined MBEDTLS_MEMORY_C -#define POLARSSL_MEMORY_C MBEDTLS_MEMORY_C -#endif #if defined MBEDTLS_MEMORY_DEBUG #define POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG #endif @@ -345,9 +339,6 @@ #if defined MBEDTLS_PADLOCK_C #define POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C #endif -#if defined MBEDTLS_PBKDF2_C -#define POLARSSL_PBKDF2_C MBEDTLS_PBKDF2_C -#endif #if defined MBEDTLS_PEM_PARSE_C #define POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C #endif @@ -429,9 +420,6 @@ #if defined MBEDTLS_PLATFORM_STD_FREE #define POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE #endif -#if defined MBEDTLS_PLATFORM_STD_MALLOC -#define POLARSSL_PLATFORM_STD_MALLOC MBEDTLS_PLATFORM_STD_MALLOC -#endif #if defined MBEDTLS_PLATFORM_STD_MEM_HDR #define POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR #endif @@ -492,12 +480,6 @@ #if defined MBEDTLS_SHA512_PROCESS_ALT #define POLARSSL_SHA512_PROCESS_ALT MBEDTLS_SHA512_PROCESS_ALT #endif -#if defined MBEDTLS_SSL_AEAD_RANDOM_IV -#define POLARSSL_SSL_AEAD_RANDOM_IV MBEDTLS_SSL_AEAD_RANDOM_IV -#endif -#if defined MBEDTLS_SSL_ALERT_MESSAGES -#define POLARSSL_SSL_ALERT_MESSAGES MBEDTLS_SSL_ALERT_MESSAGES -#endif #if defined MBEDTLS_SSL_ALL_ALERT_MESSAGES #define POLARSSL_SSL_ALL_ALERT_MESSAGES MBEDTLS_SSL_ALL_ALERT_MESSAGES #endif @@ -522,9 +504,6 @@ #if defined MBEDTLS_SSL_DEBUG_ALL #define POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL #endif -#if defined MBEDTLS_SSL_DISABLE_RENEGOTIATION -#define POLARSSL_SSL_DISABLE_RENEGOTIATION MBEDTLS_SSL_DISABLE_RENEGOTIATION -#endif #if defined MBEDTLS_SSL_DTLS_ANTI_REPLAY #define POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY #endif @@ -752,7 +731,6 @@ #define KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT #define KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION #define LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100 -#define MD_CONTEXT_T_INIT MBEDTLS_MD_CONTEXT_T_INIT #define MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC #define MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS #define MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE @@ -1017,19 +995,13 @@ #define POLARSSL_CONFIG_H MBEDTLS_CONFIG_H #define POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H #define POLARSSL_DEBUG_H MBEDTLS_DEBUG_H -#define POLARSSL_DEBUG_LOG_FULL MBEDTLS_DEBUG_LOG_FULL -#define POLARSSL_DEBUG_LOG_RAW MBEDTLS_DEBUG_LOG_RAW #define POLARSSL_DECRYPT MBEDTLS_DECRYPT #define POLARSSL_DES_H MBEDTLS_DES_H #define POLARSSL_DHM_H MBEDTLS_DHM_H -#define POLARSSL_DHM_RFC2409_MODP_1024_G MBEDTLS_DHM_RFC2409_MODP_1024_G -#define POLARSSL_DHM_RFC2409_MODP_1024_P MBEDTLS_DHM_RFC2409_MODP_1024_P #define POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G #define POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P #define POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G #define POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P -#define POLARSSL_DHM_RFC5114_MODP_1024_G MBEDTLS_DHM_RFC5114_MODP_1024_G -#define POLARSSL_DHM_RFC5114_MODP_1024_P MBEDTLS_DHM_RFC5114_MODP_1024_P #define POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G #define POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P #define POLARSSL_ECDH_H MBEDTLS_ECDH_H @@ -1117,9 +1089,6 @@ #define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR #define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG #define POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG -#define POLARSSL_ERR_MD2_FILE_IO_ERROR MBEDTLS_ERR_MD2_FILE_IO_ERROR -#define POLARSSL_ERR_MD4_FILE_IO_ERROR MBEDTLS_ERR_MD4_FILE_IO_ERROR -#define POLARSSL_ERR_MD5_FILE_IO_ERROR MBEDTLS_ERR_MD5_FILE_IO_ERROR #define POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED #define POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE @@ -1147,7 +1116,6 @@ #define POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL #define POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND #define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA MBEDTLS_ERR_PBKDF2_BAD_INPUT_DATA #define POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA #define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE #define POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA @@ -1179,7 +1147,6 @@ #define POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH #define POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE #define POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -#define POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR #define POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA #define POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING #define POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED @@ -1189,9 +1156,6 @@ #define POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED #define POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED #define POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED -#define POLARSSL_ERR_SHA1_FILE_IO_ERROR MBEDTLS_ERR_SHA1_FILE_IO_ERROR -#define POLARSSL_ERR_SHA256_FILE_IO_ERROR MBEDTLS_ERR_SHA256_FILE_IO_ERROR -#define POLARSSL_ERR_SHA512_FILE_IO_ERROR MBEDTLS_ERR_SHA512_FILE_IO_ERROR #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY @@ -1305,7 +1269,6 @@ #define POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512 #define POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H #define POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H -#define POLARSSL_MEMORY_H MBEDTLS_MEMORY_H #define POLARSSL_MODE_CBC MBEDTLS_MODE_CBC #define POLARSSL_MODE_CCM MBEDTLS_MODE_CCM #define POLARSSL_MODE_CFB MBEDTLS_MODE_CFB @@ -1319,7 +1282,7 @@ #define POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100 #define POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS #define POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE -#define POLARSSL_NET_H MBEDTLS_NET_H +#define POLARSSL_NET_H MBEDTLS_NET_SOCKETS_H #define POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG #define POLARSSL_OID_H MBEDTLS_OID_H #define POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE @@ -1329,7 +1292,6 @@ #define POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS #define POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN #define POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H -#define POLARSSL_PBKDF2_H MBEDTLS_PBKDF2_H #define POLARSSL_PEM_H MBEDTLS_PEM_H #define POLARSSL_PKCS11_H MBEDTLS_PKCS11_H #define POLARSSL_PKCS12_H MBEDTLS_PKCS12_H @@ -1712,7 +1674,6 @@ #define TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256 #define TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 #define TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA -#define UL64 MBEDTLS_UL64 #define X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1 #define X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2 #define X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3 @@ -1736,7 +1697,6 @@ #define _ssl_key_cert mbedtls_ssl_key_cert #define _ssl_premaster_secret mbedtls_ssl_premaster_secret #define _ssl_session mbedtls_ssl_session -#define _ssl_ticket_keys mbedtls_ssl_ticket_keys #define _ssl_transform mbedtls_ssl_transform #define _x509_crl mbedtls_x509_crl #define _x509_crl_entry mbedtls_x509_crl_entry @@ -1836,7 +1796,6 @@ #define cipher_definitions mbedtls_cipher_definitions #define cipher_finish mbedtls_cipher_finish #define cipher_free mbedtls_cipher_free -#define cipher_free_ctx mbedtls_cipher_free_ctx #define cipher_get_block_size mbedtls_cipher_get_block_size #define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode #define cipher_get_iv_size mbedtls_cipher_get_iv_size @@ -1855,7 +1814,6 @@ #define cipher_mode_t mbedtls_cipher_mode_t #define cipher_padding_t mbedtls_cipher_padding_t #define cipher_reset mbedtls_cipher_reset -#define cipher_self_test mbedtls_cipher_self_test #define cipher_set_iv mbedtls_cipher_set_iv #define cipher_set_padding_mode mbedtls_cipher_set_padding_mode #define cipher_setkey mbedtls_cipher_setkey @@ -1866,7 +1824,6 @@ #define ctr_drbg_context mbedtls_ctr_drbg_context #define ctr_drbg_free mbedtls_ctr_drbg_free #define ctr_drbg_init mbedtls_ctr_drbg_init -#define ctr_drbg_init_entropy_len mbedtls_ctr_drbg_init_entropy_len #define ctr_drbg_random mbedtls_ctr_drbg_random #define ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add #define ctr_drbg_reseed mbedtls_ctr_drbg_reseed @@ -1877,14 +1834,12 @@ #define ctr_drbg_update mbedtls_ctr_drbg_update #define ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file #define ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file -#define debug_fmt mbedtls_debug_fmt #define debug_print_buf mbedtls_debug_print_buf #define debug_print_crt mbedtls_debug_print_crt #define debug_print_ecp mbedtls_debug_print_ecp #define debug_print_mpi mbedtls_debug_print_mpi #define debug_print_msg mbedtls_debug_print_msg #define debug_print_ret mbedtls_debug_print_ret -#define debug_set_log_mode mbedtls_debug_set_log_mode #define debug_set_threshold mbedtls_debug_set_threshold #define des3_context mbedtls_des3_context #define des3_crypt_cbc mbedtls_des3_crypt_cbc @@ -1928,7 +1883,6 @@ #define ecdh_make_public mbedtls_ecdh_make_public #define ecdh_read_params mbedtls_ecdh_read_params #define ecdh_read_public mbedtls_ecdh_read_public -#define ecdh_self_test mbedtls_ecdh_self_test #define ecdh_side mbedtls_ecdh_side #define ecdsa_context mbedtls_ecdsa_context #define ecdsa_free mbedtls_ecdsa_free @@ -1937,7 +1891,6 @@ #define ecdsa_info mbedtls_ecdsa_info #define ecdsa_init mbedtls_ecdsa_init #define ecdsa_read_signature mbedtls_ecdsa_read_signature -#define ecdsa_self_test mbedtls_ecdsa_self_test #define ecdsa_sign mbedtls_ecdsa_sign #define ecdsa_sign_det mbedtls_ecdsa_sign_det #define ecdsa_verify mbedtls_ecdsa_verify @@ -1945,7 +1898,6 @@ #define ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det #define eckey_info mbedtls_eckey_info #define eckeydh_info mbedtls_eckeydh_info -#define ecp_add mbedtls_ecp_add #define ecp_check_privkey mbedtls_ecp_check_privkey #define ecp_check_pub_priv mbedtls_ecp_check_pub_priv #define ecp_check_pubkey mbedtls_ecp_check_pubkey @@ -1962,7 +1914,6 @@ #define ecp_group_free mbedtls_ecp_group_free #define ecp_group_id mbedtls_ecp_group_id #define ecp_group_init mbedtls_ecp_group_init -#define ecp_group_read_string mbedtls_ecp_group_read_string #define ecp_grp_id_list mbedtls_ecp_grp_id_list #define ecp_is_zero mbedtls_ecp_is_zero #define ecp_keypair mbedtls_ecp_keypair @@ -1977,7 +1928,6 @@ #define ecp_point_write_binary mbedtls_ecp_point_write_binary #define ecp_self_test mbedtls_ecp_self_test #define ecp_set_zero mbedtls_ecp_set_zero -#define ecp_sub mbedtls_ecp_sub #define ecp_tls_read_group mbedtls_ecp_tls_read_group #define ecp_tls_read_point mbedtls_ecp_tls_read_point #define ecp_tls_write_group mbedtls_ecp_tls_write_group @@ -2015,7 +1965,6 @@ #define hmac_drbg_context mbedtls_hmac_drbg_context #define hmac_drbg_free mbedtls_hmac_drbg_free #define hmac_drbg_init mbedtls_hmac_drbg_init -#define hmac_drbg_init_buf mbedtls_hmac_drbg_init_buf #define hmac_drbg_random mbedtls_hmac_drbg_random #define hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add #define hmac_drbg_reseed mbedtls_hmac_drbg_reseed @@ -2031,14 +1980,8 @@ #define md mbedtls_md #define md2 mbedtls_md2 #define md2_context mbedtls_md2_context -#define md2_file mbedtls_md2_file #define md2_finish mbedtls_md2_finish #define md2_free mbedtls_md2_free -#define md2_hmac mbedtls_md2_hmac -#define md2_hmac_finish mbedtls_md2_hmac_finish -#define md2_hmac_reset mbedtls_md2_hmac_reset -#define md2_hmac_starts mbedtls_md2_hmac_starts -#define md2_hmac_update mbedtls_md2_hmac_update #define md2_info mbedtls_md2_info #define md2_init mbedtls_md2_init #define md2_process mbedtls_md2_process @@ -2047,14 +1990,8 @@ #define md2_update mbedtls_md2_update #define md4 mbedtls_md4 #define md4_context mbedtls_md4_context -#define md4_file mbedtls_md4_file #define md4_finish mbedtls_md4_finish #define md4_free mbedtls_md4_free -#define md4_hmac mbedtls_md4_hmac -#define md4_hmac_finish mbedtls_md4_hmac_finish -#define md4_hmac_reset mbedtls_md4_hmac_reset -#define md4_hmac_starts mbedtls_md4_hmac_starts -#define md4_hmac_update mbedtls_md4_hmac_update #define md4_info mbedtls_md4_info #define md4_init mbedtls_md4_init #define md4_process mbedtls_md4_process @@ -2063,14 +2000,8 @@ #define md4_update mbedtls_md4_update #define md5 mbedtls_md5 #define md5_context mbedtls_md5_context -#define md5_file mbedtls_md5_file #define md5_finish mbedtls_md5_finish #define md5_free mbedtls_md5_free -#define md5_hmac mbedtls_md5_hmac -#define md5_hmac_finish mbedtls_md5_hmac_finish -#define md5_hmac_reset mbedtls_md5_hmac_reset -#define md5_hmac_starts mbedtls_md5_hmac_starts -#define md5_hmac_update mbedtls_md5_hmac_update #define md5_info mbedtls_md5_info #define md5_init mbedtls_md5_init #define md5_process mbedtls_md5_process @@ -2081,7 +2012,6 @@ #define md_file mbedtls_md_file #define md_finish mbedtls_md_finish #define md_free mbedtls_md_free -#define md_free_ctx mbedtls_md_free_ctx #define md_get_name mbedtls_md_get_name #define md_get_size mbedtls_md_get_size #define md_get_type mbedtls_md_get_type @@ -2109,7 +2039,6 @@ #define memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status #define memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify #define memory_buffer_set_verify mbedtls_memory_buffer_set_verify -#define memory_set_own mbedtls_memory_set_own #define mpi mbedtls_mpi #define mpi_add_abs mbedtls_mpi_add_abs #define mpi_add_int mbedtls_mpi_add_int @@ -2185,8 +2114,6 @@ #define padlock_supports mbedtls_padlock_has_support #define padlock_xcryptcbc mbedtls_padlock_xcryptcbc #define padlock_xcryptecb mbedtls_padlock_xcryptecb -#define pbkdf2_hmac mbedtls_pbkdf2_hmac -#define pbkdf2_self_test mbedtls_pbkdf2_self_test #define pem_context mbedtls_pem_context #define pem_free mbedtls_pem_free #define pem_init mbedtls_pem_init @@ -2246,13 +2173,11 @@ #define platform_entropy_poll mbedtls_platform_entropy_poll #define platform_set_exit mbedtls_platform_set_exit #define platform_set_fprintf mbedtls_platform_set_fprintf -#define platform_set_malloc_free mbedtls_platform_set_malloc_free #define platform_set_printf mbedtls_platform_set_printf #define platform_set_snprintf mbedtls_platform_set_snprintf #define polarssl_exit mbedtls_exit #define polarssl_fprintf mbedtls_fprintf #define polarssl_free mbedtls_free -#define polarssl_malloc mbedtls_malloc #define polarssl_mutex_free mbedtls_mutex_free #define polarssl_mutex_init mbedtls_mutex_init #define polarssl_mutex_lock mbedtls_mutex_lock @@ -2262,14 +2187,8 @@ #define polarssl_strerror mbedtls_strerror #define ripemd160 mbedtls_ripemd160 #define ripemd160_context mbedtls_ripemd160_context -#define ripemd160_file mbedtls_ripemd160_file #define ripemd160_finish mbedtls_ripemd160_finish #define ripemd160_free mbedtls_ripemd160_free -#define ripemd160_hmac mbedtls_ripemd160_hmac -#define ripemd160_hmac_finish mbedtls_ripemd160_hmac_finish -#define ripemd160_hmac_reset mbedtls_ripemd160_hmac_reset -#define ripemd160_hmac_starts mbedtls_ripemd160_hmac_starts -#define ripemd160_hmac_update mbedtls_ripemd160_hmac_update #define ripemd160_info mbedtls_ripemd160_info #define ripemd160_init mbedtls_ripemd160_init #define ripemd160_process mbedtls_ripemd160_process @@ -2283,12 +2202,10 @@ #define rsa_check_pubkey mbedtls_rsa_check_pubkey #define rsa_context mbedtls_rsa_context #define rsa_copy mbedtls_rsa_copy -#define rsa_decrypt_func mbedtls_rsa_decrypt_func #define rsa_free mbedtls_rsa_free #define rsa_gen_key mbedtls_rsa_gen_key #define rsa_info mbedtls_rsa_info #define rsa_init mbedtls_rsa_init -#define rsa_key_len_func mbedtls_rsa_key_len_func #define rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt #define rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt #define rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign @@ -2306,19 +2223,12 @@ #define rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext #define rsa_self_test mbedtls_rsa_self_test #define rsa_set_padding mbedtls_rsa_set_padding -#define rsa_sign_func mbedtls_rsa_sign_func #define safer_memcmp mbedtls_ssl_safer_memcmp #define set_alarm mbedtls_set_alarm #define sha1 mbedtls_sha1 #define sha1_context mbedtls_sha1_context -#define sha1_file mbedtls_sha1_file #define sha1_finish mbedtls_sha1_finish #define sha1_free mbedtls_sha1_free -#define sha1_hmac mbedtls_sha1_hmac -#define sha1_hmac_finish mbedtls_sha1_hmac_finish -#define sha1_hmac_reset mbedtls_sha1_hmac_reset -#define sha1_hmac_starts mbedtls_sha1_hmac_starts -#define sha1_hmac_update mbedtls_sha1_hmac_update #define sha1_info mbedtls_sha1_info #define sha1_init mbedtls_sha1_init #define sha1_process mbedtls_sha1_process @@ -2328,14 +2238,8 @@ #define sha224_info mbedtls_sha224_info #define sha256 mbedtls_sha256 #define sha256_context mbedtls_sha256_context -#define sha256_file mbedtls_sha256_file #define sha256_finish mbedtls_sha256_finish #define sha256_free mbedtls_sha256_free -#define sha256_hmac mbedtls_sha256_hmac -#define sha256_hmac_finish mbedtls_sha256_hmac_finish -#define sha256_hmac_reset mbedtls_sha256_hmac_reset -#define sha256_hmac_starts mbedtls_sha256_hmac_starts -#define sha256_hmac_update mbedtls_sha256_hmac_update #define sha256_info mbedtls_sha256_info #define sha256_init mbedtls_sha256_init #define sha256_process mbedtls_sha256_process @@ -2345,14 +2249,8 @@ #define sha384_info mbedtls_sha384_info #define sha512 mbedtls_sha512 #define sha512_context mbedtls_sha512_context -#define sha512_file mbedtls_sha512_file #define sha512_finish mbedtls_sha512_finish #define sha512_free mbedtls_sha512_free -#define sha512_hmac mbedtls_sha512_hmac -#define sha512_hmac_finish mbedtls_sha512_hmac_finish -#define sha512_hmac_reset mbedtls_sha512_hmac_reset -#define sha512_hmac_starts mbedtls_sha512_hmac_starts -#define sha512_hmac_update mbedtls_sha512_hmac_update #define sha512_info mbedtls_sha512_info #define sha512_init mbedtls_sha512_init #define sha512_process mbedtls_sha512_process @@ -2385,7 +2283,6 @@ #define ssl_cookie_setup mbedtls_ssl_cookie_setup #define ssl_cookie_write mbedtls_ssl_cookie_write #define ssl_cookie_write_t mbedtls_ssl_cookie_write_t -#define ssl_curve_is_acceptable mbedtls_ssl_curve_is_acceptable #define ssl_derive_keys mbedtls_ssl_derive_keys #define ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check #define ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update @@ -2453,7 +2350,6 @@ #define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support #define ssl_set_authmode mbedtls_ssl_conf_authmode #define ssl_set_bio mbedtls_ssl_set_bio -#define ssl_set_bio mbedtls_ssl_set_bio_timeout #define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain #define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting #define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites @@ -2476,8 +2372,6 @@ #define ssl_set_max_version mbedtls_ssl_conf_max_version #define ssl_set_min_version mbedtls_ssl_conf_min_version #define ssl_set_own_cert mbedtls_ssl_conf_own_cert -#define ssl_set_own_cert_alt mbedtls_ssl_set_own_cert_alt -#define ssl_set_own_cert_rsa mbedtls_ssl_set_own_cert_rsa #define ssl_set_psk mbedtls_ssl_conf_psk #define ssl_set_psk_cb mbedtls_ssl_conf_psk_cb #define ssl_set_renegotiation mbedtls_ssl_conf_renegotiation @@ -2486,7 +2380,6 @@ #define ssl_set_rng mbedtls_ssl_conf_rng #define ssl_set_session mbedtls_ssl_set_session #define ssl_set_session_cache mbedtls_ssl_conf_session_cache -#define ssl_set_session_ticket_lifetime mbedtls_ssl_conf_session_ticket_lifetime #define ssl_set_session_tickets mbedtls_ssl_conf_session_tickets #define ssl_set_sni mbedtls_ssl_conf_sni #define ssl_set_transport mbedtls_ssl_conf_transport @@ -2494,7 +2387,6 @@ #define ssl_set_verify mbedtls_ssl_conf_verify #define ssl_sig_from_pk mbedtls_ssl_sig_from_pk #define ssl_states mbedtls_ssl_states -#define ssl_ticket_keys mbedtls_ssl_ticket_keys #define ssl_transform mbedtls_ssl_transform #define ssl_transform_free mbedtls_ssl_transform_free #define ssl_write mbedtls_ssl_write @@ -2523,7 +2415,6 @@ #define test_cli_key mbedtls_test_cli_key #define test_cli_key_ec mbedtls_test_cli_key_ec #define test_cli_key_rsa mbedtls_test_cli_key_rsa -#define test_dhm_params mbedtls_test_dhm_params #define test_srv_crt mbedtls_test_srv_crt #define test_srv_crt_ec mbedtls_test_srv_crt_ec #define test_srv_crt_rsa mbedtls_test_srv_crt_rsa @@ -2578,8 +2469,6 @@ #define x509_get_time mbedtls_x509_get_time #define x509_key_size_helper mbedtls_x509_key_size_helper #define x509_name mbedtls_x509_name -#define x509_oid_get_description mbedtls_x509_oid_get_description -#define x509_oid_get_numeric_string mbedtls_x509_oid_get_numeric_string #define x509_self_test mbedtls_x509_self_test #define x509_sequence mbedtls_x509_sequence #define x509_serial_gets mbedtls_x509_serial_gets diff --git a/tools/sdk/include/mbedtls/mbedtls/config.h b/tools/sdk/include/mbedtls/mbedtls/config.h index 3b7c85b3..47c71964 100644 --- a/tools/sdk/include/mbedtls/mbedtls/config.h +++ b/tools/sdk/include/mbedtls/mbedtls/config.h @@ -55,6 +55,34 @@ */ #define MBEDTLS_HAVE_ASM +/** + * \def MBEDTLS_NO_UDBL_DIVISION + * + * The platform lacks support for double-width integer division (64-bit + * division on a 32-bit platform, 128-bit division on a 64-bit platform). + * + * Used in: + * include/mbedtls/bignum.h + * library/bignum.c + * + * The bignum code uses double-width division to speed up some operations. + * Double-width division is often implemented in software that needs to + * be linked with the program. The presence of a double-width integer + * type is usually detected automatically through preprocessor macros, + * but the automatic detection cannot know whether the code needs to + * and can be linked with an implementation of division for that type. + * By default division is assumed to be usable if the type is present. + * Uncomment this option to prevent the use of double-width division. + * + * Note that division for the native integer type is always required. + * Furthermore, a 64-bit type is always required even on a 32-bit + * platform, but it need not support multiplication or division. In some + * cases it is also desirable to disable some double-width operations. For + * example, if double-width division is implemented in software, disabling + * it can reduce code size in some embedded targets. + */ +//#define MBEDTLS_NO_UDBL_DIVISION + /** * \def MBEDTLS_HAVE_SSE2 * @@ -71,6 +99,10 @@ * The time does not need to be correct, only time differences are used, * by contrast with MBEDTLS_HAVE_TIME_DATE * + * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT, + * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and + * MBEDTLS_PLATFORM_STD_TIME. + * * Comment if your system does not support time functions */ #define MBEDTLS_HAVE_TIME @@ -148,6 +180,8 @@ * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as * MBEDTLS_PLATFORM_XXX_MACRO! * + * Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME + * * Uncomment a macro to enable alternate implementation of specific base * platform function */ @@ -157,6 +191,7 @@ //#define MBEDTLS_PLATFORM_PRINTF_ALT //#define MBEDTLS_PLATFORM_SNPRINTF_ALT //#define MBEDTLS_PLATFORM_NV_SEED_ALT +//#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT /** * \def MBEDTLS_DEPRECATED_WARNING @@ -212,16 +247,16 @@ * \def MBEDTLS_AES_ALT * * MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your - * alternate core implementation of a symmetric crypto or hash module (e.g. - * platform specific assembly optimized implementations). Keep in mind that - * the function prototypes should remain the same. + * alternate core implementation of a symmetric crypto, an arithmetic or hash + * module (e.g. platform specific assembly optimized implementations). Keep + * in mind that the function prototypes should remain the same. * * This replaces the whole module. If you only want to replace one of the * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. * * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer - * provide the "struct mbedtls_aes_context" definition and omit the base function - * declarations and implementations. "aes_alt.h" will be included from + * provide the "struct mbedtls_aes_context" definition and omit the base + * function declarations and implementations. "aes_alt.h" will be included from * "aes.h" to include the new function definitions. * * Uncomment a macro to enable alternate implementation of the corresponding @@ -240,6 +275,16 @@ //#define MBEDTLS_SHA1_ALT //#define MBEDTLS_SHA256_ALT //#define MBEDTLS_SHA512_ALT +/* + * When replacing the elliptic curve module, pleace consider, that it is + * implemented with two .c files: + * - ecp.c + * - ecp_curves.c + * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT + * macros as described above. The only difference is that you have to make sure + * that you provide functionality for both .c files. + */ +//#define MBEDTLS_ECP_ALT /** * \def MBEDTLS_MD2_PROCESS_ALT @@ -257,9 +302,15 @@ * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible * with this definition. * - * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set - * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES - * tables. + * \note Because of a signature change, the core AES encryption and decryption routines are + * currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt, + * respectively. When setting up alternative implementations, these functions should + * be overriden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt + * must stay untouched. + * + * \note If you use the AES_xxx_ALT macros, then is is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. * * Uncomment a macro to enable alternate implementation of the corresponding * function. @@ -279,6 +330,59 @@ //#define MBEDTLS_AES_ENCRYPT_ALT //#define MBEDTLS_AES_DECRYPT_ALT +/** + * \def MBEDTLS_ECP_INTERNAL_ALT + * + * Expose a part of the internal interface of the Elliptic Curve Point module. + * + * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your + * alternative core implementation of elliptic curve arithmetic. Keep in mind + * that function prototypes should remain the same. + * + * This partially replaces one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation + * is still present and it is used for group structures not supported by the + * alternative. + * + * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT + * and implementing the following functions: + * unsigned char mbedtls_internal_ecp_grp_capable( + * const mbedtls_ecp_group *grp ) + * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) + * void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp ) + * The mbedtls_internal_ecp_grp_capable function should return 1 if the + * replacement functions implement arithmetic for the given group and 0 + * otherwise. + * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are + * called before and after each point operation and provide an opportunity to + * implement optimized set up and tear down instructions. + * + * Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and + * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac + * function, but will use your mbedtls_internal_ecp_double_jac if the group is + * supported (your mbedtls_internal_ecp_grp_capable function returns 1 when + * receives it as an argument). If the group is not supported then the original + * implementation is used. The other functions and the definition of + * mbedtls_ecp_group and mbedtls_ecp_point will not change, so your + * implementation of mbedtls_internal_ecp_double_jac and + * mbedtls_internal_ecp_grp_capable must be compatible with this definition. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +/* Required for all the functions in this section */ +//#define MBEDTLS_ECP_INTERNAL_ALT +/* Support for Weierstrass curves with Jacobi representation */ +//#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT +//#define MBEDTLS_ECP_ADD_MIXED_ALT +//#define MBEDTLS_ECP_DOUBLE_JAC_ALT +//#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT +//#define MBEDTLS_ECP_NORMALIZE_JAC_ALT +/* Support for curves with Montgomery arithmetic */ +//#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT +//#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT +//#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT + /** * \def MBEDTLS_TEST_NULL_ENTROPY * @@ -934,18 +1038,6 @@ */ //#define MBEDTLS_SHA256_SMALLER -/** - * \def MBEDTLS_SSL_AEAD_RANDOM_IV - * - * Generate a random IV rather than using the record sequence number as a - * nonce for ciphersuites using and AEAD algorithm (GCM or CCM). - * - * Using the sequence number is generally recommended. - * - * Uncomment this macro to always use random IVs with AEAD ciphersuites. - */ -//#define MBEDTLS_SSL_AEAD_RANDOM_IV - /** * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES * @@ -1531,7 +1623,7 @@ * library/pkwrite.c * library/x509_create.c * library/x509write_crt.c - * library/mbedtls_x509write_csr.c + * library/x509write_csr.c */ #define MBEDTLS_ASN1_WRITE_C @@ -1665,6 +1757,19 @@ */ #define MBEDTLS_CIPHER_C +/** + * \def MBEDTLS_CMAC_C + * + * Enable the CMAC (Cipher-based Message Authentication Code) mode for block + * ciphers. + * + * Module: library/cmac.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C + * + */ +//#define MBEDTLS_CMAC_C + /** * \def MBEDTLS_CTR_DRBG_C * @@ -1879,7 +1984,7 @@ * * Enable the generic message digest layer. * - * Module: library/mbedtls_md.c + * Module: library/md.c * Caller: * * Uncomment to enable generic message digest wrappers. @@ -1891,7 +1996,7 @@ * * Enable the MD2 hash algorithm. * - * Module: library/mbedtls_md2.c + * Module: library/md2.c * Caller: * * Uncomment to enable support for (rare) MD2-signed X.509 certs. @@ -1903,7 +2008,7 @@ * * Enable the MD4 hash algorithm. * - * Module: library/mbedtls_md4.c + * Module: library/md4.c * Caller: * * Uncomment to enable support for (rare) MD4-signed X.509 certs. @@ -1915,8 +2020,8 @@ * * Enable the MD5 hash algorithm. * - * Module: library/mbedtls_md5.c - * Caller: library/mbedtls_md.c + * Module: library/md5.c + * Caller: library/md.c * library/pem.c * library/ssl_tls.c * @@ -1954,7 +2059,7 @@ * environment: * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS * - * Module: library/net.c + * Module: library/net_sockets.c * * This module provides networking routines. */ @@ -1973,11 +2078,11 @@ * library/rsa.c * library/x509.c * library/x509_create.c - * library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c * library/x509write_crt.c - * library/mbedtls_x509write_csr.c + * library/x509write_csr.c * * This modules translates between OIDs and internal values. */ @@ -2005,9 +2110,9 @@ * Module: library/pem.c * Caller: library/dhm.c * library/pkparse.c - * library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c * * Requires: MBEDTLS_BASE64_C * @@ -2023,7 +2128,7 @@ * Module: library/pem.c * Caller: library/pkwrite.c * library/x509write_crt.c - * library/mbedtls_x509write_csr.c + * library/x509write_csr.c * * Requires: MBEDTLS_BASE64_C * @@ -2053,8 +2158,8 @@ * Enable the generic public (asymetric) key parser. * * Module: library/pkparse.c - * Caller: library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c + * Caller: library/x509_crt.c + * library/x509_csr.c * * Requires: MBEDTLS_PK_C * @@ -2145,8 +2250,8 @@ * * Enable the RIPEMD-160 hash algorithm. * - * Module: library/mbedtls_ripemd160.c - * Caller: library/mbedtls_md.c + * Module: library/ripemd160.c + * Caller: library/md.c * */ #define MBEDTLS_RIPEMD160_C @@ -2174,14 +2279,15 @@ * * Enable the SHA1 cryptographic hash algorithm. * - * Module: library/mbedtls_sha1.c - * Caller: library/mbedtls_md.c + * Module: library/sha1.c + * Caller: library/md.c * library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * library/x509write_crt.c * - * This module is required for SSL/TLS and SHA1-signed certificates. + * This module is required for SSL/TLS up to version 1.1, for TLS 1.2 + * depending on the handshake parameters, and for SHA1-signed certificates. */ #define MBEDTLS_SHA1_C @@ -2190,9 +2296,9 @@ * * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. * - * Module: library/mbedtls_sha256.c + * Module: library/sha256.c * Caller: library/entropy.c - * library/mbedtls_md.c + * library/md.c * library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c @@ -2207,9 +2313,9 @@ * * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. * - * Module: library/mbedtls_sha512.c + * Module: library/sha512.c * Caller: library/entropy.c - * library/mbedtls_md.c + * library/md.c * library/ssl_cli.c * library/ssl_srv.c * @@ -2357,9 +2463,9 @@ * Enable X.509 core for using certificates. * * Module: library/x509.c - * Caller: library/mbedtls_x509_crl.c - * library/mbedtls_x509_crt.c - * library/mbedtls_x509_csr.c + * Caller: library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c * * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, * MBEDTLS_PK_PARSE_C @@ -2373,7 +2479,7 @@ * * Enable X.509 certificate parsing. * - * Module: library/mbedtls_x509_crt.c + * Module: library/x509_crt.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c @@ -2389,8 +2495,8 @@ * * Enable X.509 CRL parsing. * - * Module: library/mbedtls_x509_crl.c - * Caller: library/mbedtls_x509_crt.c + * Module: library/x509_crl.c + * Caller: library/x509_crt.c * * Requires: MBEDTLS_X509_USE_C * @@ -2403,7 +2509,7 @@ * * Enable X.509 Certificate Signing Request (CSR) parsing. * - * Module: library/mbedtls_x509_csr.c + * Module: library/x509_csr.c * Caller: library/x509_crt_write.c * * Requires: MBEDTLS_X509_USE_C @@ -2503,6 +2609,7 @@ /* Entropy options */ //#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ //#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ +//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */ /* Memory buffer allocator options */ //#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ @@ -2512,7 +2619,7 @@ //#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ @@ -2528,8 +2635,8 @@ //#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ +//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ @@ -2563,11 +2670,36 @@ /* X509 options */ //#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ +//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */ + +/** + * Allow SHA-1 in the default TLS configuration for certificate signing. + * Without this build-time option, SHA-1 support must be activated explicitly + * through mbedtls_ssl_conf_cert_profile. Turning on this option is not + * recommended because of it is possible to generte SHA-1 collisions, however + * this may be safe for legacy infrastructure where additional controls apply. + */ +// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES + +/** + * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake + * signature and ciphersuite selection. Without this build-time option, SHA-1 + * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. + * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by + * default. At the time of writing, there is no practical attack on the use + * of SHA-1 in handshake signatures, hence this option is turned on by default + * for compatibility with existing peers. + */ +#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE /* \} name SECTION: Customisation configuration options */ /* Target and application specific configurations */ -//#define YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE "target_config.h" +//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "mbedtls/target_config.h" + +#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE) +#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE +#endif /* * Allow user to override any previous default. diff --git a/tools/sdk/include/mbedtls/mbedtls/ecdsa.h b/tools/sdk/include/mbedtls/mbedtls/ecdsa.h index 52827d8d..a277715b 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ecdsa.h +++ b/tools/sdk/include/mbedtls/mbedtls/ecdsa.h @@ -69,6 +69,10 @@ extern "C" { * \param f_rng RNG function * \param p_rng RNG parameter * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.3 step 5. + * * \return 0 if successful, * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code */ @@ -89,6 +93,10 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, * \param blen Length of buf * \param md_alg MD algorithm used to hash the message * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.3 step 5. + * * \return 0 if successful, * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code */ @@ -107,6 +115,10 @@ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi * \param r First integer of the signature * \param s Second integer of the signature * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.4 step 3. + * * \return 0 if successful, * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code @@ -120,7 +132,7 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, * serialized as defined in RFC 4492 page 20. * (Not thread-safe to use same context in multiple threads) * - * \note The deterministice version (RFC 6979) is used if + * \note The deterministic version (RFC 6979) is used if * MBEDTLS_ECDSA_DETERMINISTIC is defined. * * \param ctx ECDSA context @@ -136,6 +148,10 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe. * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.3 step 5. + * * \return 0 if successful, * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or * MBEDTLS_ERR_ASN1_XXX error code @@ -172,6 +188,10 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe. * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.3 step 5. + * * \return 0 if successful, * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or * MBEDTLS_ERR_ASN1_XXX error code @@ -193,6 +213,10 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, * \param sig Signature to read and verify * \param slen Size of sig * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * prescribed by SEC1 4.1.4 step 3. + * * \return 0 if successful, * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid, * MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is diff --git a/tools/sdk/include/mbedtls/mbedtls/ecjpake.h b/tools/sdk/include/mbedtls/mbedtls/ecjpake.h index b7b61604..161a5b21 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ecjpake.h +++ b/tools/sdk/include/mbedtls/mbedtls/ecjpake.h @@ -116,7 +116,7 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, const unsigned char *secret, size_t len ); -/* +/** * \brief Check if a context is ready for use * * \param ctx Context to check diff --git a/tools/sdk/include/mbedtls/mbedtls/ecp.h b/tools/sdk/include/mbedtls/mbedtls/ecp.h index 5246c789..dad9aef0 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ecp.h +++ b/tools/sdk/include/mbedtls/mbedtls/ecp.h @@ -37,6 +37,15 @@ #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */ #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */ +#if !defined(MBEDTLS_ECP_ALT) +/* + * default mbed TLS elliptic curve arithmetic implementation + * + * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an + * alternative implementation for the whole module and it will replace this + * one.) + */ + #ifdef __cplusplus extern "C" { #endif @@ -452,7 +461,7 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp * \brief Set a group using well-known domain parameters * * \param grp Destination group - * \param index Index in the list of well-known domain parameters + * \param id Index in the list of well-known domain parameters * * \return 0 if successful, * MBEDTLS_ERR_MPI_XXX if initialization failed @@ -461,7 +470,7 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp * \note Index should be a value of RFC 4492's enum NamedCurve, * usually in the form of a MBEDTLS_ECP_DP_XXX macro. */ -int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index ); +int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ); /** * \brief Set a group from a TLS ECParameters record @@ -654,16 +663,22 @@ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv ); #if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * * \return 0 if successful, or 1 if a test failed */ int mbedtls_ecp_self_test( int verbose ); -#endif + +#endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif +#else /* MBEDTLS_ECP_ALT */ +#include "ecp_alt.h" +#endif /* MBEDTLS_ECP_ALT */ + #endif /* ecp.h */ diff --git a/tools/sdk/include/mbedtls/mbedtls/ecp_internal.h b/tools/sdk/include/mbedtls/mbedtls/ecp_internal.h new file mode 100644 index 00000000..2991e26d --- /dev/null +++ b/tools/sdk/include/mbedtls/mbedtls/ecp_internal.h @@ -0,0 +1,292 @@ +/** + * \file ecp_internal.h + * + * \brief Function declarations for alternative implementation of elliptic curve + * point arithmetic. + * + * Copyright (C) 2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * References: + * + * [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records. + * + * + * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis + * for elliptic curve cryptosystems. In : Cryptographic Hardware and + * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. + * + * + * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to + * render ECC resistant against Side Channel Attacks. IACR Cryptology + * ePrint Archive, 2004, vol. 2004, p. 342. + * + * + * [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters. + * + * + * [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic + * Curve Cryptography. + * + * [6] Digital Signature Standard (DSS), FIPS 186-4. + * + * + * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer + * Security (TLS), RFC 4492. + * + * + * [8] + * + * [9] COHEN, Henri. A Course in Computational Algebraic Number Theory. + * Springer Science & Business Media, 1 Aug 2000 + */ + +#ifndef MBEDTLS_ECP_INTERNAL_H +#define MBEDTLS_ECP_INTERNAL_H + +#if defined(MBEDTLS_ECP_INTERNAL_ALT) + +/** + * \brief Indicate if the Elliptic Curve Point module extension can + * handle the group. + * + * \param grp The pointer to the elliptic curve group that will be the + * basis of the cryptographic computations. + * + * \return Non-zero if successful. + */ +unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp ); + +/** + * \brief Initialise the Elliptic Curve Point module extension. + * + * If mbedtls_internal_ecp_grp_capable returns true for a + * group, this function has to be able to initialise the + * module for it. + * + * This module can be a driver to a crypto hardware + * accelerator, for which this could be an initialise function. + * + * \param grp The pointer to the group the module needs to be + * initialised for. + * + * \return 0 if successful. + */ +int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ); + +/** + * \brief Frees and deallocates the Elliptic Curve Point module + * extension. + * + * \param grp The pointer to the group the module was initialised for. + */ +void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ); + +#if defined(ECP_SHORTWEIERSTRASS) + +#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) +/** + * \brief Randomize jacobian coordinates: + * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l. + * + * \param grp Pointer to the group representing the curve. + * + * \param pt The point on the curve to be randomised, given with Jacobian + * coordinates. + * + * \param f_rng A function pointer to the random number generator. + * + * \param p_rng A pointer to the random number generator state. + * + * \return 0 if successful. + */ +int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +#endif + +#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) +/** + * \brief Addition: R = P + Q, mixed affine-Jacobian coordinates. + * + * The coordinates of Q must be normalized (= affine), + * but those of P don't need to. R is not normalized. + * + * This function is used only as a subrutine of + * ecp_mul_comb(). + * + * Special cases: (1) P or Q is zero, (2) R is zero, + * (3) P == Q. + * None of these cases can happen as intermediate step in + * ecp_mul_comb(): + * - at each step, P, Q and R are multiples of the base + * point, the factor being less than its order, so none of + * them is zero; + * - Q is an odd multiple of the base point, P an even + * multiple, due to the choice of precomputed points in the + * modified comb method. + * So branches for these cases do not leak secret information. + * + * We accept Q->Z being unset (saving memory in tables) as + * meaning 1. + * + * Cost in field operations if done by [5] 3.22: + * 1A := 8M + 3S + * + * \param grp Pointer to the group representing the curve. + * + * \param R Pointer to a point structure to hold the result. + * + * \param P Pointer to the first summand, given with Jacobian + * coordinates + * + * \param Q Pointer to the second summand, given with affine + * coordinates. + * + * \return 0 if successful. + */ +int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, const mbedtls_ecp_point *P, + const mbedtls_ecp_point *Q ); +#endif + +/** + * \brief Point doubling R = 2 P, Jacobian coordinates. + * + * Cost: 1D := 3M + 4S (A == 0) + * 4M + 4S (A == -3) + * 3M + 6S + 1a otherwise + * when the implementation is based on the "dbl-1998-cmo-2" + * doubling formulas in [8] and standard optimizations are + * applied when curve parameter A is one of { 0, -3 }. + * + * \param grp Pointer to the group representing the curve. + * + * \param R Pointer to a point structure to hold the result. + * + * \param P Pointer to the point that has to be doubled, given with + * Jacobian coordinates. + * + * \return 0 if successful. + */ +#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) +int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, const mbedtls_ecp_point *P ); +#endif + +/** + * \brief Normalize jacobian coordinates of an array of (pointers to) + * points. + * + * Using Montgomery's trick to perform only one inversion mod P + * the cost is: + * 1N(t) := 1I + (6t - 3)M + 1S + * (See for example Algorithm 10.3.4. in [9]) + * + * This function is used only as a subrutine of + * ecp_mul_comb(). + * + * Warning: fails (returning an error) if one of the points is + * zero! + * This should never happen, see choice of w in ecp_mul_comb(). + * + * \param grp Pointer to the group representing the curve. + * + * \param T Array of pointers to the points to normalise. + * + * \param t_len Number of elements in the array. + * + * \return 0 if successful, + * an error if one of the points is zero. + */ +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) +int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *T[], size_t t_len ); +#endif + +/** + * \brief Normalize jacobian coordinates so that Z == 0 || Z == 1. + * + * Cost in field operations if done by [5] 3.2.1: + * 1N := 1I + 3M + 1S + * + * \param grp Pointer to the group representing the curve. + * + * \param pt pointer to the point to be normalised. This is an + * input/output parameter. + * + * \return 0 if successful. + */ +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) +int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt ); +#endif + +#endif /* ECP_SHORTWEIERSTRASS */ + +#if defined(ECP_MONTGOMERY) + +#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) +int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P, + const mbedtls_ecp_point *Q, const mbedtls_mpi *d ); +#endif + +/** + * \brief Randomize projective x/z coordinates: + * (X, Z) -> (l X, l Z) for random l + * + * \param grp pointer to the group representing the curve + * + * \param P the point on the curve to be randomised given with + * projective coordinates. This is an input/output parameter. + * + * \param f_rng a function pointer to the random number generator + * + * \param p_rng a pointer to the random number generator state + * + * \return 0 if successful + */ +#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) +int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +#endif + +/** + * \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1. + * + * \param grp pointer to the group representing the curve + * + * \param P pointer to the point to be normalised. This is an + * input/output parameter. + * + * \return 0 if successful + */ +#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) +int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *P ); +#endif + +#endif /* ECP_MONTGOMERY */ + +#endif /* MBEDTLS_ECP_INTERNAL_ALT */ + +#endif /* ecp_internal.h */ + diff --git a/tools/sdk/include/mbedtls/mbedtls/entropy.h b/tools/sdk/include/mbedtls/mbedtls/entropy.h index fed0494e..747aca4d 100644 --- a/tools/sdk/include/mbedtls/mbedtls/entropy.h +++ b/tools/sdk/include/mbedtls/mbedtls/entropy.h @@ -255,9 +255,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char * /** * \brief Checkup routine * + * This module self-test also calls the entropy self-test, + * mbedtls_entropy_source_self_test(); + * * \return 0 if successful, or 1 if a test failed */ int mbedtls_entropy_self_test( int verbose ); + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) +/** + * \brief Checkup routine + * + * Verifies the integrity of the hardware entropy source + * provided by the function 'mbedtls_hardware_poll()'. + * + * Note this is the only hardware entropy source that is known + * at link time, and other entropy sources configured + * dynamically at runtime by the function + * mbedtls_entropy_add_source() will not be tested. + * + * \return 0 if successful, or 1 if a test failed + */ +int mbedtls_entropy_source_self_test( int verbose ); +#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus diff --git a/tools/sdk/include/mbedtls/mbedtls/entropy_poll.h b/tools/sdk/include/mbedtls/mbedtls/entropy_poll.h index 430e8651..81258d5f 100644 --- a/tools/sdk/include/mbedtls/mbedtls/entropy_poll.h +++ b/tools/sdk/include/mbedtls/mbedtls/entropy_poll.h @@ -41,7 +41,9 @@ extern "C" { #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */ #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */ #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */ +#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */ +#endif /** * \brief Entropy poll callback that provides 0 entropy. diff --git a/tools/sdk/include/mbedtls/mbedtls/error.h b/tools/sdk/include/mbedtls/mbedtls/error.h index 5e549f6b..31591e2d 100644 --- a/tools/sdk/include/mbedtls/mbedtls/error.h +++ b/tools/sdk/include/mbedtls/mbedtls/error.h @@ -71,7 +71,7 @@ * Name ID Nr of Errors * PEM 1 9 * PKCS#12 1 4 (Started from top) - * X509 2 19 + * X509 2 20 * PKCS5 2 4 (Started from top) * DHM 3 9 * PK 3 14 (Started from top) diff --git a/tools/sdk/include/mbedtls/mbedtls/gcm.h b/tools/sdk/include/mbedtls/mbedtls/gcm.h index 6743ac9a..1b77aaed 100644 --- a/tools/sdk/include/mbedtls/mbedtls/gcm.h +++ b/tools/sdk/include/mbedtls/mbedtls/gcm.h @@ -190,8 +190,8 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, * 16 bytes. * * \param ctx GCM context - * \param tag buffer for holding the tag (may be NULL if tag_len is 0) - * \param tag_len length of the tag to generate + * \param tag buffer for holding the tag + * \param tag_len length of the tag to generate (must be at least 4) * * \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT */ diff --git a/tools/sdk/include/mbedtls/mbedtls/md.h b/tools/sdk/include/mbedtls/mbedtls/md.h index b9023553..9b996a95 100644 --- a/tools/sdk/include/mbedtls/mbedtls/md.h +++ b/tools/sdk/include/mbedtls/mbedtls/md.h @@ -304,8 +304,8 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu /** * \brief Output HMAC. * Called after mbedtls_md_hmac_update(). - * Usually followed my mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(), - * or mbedtls_md_free(). + * Usually followed by mbedtls_md_hmac_reset(), + * mbedtls_md_hmac_starts(), or mbedtls_md_free(). * * \param ctx HMAC context * \param output Generic HMAC checksum result @@ -317,7 +317,8 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); /** * \brief Prepare to authenticate a new message with the same key. - * Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update(). + * Called after mbedtls_md_hmac_finish() and before + * mbedtls_md_hmac_update(). * * \param ctx HMAC context to be reset * diff --git a/tools/sdk/include/mbedtls/mbedtls/net.h b/tools/sdk/include/mbedtls/mbedtls/net.h index 8c6534cf..774559b3 100644 --- a/tools/sdk/include/mbedtls/mbedtls/net.h +++ b/tools/sdk/include/mbedtls/mbedtls/net.h @@ -1,9 +1,9 @@ /** * \file net.h * - * \brief Network communication functions + * \brief Deprecated header file that includes mbedtls/net_sockets.h * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -19,207 +19,13 @@ * limitations under the License. * * This file is part of mbed TLS (https://tls.mbed.org) + * + * \deprecated Superseded by mbedtls/net_sockets.h */ -#ifndef MBEDTLS_NET_H -#define MBEDTLS_NET_H -#if !defined(MBEDTLS_CONFIG_FILE) -#include "config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#include "ssl.h" - -#include -#include - -#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */ -#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */ -#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */ -#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */ -#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */ -#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */ -#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */ -#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */ -#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */ -#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */ -#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */ - -#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ - -#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */ -#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Wrapper type for sockets. - * - * Currently backed by just a file descriptor, but might be more in the future - * (eg two file descriptors for combined IPv4 + IPv6 support, or additional - * structures for hand-made UDP demultiplexing). - */ -typedef struct -{ - int fd; /**< The underlying file descriptor */ -} -mbedtls_net_context; - -/** - * \brief Initialize a context - * Just makes the context ready to be used or freed safely. - * - * \param ctx Context to initialize - */ -void mbedtls_net_init( mbedtls_net_context *ctx ); - -/** - * \brief Initiate a connection with host:port in the given protocol - * - * \param ctx Socket to use - * \param host Host to connect to - * \param port Port to connect to - * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP - * - * \return 0 if successful, or one of: - * MBEDTLS_ERR_NET_SOCKET_FAILED, - * MBEDTLS_ERR_NET_UNKNOWN_HOST, - * MBEDTLS_ERR_NET_CONNECT_FAILED - * - * \note Sets the socket in connected mode even with UDP. - */ -int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto ); - -/** - * \brief Create a receiving socket on bind_ip:port in the chosen - * protocol. If bind_ip == NULL, all interfaces are bound. - * - * \param ctx Socket to use - * \param bind_ip IP to bind to, can be NULL - * \param port Port number to use - * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP - * - * \return 0 if successful, or one of: - * MBEDTLS_ERR_NET_SOCKET_FAILED, - * MBEDTLS_ERR_NET_BIND_FAILED, - * MBEDTLS_ERR_NET_LISTEN_FAILED - * - * \note Regardless of the protocol, opens the sockets and binds it. - * In addition, make the socket listening if protocol is TCP. - */ -int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto ); - -/** - * \brief Accept a connection from a remote client - * - * \param bind_ctx Relevant socket - * \param client_ctx Will contain the connected client socket - * \param client_ip Will contain the client IP address - * \param buf_size Size of the client_ip buffer - * \param ip_len Will receive the size of the client IP written - * - * \return 0 if successful, or - * MBEDTLS_ERR_NET_ACCEPT_FAILED, or - * MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small, - * MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to - * non-blocking and accept() would block. - */ -int mbedtls_net_accept( mbedtls_net_context *bind_ctx, - mbedtls_net_context *client_ctx, - void *client_ip, size_t buf_size, size_t *ip_len ); - -/** - * \brief Set the socket blocking - * - * \param ctx Socket to set - * - * \return 0 if successful, or a non-zero error code - */ -int mbedtls_net_set_block( mbedtls_net_context *ctx ); - -/** - * \brief Set the socket non-blocking - * - * \param ctx Socket to set - * - * \return 0 if successful, or a non-zero error code - */ -int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ); - -/** - * \brief Portable usleep helper - * - * \param usec Amount of microseconds to sleep - * - * \note Real amount of time slept will not be less than - * select()'s timeout granularity (typically, 10ms). - */ -void mbedtls_net_usleep( unsigned long usec ); - -/** - * \brief Read at most 'len' characters. If no error occurs, - * the actual amount read is returned. - * - * \param ctx Socket - * \param buf The buffer to write to - * \param len Maximum length of the buffer - * - * \return the number of bytes received, - * or a non-zero error code; with a non-blocking socket, - * MBEDTLS_ERR_SSL_WANT_READ indicates read() would block. - */ -int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ); - -/** - * \brief Write at most 'len' characters. If no error occurs, - * the actual amount read is returned. - * - * \param ctx Socket - * \param buf The buffer to read from - * \param len The length of the buffer - * - * \return the number of bytes sent, - * or a non-zero error code; with a non-blocking socket, - * MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block. - */ -int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); - -/** - * \brief Read at most 'len' characters, blocking for at most - * 'timeout' seconds. If no error occurs, the actual amount - * read is returned. - * - * \param ctx Socket - * \param buf The buffer to write to - * \param len Maximum length of the buffer - * \param timeout Maximum number of milliseconds to wait for data - * 0 means no timeout (wait forever) - * - * \return the number of bytes received, - * or a non-zero error code: - * MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, - * MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. - * - * \note This function will block (until data becomes available or - * timeout is reached) even if the socket is set to - * non-blocking. Handling timeouts with non-blocking reads - * requires a different strategy. - */ -int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, - uint32_t timeout ); - -/** - * \brief Gracefully shutdown the connection and free associated data - * - * \param ctx The context to free - */ -void mbedtls_net_free( mbedtls_net_context *ctx ); - -#ifdef __cplusplus -} -#endif - -#endif /* net.h */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#include "mbedtls/net_sockets.h" +#if defined(MBEDTLS_DEPRECATED_WARNING) +#warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" +#endif /* MBEDTLS_DEPRECATED_WARNING */ +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ diff --git a/tools/sdk/include/mbedtls/mbedtls/net_sockets.h b/tools/sdk/include/mbedtls/mbedtls/net_sockets.h new file mode 100644 index 00000000..de335526 --- /dev/null +++ b/tools/sdk/include/mbedtls/mbedtls/net_sockets.h @@ -0,0 +1,225 @@ +/** + * \file net_sockets.h + * + * \brief Network communication functions + * + * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_NET_SOCKETS_H +#define MBEDTLS_NET_SOCKETS_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "ssl.h" + +#include +#include + +#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */ +#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */ +#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */ +#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */ +#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */ +#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */ +#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */ +#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */ +#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */ +#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */ +#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */ + +#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ + +#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */ +#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Wrapper type for sockets. + * + * Currently backed by just a file descriptor, but might be more in the future + * (eg two file descriptors for combined IPv4 + IPv6 support, or additional + * structures for hand-made UDP demultiplexing). + */ +typedef struct +{ + int fd; /**< The underlying file descriptor */ +} +mbedtls_net_context; + +/** + * \brief Initialize a context + * Just makes the context ready to be used or freed safely. + * + * \param ctx Context to initialize + */ +void mbedtls_net_init( mbedtls_net_context *ctx ); + +/** + * \brief Initiate a connection with host:port in the given protocol + * + * \param ctx Socket to use + * \param host Host to connect to + * \param port Port to connect to + * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP + * + * \return 0 if successful, or one of: + * MBEDTLS_ERR_NET_SOCKET_FAILED, + * MBEDTLS_ERR_NET_UNKNOWN_HOST, + * MBEDTLS_ERR_NET_CONNECT_FAILED + * + * \note Sets the socket in connected mode even with UDP. + */ +int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto ); + +/** + * \brief Create a receiving socket on bind_ip:port in the chosen + * protocol. If bind_ip == NULL, all interfaces are bound. + * + * \param ctx Socket to use + * \param bind_ip IP to bind to, can be NULL + * \param port Port number to use + * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP + * + * \return 0 if successful, or one of: + * MBEDTLS_ERR_NET_SOCKET_FAILED, + * MBEDTLS_ERR_NET_BIND_FAILED, + * MBEDTLS_ERR_NET_LISTEN_FAILED + * + * \note Regardless of the protocol, opens the sockets and binds it. + * In addition, make the socket listening if protocol is TCP. + */ +int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto ); + +/** + * \brief Accept a connection from a remote client + * + * \param bind_ctx Relevant socket + * \param client_ctx Will contain the connected client socket + * \param client_ip Will contain the client IP address + * \param buf_size Size of the client_ip buffer + * \param ip_len Will receive the size of the client IP written + * + * \return 0 if successful, or + * MBEDTLS_ERR_NET_ACCEPT_FAILED, or + * MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small, + * MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to + * non-blocking and accept() would block. + */ +int mbedtls_net_accept( mbedtls_net_context *bind_ctx, + mbedtls_net_context *client_ctx, + void *client_ip, size_t buf_size, size_t *ip_len ); + +/** + * \brief Set the socket blocking + * + * \param ctx Socket to set + * + * \return 0 if successful, or a non-zero error code + */ +int mbedtls_net_set_block( mbedtls_net_context *ctx ); + +/** + * \brief Set the socket non-blocking + * + * \param ctx Socket to set + * + * \return 0 if successful, or a non-zero error code + */ +int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ); + +/** + * \brief Portable usleep helper + * + * \param usec Amount of microseconds to sleep + * + * \note Real amount of time slept will not be less than + * select()'s timeout granularity (typically, 10ms). + */ +void mbedtls_net_usleep( unsigned long usec ); + +/** + * \brief Read at most 'len' characters. If no error occurs, + * the actual amount read is returned. + * + * \param ctx Socket + * \param buf The buffer to write to + * \param len Maximum length of the buffer + * + * \return the number of bytes received, + * or a non-zero error code; with a non-blocking socket, + * MBEDTLS_ERR_SSL_WANT_READ indicates read() would block. + */ +int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ); + +/** + * \brief Write at most 'len' characters. If no error occurs, + * the actual amount read is returned. + * + * \param ctx Socket + * \param buf The buffer to read from + * \param len The length of the buffer + * + * \return the number of bytes sent, + * or a non-zero error code; with a non-blocking socket, + * MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block. + */ +int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); + +/** + * \brief Read at most 'len' characters, blocking for at most + * 'timeout' seconds. If no error occurs, the actual amount + * read is returned. + * + * \param ctx Socket + * \param buf The buffer to write to + * \param len Maximum length of the buffer + * \param timeout Maximum number of milliseconds to wait for data + * 0 means no timeout (wait forever) + * + * \return the number of bytes received, + * or a non-zero error code: + * MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, + * MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. + * + * \note This function will block (until data becomes available or + * timeout is reached) even if the socket is set to + * non-blocking. Handling timeouts with non-blocking reads + * requires a different strategy. + */ +int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, + uint32_t timeout ); + +/** + * \brief Gracefully shutdown the connection and free associated data + * + * \param ctx The context to free + */ +void mbedtls_net_free( mbedtls_net_context *ctx ); + +#ifdef __cplusplus +} +#endif + +#endif /* net_sockets.h */ diff --git a/tools/sdk/include/mbedtls/mbedtls/platform.h b/tools/sdk/include/mbedtls/mbedtls/platform.h index caf8f252..35010f88 100644 --- a/tools/sdk/include/mbedtls/mbedtls/platform.h +++ b/tools/sdk/include/mbedtls/mbedtls/platform.h @@ -29,6 +29,10 @@ #include MBEDTLS_CONFIG_FILE #endif +#if defined(MBEDTLS_HAVE_TIME) +#include "mbedtls/platform_time.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -243,39 +247,6 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); #define MBEDTLS_EXIT_FAILURE 1 #endif -/* - * The time_t datatype - */ -#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) -typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t; -#else -/* For time_t */ -#include -typedef time_t mbedtls_time_t; -#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ - -/* - * The function pointers for time - */ -#if defined(MBEDTLS_PLATFORM_TIME_ALT) -extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); - -/** - * \brief Set your own time function pointer - * - * \param time_func the time function implementation - * - * \return 0 - */ -int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); -#else -#if defined(MBEDTLS_PLATFORM_TIME_MACRO) -#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO -#else -#define mbedtls_time time -#endif /* MBEDTLS_PLATFORM_TIME_MACRO */ -#endif /* MBEDTLS_PLATFORM_TIME_ALT */ - /* * The function pointers for reading from and writing a seed file to * Non-Volatile storage (NV) in a platform-independent way @@ -317,6 +288,54 @@ int mbedtls_platform_set_nv_seed( #endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ #endif /* MBEDTLS_ENTROPY_NV_SEED */ +#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) + +/** + * \brief Platform context structure + * + * \note This structure may be used to assist platform-specific + * setup/teardown operations. + */ +typedef struct { + char dummy; /**< Placeholder member as empty structs are not portable */ +} +mbedtls_platform_context; + +#else +#include "platform_alt.h" +#endif /* !MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */ + +/** + * \brief Perform any platform initialisation operations + * + * \param ctx mbed TLS context + * + * \return 0 if successful + * + * \note This function is intended to allow platform specific initialisation, + * and should be called before any other library functions. Its + * implementation is platform specific, and by default, unless platform + * specific code is provided, it does nothing. + * + * Its use and whether its necessary to be called is dependent on the + * platform. + */ +int mbedtls_platform_setup( mbedtls_platform_context *ctx ); +/** + * \brief Perform any platform teardown operations + * + * \param ctx mbed TLS context + * + * \note This function should be called after every other mbed TLS module has + * been correctly freed using the appropriate free function. + * Its implementation is platform specific, and by default, unless + * platform specific code is provided, it does nothing. + * + * Its use and whether its necessary to be called is dependent on the + * platform. + */ +void mbedtls_platform_teardown( mbedtls_platform_context *ctx ); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/mbedtls/mbedtls/platform_time.h b/tools/sdk/include/mbedtls/mbedtls/platform_time.h new file mode 100644 index 00000000..abb34314 --- /dev/null +++ b/tools/sdk/include/mbedtls/mbedtls/platform_time.h @@ -0,0 +1,81 @@ +/** + * \file platform_time.h + * + * \brief mbed TLS Platform time abstraction + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PLATFORM_TIME_H +#define MBEDTLS_PLATFORM_TIME_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SECTION: Module settings + * + * The configuration options you can set for this module are in this section. + * Either change them in config.h or define them on the compiler command line. + * \{ + */ + +/* + * The time_t datatype + */ +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) +typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t; +#else +/* For time_t */ +#include +typedef time_t mbedtls_time_t; +#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ + +/* + * The function pointers for time + */ +#if defined(MBEDTLS_PLATFORM_TIME_ALT) +extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); + +/** + * \brief Set your own time function pointer + * + * \param time_func the time function implementation + * + * \return 0 + */ +int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); +#else +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) +#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO +#else +#define mbedtls_time time +#endif /* MBEDTLS_PLATFORM_TIME_MACRO */ +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ + +#ifdef __cplusplus +} +#endif + +#endif /* platform_time.h */ diff --git a/tools/sdk/include/mbedtls/mbedtls/rsa.h b/tools/sdk/include/mbedtls/mbedtls/rsa.h index 9c8645df..7d7469d5 100644 --- a/tools/sdk/include/mbedtls/mbedtls/rsa.h +++ b/tools/sdk/include/mbedtls/mbedtls/rsa.h @@ -99,7 +99,7 @@ typedef struct mbedtls_mpi Vf; /*!< cached un-blinding value */ int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and - RSA_PKCS_v21 for OAEP/PSS */ + MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */ int hash_id; /*!< Hash identifier of mbedtls_md_type_t as specified in the mbedtls_md.h header file for the EME-OAEP and EMSA-PSS @@ -206,7 +206,7 @@ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rs * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code * * \note This function does NOT take care of message - * padding. Also, be sure to set input[0] = 0 or assure that + * padding. Also, be sure to set input[0] = 0 or ensure that * input is smaller than N. * * \note The input and output buffers must be large @@ -329,9 +329,15 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, * * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code * - * \note The output buffer must be as large as the size - * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise - * an error is thrown. + * \note The output buffer length \c output_max_len should be + * as large as the size ctx->len of ctx->N (eg. 128 bytes + * if RSA-1024 is used) to be able to hold an arbitrary + * decrypted message. If it is not large enough to hold + * the decryption of the particular ciphertext provided, + * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. + * + * \note The input buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -355,9 +361,15 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, * * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code * - * \note The output buffer must be as large as the size - * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise - * an error is thrown. + * \note The output buffer length \c output_max_len should be + * as large as the size ctx->len of ctx->N (eg. 128 bytes + * if RSA-1024 is used) to be able to hold an arbitrary + * decrypted message. If it is not large enough to hold + * the decryption of the particular ciphertext provided, + * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. + * + * \note The input buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -383,9 +395,15 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, * * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code * - * \note The output buffer must be as large as the size - * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise - * an error is thrown. + * \note The output buffer length \c output_max_len should be + * as large as the size ctx->len of ctx->N (eg. 128 bytes + * if RSA-1024 is used) to be able to hold an arbitrary + * decrypted message. If it is not large enough to hold + * the decryption of the particular ciphertext provided, + * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. + * + * \note The input buffer must be as large as the size + * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), diff --git a/tools/sdk/include/mbedtls/mbedtls/ssl.h b/tools/sdk/include/mbedtls/mbedtls/ssl.h index 7e1a17c8..cc000700 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ssl.h +++ b/tools/sdk/include/mbedtls/mbedtls/ssl.h @@ -29,7 +29,6 @@ #include MBEDTLS_CONFIG_FILE #endif -#include "platform.h" #include "bignum.h" #include "ecp.h" @@ -53,7 +52,7 @@ #endif #if defined(MBEDTLS_HAVE_TIME) -#include +#include "mbedtls/platform_time.h" #endif /* @@ -108,6 +107,8 @@ #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /**< The operation timed out. */ #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780 /**< The client initiated a reconnect from the same port. */ #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700 /**< Record header looks valid but is not expected. */ +#define MBEDTLS_ERR_SSL_NON_FATAL -0x6680 /**< The alert message received indicates a non-fatal error. */ +#define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */ /* * Various constants @@ -184,6 +185,9 @@ #define MBEDTLS_SSL_PRESET_DEFAULT 0 #define MBEDTLS_SSL_PRESET_SUITEB 2 +#define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1 +#define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0 + /* * Default range for DTLS retransmission timer value, in milliseconds. * RFC 6347 4.2.4.1 says from 1 second to 60 seconds. @@ -530,6 +534,7 @@ typedef struct mbedtls_ssl_config mbedtls_ssl_config; /* Defined in ssl_internal.h */ typedef struct mbedtls_ssl_transform mbedtls_ssl_transform; typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params; +typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t; #if defined(MBEDTLS_X509_CRT_PARSE_C) typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert; #endif @@ -748,6 +753,10 @@ struct mbedtls_ssl_config #if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C) unsigned int fallback : 1; /*!< is this a fallback? */ #endif +#if defined(MBEDTLS_SSL_SRV_C) + unsigned int cert_req_ca_list : 1; /*!< enable sending CA list in + Certificate Request messages? */ +#endif }; @@ -836,7 +845,9 @@ struct mbedtls_ssl_context size_t in_hslen; /*!< current handshake message length, including the handshake header */ int nb_zero; /*!< # of 0-length encrypted messages */ - int record_read; /*!< record is already present */ + + int keep_current_message; /*!< drop or reuse current message + on next call to record layer? */ /* * Record layer (outgoing data) @@ -1041,7 +1052,7 @@ void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode ); * * If set, the verify callback is called for each * certificate in the chain. For implementation - * information, please see \c x509parse_verify() + * information, please see \c mbedtls_x509_crt_verify() * * \param conf SSL configuration * \param f_vrfy verification function @@ -1106,9 +1117,10 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, * \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for * the conventions those callbacks must follow. * - * \note On some platforms, net.c provides \c mbedtls_net_send(), - * \c mbedtls_net_recv() and \c mbedtls_net_recv_timeout() - * that are suitable to be used here. + * \note On some platforms, net_sockets.c provides + * \c mbedtls_net_send(), \c mbedtls_net_recv() and + * \c mbedtls_net_recv_timeout() that are suitable to be used + * here. */ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, void *p_bio, @@ -1144,7 +1156,7 @@ void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout ) * * \note See the documentation of \c mbedtls_ssl_set_timer_t and * \c mbedtls_ssl_get_timer_t for the conventions this pair of - * callbacks must fallow. + * callbacks must follow. * * \note On some platforms, timing.c provides * \c mbedtls_timing_set_delay() and @@ -2029,6 +2041,20 @@ void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 ); #endif /* MBEDTLS_ARC4_C */ +#if defined(MBEDTLS_SSL_SRV_C) +/** + * \brief Whether to send a list of acceptable CAs in + * CertificateRequest messages. + * (Default: do send) + * + * \param conf SSL configuration + * \param cert_req_ca_list MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED or + * MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED + */ +void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf, + char cert_req_ca_list ); +#endif /* MBEDTLS_SSL_SRV_C */ + #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** * \brief Set the maximum fragment length to emit and/or negotiate @@ -2181,7 +2207,7 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_ /** * \brief Set record counter threshold for periodic renegotiation. - * (Default: 2^64 - 256.) + * (Default: 2^48 - 1) * * Renegotiation is automatically triggered when a record * counter (outgoing or ingoing) crosses the defined @@ -2192,9 +2218,17 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_ * Lower values can be used to enforce policies such as "keys * must be refreshed every N packets with cipher X". * + * The renegotiation period can be disabled by setting + * conf->disable_renegotiation to + * MBEDTLS_SSL_RENEGOTIATION_DISABLED. + * + * \note When the configured transport is + * MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation + * period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM, + * the maximum renegotiation period is 2^64 - 1. + * * \param conf SSL configuration * \param period The threshold value: a big-endian 64-bit number. - * Set to 2^64 - 1 to disable periodic renegotiation */ void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf, const unsigned char period[8] ); @@ -2426,7 +2460,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) * \param len how many bytes must be written * * \return the number of bytes actually written (may be less than len), - * or MBEDTLS_ERR_SSL_WANT_WRITE of MBEDTLS_ERR_SSL_WANT_READ, + * or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ, * or another negative error code. * * \note If this function returns something other than a positive @@ -2511,7 +2545,6 @@ void mbedtls_ssl_config_init( mbedtls_ssl_config *conf ); * \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or * MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS * \param preset a MBEDTLS_SSL_PRESET_XXX value - * (currently unused). * * \note See \c mbedtls_ssl_conf_transport() for notes on DTLS. * diff --git a/tools/sdk/include/mbedtls/mbedtls/ssl_ciphersuites.h b/tools/sdk/include/mbedtls/mbedtls/ssl_ciphersuites.h index deaaa375..9101d9cc 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ssl_ciphersuites.h +++ b/tools/sdk/include/mbedtls/mbedtls/ssl_ciphersuites.h @@ -260,6 +260,47 @@ typedef enum { #define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED #endif +/* Key exchanges allowing client certificate requests */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED +#endif + +/* Key exchanges involving server signature in ServerKeyExchange */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED +#endif + +/* Key exchanges using ECDH */ +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED +#endif + +/* Key exchanges that don't involve ephemeral keys */ +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED +#endif + +/* Key exchanges that involve ephemeral keys */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED +#endif + /* Key exchanges using a PSK */ #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ @@ -268,7 +309,13 @@ typedef enum { #define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED #endif -/* Key exchanges using a ECDHE */ +/* Key exchanges using DHE */ +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +#define MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED +#endif + +/* Key exchanges using ECDHE */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) @@ -309,11 +356,128 @@ const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuit #if defined(MBEDTLS_PK_C) mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info ); +mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg( const mbedtls_ssl_ciphersuite_t *info ); #endif int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info ); int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info ); +#if defined(MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED) +static inline int mbedtls_ssl_ciphersuite_has_pfs( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_DHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + case MBEDTLS_KEY_EXCHANGE_ECJPAKE: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED) +static inline int mbedtls_ssl_ciphersuite_no_pfs( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + case MBEDTLS_KEY_EXCHANGE_RSA: + case MBEDTLS_KEY_EXCHANGE_PSK: + case MBEDTLS_KEY_EXCHANGE_RSA_PSK: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED) +static inline int mbedtls_ssl_ciphersuite_uses_ecdh( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */ + +static inline int mbedtls_ssl_ciphersuite_cert_req_allowed( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_RSA: + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + return( 1 ); + + default: + return( 0 ); + } +} + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED) +static inline int mbedtls_ssl_ciphersuite_uses_dhe( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_DHE_PSK: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED) */ + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) +static inline int mbedtls_ssl_ciphersuite_uses_ecdhe( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) */ + +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) +static inline int mbedtls_ssl_ciphersuite_uses_server_signature( const mbedtls_ssl_ciphersuite_t *info ) +{ + switch( info->key_exchange ) + { + case MBEDTLS_KEY_EXCHANGE_DHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA: + case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA: + return( 1 ); + + default: + return( 0 ); + } +} +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/mbedtls/mbedtls/ssl_internal.h b/tools/sdk/include/mbedtls/mbedtls/ssl_internal.h index d63d7d4e..756360b1 100644 --- a/tools/sdk/include/mbedtls/mbedtls/ssl_internal.h +++ b/tools/sdk/include/mbedtls/mbedtls/ssl_internal.h @@ -157,6 +157,24 @@ extern "C" { #endif +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) +/* + * Abstraction for a grid of allowed signature-hash-algorithm pairs. + */ +struct mbedtls_ssl_sig_hash_set_t +{ + /* At the moment, we only need to remember a single suitable + * hash algorithm per signature algorithm. As long as that's + * the case - and we don't need a general lookup function - + * we can implement the sig-hash-set as a map from signatures + * to hash algorithms. */ + mbedtls_md_type_t rsa; + mbedtls_md_type_t ecdsa; +}; +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ + /* * This structure contains the parameters only needed during handshake. */ @@ -165,8 +183,11 @@ struct mbedtls_ssl_handshake_params /* * Handshake specific crypto variables */ - int sig_alg; /*!< Hash algorithm for signature */ - int verify_sig_alg; /*!< Signature algorithm for verify */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + mbedtls_ssl_sig_hash_set_t hash_algs; /*!< Set of suitable sig-hash pairs */ +#endif #if defined(MBEDTLS_DHM_C) mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */ #endif @@ -179,7 +200,7 @@ struct mbedtls_ssl_handshake_params unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */ size_t ecjpake_cache_len; /*!< Length of cached data */ #endif -#endif +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \ defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */ @@ -195,7 +216,7 @@ struct mbedtls_ssl_handshake_params mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */ mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */ mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */ -#endif +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_PROTO_DTLS) unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */ @@ -218,7 +239,7 @@ struct mbedtls_ssl_handshake_params resending messages */ unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter for resending messages */ -#endif +#endif /* MBEDTLS_SSL_PROTO_DTLS */ /* * Checksum contexts @@ -329,6 +350,28 @@ struct mbedtls_ssl_flight_item }; #endif /* MBEDTLS_SSL_PROTO_DTLS */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + +/* Find an entry in a signature-hash set matching a given hash algorithm. */ +mbedtls_md_type_t mbedtls_ssl_sig_hash_set_find( mbedtls_ssl_sig_hash_set_t *set, + mbedtls_pk_type_t sig_alg ); +/* Add a signature-hash-pair to a signature-hash set */ +void mbedtls_ssl_sig_hash_set_add( mbedtls_ssl_sig_hash_set_t *set, + mbedtls_pk_type_t sig_alg, + mbedtls_md_type_t md_alg ); +/* Allow exactly one hash algorithm for each signature. */ +void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set, + mbedtls_md_type_t md_alg ); + +/* Setup an empty signature-hash set */ +static inline void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set ) +{ + mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE ); +} + +#endif /* MBEDTLS_SSL_PROTO_TLS1_2) && + MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */ /** * \brief Free referenced items in an SSL transform context and clear @@ -355,6 +398,84 @@ int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl ); int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ); +void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); + +/** + * \brief Update record layer + * + * This function roughly separates the implementation + * of the logic of (D)TLS from the implementation + * of the secure transport. + * + * \param ssl SSL context to use + * + * \return 0 or non-zero error code. + * + * \note A clarification on what is called 'record layer' here + * is in order, as many sensible definitions are possible: + * + * The record layer takes as input an untrusted underlying + * transport (stream or datagram) and transforms it into + * a serially multiplexed, secure transport, which + * conceptually provides the following: + * + * (1) Three datagram based, content-agnostic transports + * for handshake, alert and CCS messages. + * (2) One stream- or datagram-based transport + * for application data. + * (3) Functionality for changing the underlying transform + * securing the contents. + * + * The interface to this functionality is given as follows: + * + * a Updating + * [Currently implemented by mbedtls_ssl_read_record] + * + * Check if and on which of the four 'ports' data is pending: + * Nothing, a controlling datagram of type (1), or application + * data (2). In any case data is present, internal buffers + * provide access to the data for the user to process it. + * Consumption of type (1) datagrams is done automatically + * on the next update, invalidating that the internal buffers + * for previous datagrams, while consumption of application + * data (2) is user-controlled. + * + * b Reading of application data + * [Currently manual adaption of ssl->in_offt pointer] + * + * As mentioned in the last paragraph, consumption of data + * is different from the automatic consumption of control + * datagrams (1) because application data is treated as a stream. + * + * c Tracking availability of application data + * [Currently manually through decreasing ssl->in_msglen] + * + * For efficiency and to retain datagram semantics for + * application data in case of DTLS, the record layer + * provides functionality for checking how much application + * data is still available in the internal buffer. + * + * d Changing the transformation securing the communication. + * + * Given an opaque implementation of the record layer in the + * above sense, it should be possible to implement the logic + * of (D)TLS on top of it without the need to know anything + * about the record layer's internals. This is done e.g. + * in all the handshake handling functions, and in the + * application data reading function mbedtls_ssl_read. + * + * \note The above tries to give a conceptual picture of the + * record layer, but the current implementation deviates + * from it in some places. For example, our implementation of + * the update functionality through mbedtls_ssl_read_record + * discards datagrams depending on the current state, which + * wouldn't fall under the record layer's responsibility + * following the above definition. + * + */ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ); int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ); @@ -379,11 +500,13 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch #if defined(MBEDTLS_PK_C) unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk ); +unsigned char mbedtls_ssl_sig_from_pk_alg( mbedtls_pk_type_t type ); mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig ); #endif mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash ); unsigned char mbedtls_ssl_hash_from_md_alg( int md ); +int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ); #if defined(MBEDTLS_ECP_C) int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id ); diff --git a/tools/sdk/include/mbedtls/mbedtls/version.h b/tools/sdk/include/mbedtls/mbedtls/version.h index b40aa510..3b209a6b 100644 --- a/tools/sdk/include/mbedtls/mbedtls/version.h +++ b/tools/sdk/include/mbedtls/mbedtls/version.h @@ -38,7 +38,7 @@ * Major, Minor, Patchlevel */ #define MBEDTLS_VERSION_MAJOR 2 -#define MBEDTLS_VERSION_MINOR 3 +#define MBEDTLS_VERSION_MINOR 6 #define MBEDTLS_VERSION_PATCH 0 /** @@ -46,9 +46,9 @@ * MMNNPP00 * Major version | Minor version | Patch version */ -#define MBEDTLS_VERSION_NUMBER 0x02030000 -#define MBEDTLS_VERSION_STRING "2.3.0" -#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.3.0" +#define MBEDTLS_VERSION_NUMBER 0x02060000 +#define MBEDTLS_VERSION_STRING "2.6.0" +#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.6.0" #if defined(MBEDTLS_VERSION_C) diff --git a/tools/sdk/include/mbedtls/mbedtls/x509.h b/tools/sdk/include/mbedtls/mbedtls/x509.h index 54dac166..d7e318df 100644 --- a/tools/sdk/include/mbedtls/mbedtls/x509.h +++ b/tools/sdk/include/mbedtls/mbedtls/x509.h @@ -76,6 +76,7 @@ #define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */ #define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */ #define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */ +#define MBEDTLS_ERR_X509_FATAL_ERROR -0x3000 /**< A fatal error occured, eg the chain is too long or the vrfy callback failed. */ /* \} name */ /** @@ -157,7 +158,7 @@ #define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13) #define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14) -#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* Parsed (and then ?) */ +#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* * Storage format identifiers @@ -246,12 +247,12 @@ int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *se * \note Intended usage is "if( is_past( valid_to ) ) ERROR". * Hence the return value of 1 if on internal errors. * - * \param time mbedtls_x509_time to check + * \param to mbedtls_x509_time to check * * \return 1 if the given time is in the past or an error occured, * 0 otherwise. */ -int mbedtls_x509_time_is_past( const mbedtls_x509_time *time ); +int mbedtls_x509_time_is_past( const mbedtls_x509_time *to ); /** * \brief Check a given mbedtls_x509_time against the system time @@ -260,12 +261,12 @@ int mbedtls_x509_time_is_past( const mbedtls_x509_time *time ); * \note Intended usage is "if( is_future( valid_from ) ) ERROR". * Hence the return value of 1 if on internal errors. * - * \param time mbedtls_x509_time to check + * \param from mbedtls_x509_time to check * * \return 1 if the given time is in the future or an error occured, * 0 otherwise. */ -int mbedtls_x509_time_is_future( const mbedtls_x509_time *time ); +int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ); /** * \brief Checkup routine @@ -294,7 +295,7 @@ int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x50 mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, void **sig_opts ); int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end, - mbedtls_x509_time *time ); + mbedtls_x509_time *t ); int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *serial ); int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, diff --git a/tools/sdk/include/mbedtls/mbedtls/x509_crt.h b/tools/sdk/include/mbedtls/mbedtls/x509_crt.h index 41b6bfe5..06166d8b 100644 --- a/tools/sdk/include/mbedtls/mbedtls/x509_crt.h +++ b/tools/sdk/include/mbedtls/mbedtls/x509_crt.h @@ -120,6 +120,10 @@ mbedtls_x509_crt_profile; #define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32 #define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15 +#if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN ) +#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 +#endif + /** * Container for writing a certificate (CRT) */ @@ -263,7 +267,13 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix, * * All flags left after returning from the callback * are also returned to the application. The function should - * return 0 for anything but a fatal error. + * return 0 for anything (including invalid certificates) + * other than fatal error, as a non-zero return code + * immediately aborts the verification process. For fatal + * errors, a specific error code should be used (different + * from MBEDTLS_ERR_X509_CERT_VERIFY_FAILED which should not + * be returned at this point), or MBEDTLS_ERR_X509_FATAL_ERROR + * can be used if no better code is available. * * \note In case verification failed, the results can be displayed * using \c mbedtls_x509_crt_verify_info() @@ -285,12 +295,13 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix, * \param f_vrfy verification function * \param p_vrfy verification parameter * - * \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED - * in which case *flags will have one or more - * MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags - * set, - * or another error in case of a fatal error encountered - * during the verification process. + * \return 0 (and flags set to 0) if the chain was verified and valid, + * MBEDTLS_ERR_X509_CERT_VERIFY_FAILED if the chain was verified + * but found to be invalid, in which case *flags will have one + * or more MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX + * flags set, or another error (and flags set to 0xffffffff) + * in case of a fatal error encountered during the + * verification process. */ int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, diff --git a/tools/sdk/include/mbedtls/mbedtls/x509_csr.h b/tools/sdk/include/mbedtls/mbedtls/x509_csr.h index 7a9c2e05..fe9843cb 100644 --- a/tools/sdk/include/mbedtls/mbedtls/x509_csr.h +++ b/tools/sdk/include/mbedtls/mbedtls/x509_csr.h @@ -282,7 +282,7 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s * * \note f_rng may be NULL if RSA is used for signature and the * signature is made offline (otherwise f_rng is desirable - * for couermeasures against timing attacks). + * for countermeasures against timing attacks). * ECDSA signatures always require a non-NULL f_rng. */ int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size, diff --git a/tools/sdk/include/mbedtls_port/aes_alt.h b/tools/sdk/include/mbedtls_port/aes_alt.h index d4da6ca8..a4d0b70c 100644 --- a/tools/sdk/include/mbedtls_port/aes_alt.h +++ b/tools/sdk/include/mbedtls_port/aes_alt.h @@ -34,8 +34,8 @@ typedef esp_aes_context mbedtls_aes_context; #define mbedtls_aes_init esp_aes_init #define mbedtls_aes_free esp_aes_free -#define mbedtls_aes_setkey_enc esp_aes_setkey_enc -#define mbedtls_aes_setkey_dec esp_aes_setkey_dec +#define mbedtls_aes_setkey_enc esp_aes_setkey +#define mbedtls_aes_setkey_dec esp_aes_setkey #define mbedtls_aes_crypt_ecb esp_aes_crypt_ecb #if defined(MBEDTLS_CIPHER_MODE_CBC) #define mbedtls_aes_crypt_cbc esp_aes_crypt_cbc diff --git a/tools/sdk/include/mbedtls_port/mbedtls/config.h b/tools/sdk/include/mbedtls_port/mbedtls/config.h new file mode 100644 index 00000000..cf3d904d --- /dev/null +++ b/tools/sdk/include/mbedtls_port/mbedtls/config.h @@ -0,0 +1,9 @@ +/* This shim header is added so that any application code + which includes "mbedtls/config.h" directly gets the correct + config. */ +#pragma once +#if !defined(MBEDTLS_CONFIG_FILE) +#include_next "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif diff --git a/tools/sdk/include/mbedtls_port/mbedtls/esp_config.h b/tools/sdk/include/mbedtls_port/mbedtls/esp_config.h index 447fc302..c81bf1a0 100644 --- a/tools/sdk/include/mbedtls_port/mbedtls/esp_config.h +++ b/tools/sdk/include/mbedtls_port/mbedtls/esp_config.h @@ -430,7 +430,9 @@ * * Uncomment this macro to remove RC4 ciphersuites by default. */ +#ifdef CONFIG_MBEDTLS_RC4_ENABLED #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES +#endif /** * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED @@ -440,18 +442,42 @@ * * Comment macros to disable the curve and functions for it */ +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED #define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED #define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED #define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED #define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED #define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED #define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED #define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED #define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED #define MBEDTLS_ECP_DP_BP256R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED #define MBEDTLS_ECP_DP_BP384R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_BP512R1_ENABLED +#endif +#ifdef CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#endif /** * \def MBEDTLS_ECP_NIST_OPTIM @@ -462,7 +488,9 @@ * * Comment this macro to disable NIST curves optimisation. */ +#ifdef CONFIG_MBEDTLS_ECP_NIST_OPTIM #define MBEDTLS_ECP_NIST_OPTIM +#endif /** * \def MBEDTLS_ECDSA_DETERMINISTIC @@ -498,7 +526,9 @@ * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_PSK #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED @@ -522,7 +552,9 @@ * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK #define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED @@ -542,7 +574,9 @@ * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK #define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED @@ -567,7 +601,9 @@ * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED @@ -595,7 +631,9 @@ * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_RSA #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED @@ -621,7 +659,9 @@ * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED @@ -646,7 +686,9 @@ * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED @@ -670,7 +712,9 @@ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED @@ -694,7 +738,9 @@ * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED @@ -718,7 +764,9 @@ * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */ +#ifdef CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED +#endif /** * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED @@ -971,7 +1019,9 @@ * * Comment this macro to disable support for Encrypt-then-MAC */ +#ifdef CONFIG_MBEDTLS_TLS_ENABLED #define MBEDTLS_SSL_ENCRYPT_THEN_MAC +#endif /** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET * @@ -989,7 +1039,9 @@ * * Comment this macro to disable support for Extended Master Secret. */ +#ifdef CONFIG_MBEDTLS_TLS_ENABLED #define MBEDTLS_SSL_EXTENDED_MASTER_SECRET +#endif /** * \def MBEDTLS_SSL_FALLBACK_SCSV @@ -1028,7 +1080,9 @@ * * Comment this macro to disable 1/n-1 record splitting. */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) #define MBEDTLS_SSL_CBC_RECORD_SPLITTING +#endif /** * \def MBEDTLS_SSL_RENEGOTIATION @@ -1043,7 +1097,9 @@ * * Comment this to disable support for renegotiation. */ +#ifdef CONFIG_MBEDTLS_SSL_RENEGOTIATION #define MBEDTLS_SSL_RENEGOTIATION +#endif /** * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO @@ -1084,7 +1140,9 @@ * * Comment this macro to disable support for SSL 3.0 */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_SSL3 #define MBEDTLS_SSL_PROTO_SSL3 +#endif /** * \def MBEDTLS_SSL_PROTO_TLS1 @@ -1096,7 +1154,9 @@ * * Comment this macro to disable support for TLS 1.0 */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1 #define MBEDTLS_SSL_PROTO_TLS1 +#endif /** * \def MBEDTLS_SSL_PROTO_TLS1_1 @@ -1108,7 +1168,9 @@ * * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 #define MBEDTLS_SSL_PROTO_TLS1_1 +#endif /** * \def MBEDTLS_SSL_PROTO_TLS1_2 @@ -1120,7 +1182,9 @@ * * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 #define MBEDTLS_SSL_PROTO_TLS1_2 +#endif /** * \def MBEDTLS_SSL_PROTO_DTLS @@ -1135,7 +1199,9 @@ * * Comment this macro to disable support for DTLS */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_PROTO_DTLS +#endif /** * \def MBEDTLS_SSL_ALPN @@ -1144,7 +1210,9 @@ * * Comment this macro to disable support for ALPN. */ +#ifdef CONFIG_MBEDTLS_SSL_ALPN #define MBEDTLS_SSL_ALPN +#endif /** * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY @@ -1159,7 +1227,9 @@ * * Comment this to disable anti-replay in DTLS. */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_DTLS_ANTI_REPLAY +#endif /** * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY @@ -1177,7 +1247,9 @@ * * Comment this to disable support for HelloVerifyRequest. */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_DTLS_HELLO_VERIFY +#endif /** * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE @@ -1193,7 +1265,9 @@ * * Comment this to disable support for clients reusing the source port. */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE +#endif /** * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT @@ -1204,7 +1278,9 @@ * * Requires: MBEDTLS_SSL_PROTO_DTLS */ +#ifdef CONFIG_MBEDTLS_SSL_PROTO_DTLS #define MBEDTLS_SSL_DTLS_BADMAC_LIMIT +#endif /** * \def MBEDTLS_SSL_SESSION_TICKETS @@ -1218,7 +1294,9 @@ * * Comment this macro to disable support for SSL session tickets */ +#ifdef CONFIG_MBEDTLS_SSL_SESSION_TICKETS #define MBEDTLS_SSL_SESSION_TICKETS +#endif /** * \def MBEDTLS_SSL_EXPORT_KEYS @@ -1461,7 +1539,9 @@ * * PEM_PARSE uses AES for decrypting encrypted keys. */ +#ifdef CONFIG_MBEDTLS_AES_C #define MBEDTLS_AES_C +#endif /** * \def MBEDTLS_ARC4_C @@ -1484,7 +1564,9 @@ * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA */ +#if defined(CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT) || defined(CONFIG_MBEDTLS_RC4_ENABLED) #define MBEDTLS_ARC4_C +#endif /** * \def MBEDTLS_ASN1_PARSE_C @@ -1549,7 +1631,9 @@ * * Module: library/blowfish.c */ +#ifdef CONFIG_MBEDTLS_BLOWFISH_C #define MBEDTLS_BLOWFISH_C +#endif /** * \def MBEDTLS_CAMELLIA_C @@ -1604,7 +1688,9 @@ * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 */ +#ifdef CONFIG_MBEDTLS_CAMELLIA_C #define MBEDTLS_CAMELLIA_C +#endif /** * \def MBEDTLS_CCM_C @@ -1618,7 +1704,9 @@ * This module enables the AES-CCM ciphersuites, if other requisites are * enabled as well. */ +#ifdef CONFIG_MBEDTLS_CCM_C #define MBEDTLS_CCM_C +#endif /** * \def MBEDTLS_CERTS_C @@ -1698,7 +1786,9 @@ * * PEM_PARSE uses DES/3DES for decrypting encrypted keys. */ +#ifdef CONFIG_MBEDTLS_DES_C #define MBEDTLS_DES_C +#endif /** * \def MBEDTLS_DHM_C @@ -1728,7 +1818,9 @@ * * Requires: MBEDTLS_ECP_C */ +#ifdef CONFIG_MBEDTLS_ECDH_C #define MBEDTLS_ECDH_C +#endif /** * \def MBEDTLS_ECDSA_C @@ -1743,7 +1835,9 @@ * * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C */ +#ifdef CONFIG_MBEDTLS_ECDSA_C #define MBEDTLS_ECDSA_C +#endif /** * \def MBEDTLS_ECJPAKE_C @@ -1776,7 +1870,9 @@ * * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED */ +#ifdef CONFIG_MBEDTLS_ECP_C #define MBEDTLS_ECP_C +#endif /** * \def MBEDTLS_ENTROPY_C @@ -1816,7 +1912,9 @@ * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other * requisites are enabled as well. */ +#ifdef CONFIG_MBEDTLS_GCM_C #define MBEDTLS_GCM_C +#endif /** * \def MBEDTLS_HAVEGE_C @@ -1986,7 +2084,9 @@ * * This modules adds support for decoding / parsing PEM files. */ +#ifdef CONFIG_MBEDTLS_PEM_PARSE_C #define MBEDTLS_PEM_PARSE_C +#endif /** * \def MBEDTLS_PEM_WRITE_C @@ -2002,7 +2102,9 @@ * * This modules adds support for encoding / writing PEM files. */ +#ifdef CONFIG_MBEDTLS_PEM_WRITE_C #define MBEDTLS_PEM_WRITE_C +#endif /** * \def MBEDTLS_PK_C @@ -2122,7 +2224,9 @@ * Caller: library/mbedtls_md.c * */ +#ifdef CONFIG_MBEDTLS_RIPEMD160_C #define MBEDTLS_RIPEMD160_C +#endif /** * \def MBEDTLS_RSA_C @@ -2236,7 +2340,9 @@ * * This module is required for SSL/TLS client support. */ +#ifdef CONFIG_MBEDTLS_TLS_CLIENT #define MBEDTLS_SSL_CLI_C +#endif /** * \def MBEDTLS_SSL_SRV_C @@ -2250,7 +2356,9 @@ * * This module is required for SSL/TLS server support. */ +#ifdef CONFIG_MBEDTLS_TLS_SERVER #define MBEDTLS_SSL_SRV_C +#endif /** * \def MBEDTLS_SSL_TLS_C @@ -2266,7 +2374,9 @@ * * This module is required for SSL/TLS. */ +#ifdef CONFIG_MBEDTLS_TLS_ENABLED #define MBEDTLS_SSL_TLS_C +#endif /** * \def MBEDTLS_THREADING_C @@ -2357,7 +2467,9 @@ * * This module is required for X.509 CRL parsing. */ +#ifdef CONFIG_MBEDTLS_X509_CRL_PARSE_C #define MBEDTLS_X509_CRL_PARSE_C +#endif /** * \def MBEDTLS_X509_CSR_PARSE_C @@ -2371,7 +2483,9 @@ * * This module is used for reading X.509 certificate request. */ +#ifdef CONFIG_MBEDTLS_X509_CSR_PARSE_C #define MBEDTLS_X509_CSR_PARSE_C +#endif /** * \def MBEDTLS_X509_CREATE_C @@ -2420,7 +2534,9 @@ * Module: library/xtea.c * Caller: */ +#ifdef CONFIG_MBEDTLS_XTEA_C #define MBEDTLS_XTEA_C +#endif /* \} name SECTION: mbed TLS modules */ @@ -2516,6 +2632,17 @@ /* X509 options */ //#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ +/** + * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake + * signature and ciphersuite selection. Without this build-time option, SHA-1 + * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. + * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by + * default. At the time of writing, there is no practical attack on the use + * of SHA-1 in handshake signatures, hence this option is turned on by default + * for compatibility with existing peers. + */ +#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE + /* \} name SECTION: Module configuration options */ #if defined(TARGET_LIKE_MBED) diff --git a/tools/sdk/include/newlib/esp_newlib.h b/tools/sdk/include/newlib/esp_newlib.h index eac35442..19284439 100644 --- a/tools/sdk/include/newlib/esp_newlib.h +++ b/tools/sdk/include/newlib/esp_newlib.h @@ -34,10 +34,8 @@ void esp_reent_init(struct _reent* r); void esp_setup_syscall_table(); /** - * Initialize hardware timer used as time source for newlib time functions. - * - * Called from the startup code, not intended to be called from application. + * Update current microsecond time from RTC */ -void esp_setup_time_syscalls(); +void esp_set_time_from_rtc(); #endif //__ESP_NEWLIB_H__ diff --git a/tools/sdk/include/newlib/sys/features.h b/tools/sdk/include/newlib/sys/features.h index 1d90921a..87f3314f 100644 --- a/tools/sdk/include/newlib/sys/features.h +++ b/tools/sdk/include/newlib/sys/features.h @@ -210,6 +210,12 @@ extern "C" { #endif /* __CYGWIN__ */ +/* ESP-IDF-specific: enable pthreads support */ +#ifdef __XTENSA__ +#define _POSIX_THREADS 1 +#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 +#endif + /* Per the permission given in POSIX.1-2008 section 2.2.1, define * _POSIX_C_SOURCE if _XOPEN_SOURCE is defined and _POSIX_C_SOURCE is not. * (_XOPEN_SOURCE indicates that XSI extensions are desired by an application.) diff --git a/tools/sdk/include/newlib/sys/sched.h b/tools/sdk/include/newlib/sys/sched.h index 58f99d68..8554fc2b 100644 --- a/tools/sdk/include/newlib/sys/sched.h +++ b/tools/sdk/include/newlib/sys/sched.h @@ -58,6 +58,8 @@ struct sched_param { #endif }; +int sched_yield( void ); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/newlib/sys/time.h b/tools/sdk/include/newlib/sys/time.h index be16497f..8e3ef808 100644 --- a/tools/sdk/include/newlib/sys/time.h +++ b/tools/sdk/include/newlib/sys/time.h @@ -20,7 +20,7 @@ struct timeval { }; /* BSD time macros used by RTEMS code */ -#if defined (__rtems__) || defined (__CYGWIN__) +#if defined (__rtems__) || defined (__CYGWIN__) || defined(__XTENSA__) /* Convenience macros for operations on timevals. NOTE: `timercmp' does not work for >= or <=. */ diff --git a/tools/sdk/include/nvs_flash/nvs.h b/tools/sdk/include/nvs_flash/nvs.h index 5b469f76..dfdd18c9 100644 --- a/tools/sdk/include/nvs_flash/nvs.h +++ b/tools/sdk/include/nvs_flash/nvs.h @@ -43,7 +43,9 @@ typedef uint32_t nvs_handle; #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ #define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_PART_NOT_FOUND (ESP_ERR_NVS_BASE + 0x0f) /*!< Partition with specified name is not found in the partition table */ +#define NVS_DEFAULT_PART_NAME "nvs" /*!< Default partition name of the NVS partition in the partition table */ /** * @brief Mode of opening the non-volatile storage * @@ -54,15 +56,45 @@ typedef enum { } nvs_open_mode; /** - * @brief Open non-volatile storage with a given namespace + * @brief Open non-volatile storage with a given namespace from the default NVS partition * * Multiple internal ESP-IDF and third party application modules can store * their key-value pairs in the NVS module. In order to reduce possible * conflicts on key names, each module can use its own namespace. + * The default NVS partition is the one that is labelled "nvs" in the partition + * table. * * @param[in] name Namespace name. Maximal length is determined by the * underlying implementation, but is guaranteed to be * at least 15 characters. Shouldn't be empty. + * @param[in] open_mode NVS_READWRITE or NVS_READONLY. If NVS_READONLY, will + * open a handle for reading only. All write requests will + * be rejected for this handle. + * @param[out] out_handle If successful (return code is zero), handle will be + * returned in this argument. + * + * @return + * - ESP_OK if storage handle was opened successfully + * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized + * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with label "nvs" is not found + * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and + * mode is NVS_READONLY + * - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints + * - other error codes from the underlying storage driver + */ +esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_handle); + +/** + * @brief Open non-volatile storage with a given namespace from specified partition + * + * The behaviour is same as nvs_open() API. However this API can operate on a specified NVS + * partition instead of default NVS partition. Note that the specified partition must be registered + * with NVS using nvs_flash_init_partition() API. + * + * @param[in] part_name Label (name) of the partition of interest for object read/write/erase + * @param[in] name Namespace name. Maximal length is determined by the + * underlying implementation, but is guaranteed to be + * at least 15 characters. Shouldn't be empty. * @param[in] open_mode NVS_READWRITE or NVS_READONLY. If NVS_READONLY, will * open a handle for reading only. All write requests will * be rejected for this handle. @@ -72,12 +104,13 @@ typedef enum { * @return * - ESP_OK if storage handle was opened successfully * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized + * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with specified name is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and * mode is NVS_READONLY * - ESP_ERR_NVS_INVALID_NAME if namespace name doesn't satisfy constraints * - other error codes from the underlying storage driver */ -esp_err_t nvs_open(const char* name, nvs_open_mode open_mode, nvs_handle *out_handle); +esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_open_mode open_mode, nvs_handle *out_handle); /**@{*/ /** diff --git a/tools/sdk/include/nvs_flash/nvs_flash.h b/tools/sdk/include/nvs_flash/nvs_flash.h index 9220f0d3..c9e4a72d 100644 --- a/tools/sdk/include/nvs_flash/nvs_flash.h +++ b/tools/sdk/include/nvs_flash/nvs_flash.h @@ -21,28 +21,61 @@ extern "C" { #include "nvs.h" /** - * @brief Initialize NVS flash storage with layout given in the partition table. + * @brief Initialize the default NVS partition. + * + * This API initialises the default NVS partition. The default NVS partition + * is the one that is labelled "nvs" in the partition table. * * @return * - ESP_OK if storage was successfully initialized. * - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages * (which may happen if NVS partition was truncated) + * - ESP_ERR_NOT_FOUND if no partition with label "nvs" is found in the partition table * - one of the error codes from the underlying flash storage driver */ esp_err_t nvs_flash_init(void); +/** + * @brief Initialize NVS flash storage for the specified partition. + * + * @param[in] partition_name Name (label) of the partition. Note that internally a reference to + * passed value is kept and it should be accessible for future operations + * + * @return + * - ESP_OK if storage was successfully initialized. + * - ESP_ERR_NVS_NO_FREE_PAGES if the NVS storage contains no empty pages + * (which may happen if NVS partition was truncated) + * - ESP_ERR_NOT_FOUND if specified partition is not found in the partition table + * - one of the error codes from the underlying flash storage driver + */ +esp_err_t nvs_flash_init_partition(const char *partition_name); /** - * @brief Erase NVS partition + * @brief Erase the default NVS partition * - * This function erases all contents of NVS partition + * This function erases all contents of the default NVS partition (one with label "nvs") * * @return * - ESP_OK on success - * - ESP_ERR_NOT_FOUND if there is no NVS partition in the partition table + * - ESP_ERR_NOT_FOUND if there is no NVS partition labeled "nvs" in the + * partition table */ esp_err_t nvs_flash_erase(void); +/** + * @brief Erase specified NVS partition + * + * This function erases all contents of specified NVS partition + * + * @param[in] part_name Name (label) of the partition to be erased + * + * @return + * - ESP_OK on success + * - ESP_ERR_NOT_FOUND if there is no NVS partition with the specified name + * in the partition table + */ +esp_err_t nvs_flash_erase_partition(const char *part_name); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/include/soc/soc/adc_channel.h b/tools/sdk/include/soc/soc/adc_channel.h new file mode 100644 index 00000000..e8835d35 --- /dev/null +++ b/tools/sdk/include/soc/soc/adc_channel.h @@ -0,0 +1,72 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_ADC_CHANNEL_H +#define _SOC_ADC_CHANNEL_H + +#define ADC1_GPIO36_CHANNEL ADC1_CHANNEL_0 +#define ADC1_CHANNEL_0_GPIO_NUM 36 + +#define ADC1_GPIO37_CHANNEL ADC1_CHANNEL_1 +#define ADC1_CHANNEL_1_GPIO_NUM 37 + +#define ADC1_GPIO38_CHANNEL ADC1_CHANNEL_2 +#define ADC1_CHANNEL_2_GPIO_NUM 38 + +#define ADC1_GPIO39_CHANNEL ADC1_CHANNEL_3 +#define ADC1_CHANNEL_3_GPIO_NUM 39 + +#define ADC1_GPIO32_CHANNEL ADC1_CHANNEL_4 +#define ADC1_CHANNEL_4_GPIO_NUM 32 + +#define ADC1_GPIO33_CHANNEL ADC1_CHANNEL_5 +#define ADC1_CHANNEL_5_GPIO_NUM 33 + +#define ADC1_GPIO34_CHANNEL ADC1_CHANNEL_6 +#define ADC1_CHANNEL_6_GPIO_NUM 34 + +#define ADC1_GPIO35_CHANNEL ADC1_CHANNEL_7 +#define ADC1_CHANNEL_7_GPIO_NUM 35 + +#define ADC2_GPIO4_CHANNEL ADC2_CHANNEL_0 +#define ADC2_CHANNEL_0_GPIO_NUM 4 + +#define ADC2_GPIO0_CHANNEL ADC2_CHANNEL_1 +#define ADC2_CHANNEL_1_GPIO_NUM 0 + +#define ADC2_GPIO2_CHANNEL ADC2_CHANNEL_2 +#define ADC2_CHANNEL_2_GPIO_NUM 2 + +#define ADC2_GPIO15_CHANNEL ADC2_CHANNEL_3 +#define ADC2_CHANNEL_3_GPIO_NUM 15 + +#define ADC2_GPIO13_CHANNEL ADC2_CHANNEL_4 +#define ADC2_CHANNEL_4_GPIO_NUM 13 + +#define ADC2_GPIO12_CHANNEL ADC2_CHANNEL_5 +#define ADC2_CHANNEL_5_GPIO_NUM 12 + +#define ADC2_GPIO14_CHANNEL ADC2_CHANNEL_6 +#define ADC2_CHANNEL_6_GPIO_NUM 14 + +#define ADC2_GPIO27_CHANNEL ADC2_CHANNEL_7 +#define ADC2_CHANNEL_7_GPIO_NUM 27 + +#define ADC2_GPIO25_CHANNEL ADC2_CHANNEL_8 +#define ADC2_CHANNEL_8_GPIO_NUM 25 + +#define ADC2_GPIO26_CHANNEL ADC2_CHANNEL_9 +#define ADC2_CHANNEL_9_GPIO_NUM 26 + +#endif diff --git a/tools/sdk/include/soc/soc/apb_ctrl_struct.h b/tools/sdk/include/soc/soc/apb_ctrl_struct.h index d2596783..0d8e49a4 100644 --- a/tools/sdk/include/soc/soc/apb_ctrl_struct.h +++ b/tools/sdk/include/soc/soc/apb_ctrl_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_APB_CTRL_STRUCT_H_ #define _SOC_APB_CTRL_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { union { struct { @@ -117,4 +122,9 @@ typedef struct { volatile uint32_t date; /**/ } apb_ctrl_dev_t; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_APB_CTRL_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/clkout_channel.h b/tools/sdk/include/soc/soc/clkout_channel.h new file mode 100644 index 00000000..5161e3f0 --- /dev/null +++ b/tools/sdk/include/soc/soc/clkout_channel.h @@ -0,0 +1,26 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_CLKOUT_CHANNEL_H +#define _SOC_CLKOUT_CHANNEL_H + +//CLKOUT channels +#define CLKOUT_GPIO0_DIRECT_CHANNEL CLKOUT_CHANNEL_1 +#define CLKOUT_CHANNEL_1_DIRECT_GPIO_NUM 0 +#define CLKOUT_GPIO3_DIRECT_CHANNEL CLKOUT_CHANNEL_2 +#define CLKOUT_CHANNEL_2_DIRECT_GPIO_NUM 3 +#define CLKOUT_GPIO1_DIRECT_CHANNEL CLKOUT_CHANNEL_3 +#define CLKOUT_CHANNEL_3_DIRECT_GPIO_NUM 1 + +#endif diff --git a/tools/sdk/include/soc/soc/dac_channel.h b/tools/sdk/include/soc/soc/dac_channel.h new file mode 100644 index 00000000..241a067b --- /dev/null +++ b/tools/sdk/include/soc/soc/dac_channel.h @@ -0,0 +1,24 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_DAC_CHANNEL_H +#define _SOC_DAC_CHANNEL_H + +#define DAC_GPIO25_CHANNEL DAC_CHANNEL_1 +#define DAC_CHANNEL_1_GPIO_NUM 25 + +#define DAC_GPIO26_CHANNEL DAC_CHANNEL_2 +#define DAC_CHANNEL_2_GPIO_NUM 26 + +#endif diff --git a/tools/sdk/include/soc/soc/dport_access.h b/tools/sdk/include/soc/soc/dport_access.h index d1d264cb..817ac98e 100644 --- a/tools/sdk/include/soc/soc/dport_access.h +++ b/tools/sdk/include/soc/soc/dport_access.h @@ -25,14 +25,21 @@ extern "C" { //Registers Operation {{ -//Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe. +// The _DPORT_xxx register read macros access DPORT memory directly (as opposed to +// DPORT_REG_READ which applies SMP-safe protections). +// +// Use DPORT_REG_READ versions to be SMP-safe in IDF apps. If you want to +// make a sequence of DPORT reads, use DPORT_STALL_OTHER_CPU_START() macro +// explicitly and then use _DPORT_REG_READ macro while other CPU is stalled. +// +// _DPORT_REG_WRITE & DPORT_REG_WRITE are equivalent. #define _DPORT_REG_READ(_r) (*(volatile uint32_t *)(_r)) #define _DPORT_REG_WRITE(_r, _v) (*(volatile uint32_t *)(_r)) = (_v) -//write value to register +// Write value to DPORT register (does not require protecting) #define DPORT_REG_WRITE(_r, _v) _DPORT_REG_WRITE((_r), (_v)) -//read value from register +// Read value from register, SMP-safe version. static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg) { uint32_t val; @@ -40,7 +47,7 @@ static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg) DPORT_STALL_OTHER_CPU_START(); val = _DPORT_REG_READ(reg); DPORT_STALL_OTHER_CPU_END(); - + return val; } @@ -81,8 +88,10 @@ static inline uint32_t IRAM_ATTR DPORT_REG_READ(uint32_t reg) #define DPORT_FIELD_TO_VALUE2(_f, _v) (((_v)<<_f##_S) & (_f)) //Register read macros with an underscore prefix access DPORT memory directly. In IDF apps, use the non-underscore versions to be SMP-safe. -#define _DPORT_READ_PERI_REG(addr) (*((volatile uint32_t *)(addr))) -#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)(addr))) = (uint32_t)(val) +#define _DPORT_READ_PERI_REG(addr) (*((volatile uint32_t *)(addr))) +#define _DPORT_WRITE_PERI_REG(addr, val) (*((volatile uint32_t *)(addr))) = (uint32_t)(val) +#define _DPORT_REG_SET_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r)|(_b))) +#define _DPORT_REG_CLR_BIT(_r, _b) _DPORT_REG_WRITE((_r), (_DPORT_REG_READ(_r) & (~(_b)))) //read value from register static inline uint32_t IRAM_ATTR DPORT_READ_PERI_REG(uint32_t addr) diff --git a/tools/sdk/include/soc/soc/dport_reg.h b/tools/sdk/include/soc/soc/dport_reg.h index 56e18246..98e60365 100644 --- a/tools/sdk/include/soc/soc/dport_reg.h +++ b/tools/sdk/include/soc/soc/dport_reg.h @@ -1055,6 +1055,8 @@ #define DPORT_WIFI_CLK_BT_EN_S 11 /* Remaining single bit clock masks */ #define DPORT_WIFI_CLK_SDIOSLAVE_EN BIT(4) +#define DPORT_WIFI_CLK_UNUSED_BIT5 BIT(5) +#define DPORT_WIFI_CLK_UNUSED_BIT12 BIT(12) #define DPORT_WIFI_CLK_SDIO_HOST_EN BIT(13) #define DPORT_WIFI_CLK_EMAC_EN BIT(14) #define DPORT_WIFI_CLK_RNG_EN BIT(15) diff --git a/tools/sdk/include/soc/soc/frc_timer_reg.h b/tools/sdk/include/soc/soc/frc_timer_reg.h index d76199c4..a2152c5c 100644 --- a/tools/sdk/include/soc/soc/frc_timer_reg.h +++ b/tools/sdk/include/soc/soc/frc_timer_reg.h @@ -32,12 +32,15 @@ #define FRC_TIMER_COUNT_S 0 #define FRC_TIMER_CTRL_REG(i) (REG_FRC_TIMER_BASE(i) + 0x8) -#define FRC_TIMER_INT_ENABLE (BIT(8)) // enable interrupt +#define FRC_TIMER_INT_STATUS (BIT(8)) // interrupt status (RO) #define FRC_TIMER_ENABLE (BIT(7)) // enable timer #define FRC_TIMER_AUTOLOAD (BIT(6)) // enable autoload -#define FRC_TIMER_PRESCALER 0x00000007 // 0: divide by 1, 2: divide by 16, 4: divide by 256 +#define FRC_TIMER_PRESCALER 0x00000007 #define FRC_TIMER_PRESCALER_S 1 -#define FRC_TIMER_EDGE_INT (BIT(0)) // 0: level, 1: edge +#define FRC_TIMER_PRESCALER_1 (0 << FRC_TIMER_PRESCALER_S) +#define FRC_TIMER_PRESCALER_16 (2 << FRC_TIMER_PRESCALER_S) +#define FRC_TIMER_PRESCALER_256 (4 << FRC_TIMER_PRESCALER_S) +#define FRC_TIMER_LEVEL_INT (BIT(0)) // 1: level, 0: edge #define FRC_TIMER_INT_REG(i) (REG_FRC_TIMER_BASE(i) + 0xC) #define FRC_TIMER_INT_CLR (BIT(0)) // clear interrupt diff --git a/tools/sdk/include/soc/soc/gpio_sd_struct.h b/tools/sdk/include/soc/soc/gpio_sd_struct.h index 94ddd5ba..e5001c23 100644 --- a/tools/sdk/include/soc/soc/gpio_sd_struct.h +++ b/tools/sdk/include/soc/soc/gpio_sd_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_GPIO_SD_STRUCT_H_ #define _SOC_GPIO_SD_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -45,4 +50,9 @@ typedef volatile struct { } version; } gpio_sd_dev_t; extern gpio_sd_dev_t SIGMADELTA; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_GPIO_SD_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/gpio_struct.h b/tools/sdk/include/soc/soc/gpio_struct.h index 7a90b71a..46ee8822 100644 --- a/tools/sdk/include/soc/soc/gpio_struct.h +++ b/tools/sdk/include/soc/soc/gpio_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_GPIO_STRUCT_H_ #define _SOC_GPIO_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { uint32_t bt_select; /*NA*/ uint32_t out; /*GPIO0~31 output value*/ @@ -201,4 +206,9 @@ typedef volatile struct { } func_out_sel_cfg[40]; } gpio_dev_t; extern gpio_dev_t GPIO; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_GPIO_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/hwcrypto_reg.h b/tools/sdk/include/soc/soc/hwcrypto_reg.h index 10e80d93..d0dfa748 100644 --- a/tools/sdk/include/soc/soc/hwcrypto_reg.h +++ b/tools/sdk/include/soc/soc/hwcrypto_reg.h @@ -57,4 +57,12 @@ #define SHA_512_LOAD_REG ((DR_REG_SHA_BASE) + 0xb8) #define SHA_512_BUSY_REG ((DR_REG_SHA_BASE) + 0xbc) +/* AES acceleration registers */ +#define AES_START_REG ((DR_REG_AES_BASE) + 0x00) +#define AES_IDLE_REG ((DR_REG_AES_BASE) + 0x04) +#define AES_MODE_REG ((DR_REG_AES_BASE) + 0x08) +#define AES_KEY_BASE ((DR_REG_AES_BASE) + 0x10) +#define AES_TEXT_BASE ((DR_REG_AES_BASE) + 0x30) +#define AES_ENDIAN ((DR_REG_AES_BASE) + 0x40) + #endif diff --git a/tools/sdk/include/soc/soc/i2c_struct.h b/tools/sdk/include/soc/soc/i2c_struct.h index ea50d6be..7e781870 100644 --- a/tools/sdk/include/soc/soc/i2c_struct.h +++ b/tools/sdk/include/soc/soc/i2c_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_I2C_STRUCT_H_ #define _SOC_I2C_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -286,4 +291,9 @@ typedef volatile struct { } i2c_dev_t; extern i2c_dev_t I2C0; extern i2c_dev_t I2C1; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_I2C_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/i2s_struct.h b/tools/sdk/include/soc/soc/i2s_struct.h index 6d9fcbab..8ec3145c 100644 --- a/tools/sdk/include/soc/soc/i2s_struct.h +++ b/tools/sdk/include/soc/soc/i2s_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_I2S_STRUCT_H_ #define _SOC_I2S_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { uint32_t reserved_0; uint32_t reserved_4; @@ -458,4 +463,8 @@ typedef volatile struct { extern i2s_dev_t I2S0; extern i2s_dev_t I2S1; +#ifdef __cplusplus +} +#endif + #endif /* _SOC_I2S_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/ledc_struct.h b/tools/sdk/include/soc/soc/ledc_struct.h index 0745a2ec..dd3c364b 100644 --- a/tools/sdk/include/soc/soc/ledc_struct.h +++ b/tools/sdk/include/soc/soc/ledc_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_LEDC_STRUCT_H_ #define _SOC_LEDC_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { struct { struct { @@ -243,4 +248,9 @@ typedef volatile struct { uint32_t date; /*This register represents the version .*/ } ledc_dev_t; extern ledc_dev_t LEDC; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_LEDC_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/mcpwm_struct.h b/tools/sdk/include/soc/soc/mcpwm_struct.h index 4d49e504..f41d40c6 100644 --- a/tools/sdk/include/soc/soc/mcpwm_struct.h +++ b/tools/sdk/include/soc/soc/mcpwm_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_MCPWM_STRUCT_H__ #define _SOC_MCPWM_STRUCT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -449,4 +454,9 @@ typedef volatile struct { } mcpwm_dev_t; extern mcpwm_dev_t MCPWM0; extern mcpwm_dev_t MCPWM1; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_MCPWM_STRUCT_H__ */ diff --git a/tools/sdk/include/soc/soc/pcnt_struct.h b/tools/sdk/include/soc/soc/pcnt_struct.h index 506141ba..8cfd4ca3 100644 --- a/tools/sdk/include/soc/soc/pcnt_struct.h +++ b/tools/sdk/include/soc/soc/pcnt_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_PCNT_STRUCT_H_ #define _SOC_PCNT_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { struct{ union { @@ -169,4 +174,9 @@ typedef volatile struct { uint32_t date; /**/ } pcnt_dev_t; extern pcnt_dev_t PCNT; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_PCNT_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/rmt_struct.h b/tools/sdk/include/soc/soc/rmt_struct.h index 335cb819..68e244ad 100644 --- a/tools/sdk/include/soc/soc/rmt_struct.h +++ b/tools/sdk/include/soc/soc/rmt_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_RMT_STRUCT_H_ #define _SOC_RMT_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { uint32_t data_ch[8]; /*The R/W ram address for channel0-7 by apb fifo access.*/ struct{ @@ -259,4 +264,8 @@ typedef volatile struct { } rmt_mem_t; extern rmt_mem_t RMTMEM; +#ifdef __cplusplus +} +#endif + #endif /* _SOC_RMT_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/rtc.h b/tools/sdk/include/soc/soc/rtc.h index a85265fd..b47e39e1 100644 --- a/tools/sdk/include/soc/soc/rtc.h +++ b/tools/sdk/include/soc/soc/rtc.h @@ -393,6 +393,7 @@ typedef struct { uint32_t rtc_dbias_wak : 3; //!< set bias for RTC domain, in active mode uint32_t rtc_dbias_slp : 3; //!< set bias for RTC domain, in sleep mode uint32_t lslp_meminf_pd : 1; //!< remove all peripheral force power up flags + uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator } rtc_sleep_config_t; /** @@ -419,7 +420,8 @@ typedef struct { .dig_dbias_slp = RTC_CNTL_DBIAS_0V90, \ .rtc_dbias_wak = RTC_CNTL_DBIAS_0V90, \ .rtc_dbias_slp = RTC_CNTL_DBIAS_0V90, \ - .lslp_meminf_pd = 1 \ + .lslp_meminf_pd = 1, \ + .vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \ }; #define RTC_SLEEP_PD_DIG BIT(0) //!< Deep sleep (power down digital domain) @@ -427,6 +429,7 @@ typedef struct { #define RTC_SLEEP_PD_RTC_SLOW_MEM BIT(2) //!< Power down RTC SLOW memory #define RTC_SLEEP_PD_RTC_FAST_MEM BIT(3) //!< Power down RTC FAST memory #define RTC_SLEEP_PD_RTC_MEM_FOLLOW_CPU BIT(4) //!< RTC FAST and SLOW memories are automatically powered up and down along with the CPU +#define RTC_SLEEP_PD_VDDSDIO BIT(5) //!< Power down VDDSDIO regulator /** * @brief Prepare the chip to enter sleep mode diff --git a/tools/sdk/include/soc/soc/rtc_cntl_struct.h b/tools/sdk/include/soc/soc/rtc_cntl_struct.h index acb12432..e2037226 100644 --- a/tools/sdk/include/soc/soc/rtc_cntl_struct.h +++ b/tools/sdk/include/soc/soc/rtc_cntl_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_RTC_CNTL_STRUCT_H_ #define _SOC_RTC_CNTL_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -550,4 +555,10 @@ typedef volatile struct { uint32_t val; } date; } rtc_cntl_dev_t; +extern rtc_cntl_dev_t RTCCNTL; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_RTC_CNTL_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/rtc_gpio_channel.h b/tools/sdk/include/soc/soc/rtc_gpio_channel.h new file mode 100644 index 00000000..c5107a0f --- /dev/null +++ b/tools/sdk/include/soc/soc/rtc_gpio_channel.h @@ -0,0 +1,73 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_RTC_GPIO_CHANNEL_H +#define _SOC_RTC_GPIO_CHANNEL_H + +//RTC GPIO channels +#define RTCIO_GPIO36_CHANNEL 0 //RTCIO_CHANNEL_0 +#define RTCIO_CHANNEL_0_GPIO_NUM 36 + +#define RTCIO_GPIO37_CHANNEL 1 //RTCIO_CHANNEL_1 +#define RTCIO_CHANNEL_1_GPIO_NUM 37 + +#define RTCIO_GPIO38_CHANNEL 2 //RTCIO_CHANNEL_2 +#define RTCIO_CHANNEL_2_GPIO_NUM 38 + +#define RTCIO_GPIO39_CHANNEL 3 //RTCIO_CHANNEL_3 +#define RTCIO_CHANNEL_3_GPIO_NUM 39 + +#define RTCIO_GPIO34_CHANNEL 4 //RTCIO_CHANNEL_4 +#define RTCIO_CHANNEL_4_GPIO_NUM 34 + +#define RTCIO_GPIO35_CHANNEL 5 //RTCIO_CHANNEL_5 +#define RTCIO_CHANNEL_5_GPIO_NUM 35 + +#define RTCIO_GPIO25_CHANNEL 6 //RTCIO_CHANNEL_6 +#define RTCIO_CHANNEL_6_GPIO_NUM 25 + +#define RTCIO_GPIO26_CHANNEL 7 //RTCIO_CHANNEL_7 +#define RTCIO_CHANNEL_7_GPIO_NUM 26 + +#define RTCIO_GPIO33_CHANNEL 8 //RTCIO_CHANNEL_8 +#define RTCIO_CHANNEL_8_GPIO_NUM 33 + +#define RTCIO_GPIO32_CHANNEL 9 //RTCIO_CHANNEL_9 +#define RTCIO_CHANNEL_9_GPIO_NUM 32 + +#define RTCIO_GPIO4_CHANNEL 10 //RTCIO_CHANNEL_10 +#define RTCIO_CHANNEL_10_GPIO_NUM 4 + +#define RTCIO_GPIO0_CHANNEL 11 //RTCIO_CHANNEL_11 +#define RTCIO_CHANNEL_11_GPIO_NUM 0 + +#define RTCIO_GPIO2_CHANNEL 12 //RTCIO_CHANNEL_12 +#define RTCIO_CHANNEL_12_GPIO_NUM 2 + +#define RTCIO_GPIO15_CHANNEL 13 //RTCIO_CHANNEL_13 +#define RTCIO_CHANNEL_13_GPIO_NUM 15 + +#define RTCIO_GPIO13_CHANNEL 14 //RTCIO_CHANNEL_14 +#define RTCIO_CHANNEL_14_GPIO_NUM 13 + +#define RTCIO_GPIO12_CHANNEL 15 //RTCIO_CHANNEL_15 +#define RTCIO_CHANNEL_15_GPIO_NUM 12 + +#define RTCIO_GPIO14_CHANNEL 16 //RTCIO_CHANNEL_16 +#define RTCIO_CHANNEL_16_GPIO_NUM 14 + +#define RTCIO_GPIO27_CHANNEL 17 //RTCIO_CHANNEL_17 +#define RTCIO_CHANNEL_17_GPIO_NUM 27 + +#endif diff --git a/tools/sdk/include/soc/soc/rtc_io_struct.h b/tools/sdk/include/soc/soc/rtc_io_struct.h index da27078c..f20ad4c2 100644 --- a/tools/sdk/include/soc/soc/rtc_io_struct.h +++ b/tools/sdk/include/soc/soc/rtc_io_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_RTC_IO_STRUCT_H_ #define _SOC_RTC_IO_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -277,4 +282,10 @@ typedef volatile struct { uint32_t val; } date; } rtc_io_dev_t; +extern rtc_io_dev_t RTCIO; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_RTC_IO_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/sdmmc_struct.h b/tools/sdk/include/soc/soc/sdmmc_struct.h index 20bb9d26..9f3625a3 100644 --- a/tools/sdk/include/soc/soc/sdmmc_struct.h +++ b/tools/sdk/include/soc/soc/sdmmc_struct.h @@ -16,6 +16,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { uint32_t reserved1: 1; uint32_t disable_int_on_completion: 1; @@ -366,6 +370,8 @@ extern sdmmc_dev_t SDMMC; _Static_assert(sizeof(sdmmc_dev_t) == 0x804, "invalid size of sdmmc_dev_t structure"); - +#ifdef __cplusplus +} +#endif #endif //_SOC_SDMMC_STRUCT_H_ diff --git a/tools/sdk/include/soc/soc/sens_struct.h b/tools/sdk/include/soc/soc/sens_struct.h new file mode 100644 index 00000000..825c85b1 --- /dev/null +++ b/tools/sdk/include/soc/soc/sens_struct.h @@ -0,0 +1,326 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef _SOC_SENS_STRUCT_H_ +#define _SOC_SENS_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef volatile struct { + union { + struct { + uint32_t sar1_clk_div: 8; + uint32_t sar1_sample_cycle: 8; + uint32_t sar1_sample_bit: 2; + uint32_t sar1_clk_gated: 1; + uint32_t sar1_sample_num: 8; + uint32_t sar1_dig_force: 1; + uint32_t sar1_data_inv: 1; + uint32_t reserved29: 3; + }; + uint32_t val; + } sar_read_ctrl; + uint32_t sar_read_status1; /**/ + union { + struct { + uint32_t sar_amp_wait1:16; + uint32_t sar_amp_wait2:16; + }; + uint32_t val; + } sar_meas_wait1; + union { + struct { + uint32_t sar_amp_wait3: 16; + uint32_t force_xpd_amp: 2; + uint32_t force_xpd_sar: 2; + uint32_t sar2_rstb_wait: 8; + uint32_t reserved28: 4; + }; + uint32_t val; + } sar_meas_wait2; + union { + struct { + uint32_t xpd_sar_amp_fsm: 4; + uint32_t amp_rst_fb_fsm: 4; + uint32_t amp_short_ref_fsm: 4; + uint32_t amp_short_ref_gnd_fsm: 4; + uint32_t xpd_sar_fsm: 4; + uint32_t sar_rstb_fsm: 4; + uint32_t sar2_xpd_wait: 8; + }; + uint32_t val; + } sar_meas_ctrl; + uint32_t sar_read_status2; /**/ + uint32_t ulp_cp_sleep_cyc0; /**/ + uint32_t ulp_cp_sleep_cyc1; /**/ + uint32_t ulp_cp_sleep_cyc2; /**/ + uint32_t ulp_cp_sleep_cyc3; /**/ + uint32_t ulp_cp_sleep_cyc4; /**/ + union { + struct { + uint32_t sar1_bit_width: 2; + uint32_t sar2_bit_width: 2; + uint32_t sar2_en_test: 1; + uint32_t sar2_pwdet_cct: 3; + uint32_t ulp_cp_force_start_top: 1; + uint32_t ulp_cp_start_top: 1; + uint32_t sarclk_en: 1; + uint32_t pc_init: 11; + uint32_t sar2_stop: 1; + uint32_t sar1_stop: 1; + uint32_t sar2_pwdet_en: 1; + uint32_t reserved25: 7; + }; + uint32_t val; + } sar_start_force; + union { + struct { + uint32_t mem_wr_addr_init: 11; + uint32_t mem_wr_addr_size: 11; + uint32_t rtc_mem_wr_offst_clr: 1; + uint32_t reserved23: 9; + }; + uint32_t val; + } sar_mem_wr_ctrl; + uint32_t sar_atten1; /**/ + uint32_t sar_atten2; /**/ + union { + struct { + uint32_t i2c_slave_addr1: 11; + uint32_t i2c_slave_addr0: 11; + uint32_t meas_status: 8; + uint32_t reserved30: 2; + }; + uint32_t val; + } sar_slave_addr1; + union { + struct { + uint32_t i2c_slave_addr3:11; + uint32_t i2c_slave_addr2:11; + uint32_t reserved22: 10; + }; + uint32_t val; + } sar_slave_addr2; + union { + struct { + uint32_t i2c_slave_addr5:11; + uint32_t i2c_slave_addr4:11; + uint32_t tsens_out: 8; + uint32_t tsens_rdy_out: 1; + uint32_t reserved31: 1; + }; + uint32_t val; + } sar_slave_addr3; + union { + struct { + uint32_t i2c_slave_addr7:11; + uint32_t i2c_slave_addr6:11; + uint32_t i2c_rdata: 8; + uint32_t i2c_done: 1; + uint32_t reserved31: 1; + }; + uint32_t val; + } sar_slave_addr4; + union { + struct { + uint32_t tsens_xpd_wait: 12; + uint32_t tsens_xpd_force: 1; + uint32_t tsens_clk_inv: 1; + uint32_t tsens_clk_gated: 1; + uint32_t tsens_in_inv: 1; + uint32_t tsens_clk_div: 8; + uint32_t tsens_power_up: 1; + uint32_t tsens_power_up_force: 1; + uint32_t tsens_dump_out: 1; + uint32_t reserved27: 5; + }; + uint32_t val; + } sar_tctrl; + union { + struct { + uint32_t sar_i2c_ctrl: 28; + uint32_t sar_i2c_start: 1; + uint32_t sar_i2c_start_force: 1; + uint32_t reserved30: 2; + }; + uint32_t val; + } sar_i2c_ctrl; + union { + struct { + uint32_t meas1_data_sar: 16; + uint32_t meas1_done_sar: 1; + uint32_t meas1_start_sar: 1; + uint32_t meas1_start_force: 1; + uint32_t sar1_en_pad: 12; + uint32_t sar1_en_pad_force: 1; + }; + uint32_t val; + } sar_meas_start1; + union { + struct { + uint32_t touch_meas_delay:16; + uint32_t touch_xpd_wait: 8; + uint32_t touch_out_sel: 1; + uint32_t touch_out_1en: 1; + uint32_t xpd_hall_force: 1; + uint32_t hall_phase_force: 1; + uint32_t reserved28: 4; + }; + uint32_t val; + } sar_touch_ctrl1; + union { + struct { + uint32_t l_thresh: 16; + uint32_t h_thresh: 16; + }; + uint32_t val; + } touch_thresh[5]; + union { + struct { + uint32_t l_val: 16; + uint32_t h_val: 16; + }; + uint32_t val; + } touch_meas[5]; + union { + struct { + uint32_t touch_meas_en: 10; + uint32_t touch_meas_done: 1; + uint32_t touch_start_fsm_en: 1; + uint32_t touch_start_en: 1; + uint32_t touch_start_force: 1; + uint32_t touch_sleep_cycles:16; + uint32_t touch_meas_en_clr: 1; + uint32_t reserved31: 1; + }; + uint32_t val; + } sar_touch_ctrl2; + uint32_t reserved_88; + union { + struct { + uint32_t touch_pad_worken:10; + uint32_t touch_pad_outen2:10; + uint32_t touch_pad_outen1:10; + uint32_t reserved30: 2; + }; + uint32_t val; + } sar_touch_enable; + union { + struct { + uint32_t sar2_clk_div: 8; + uint32_t sar2_sample_cycle: 8; + uint32_t sar2_sample_bit: 2; + uint32_t sar2_clk_gated: 1; + uint32_t sar2_sample_num: 8; + uint32_t sar2_pwdet_force: 1; + uint32_t sar2_dig_force: 1; + uint32_t sar2_data_inv: 1; + uint32_t reserved30: 2; + }; + uint32_t val; + } sar_read_ctrl2; + union { + struct { + uint32_t meas2_data_sar: 16; + uint32_t meas2_done_sar: 1; + uint32_t meas2_start_sar: 1; + uint32_t meas2_start_force: 1; + uint32_t sar2_en_pad: 12; + uint32_t sar2_en_pad_force: 1; + }; + uint32_t val; + } sar_meas_start2; + union { + struct { + uint32_t sw_fstep: 16; + uint32_t sw_tone_en: 1; + uint32_t debug_bit_sel: 5; + uint32_t dac_dig_force: 1; + uint32_t dac_clk_force_low: 1; + uint32_t dac_clk_force_high: 1; + uint32_t dac_clk_inv: 1; + uint32_t reserved26: 6; + }; + uint32_t val; + } sar_dac_ctrl1; + union { + struct { + uint32_t dac_dc1: 8; + uint32_t dac_dc2: 8; + uint32_t dac_scale1: 2; + uint32_t dac_scale2: 2; + uint32_t dac_inv1: 2; + uint32_t dac_inv2: 2; + uint32_t dac_cw_en1: 1; + uint32_t dac_cw_en2: 1; + uint32_t reserved26: 6; + }; + uint32_t val; + } sar_dac_ctrl2; + union { + struct { + uint32_t sar1_dac_xpd_fsm: 4; + uint32_t sar1_dac_xpd_fsm_idle: 1; + uint32_t xpd_sar_amp_fsm_idle: 1; + uint32_t amp_rst_fb_fsm_idle: 1; + uint32_t amp_short_ref_fsm_idle: 1; + uint32_t amp_short_ref_gnd_fsm_idle: 1; + uint32_t xpd_sar_fsm_idle: 1; + uint32_t sar_rstb_fsm_idle: 1; + uint32_t sar2_rstb_force: 2; + uint32_t amp_rst_fb_force: 2; + uint32_t amp_short_ref_force: 2; + uint32_t amp_short_ref_gnd_force: 2; + uint32_t reserved19: 13; + }; + uint32_t val; + } sar_meas_ctrl2; + uint32_t reserved_a4; + uint32_t reserved_a8; + uint32_t reserved_ac; + uint32_t reserved_b0; + uint32_t reserved_b4; + uint32_t reserved_b8; + uint32_t reserved_bc; + uint32_t reserved_c0; + uint32_t reserved_c4; + uint32_t reserved_c8; + uint32_t reserved_cc; + uint32_t reserved_d0; + uint32_t reserved_d4; + uint32_t reserved_d8; + uint32_t reserved_dc; + uint32_t reserved_e0; + uint32_t reserved_e4; + uint32_t reserved_e8; + uint32_t reserved_ec; + uint32_t reserved_f0; + uint32_t reserved_f4; + uint32_t sar_nouse; /**/ + union { + struct { + uint32_t sar_date: 28; + uint32_t reserved28: 4; + }; + uint32_t val; + } sardate; +} sens_dev_t; +extern sens_dev_t SENS; + +#ifdef __cplusplus +} +#endif + +#endif /* _SOC_SENS_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/soc.h b/tools/sdk/include/soc/soc/soc.h index 3b1e85f2..5d5cf3b7 100644 --- a/tools/sdk/include/soc/soc/soc.h +++ b/tools/sdk/include/soc/soc/soc.h @@ -67,11 +67,15 @@ #define SOC_RTC_IRAM_HIGH 0x400C2000 #define SOC_RTC_DATA_LOW 0x50000000 #define SOC_RTC_DATA_HIGH 0x50002000 +#define SOC_EXTRAM_DATA_LOW 0x3F800000 +#define SOC_EXTRAM_DATA_HIGH 0x3FC00000 + #define DR_REG_DPORT_BASE 0x3ff00000 -#define DR_REG_DPORT_END 0x3ff00FFC +#define DR_REG_AES_BASE 0x3ff01000 #define DR_REG_RSA_BASE 0x3ff02000 #define DR_REG_SHA_BASE 0x3ff03000 +#define DR_REG_DPORT_END 0x3ff03FFC #define DR_REG_UART_BASE 0x3ff40000 #define DR_REG_SPI1_BASE 0x3ff42000 #define DR_REG_SPI0_BASE 0x3ff43000 @@ -118,7 +122,7 @@ #define DR_REG_UART2_BASE 0x3ff6E000 #define DR_REG_PWM2_BASE 0x3ff6F000 #define DR_REG_PWM3_BASE 0x3ff70000 -#define PERIPHS_SPI_ENCRYPT_BASEADDR DR_REG_SPI_ENCRYPT_BASE +#define PERIPHS_SPI_ENCRYPT_BASEADDR DR_REG_SPI_ENCRYPT_BASE //Registers Operation {{ #define ETS_UNCACHED_ADDR(addr) (addr) @@ -376,7 +380,7 @@ * 7 1 software BT/BLE VHCI BT/BLE VHCI * 8 1 extern level BT/BLE BB(RX/TX) BT/BLE BB(RX/TX) * 9 1 extern level - * 10 1 extern edge Internal Timer + * 10 1 extern edge * 11 3 profiling * 12 1 extern level * 13 1 extern level @@ -388,7 +392,7 @@ * 19 2 extern level * 20 2 extern level * 21 2 extern level - * 22 3 extern edge FRC1 timer + * 22 3 extern edge * 23 3 extern level * 24 4 extern level TG1_WDT * 25 4 extern level CACHEERR diff --git a/tools/sdk/include/soc/soc/spi_struct.h b/tools/sdk/include/soc/soc/spi_struct.h index 149782ff..a52ddf41 100644 --- a/tools/sdk/include/soc/soc/spi_struct.h +++ b/tools/sdk/include/soc/soc/spi_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_SPI_STRUCT_H_ #define _SOC_SPI_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -36,7 +41,7 @@ typedef volatile struct { }; uint32_t val; } cmd; - uint32_t addr; /*addr to slave / from master */ + uint32_t addr; /*addr to slave / from master. SPI transfer from the MSB to the LSB. If length > 32 bits, then address continues from MSB of slv_wr_status.*/ union { struct { uint32_t reserved0: 10; /*reserved*/ @@ -143,7 +148,7 @@ typedef volatile struct { } user1; union { struct { - uint32_t usr_command_value: 16; /*The value of command.*/ + uint32_t usr_command_value: 16; /*The value of command. Output sequence: bit 7-0 and then 15-8.*/ uint32_t reserved16: 12; /*reserved*/ uint32_t usr_command_bitlen: 4; /*The length in bits of command phase. The register value shall be (bit_num-1)*/ }; @@ -673,4 +678,9 @@ extern spi_dev_t SPI0; /* SPI0 IS FOR INTER extern spi_dev_t SPI1; extern spi_dev_t SPI2; extern spi_dev_t SPI3; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_SPI_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/syscon_struct.h b/tools/sdk/include/soc/soc/syscon_struct.h index 700aeecf..60d8ed0a 100644 --- a/tools/sdk/include/soc/soc/syscon_struct.h +++ b/tools/sdk/include/soc/soc/syscon_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_SYSCON_STRUCT_H_ #define _SOC_SYSCON_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { union { struct { @@ -117,4 +122,8 @@ typedef struct { volatile uint32_t date; /**/ } syscon_dev_t; +#ifdef __cplusplus +} +#endif + #endif /* _SOC_SYSCON_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/timer_group_struct.h b/tools/sdk/include/soc/soc/timer_group_struct.h index 696b439d..da9acd0c 100644 --- a/tools/sdk/include/soc/soc/timer_group_struct.h +++ b/tools/sdk/include/soc/soc/timer_group_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_TIMG_STRUCT_H_ #define _SOC_TIMG_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { struct{ union { @@ -192,4 +197,9 @@ typedef volatile struct { } timg_dev_t; extern timg_dev_t TIMERG0; extern timg_dev_t TIMERG1; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_TIMG_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/touch_channel.h b/tools/sdk/include/soc/soc/touch_channel.h new file mode 100644 index 00000000..a9aa838b --- /dev/null +++ b/tools/sdk/include/soc/soc/touch_channel.h @@ -0,0 +1,49 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_TOUCH_CHANNEL_H +#define _SOC_TOUCH_CHANNEL_H + +//Touch channels +#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM0 +#define TOUCH_PAD_NUM0_GPIO_NUM 4 + +#define TOUCH_PAD_GPIO0_CHANNEL TOUCH_PAD_NUM1 +#define TOUCH_PAD_NUM1_GPIO_NUM 0 + +#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM2 +#define TOUCH_PAD_NUM2_GPIO_NUM 2 + +#define TOUCH_PAD_GPIO15_CHANNEL TOUCH_PAD_NUM3 +#define TOUCH_PAD_NUM3_GPIO_NUM 15 + +#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM4 +#define TOUCH_PAD_NUM4_GPIO_NUM 13 + +#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM5 +#define TOUCH_PAD_NUM5_GPIO_NUM 12 + +#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM6 +#define TOUCH_PAD_NUM6_GPIO_NUM 14 + +#define TOUCH_PAD_GPIO27_CHANNEL TOUCH_PAD_NUM7 +#define TOUCH_PAD_NUM7_GPIO_NUM 27 + +#define TOUCH_PAD_GPIO33_CHANNEL TOUCH_PAD_NUM8 +#define TOUCH_PAD_NUM8_GPIO_NUM 33 + +#define TOUCH_PAD_GPIO32_CHANNEL TOUCH_PAD_NUM9 +#define TOUCH_PAD_NUM9_GPIO_NUM 32 + +#endif diff --git a/tools/sdk/include/soc/soc/uart_channel.h b/tools/sdk/include/soc/soc/uart_channel.h new file mode 100644 index 00000000..5b8dc56d --- /dev/null +++ b/tools/sdk/include/soc/soc/uart_channel.h @@ -0,0 +1,61 @@ +// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _SOC_UART_CHANNEL_H +#define _SOC_UART_CHANNEL_H + +//UART channels +#define UART_GPIO1_DIRECT_CHANNEL UART_NUM_0 +#define UART_NUM_0_TXD_DIRECT_GPIO_NUM 1 +#define UART_GPIO3_DIRECT_CHANNEL UART_NUM_0 +#define UART_NUM_0_RXD_DIRECT_GPIO_NUM 3 +#define UART_GPIO19_DIRECT_CHANNEL UART_NUM_0 +#define UART_NUM_0_CTS_DIRECT_GPIO_NUM 19 +#define UART_GPIO22_DIRECT_CHANNEL UART_NUM_0 +#define UART_NUM_0_RTS_DIRECT_GPIO_NUM 22 + +#define UART_TXD_GPIO1_DIRECT_CHANNEL UART_GPIO1_DIRECT_CHANNEL +#define UART_RXD_GPIO3_DIRECT_CHANNEL UART_GPIO3_DIRECT_CHANNEL +#define UART_CTS_GPIO19_DIRECT_CHANNEL UART_GPIO19_DIRECT_CHANNEL +#define UART_RTS_GPIO22_DIRECT_CHANNEL UART_GPIO22_DIRECT_CHANNEL + +#define UART_GPIO10_DIRECT_CHANNEL UART_NUM_1 +#define UART_NUM_1_TXD_DIRECT_GPIO_NUM 10 +#define UART_GPIO9_DIRECT_CHANNEL UART_NUM_1 +#define UART_NUM_1_RXD_DIRECT_GPIO_NUM 9 +#define UART_GPIO6_DIRECT_CHANNEL UART_NUM_1 +#define UART_NUM_1_CTS_DIRECT_GPIO_NUM 6 +#define UART_GPIO11_DIRECT_CHANNEL UART_NUM_1 +#define UART_NUM_1_RTS_DIRECT_GPIO_NUM 11 + +#define UART_TXD_GPIO10_DIRECT_CHANNEL UART_GPIO10_DIRECT_CHANNEL +#define UART_RXD_GPIO9_DIRECT_CHANNEL UART_GPIO9_DIRECT_CHANNEL +#define UART_CTS_GPIO6_DIRECT_CHANNEL UART_GPIO6_DIRECT_CHANNEL +#define UART_RTS_GPIO11_DIRECT_CHANNEL UART_GPIO11_DIRECT_CHANNEL + +#define UART_GPIO17_DIRECT_CHANNEL UART_NUM_2 +#define UART_NUM_2_TXD_DIRECT_GPIO_NUM 17 +#define UART_GPIO16_DIRECT_CHANNEL UART_NUM_2 +#define UART_NUM_2_RXD_DIRECT_GPIO_NUM 16 +#define UART_GPIO8_DIRECT_CHANNEL UART_NUM_2 +#define UART_NUM_2_CTS_DIRECT_GPIO_NUM 8 +#define UART_GPIO7_DIRECT_CHANNEL UART_NUM_2 +#define UART_NUM_2_RTS_DIRECT_GPIO_NUM 7 + +#define UART_TXD_GPIO17_DIRECT_CHANNEL UART_GPIO17_DIRECT_CHANNEL +#define UART_RXD_GPIO16_DIRECT_CHANNEL UART_GPIO16_DIRECT_CHANNEL +#define UART_CTS_GPIO8_DIRECT_CHANNEL UART_GPIO8_DIRECT_CHANNEL +#define UART_RTS_GPIO7_DIRECT_CHANNEL UART_GPIO7_DIRECT_CHANNEL + +#endif diff --git a/tools/sdk/include/soc/soc/uart_struct.h b/tools/sdk/include/soc/soc/uart_struct.h index 05b54867..eb14620a 100644 --- a/tools/sdk/include/soc/soc/uart_struct.h +++ b/tools/sdk/include/soc/soc/uart_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_UART_STRUCT_H_ #define _SOC_UART_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -362,4 +367,9 @@ typedef volatile struct { extern uart_dev_t UART0; extern uart_dev_t UART1; extern uart_dev_t UART2; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_UART_STRUCT_H_ */ diff --git a/tools/sdk/include/soc/soc/uhci_struct.h b/tools/sdk/include/soc/soc/uhci_struct.h index 0c939796..1c1ff0b8 100644 --- a/tools/sdk/include/soc/soc/uhci_struct.h +++ b/tools/sdk/include/soc/soc/uhci_struct.h @@ -13,6 +13,11 @@ // limitations under the License. #ifndef _SOC_UHCI_STRUCT_H_ #define _SOC_UHCI_STRUCT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + typedef volatile struct { union { struct { @@ -334,4 +339,9 @@ typedef volatile struct { } uhci_dev_t; extern uhci_dev_t UHCI0; extern uhci_dev_t UHCI1; + +#ifdef __cplusplus +} +#endif + #endif /* _SOC_UHCI_STRUCT_H_ */ diff --git a/tools/sdk/include/spiffs/esp_spiffs.h b/tools/sdk/include/spiffs/esp_spiffs.h new file mode 100644 index 00000000..9a1f12c4 --- /dev/null +++ b/tools/sdk/include/spiffs/esp_spiffs.h @@ -0,0 +1,94 @@ +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef _ESP_SPIFFS_H_ +#define _ESP_SPIFFS_H_ + +#include +#include "esp_err.h" + +/** + * @brief Configuration structure for esp_vfs_spiffs_register + */ +typedef struct { + const char* base_path; /*!< File path prefix associated with the filesystem. */ + const char* partition_label; /*!< Optional, label of SPIFFS partition to use. If set to NULL, first partition with subtype=spiffs will be used. */ + size_t max_files; /*!< Maximum files that could be open at the same time. */ + bool format_if_mount_failed; /*!< If true, it will format the file system if it fails to mount. */ +} esp_vfs_spiffs_conf_t; + +/** + * Register and mount SPIFFS to VFS with given path prefix. + * + * @param conf Pointer to esp_vfs_spiffs_conf_t configuration structure + * + * @return + * - ESP_OK if success + * - ESP_ERR_NO_MEM if objects could not be allocated + * - ESP_ERR_INVALID_STATE if already mounted or partition is encrypted + * - ESP_ERR_NOT_FOUND if partition for SPIFFS was not found + * - ESP_FAIL if mount or format fails + */ +esp_err_t esp_vfs_spiffs_register(const esp_vfs_spiffs_conf_t * conf); + +/** + * Unregister and unmount SPIFFS from VFS + * + * @param partition_label Optional, label of the partition to unregister. + * If not specified, first partition with subtype=spiffs is used. + * + * @return + * - ESP_OK if successful + * - ESP_ERR_INVALID_STATE already unregistered + */ +esp_err_t esp_vfs_spiffs_unregister(const char* partition_label); + +/** + * Check if SPIFFS is mounted + * + * @param partition_label Optional, label of the partition to check. + * If not specified, first partition with subtype=spiffs is used. + * + * @return + * - true if mounted + * - false if not mounted + */ +bool esp_spiffs_mounted(const char* partition_label); + +/** + * Format the SPIFFS partition + * + * @param partition_label Optional, label of the partition to format. + * If not specified, first partition with subtype=spiffs is used. + * @return + * - ESP_OK if successful + * - ESP_FAIL on error + */ +esp_err_t esp_spiffs_format(const char* partition_label); + +/** + * Get information for SPIFFS + * + * @param partition_label Optional, label of the partition to get info for. + * If not specified, first partition with subtype=spiffs is used. + * @param[out] total_bytes Size of the file system + * @param[out] used_bytes Current used bytes in the file system + * + * @return + * - ESP_OK if success + * - ESP_ERR_INVALID_STATE if not mounted + */ +esp_err_t esp_spiffs_info(const char* partition_label, size_t *total_bytes, size_t *used_bytes); + +#endif /* _ESP_SPIFFS_H_ */ diff --git a/tools/sdk/include/spiffs/spiffs_config.h b/tools/sdk/include/spiffs/spiffs_config.h new file mode 100755 index 00000000..e0c9d7f9 --- /dev/null +++ b/tools/sdk/include/spiffs/spiffs_config.h @@ -0,0 +1,313 @@ +/* + * spiffs_config.h + * + * Created on: Jul 3, 2013 + * Author: petera + */ + +#ifndef SPIFFS_CONFIG_H_ +#define SPIFFS_CONFIG_H_ + +// ----------- 8< ------------ +// Following includes are for the linux test build of spiffs +// These may/should/must be removed/altered/replaced in your target +#include +#include +#include +#include +#include +#include +#include +#include + +// compile time switches +#define SPIFFS_TAG "SPIFFS" + +// Set generic spiffs debug output call. +#if CONGIG_SPIFFS_DBG +#define SPIFFS_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#else +#define SPIFFS_DBG(...) +#endif +#if CONGIG_SPIFFS_API_DBG +#define SPIFFS_API_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#else +#define SPIFFS_API_DBG(...) +#endif +#if CONGIG_SPIFFS_DBG +#define SPIFFS_GC_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#else +#define SPIFFS_GC_DBG(...) +#endif +#if CONGIG_SPIFFS_CACHE_DBG +#define SPIFFS_CACHE_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#else +#define SPIFFS_CACHE_DBG(...) +#endif +#if CONGIG_SPIFFS_CHECK_DBG +#define SPIFFS_CHECK_DBG(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#else +#define SPIFFS_CHECK_DBG(...) +#endif + +// needed types +typedef signed int s32_t; +typedef unsigned int u32_t; +typedef signed short s16_t; +typedef unsigned short u16_t; +typedef signed char s8_t; +typedef unsigned char u8_t; + +struct spiffs_t; +extern void spiffs_api_lock(struct spiffs_t *fs); +extern void spiffs_api_unlock(struct spiffs_t *fs); + +// Defines spiffs debug print formatters +// some general signed number +#define _SPIPRIi "%d" +// address +#define _SPIPRIad "%08x" +// block +#define _SPIPRIbl "%04x" +// page +#define _SPIPRIpg "%04x" +// span index +#define _SPIPRIsp "%04x" +// file descriptor +#define _SPIPRIfd "%d" +// file object id +#define _SPIPRIid "%04x" +// file flags +#define _SPIPRIfl "%02x" + + +// Enable/disable API functions to determine exact number of bytes +// for filedescriptor and cache buffers. Once decided for a configuration, +// this can be disabled to reduce flash. +#define SPIFFS_BUFFER_HELP 0 + +// Enables/disable memory read caching of nucleus file system operations. +// If enabled, memory area must be provided for cache in SPIFFS_mount. +#ifdef CONFIG_SPIFFS_CACHE +#define SPIFFS_CACHE (1) +#else +#define SPIFFS_CACHE (0) +#endif +#if SPIFFS_CACHE +// Enables memory write caching for file descriptors in hydrogen +#ifdef CONFIG_SPIFFS_CACHE_WR +#define SPIFFS_CACHE_WR (1) +#else +#define SPIFFS_CACHE_WR (0) +#endif + +// Enable/disable statistics on caching. Debug/test purpose only. +#ifdef CONFIG_SPIFFS_CACHE_STATS +#define SPIFFS_CACHE_STATS (1) +#else +#define SPIFFS_CACHE_STATS (0) +#endif +#endif + +// Always check header of each accessed page to ensure consistent state. +// If enabled it will increase number of reads, will increase flash. +#ifdef CONFIG_SPIFFS_PAGE_CHECK +#define SPIFFS_PAGE_CHECK (1) +#else +#define SPIFFS_PAGE_CHECK (0) +#endif + +// Define maximum number of gc runs to perform to reach desired free pages. +#define SPIFFS_GC_MAX_RUNS CONFIG_SPIFFS_GC_MAX_RUNS + +// Enable/disable statistics on gc. Debug/test purpose only. +#ifdef CONFIG_SPIFFS_GC_STATS +#define SPIFFS_GC_STATS (1) +#else +#define SPIFFS_GC_STATS (0) +#endif + +// Garbage collecting examines all pages in a block which and sums up +// to a block score. Deleted pages normally gives positive score and +// used pages normally gives a negative score (as these must be moved). +// To have a fair wear-leveling, the erase age is also included in score, +// whose factor normally is the most positive. +// The larger the score, the more likely it is that the block will +// picked for garbage collection. + +// Garbage collecting heuristics - weight used for deleted pages. +#define SPIFFS_GC_HEUR_W_DELET (5) +// Garbage collecting heuristics - weight used for used pages. +#define SPIFFS_GC_HEUR_W_USED (-1) +// Garbage collecting heuristics - weight used for time between +// last erased and erase of this block. +#define SPIFFS_GC_HEUR_W_ERASE_AGE (50) + +// Object name maximum length. Note that this length include the +// zero-termination character, meaning maximum string of characters +// can at most be SPIFFS_OBJ_NAME_LEN - 1. +#define SPIFFS_OBJ_NAME_LEN (CONFIG_SPIFFS_OBJ_NAME_LEN) + +// Maximum length of the metadata associated with an object. +// Setting to non-zero value enables metadata-related API but also +// changes the on-disk format, so the change is not backward-compatible. +// +// Do note: the meta length must never exceed +// logical_page_size - (SPIFFS_OBJ_NAME_LEN + 64) +// +// This is derived from following: +// logical_page_size - (SPIFFS_OBJ_NAME_LEN + sizeof(spiffs_page_header) + +// spiffs_object_ix_header fields + at least some LUT entries) +#define SPIFFS_OBJ_META_LEN (0) + +// Size of buffer allocated on stack used when copying data. +// Lower value generates more read/writes. No meaning having it bigger +// than logical page size. +#define SPIFFS_COPY_BUFFER_STACK (256) + +// Enable this to have an identifiable spiffs filesystem. This will look for +// a magic in all sectors to determine if this is a valid spiffs system or +// not on mount point. If not, SPIFFS_format must be called prior to mounting +// again. +#ifdef CONFIG_SPIFFS_USE_MAGIC +#define SPIFFS_USE_MAGIC (1) +#else +#define SPIFFS_USE_MAGIC (0) +#endif + +#if SPIFFS_USE_MAGIC +// Only valid when SPIFFS_USE_MAGIC is enabled. If SPIFFS_USE_MAGIC_LENGTH is +// enabled, the magic will also be dependent on the length of the filesystem. +// For example, a filesystem configured and formatted for 4 megabytes will not +// be accepted for mounting with a configuration defining the filesystem as 2 +// megabytes. +#ifdef CONFIG_SPIFFS_USE_MAGIC_LENGTH +#define SPIFFS_USE_MAGIC_LENGTH (1) +#else +#define SPIFFS_USE_MAGIC_LENGTH (0) +#endif +#endif + +// SPIFFS_LOCK and SPIFFS_UNLOCK protects spiffs from reentrancy on api level +// These should be defined on a multithreaded system + +// define this to enter a mutex if you're running on a multithreaded system +#define SPIFFS_LOCK(fs) spiffs_api_lock(fs) +// define this to exit a mutex if you're running on a multithreaded system +#define SPIFFS_UNLOCK(fs) spiffs_api_unlock(fs) + +// Enable if only one spiffs instance with constant configuration will exist +// on the target. This will reduce calculations, flash and memory accesses. +// Parts of configuration must be defined below instead of at time of mount. +#define SPIFFS_SINGLETON 0 + +// Enable this if your target needs aligned data for index tables +#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0 + +// Enable this if you want the HAL callbacks to be called with the spiffs struct +#define SPIFFS_HAL_CALLBACK_EXTRA 1 + +// Enable this if you want to add an integer offset to all file handles +// (spiffs_file). This is useful if running multiple instances of spiffs on +// same target, in order to recognise to what spiffs instance a file handle +// belongs. +// NB: This adds config field fh_ix_offset in the configuration struct when +// mounting, which must be defined. +#define SPIFFS_FILEHDL_OFFSET 0 + +// Enable this to compile a read only version of spiffs. +// This will reduce binary size of spiffs. All code comprising modification +// of the file system will not be compiled. Some config will be ignored. +// HAL functions for erasing and writing to spi-flash may be null. Cache +// can be disabled for even further binary size reduction (and ram savings). +// Functions modifying the fs will return SPIFFS_ERR_RO_NOT_IMPL. +// If the file system cannot be mounted due to aborted erase operation and +// SPIFFS_USE_MAGIC is enabled, SPIFFS_ERR_RO_ABORTED_OPERATION will be +// returned. +// Might be useful for e.g. bootloaders and such. +#define SPIFFS_READ_ONLY 0 + +// Enable this to add a temporal file cache using the fd buffer. +// The effects of the cache is that SPIFFS_open will find the file faster in +// certain cases. It will make it a lot easier for spiffs to find files +// opened frequently, reducing number of readings from the spi flash for +// finding those files. +// This will grow each fd by 6 bytes. If your files are opened in patterns +// with a degree of temporal locality, the system is optimized. +// Examples can be letting spiffs serve web content, where one file is the css. +// The css is accessed for each html file that is opened, meaning it is +// accessed almost every second time a file is opened. Another example could be +// a log file that is often opened, written, and closed. +// The size of the cache is number of given file descriptors, as it piggybacks +// on the fd update mechanism. The cache lives in the closed file descriptors. +// When closed, the fd know the whereabouts of the file. Instead of forgetting +// this, the temporal cache will keep handling updates to that file even if the +// fd is closed. If the file is opened again, the location of the file is found +// directly. If all available descriptors become opened, all cache memory is +// lost. +#define SPIFFS_TEMPORAL_FD_CACHE 1 + +// Temporal file cache hit score. Each time a file is opened, all cached files +// will lose one point. If the opened file is found in cache, that entry will +// gain SPIFFS_TEMPORAL_CACHE_HIT_SCORE points. One can experiment with this +// value for the specific access patterns of the application. However, it must +// be between 1 (no gain for hitting a cached entry often) and 255. +#define SPIFFS_TEMPORAL_CACHE_HIT_SCORE 4 + +// Enable to be able to map object indices to memory. +// This allows for faster and more deterministic reading if cases of reading +// large files and when changing file offset by seeking around a lot. +// When mapping a file's index, the file system will be scanned for index pages +// and the info will be put in memory provided by user. When reading, the +// memory map can be looked up instead of searching for index pages on the +// medium. This way, user can trade memory against performance. +// Whole, parts of, or future parts not being written yet can be mapped. The +// memory array will be owned by spiffs and updated accordingly during garbage +// collecting or when modifying the indices. The latter is invoked by when the +// file is modified in some way. The index buffer is tied to the file +// descriptor. +#define SPIFFS_IX_MAP 1 + +// Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function +// in the api. This function will visualize all filesystem using given printf +// function. +#ifdef CONFIG_SPIFFS_TEST_VISUALISATION +#define SPIFFS_TEST_VISUALISATION 1 +#else +#define SPIFFS_TEST_VISUALISATION 0 +#endif +#if SPIFFS_TEST_VISUALISATION +#ifndef spiffs_printf +#define spiffs_printf(...) ESP_LOGD(SPIFFS_TAG, __VA_ARGS__) +#endif +// spiffs_printf argument for a free page +#define SPIFFS_TEST_VIS_FREE_STR "_" +// spiffs_printf argument for a deleted page +#define SPIFFS_TEST_VIS_DELE_STR "/" +// spiffs_printf argument for an index page for given object id +#define SPIFFS_TEST_VIS_INDX_STR(id) "i" +// spiffs_printf argument for a data page for given object id +#define SPIFFS_TEST_VIS_DATA_STR(id) "d" +#endif + +// Types depending on configuration such as the amount of flash bytes +// given to spiffs file system in total (spiffs_file_system_size), +// the logical block size (log_block_size), and the logical page size +// (log_page_size) + +// Block index type. Make sure the size of this type can hold +// the highest number of all blocks - i.e. spiffs_file_system_size / log_block_size +typedef u16_t spiffs_block_ix; +// Page index type. Make sure the size of this type can hold +// the highest page number of all pages - i.e. spiffs_file_system_size / log_page_size +typedef u16_t spiffs_page_ix; +// Object id type - most significant bit is reserved for index flag. Make sure the +// size of this type can hold the highest object id on a full system, +// i.e. 2 + (spiffs_file_system_size / (2*log_page_size))*2 +typedef u16_t spiffs_obj_id; +// Object span index type. Make sure the size of this type can +// hold the largest possible span index on the system - +// i.e. (spiffs_file_system_size / log_page_size) - 1 +typedef u16_t spiffs_span_ix; + +#endif /* SPIFFS_CONFIG_H_ */ diff --git a/tools/sdk/include/tcpip_adapter/tcpip_adapter.h b/tools/sdk/include/tcpip_adapter/tcpip_adapter.h index f1a0a9e2..2e6db6b5 100644 --- a/tools/sdk/include/tcpip_adapter/tcpip_adapter.h +++ b/tools/sdk/include/tcpip_adapter/tcpip_adapter.h @@ -154,6 +154,10 @@ typedef struct tcpip_adapter_api_msg_s { #define TCPIP_ADAPTER_IPC_CALL(_if, _mac, _ip, _hostname, _fn) do {\ tcpip_adapter_api_msg_t msg;\ + if (tcpip_inited == false) {\ + ESP_LOGE(TAG, "tcpip_adapter is not initialized!");\ + abort();\ + }\ memset(&msg, 0, sizeof(msg));\ msg.tcpip_if = (_if);\ msg.mac = (_mac);\ @@ -168,6 +172,9 @@ typedef struct tcpip_adapter_api_msg_s { }\ }while(0) +typedef struct tcpip_adatper_ip_lost_timer_s { + bool timer_running; +} tcpip_adapter_ip_lost_timer_t; /** * @brief Initialize tcpip adapter @@ -177,13 +184,8 @@ typedef struct tcpip_adapter_api_msg_s { void tcpip_adapter_init(void); /** - * @brief Start an interface with specific MAC and IP + * @brief Start the ethernet interface with specific MAC and IP * - * softAP or station interface will be initialized, connect WiFi stack with TCPIP stack. - * - * For softAP interface, DHCP server will be started automatically. - * - * @param[in] tcpip_if: the interface which we will start * @param[in] mac: set MAC address of this interface * @param[in] ip_info: set IP address of this interface * @@ -191,7 +193,37 @@ void tcpip_adapter_init(void); * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS * ESP_ERR_NO_MEM */ -esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); +esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); + +/** + * @brief Start the Wi-Fi station interface with specific MAC and IP + * + * Station interface will be initialized, connect WiFi stack with TCPIP stack. + * + * @param[in] mac: set MAC address of this interface + * @param[in] ip_info: set IP address of this interface + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + * ESP_ERR_NO_MEM + */ +esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); + +/** + * @brief Start the Wi-Fi AP interface with specific MAC and IP + * + * softAP interface will be initialized, connect WiFi stack with TCPIP stack. + * + * DHCP server will be started automatically. + * + * @param[in] mac: set MAC address of this interface + * @param[in] ip_info: set IP address of this interface + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + * ESP_ERR_NO_MEM + */ +esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); /** * @brief Stop an interface @@ -253,13 +285,44 @@ esp_err_t tcpip_adapter_get_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_i * This function is mainly used for setting static IP. * * @param[in] tcpip_if: the interface which we want to set IP information - * @param[in] ip_info: If successful, IP information will be returned in this argument. + * @param[in] ip_info: store the IP information which needs to be set to specified interface * * @return ESP_OK * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS */ esp_err_t tcpip_adapter_set_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info); +/** + * @brief Get interface's old IP information + * + * When the interface successfully gets a valid IP from DHCP server or static configured, a copy of + * the IP information is set to the old IP information. When IP lost timer expires, the old IP + * information is reset to 0. + * + * @param[in] tcpip_if: the interface which we want to get old IP information + * @param[out] ip_info: If successful, IP information will be returned in this argument. + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + */ +esp_err_t tcpip_adapter_get_old_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info); + +/** + * @brief Set interface's old IP information + * + * When the interface successfully gets a valid IP from DHCP server or static configured, a copy of + * the IP information is set to the old IP information. When IP lost timer expires, the old IP + * information is reset to 0. + * + * @param[in] tcpip_if: the interface which we want to set old IP information + * @param[in] ip_info: store the IP information which needs to be set to specified interface + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + */ +esp_err_t tcpip_adapter_set_old_ip_info(tcpip_adapter_if_t tcpip_if, tcpip_adapter_ip_info_t *ip_info); + + /** * @brief create interface's linklocal IPv6 information * diff --git a/tools/sdk/include/vfs/esp_vfs.h b/tools/sdk/include/vfs/esp_vfs.h index a3ce6b95..6ced2ce2 100644 --- a/tools/sdk/include/vfs/esp_vfs.h +++ b/tools/sdk/include/vfs/esp_vfs.h @@ -17,6 +17,7 @@ #include #include +#include #include "esp_err.h" #include #include @@ -140,6 +141,10 @@ typedef struct int (*rmdir_p)(void* ctx, const char* name); int (*rmdir)(const char* name); }; + union { + int (*fcntl_p)(void* ctx, int fd, int cmd, va_list args); + int (*fcntl)(int fd, int cmd, va_list args); + }; } esp_vfs_t; diff --git a/tools/sdk/include/vfs/esp_vfs_dev.h b/tools/sdk/include/vfs/esp_vfs_dev.h index bb2579ee..b51527fc 100644 --- a/tools/sdk/include/vfs/esp_vfs_dev.h +++ b/tools/sdk/include/vfs/esp_vfs_dev.h @@ -1,4 +1,4 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,15 @@ #include "esp_vfs.h" +/** + * @brief Line ending settings + */ +typedef enum { + ESP_LINE_ENDINGS_CRLF,//!< CR + LF + ESP_LINE_ENDINGS_CR, //!< CR + ESP_LINE_ENDINGS_LF, //!< LF +} esp_line_endings_t; + /** * @brief add /dev/uart virtual filesystem driver * @@ -24,5 +33,52 @@ */ void esp_vfs_dev_uart_register(); +/** + * @brief Set the line endings expected to be received on UART + * + * This specifies the conversion between line endings received on UART and + * newlines ('\n', LF) passed into stdin: + * + * - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF + * - ESP_LINE_ENDINGS_CR: convert CR to LF + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. reading from UART + * + * @param mode line endings expected on UART + */ +void esp_vfs_dev_uart_set_rx_line_endings(esp_line_endings_t mode); + +/** + * @brief Set the line endings to sent to UART + * + * This specifies the conversion between newlines ('\n', LF) on stdout and line + * endings sent over UART: + * + * - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF + * - ESP_LINE_ENDINGS_CR: convert LF to CR + * - ESP_LINE_ENDINGS_LF: no modification + * + * @note this function is not thread safe w.r.t. writing to UART + * + * @param mode line endings to send to UART + */ +void esp_vfs_dev_uart_set_tx_line_endings(esp_line_endings_t mode); + +/** + * @brief set VFS to use simple functions for reading and writing UART + * Read is non-blocking, write is busy waiting until TX FIFO has enough space. + * These functions are used by default. + * @param uart_num UART peripheral number + */ +void esp_vfs_dev_uart_use_nonblocking(int uart_num); + +/** + * @brief set VFS to use UART driver for reading and writing + * @note application must configure UART driver before calling these functions + * With these functions, read and write are blocking and interrupt-driven. + * @param uart_num UART peripheral number + */ +void esp_vfs_dev_uart_use_driver(int uart_num); #endif //__ESP_VFS_DEV_H__ diff --git a/tools/sdk/ld/esp32.common.ld b/tools/sdk/ld/esp32.common.ld index 883dd29d..99f9dd54 100644 --- a/tools/sdk/ld/esp32.common.ld +++ b/tools/sdk/ld/esp32.common.ld @@ -84,6 +84,7 @@ SECTIONS *(.iram1 .iram1.*) *libfreertos.a:(.literal .text .literal.* .text.*) *libheap.a:multi_heap.o(.literal .text .literal.* .text.*) + *libheap.a:multi_heap_poisoning.o(.literal .text .literal.* .text.*) *libesp32.a:panic.o(.literal .text .literal.* .text.*) *libesp32.a:core_dump.o(.literal .text .literal.* .text.*) *libapp_trace.a:(.literal .text .literal.* .text.*) @@ -93,6 +94,7 @@ SECTIONS *librtc.a:(.literal .text .literal.* .text.*) *libsoc.a:(.literal .text .literal.* .text.*) *libhal.a:(.literal .text .literal.* .text.*) + *libgcc.a:lib2funcs.o(.literal .text .literal.* .text.*) *libspi_flash.a:spi_flash_rom_patch.o(.literal .text .literal.* .text.*) _iram_text_end = ABSOLUTE(.); } > iram0_0_seg @@ -116,6 +118,7 @@ SECTIONS *libphy.a:(.rodata .rodata.*) *libapp_trace.a:(.rodata .rodata.*) *libheap.a:multi_heap.o(.rodata .rodata.*) + *libheap.a:multi_heap_poisoning.o(.rodata .rodata.*) _data_end = ABSOLUTE(.); . = ALIGN(4); } >dram0_0_seg @@ -154,11 +157,13 @@ SECTIONS *(.rodata1) __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); *(.xt_except_table) - *(.gcc_except_table) + *(.gcc_except_table .gcc_except_table.*) *(.gnu.linkonce.e.*) *(.gnu.version_r) - *(.eh_frame) . = (. + 3) & ~ 3; + __eh_frame = ABSOLUTE(.); + KEEP(*(.eh_frame)) + . = (. + 7) & ~ 3; /* C++ constructor and destructor tables, properly ordered: */ __init_array_start = ABSOLUTE(.); KEEP (*crtbegin.o(.ctors)) diff --git a/tools/sdk/ld/esp32.ld b/tools/sdk/ld/esp32.ld index b27a49ee..2df1b3e8 100644 --- a/tools/sdk/ld/esp32.ld +++ b/tools/sdk/ld/esp32.ld @@ -16,6 +16,11 @@ */ #include "sdkconfig.h" +/* If BT is not built at all */ +#ifndef CONFIG_BT_RESERVE_DRAM +#define CONFIG_BT_RESERVE_DRAM 0 +#endif + MEMORY { /* All these values assume the flash cache is on, and have the blocks this uses subtracted from the length diff --git a/tools/sdk/ld/esp32.peripherals.ld b/tools/sdk/ld/esp32.peripherals.ld index 79becfc9..2ff635f2 100644 --- a/tools/sdk/ld/esp32.peripherals.ld +++ b/tools/sdk/ld/esp32.peripherals.ld @@ -3,6 +3,9 @@ PROVIDE ( SPI1 = 0x3ff42000 ); PROVIDE ( SPI0 = 0x3ff43000 ); PROVIDE ( GPIO = 0x3ff44000 ); PROVIDE ( SIGMADELTA = 0x3ff44f00 ); +PROVIDE ( RTCCNTL = 0x3ff48000 ); +PROVIDE ( RTCIO = 0x3ff48400 ); +PROVIDE ( SENS = 0x3ff48800 ); PROVIDE ( UHCI1 = 0x3ff4C000 ); PROVIDE ( I2S0 = 0x3ff4F000 ); PROVIDE ( UART1 = 0x3ff50000 ); diff --git a/tools/sdk/ld/esp32.rom.ld b/tools/sdk/ld/esp32.rom.ld index 6961854b..d60eeb90 100644 --- a/tools/sdk/ld/esp32.rom.ld +++ b/tools/sdk/ld/esp32.rom.ld @@ -4,7 +4,6 @@ Generated for ROM with MD5sum: ab8282ae908fe9e7a63fb2a4ac2df013 ../../rom_image/prorom.elf */ PROVIDE ( abort = 0x4000bba4 ); -PROVIDE ( abs = 0x40056340 ); PROVIDE ( __absvdi2 = 0x4006387c ); PROVIDE ( __absvsi2 = 0x40063868 ); PROVIDE ( Add2SelfBigHex256 = 0x40015b7c ); @@ -21,15 +20,8 @@ PROVIDE ( aes_128_cbc_encrypt = 0x4005cc18 ); PROVIDE ( aes_unwrap = 0x4005ccf0 ); PROVIDE ( app_gpio_arg = 0x3ffe003c ); PROVIDE ( app_gpio_handler = 0x3ffe0040 ); -PROVIDE ( __ascii_wctomb = 0x40058ef0 ); -PROVIDE ( asctime = 0x40059588 ); -PROVIDE ( asctime_r = 0x40000ec8 ); PROVIDE ( __ashldi3 = 0x4000c818 ); PROVIDE ( __ashrdi3 = 0x4000c830 ); -PROVIDE ( atoi = 0x400566c4 ); -PROVIDE ( _atoi_r = 0x400566d4 ); -PROVIDE ( atol = 0x400566ec ); -PROVIDE ( _atol_r = 0x400566fc ); PROVIDE ( base64_decode = 0x4005ced8 ); PROVIDE ( base64_encode = 0x4005cdbc ); PROVIDE ( BasePoint_x_256 = 0x3ff97488 ); @@ -49,7 +41,6 @@ PROVIDE ( btdm_r_modules_func_p_get = 0x4005427c ); PROVIDE ( btdm_r_modules_func_p_set = 0x40054270 ); PROVIDE ( btdm_r_plf_func_p_set = 0x40054288 ); PROVIDE ( bt_util_buf_env = 0x3ffb8bd4 ); -PROVIDE ( bzero = 0x4000c1f4 ); PROVIDE ( cache_flash_mmu_set_rom = 0x400095e0 ); PROVIDE ( Cache_Flush_rom = 0x40009a14 ); PROVIDE ( Cache_Read_Disable_rom = 0x40009ab8 ); @@ -60,10 +51,7 @@ PROVIDE ( cache_sram_mmu_set_rom = 0x400097f4 ); PROVIDE ( calc_rtc_memory_crc = 0x40008170 ); PROVIDE ( calloc = 0x4000bee4 ); PROVIDE ( _calloc_r = 0x4000bbf8 ); -PROVIDE ( _cleanup = 0x40001df8 ); -PROVIDE ( _cleanup_r = 0x40001d48 ); PROVIDE ( __clear_cache = 0x40063860 ); -PROVIDE ( close = 0x40001778 ); PROVIDE ( _close_r = 0x4000bd3c ); PROVIDE ( __clrsbdi2 = 0x40064a38 ); PROVIDE ( __clrsbsi2 = 0x40064a20 ); @@ -79,9 +67,6 @@ PROVIDE ( crc32_be = 0x4005d024 ); PROVIDE ( crc32_le = 0x4005cfec ); PROVIDE ( crc8_be = 0x4005d114 ); PROVIDE ( crc8_le = 0x4005d0e0 ); -PROVIDE ( creat = 0x40000e8c ); -PROVIDE ( ctime = 0x400595b0 ); -PROVIDE ( ctime_r = 0x400595c4 ); PROVIDE ( _ctype_ = 0x3ff96354 ); PROVIDE ( __ctype_ptr__ = 0x3ff96350 ); PROVIDE ( __ctzdi2 = 0x4000ca64 ); @@ -118,7 +103,6 @@ PROVIDE ( dh_group2_generator = 0x3ff9ada2 ); PROVIDE ( dh_group2_prime = 0x3ff9ad22 ); PROVIDE ( dh_group5_generator = 0x3ff9ad21 ); PROVIDE ( dh_group5_prime = 0x3ff9ac61 ); -PROVIDE ( div = 0x40056348 ); PROVIDE ( __divdc3 = 0x40064460 ); PROVIDE ( __divdf3 = 0x40002954 ); PROVIDE ( __divdi3 = 0x4000ca84 ); @@ -126,14 +110,10 @@ PROVIDE ( __divsc3 = 0x40064200 ); PROVIDE ( __divsf3 = 0x4000234c ); PROVIDE ( __divsi3 = 0x4000c7b8 ); PROVIDE ( g_rom_spiflash_dummy_len_plus = 0x3ffae290 ); -PROVIDE ( __dummy_lock = 0x4000c728 ); -PROVIDE ( __dummy_lock_try = 0x4000c730 ); PROVIDE ( ecc_env = 0x3ffb8d60 ); PROVIDE ( ecc_Jacobian_InfinityPoint256 = 0x3ff972e8 ); PROVIDE ( em_buf_env = 0x3ffb8d74 ); PROVIDE ( environ = 0x3ffae0b4 ); -PROVIDE ( __env_lock = 0x40001fd4 ); -PROVIDE ( __env_unlock = 0x40001fe0 ); PROVIDE ( __eqdf2 = 0x400636a8 ); PROVIDE ( __eqsf2 = 0x40063374 ); PROVIDE ( esp_crc8 = 0x4005d144 ); @@ -143,13 +123,8 @@ PROVIDE ( ets_startup_callback = 0x3ffe0404 ); PROVIDE ( exc_cause_table = 0x3ff991d0 ); PROVIDE ( _exit_r = 0x4000bd28 ); PROVIDE ( __extendsfdf2 = 0x40002c34 ); -PROVIDE ( fclose = 0x400020ac ); -PROVIDE ( _fclose_r = 0x40001fec ); -PROVIDE ( fflush = 0x40059394 ); -PROVIDE ( _fflush_r = 0x40059320 ); PROVIDE ( __ffsdi2 = 0x4000ca2c ); PROVIDE ( __ffssi2 = 0x4000c804 ); -PROVIDE ( _findenv_r = 0x40001f44 ); PROVIDE ( __fixdfdi = 0x40002ac4 ); PROVIDE ( __fixdfsi = 0x40002a78 ); PROVIDE ( __fixsfdi = 0x4000244c ); @@ -165,31 +140,19 @@ PROVIDE ( __floatundidf = 0x4000c978 ); PROVIDE ( __floatundisf = 0x4000c8b0 ); PROVIDE ( __floatunsidf = 0x4000c938 ); PROVIDE ( __floatunsisf = 0x4000c864 ); -PROVIDE ( __fp_lock_all = 0x40001f1c ); -PROVIDE ( __fp_unlock_all = 0x40001f30 ); -PROVIDE ( fputwc = 0x40058ea8 ); -PROVIDE ( __fputwc = 0x40058da0 ); -PROVIDE ( _fputwc_r = 0x40058e4c ); PROVIDE ( free = 0x4000beb8 ); PROVIDE ( _free_r = 0x4000bbcc ); PROVIDE ( _fstat_r = 0x4000bccc ); -PROVIDE ( _fwalk = 0x4000c738 ); -PROVIDE ( _fwalk_reent = 0x4000c770 ); PROVIDE ( __gcc_bcmp = 0x40064a70 ); PROVIDE ( __gedf2 = 0x40063768 ); PROVIDE ( __gesf2 = 0x4006340c ); -PROVIDE ( __get_current_time_locale = 0x40001834 ); -PROVIDE ( _getenv_r = 0x40001fbc ); PROVIDE ( _getpid_r = 0x4000bcfc ); PROVIDE ( __getreent = 0x4000be8c ); PROVIDE ( _gettimeofday_r = 0x4000bc58 ); -PROVIDE ( __gettzinfo = 0x40001fcc ); PROVIDE ( GF_Jacobian_Point_Addition256 = 0x400163a4 ); PROVIDE ( GF_Jacobian_Point_Double256 = 0x40016260 ); PROVIDE ( GF_Point_Jacobian_To_Affine256 = 0x40016b0c ); PROVIDE ( _global_impure_ptr = 0x3ffae0b0 ); -PROVIDE ( gmtime = 0x40059848 ); -PROVIDE ( gmtime_r = 0x40059868 ); PROVIDE ( g_phyFuns_instance = 0x3ffae0c4 ); PROVIDE ( g_rom_flashchip = 0x3ffae270 ); PROVIDE ( __gtdf2 = 0x400636dc ); @@ -216,26 +179,10 @@ PROVIDE ( hmac_sha1 = 0x40060acc ); PROVIDE ( hmac_sha1_vector = 0x400609e4 ); PROVIDE ( hmac_sha256 = 0x40060d58 ); PROVIDE ( hmac_sha256_vector = 0x40060c84 ); -PROVIDE ( isalnum = 0x40000f04 ); -PROVIDE ( isalpha = 0x40000f18 ); -PROVIDE ( isascii = 0x4000c20c ); -PROVIDE ( _isatty_r = 0x40000ea0 ); -PROVIDE ( isblank = 0x40000f2c ); -PROVIDE ( iscntrl = 0x40000f50 ); -PROVIDE ( isdigit = 0x40000f64 ); -PROVIDE ( isgraph = 0x40000f94 ); -PROVIDE ( islower = 0x40000f78 ); -PROVIDE ( isprint = 0x40000fa8 ); -PROVIDE ( ispunct = 0x40000fc0 ); -PROVIDE ( isspace = 0x40000fd4 ); -PROVIDE ( isupper = 0x40000fe8 ); -PROVIDE ( itoa = 0x400566b4 ); -PROVIDE ( __itoa = 0x40056678 ); PROVIDE ( jd_decomp = 0x400613e8 ); PROVIDE ( jd_prepare = 0x40060fa8 ); PROVIDE ( ke_env = 0x3ffb93cc ); PROVIDE ( _kill_r = 0x4000bd10 ); -PROVIDE ( labs = 0x40056370 ); PROVIDE ( lb_default_handler = 0x3ff982b8 ); PROVIDE ( lb_default_state_tab_p_get = 0x4001c198 ); PROVIDE ( lb_env = 0x3ffb9424 ); @@ -251,7 +198,6 @@ PROVIDE ( ld_acl_br_types = 0x3ff98a36 ); PROVIDE ( ld_acl_edr_sizes = 0x3ff98a14 ); PROVIDE ( ld_acl_edr_types = 0x3ff98a22 ); PROVIDE ( ld_env = 0x3ffb9510 ); -PROVIDE ( ldiv = 0x40056378 ); PROVIDE ( ld_pcm_settings_dft = 0x3ff98a0c ); PROVIDE ( ld_sched_params = 0x3ffb96c0 ); PROVIDE ( ld_sync_train_channels = 0x3ff98a3c ); @@ -292,25 +238,14 @@ PROVIDE ( lm_n_page_tab = 0x3ff990e8 ); PROVIDE ( lmp_desc_tab = 0x3ff96e6c ); PROVIDE ( lmp_ext_desc_tab = 0x3ff96d9c ); PROVIDE ( lm_state = 0x3ffb9a1c ); -PROVIDE ( __locale_charset = 0x40059540 ); -PROVIDE ( __locale_cjk_lang = 0x40059558 ); -PROVIDE ( localeconv = 0x4005957c ); -PROVIDE ( _localeconv_r = 0x40059560 ); -PROVIDE ( __locale_mb_cur_max = 0x40059548 ); -PROVIDE ( __locale_msgcharset = 0x40059550 ); -PROVIDE ( localtime = 0x400595dc ); -PROVIDE ( localtime_r = 0x400595fc ); -PROVIDE ( _lock_acquire = 0x4000be14 ); PROVIDE ( _lock_acquire_recursive = 0x4000be28 ); PROVIDE ( _lock_close = 0x4000bdec ); PROVIDE ( _lock_close_recursive = 0x4000be00 ); PROVIDE ( _lock_init = 0x4000bdc4 ); PROVIDE ( _lock_init_recursive = 0x4000bdd8 ); -PROVIDE ( _lock_release = 0x4000be64 ); PROVIDE ( _lock_release_recursive = 0x4000be78 ); PROVIDE ( _lock_try_acquire = 0x4000be3c ); PROVIDE ( _lock_try_acquire_recursive = 0x4000be50 ); -PROVIDE ( longjmp = 0x400562cc ); PROVIDE ( _lseek_r = 0x4000bd8c ); PROVIDE ( __lshrdi3 = 0x4000c84c ); PROVIDE ( __ltdf2 = 0x40063790 ); @@ -323,14 +258,6 @@ PROVIDE ( MD5Final = 0x4005db1c ); PROVIDE ( MD5Init = 0x4005da7c ); PROVIDE ( MD5Update = 0x4005da9c ); PROVIDE ( md5_vector = 0x4005db80 ); -PROVIDE ( memccpy = 0x4000c220 ); -PROVIDE ( memchr = 0x4000c244 ); -PROVIDE ( memcmp = 0x4000c260 ); -PROVIDE ( memcpy = 0x4000c2c8 ); -PROVIDE ( memmove = 0x4000c3c0 ); -PROVIDE ( memrchr = 0x4000c400 ); -PROVIDE ( memset = 0x4000c44c ); -PROVIDE ( mktime = 0x4005a5e8 ); PROVIDE ( mmu_init = 0x400095a4 ); PROVIDE ( __moddi3 = 0x4000cd4c ); PROVIDE ( __modsi3 = 0x4000c7c0 ); @@ -360,7 +287,6 @@ PROVIDE ( __nesf2 = 0x40063374 ); PROVIDE ( notEqual256 = 0x40015b04 ); PROVIDE ( __nsau_data = 0x3ff96544 ); PROVIDE ( one_bits = 0x3ff971f8 ); -PROVIDE ( open = 0x4000178c ); PROVIDE ( _open_r = 0x4000bd54 ); PROVIDE ( __paritysi2 = 0x40002f3c ); PROVIDE ( pbkdf2_sha1 = 0x40060ba4 ); @@ -372,10 +298,6 @@ PROVIDE ( __powidf2 = 0x400638d4 ); PROVIDE ( __powisf2 = 0x4006389c ); PROVIDE ( _Pri_4_HandlerAddress = 0x3ffe0648 ); PROVIDE ( _Pri_5_HandlerAddress = 0x3ffe064c ); -PROVIDE ( qsort = 0x40056424 ); -PROVIDE ( _raise_r = 0x4000bc70 ); -PROVIDE ( rand = 0x40001058 ); -PROVIDE ( rand_r = 0x400010d4 ); PROVIDE ( r_btdm_option_data = 0x3ffae6e0 ); PROVIDE ( r_bt_util_buf_acl_rx_alloc = 0x40010218 ); PROVIDE ( r_bt_util_buf_acl_rx_free = 0x40010234 ); @@ -419,7 +341,6 @@ PROVIDE ( r_E22 = 0x400109b4 ); PROVIDE ( r_E3 = 0x40010a58 ); PROVIDE ( r_ea_alarm_clear = 0x40015ab4 ); PROVIDE ( r_ea_alarm_set = 0x40015a10 ); -PROVIDE ( read = 0x400017dc ); PROVIDE ( _read_r = 0x4000bda8 ); PROVIDE ( r_ea_elt_cancel = 0x400150d0 ); PROVIDE ( r_ea_elt_create = 0x40015264 ); @@ -1440,24 +1361,10 @@ PROVIDE ( rwip_priority = 0x3ff99159 ); PROVIDE ( rwip_rf = 0x3ffbdb28 ); PROVIDE ( rwip_rf_p_get = 0x400558f4 ); PROVIDE ( r_XorKey = 0x400112c0 ); -PROVIDE ( sbrk = 0x400017f4 ); PROVIDE ( _sbrk_r = 0x4000bce4 ); -PROVIDE ( __sccl = 0x4000c498 ); -PROVIDE ( __sclose = 0x400011b8 ); -PROVIDE ( __seofread = 0x40001148 ); -PROVIDE ( setjmp = 0x40056268 ); -PROVIDE ( setlocale = 0x40059568 ); -PROVIDE ( _setlocale_r = 0x4005950c ); PROVIDE ( __sf_fake_stderr = 0x3ff96458 ); PROVIDE ( __sf_fake_stdin = 0x3ff96498 ); PROVIDE ( __sf_fake_stdout = 0x3ff96478 ); -PROVIDE ( __sflush_r = 0x400591e0 ); -PROVIDE ( __sfmoreglue = 0x40001dc8 ); -PROVIDE ( __sfp = 0x40001e90 ); -PROVIDE ( __sfp_lock_acquire = 0x40001e08 ); -PROVIDE ( __sfp_lock_release = 0x40001e14 ); -PROVIDE ( __sfputs_r = 0x40057790 ); -PROVIDE ( __sfvwrite_r = 0x4005893c ); PROVIDE ( sha1_prf = 0x40060ae8 ); PROVIDE ( sha1_vector = 0x40060b64 ); PROVIDE ( sha256_prf = 0x40060d70 ); @@ -1466,9 +1373,6 @@ PROVIDE ( sha_blk_bits = 0x3ff99290 ); PROVIDE ( sha_blk_bits_bytes = 0x3ff99288 ); PROVIDE ( sha_blk_hash_bytes = 0x3ff9928c ); PROVIDE ( sig_matrix = 0x3ffae293 ); -PROVIDE ( __sinit = 0x40001e38 ); -PROVIDE ( __sinit_lock_acquire = 0x40001e20 ); -PROVIDE ( __sinit_lock_release = 0x40001e2c ); PROVIDE ( sip_after_tx_complete = 0x4000b358 ); PROVIDE ( sip_alloc_to_host_evt = 0x4000ab9c ); PROVIDE ( sip_get_ptr = 0x4000b34c ); @@ -1494,15 +1398,7 @@ PROVIDE ( slc_reattach = 0x4000b62c ); PROVIDE ( slc_send_to_host_chain = 0x4000b6a0 ); PROVIDE ( slc_set_host_io_max_window = 0x4000b89c ); PROVIDE ( slc_to_host_chain_recycle = 0x4000b758 ); -PROVIDE ( __smakebuf_r = 0x40059108 ); PROVIDE ( specialModP256 = 0x4001600c ); -PROVIDE ( srand = 0x40001004 ); -PROVIDE ( __sread = 0x40001118 ); -PROVIDE ( __srefill_r = 0x400593d4 ); -PROVIDE ( __sseek = 0x40001184 ); -PROVIDE ( __ssprint_r = 0x40056ff8 ); -PROVIDE ( __ssputs_r = 0x40056f2c ); -PROVIDE ( __ssrefill_r = 0x40057fec ); PROVIDE ( __stack = 0x3ffe3f20 ); PROVIDE ( __stack_app = 0x3ffe7e30 ); PROVIDE ( _stack_sentry = 0x3ffe1320 ); @@ -1511,41 +1407,7 @@ PROVIDE ( _start = 0x40000704 ); PROVIDE ( start_tb_console = 0x4005a980 ); PROVIDE ( _stat_r = 0x4000bcb4 ); PROVIDE ( _stext = 0x40000560 ); -PROVIDE ( strcasecmp = 0x400011cc ); -PROVIDE ( strcasestr = 0x40001210 ); -PROVIDE ( strcat = 0x4000c518 ); -PROVIDE ( strchr = 0x4000c53c ); -PROVIDE ( strcmp = 0x40001274 ); -PROVIDE ( strcoll = 0x40001398 ); -PROVIDE ( strcpy = 0x400013ac ); -PROVIDE ( strcspn = 0x4000c558 ); -PROVIDE ( strdup = 0x4000143c ); -PROVIDE ( _strdup_r = 0x40001450 ); -PROVIDE ( strftime = 0x40059ab4 ); -PROVIDE ( strlcat = 0x40001470 ); -PROVIDE ( strlcpy = 0x4000c584 ); -PROVIDE ( strlen = 0x400014c0 ); -PROVIDE ( strlwr = 0x40001524 ); -PROVIDE ( strncasecmp = 0x40001550 ); -PROVIDE ( strncat = 0x4000c5c4 ); -PROVIDE ( strncmp = 0x4000c5f4 ); -PROVIDE ( strncpy = 0x400015d4 ); -PROVIDE ( strndup = 0x400016b0 ); -PROVIDE ( _strndup_r = 0x400016c4 ); -PROVIDE ( strnlen = 0x4000c628 ); -PROVIDE ( strrchr = 0x40001708 ); -PROVIDE ( strsep = 0x40001734 ); -PROVIDE ( strspn = 0x4000c648 ); -PROVIDE ( strstr = 0x4000c674 ); -PROVIDE ( __strtok_r = 0x4000c6a8 ); -PROVIDE ( strtok_r = 0x4000c70c ); -PROVIDE ( strtol = 0x4005681c ); -PROVIDE ( _strtol_r = 0x40056714 ); -PROVIDE ( strtoul = 0x4005692c ); -PROVIDE ( _strtoul_r = 0x40056834 ); -PROVIDE ( strupr = 0x4000174c ); PROVIDE ( __subdf3 = 0x400026e4 ); -PROVIDE ( __submore = 0x40058f3c ); PROVIDE ( __subsf3 = 0x400021d0 ); PROVIDE ( SubtractBigHex256 = 0x40015bcc ); PROVIDE ( SubtractBigHexMod256 = 0x40015e8c ); @@ -1554,15 +1416,9 @@ PROVIDE ( SubtractFromSelfBigHex256 = 0x40015c20 ); PROVIDE ( SubtractFromSelfBigHexSign256 = 0x40015dc8 ); PROVIDE ( __subvdi3 = 0x40002d20 ); PROVIDE ( __subvsi3 = 0x40002cf8 ); -PROVIDE ( _sungetc_r = 0x40057f6c ); -PROVIDE ( __swbuf = 0x40058cb4 ); -PROVIDE ( __swbuf_r = 0x40058bec ); -PROVIDE ( __swrite = 0x40001150 ); -PROVIDE ( __swsetup_r = 0x40058cc8 ); PROVIDE ( sw_to_hw = 0x3ffb8d40 ); PROVIDE ( syscall_table_ptr_app = 0x3ffae020 ); PROVIDE ( syscall_table_ptr_pro = 0x3ffae024 ); -PROVIDE ( _system_r = 0x4000bc10 ); PROVIDE ( tdefl_compress = 0x400600bc ); PROVIDE ( tdefl_compress_buffer = 0x400607f4 ); PROVIDE ( tdefl_compress_mem_to_mem = 0x40060900 ); @@ -1572,24 +1428,13 @@ PROVIDE ( tdefl_get_prev_return_status = 0x400608d0 ); PROVIDE ( tdefl_init = 0x40060810 ); PROVIDE ( tdefl_write_image_to_png_file_in_memory = 0x4006091c ); PROVIDE ( tdefl_write_image_to_png_file_in_memory_ex = 0x40060910 ); -PROVIDE ( time = 0x40001844 ); -PROVIDE ( __time_load_locale = 0x4000183c ); -PROVIDE ( times = 0x40001808 ); PROVIDE ( _times_r = 0x4000bc40 ); PROVIDE ( _timezone = 0x3ffae0a0 ); PROVIDE ( tinfl_decompress = 0x4005ef30 ); PROVIDE ( tinfl_decompress_mem_to_callback = 0x40060090 ); PROVIDE ( tinfl_decompress_mem_to_mem = 0x40060050 ); -PROVIDE ( toascii = 0x4000c720 ); -PROVIDE ( tolower = 0x40001868 ); -PROVIDE ( toupper = 0x40001884 ); PROVIDE ( __truncdfsf2 = 0x40002b90 ); -PROVIDE ( __tzcalc_limits = 0x400018a0 ); -PROVIDE ( __tz_lock = 0x40001a04 ); PROVIDE ( _tzname = 0x3ffae030 ); -PROVIDE ( tzset = 0x40001a1c ); -PROVIDE ( _tzset_r = 0x40001a28 ); -PROVIDE ( __tz_unlock = 0x40001a10 ); PROVIDE ( UartDev = 0x3ffe019c ); PROVIDE ( __ucmpdi2 = 0x40063840 ); PROVIDE ( __udivdi3 = 0x4000cff8 ); @@ -1599,20 +1444,12 @@ PROVIDE ( __udiv_w_sdiv = 0x40064aa8 ); PROVIDE ( __umoddi3 = 0x4000d280 ); PROVIDE ( __umodsi3 = 0x4000c7d0 ); PROVIDE ( __umulsidi3 = 0x4000c7d8 ); -PROVIDE ( ungetc = 0x400590f4 ); -PROVIDE ( _ungetc_r = 0x40058fa0 ); PROVIDE ( _unlink_r = 0x4000bc84 ); PROVIDE ( __unorddf2 = 0x400637f4 ); PROVIDE ( __unordsf2 = 0x40063478 ); PROVIDE ( user_code_start = 0x3ffe0400 ); -PROVIDE ( utoa = 0x40056258 ); -PROVIDE ( __utoa = 0x400561f0 ); PROVIDE ( veryBigHexP256 = 0x3ff9736c ); -PROVIDE ( wcrtomb = 0x40058920 ); -PROVIDE ( _wcrtomb_r = 0x400588d8 ); PROVIDE ( __wctomb = 0x3ff96540 ); -PROVIDE ( _wctomb_r = 0x40058f14 ); -PROVIDE ( write = 0x4000181c ); PROVIDE ( _write_r = 0x4000bd70 ); PROVIDE ( xthal_bcopy = 0x4000c098 ); PROVIDE ( xthal_copy123 = 0x4000c124 ); diff --git a/tools/sdk/ld/esp32.rom.spiram_incompatible_fns.ld b/tools/sdk/ld/esp32.rom.spiram_incompatible_fns.ld new file mode 100644 index 00000000..e4899b66 --- /dev/null +++ b/tools/sdk/ld/esp32.rom.spiram_incompatible_fns.ld @@ -0,0 +1,167 @@ +/* + If the spiram compiler workaround is active, these functions from ROM cannot be used. If the workaround is not + active (e.g. because the system does not use SPI RAM) then these functions are okay to use. +*/ +PROVIDE ( abs = 0x40056340 ); +PROVIDE ( __ascii_wctomb = 0x40058ef0 ); +PROVIDE ( asctime = 0x40059588 ); +PROVIDE ( asctime_r = 0x40000ec8 ); +PROVIDE ( atoi = 0x400566c4 ); +PROVIDE ( _atoi_r = 0x400566d4 ); +PROVIDE ( atol = 0x400566ec ); +PROVIDE ( _atol_r = 0x400566fc ); +PROVIDE ( bzero = 0x4000c1f4 ); +PROVIDE ( _cleanup = 0x40001df8 ); +PROVIDE ( _cleanup_r = 0x40001d48 ); +PROVIDE ( close = 0x40001778 ); +PROVIDE ( creat = 0x40000e8c ); +PROVIDE ( ctime = 0x400595b0 ); +PROVIDE ( ctime_r = 0x400595c4 ); +PROVIDE ( div = 0x40056348 ); +PROVIDE ( __dummy_lock = 0x4000c728 ); +PROVIDE ( __dummy_lock_try = 0x4000c730 ); +PROVIDE ( __env_lock = 0x40001fd4 ); +PROVIDE ( __env_unlock = 0x40001fe0 ); +PROVIDE ( fclose = 0x400020ac ); +PROVIDE ( _fclose_r = 0x40001fec ); +PROVIDE ( fflush = 0x40059394 ); +PROVIDE ( _fflush_r = 0x40059320 ); +PROVIDE ( _findenv_r = 0x40001f44 ); +PROVIDE ( __fp_lock_all = 0x40001f1c ); +PROVIDE ( __fp_unlock_all = 0x40001f30 ); +PROVIDE ( fputwc = 0x40058ea8 ); +PROVIDE ( __fputwc = 0x40058da0 ); +PROVIDE ( _fputwc_r = 0x40058e4c ); +PROVIDE ( _fwalk = 0x4000c738 ); +PROVIDE ( _fwalk_reent = 0x4000c770 ); +PROVIDE ( __get_current_time_locale = 0x40001834 ); +PROVIDE ( _getenv_r = 0x40001fbc ); +PROVIDE ( __gettzinfo = 0x40001fcc ); +PROVIDE ( gmtime = 0x40059848 ); +PROVIDE ( gmtime_r = 0x40059868 ); +PROVIDE ( isalnum = 0x40000f04 ); +PROVIDE ( isalpha = 0x40000f18 ); +PROVIDE ( isascii = 0x4000c20c ); +PROVIDE ( _isatty_r = 0x40000ea0 ); +PROVIDE ( isblank = 0x40000f2c ); +PROVIDE ( iscntrl = 0x40000f50 ); +PROVIDE ( isdigit = 0x40000f64 ); +PROVIDE ( isgraph = 0x40000f94 ); +PROVIDE ( islower = 0x40000f78 ); +PROVIDE ( isprint = 0x40000fa8 ); +PROVIDE ( ispunct = 0x40000fc0 ); +PROVIDE ( isspace = 0x40000fd4 ); +PROVIDE ( isupper = 0x40000fe8 ); +PROVIDE ( itoa = 0x400566b4 ); +PROVIDE ( __itoa = 0x40056678 ); +PROVIDE ( labs = 0x40056370 ); +PROVIDE ( ldiv = 0x40056378 ); +PROVIDE ( __locale_charset = 0x40059540 ); +PROVIDE ( __locale_cjk_lang = 0x40059558 ); +PROVIDE ( localeconv = 0x4005957c ); +PROVIDE ( _localeconv_r = 0x40059560 ); +PROVIDE ( __locale_mb_cur_max = 0x40059548 ); +PROVIDE ( __locale_msgcharset = 0x40059550 ); +PROVIDE ( localtime = 0x400595dc ); +PROVIDE ( localtime_r = 0x400595fc ); +PROVIDE ( _lock_acquire = 0x4000be14 ); +PROVIDE ( _lock_release = 0x4000be64 ); +PROVIDE ( longjmp = 0x400562cc ); +PROVIDE ( memccpy = 0x4000c220 ); +PROVIDE ( memchr = 0x4000c244 ); +PROVIDE ( memcmp = 0x4000c260 ); +PROVIDE ( memcpy = 0x4000c2c8 ); +PROVIDE ( memmove = 0x4000c3c0 ); +PROVIDE ( memrchr = 0x4000c400 ); +PROVIDE ( memset = 0x4000c44c ); +PROVIDE ( mktime = 0x4005a5e8 ); +PROVIDE ( open = 0x4000178c ); +PROVIDE ( qsort = 0x40056424 ); +PROVIDE ( _raise_r = 0x4000bc70 ); +PROVIDE ( rand = 0x40001058 ); +PROVIDE ( rand_r = 0x400010d4 ); +PROVIDE ( read = 0x400017dc ); +PROVIDE ( sbrk = 0x400017f4 ); +PROVIDE ( __sccl = 0x4000c498 ); +PROVIDE ( __sclose = 0x400011b8 ); +PROVIDE ( __seofread = 0x40001148 ); +PROVIDE ( setjmp = 0x40056268 ); +PROVIDE ( setlocale = 0x40059568 ); +PROVIDE ( _setlocale_r = 0x4005950c ); +PROVIDE ( __sflush_r = 0x400591e0 ); +PROVIDE ( __sfmoreglue = 0x40001dc8 ); +PROVIDE ( __sfp = 0x40001e90 ); +PROVIDE ( __sfp_lock_acquire = 0x40001e08 ); +PROVIDE ( __sfp_lock_release = 0x40001e14 ); +PROVIDE ( __sfputs_r = 0x40057790 ); +PROVIDE ( __sfvwrite_r = 0x4005893c ); +PROVIDE ( __sinit = 0x40001e38 ); +PROVIDE ( __sinit_lock_acquire = 0x40001e20 ); +PROVIDE ( __sinit_lock_release = 0x40001e2c ); +PROVIDE ( __smakebuf_r = 0x40059108 ); +PROVIDE ( srand = 0x40001004 ); +PROVIDE ( __sread = 0x40001118 ); +PROVIDE ( __srefill_r = 0x400593d4 ); +PROVIDE ( __sseek = 0x40001184 ); +PROVIDE ( __ssprint_r = 0x40056ff8 ); +PROVIDE ( __ssputs_r = 0x40056f2c ); +PROVIDE ( __ssrefill_r = 0x40057fec ); +PROVIDE ( strcasecmp = 0x400011cc ); +PROVIDE ( strcasestr = 0x40001210 ); +PROVIDE ( strcat = 0x4000c518 ); +PROVIDE ( strchr = 0x4000c53c ); +PROVIDE ( strcmp = 0x40001274 ); +PROVIDE ( strcoll = 0x40001398 ); +PROVIDE ( strcpy = 0x400013ac ); +PROVIDE ( strcspn = 0x4000c558 ); +PROVIDE ( strdup = 0x4000143c ); +PROVIDE ( _strdup_r = 0x40001450 ); +PROVIDE ( strftime = 0x40059ab4 ); +PROVIDE ( strlcat = 0x40001470 ); +PROVIDE ( strlcpy = 0x4000c584 ); +PROVIDE ( strlen = 0x400014c0 ); +PROVIDE ( strlwr = 0x40001524 ); +PROVIDE ( strncasecmp = 0x40001550 ); +PROVIDE ( strncat = 0x4000c5c4 ); +PROVIDE ( strncmp = 0x4000c5f4 ); +PROVIDE ( strncpy = 0x400015d4 ); +PROVIDE ( strndup = 0x400016b0 ); +PROVIDE ( _strndup_r = 0x400016c4 ); +PROVIDE ( strnlen = 0x4000c628 ); +PROVIDE ( strrchr = 0x40001708 ); +PROVIDE ( strsep = 0x40001734 ); +PROVIDE ( strspn = 0x4000c648 ); +PROVIDE ( strstr = 0x4000c674 ); +PROVIDE ( __strtok_r = 0x4000c6a8 ); +PROVIDE ( strtok_r = 0x4000c70c ); +PROVIDE ( strtol = 0x4005681c ); +PROVIDE ( _strtol_r = 0x40056714 ); +PROVIDE ( strtoul = 0x4005692c ); +PROVIDE ( _strtoul_r = 0x40056834 ); +PROVIDE ( strupr = 0x4000174c ); +PROVIDE ( __submore = 0x40058f3c ); +PROVIDE ( _sungetc_r = 0x40057f6c ); +PROVIDE ( __swbuf = 0x40058cb4 ); +PROVIDE ( __swbuf_r = 0x40058bec ); +PROVIDE ( __swrite = 0x40001150 ); +PROVIDE ( __swsetup_r = 0x40058cc8 ); +PROVIDE ( _system_r = 0x4000bc10 ); +PROVIDE ( time = 0x40001844 ); +PROVIDE ( __time_load_locale = 0x4000183c ); +PROVIDE ( times = 0x40001808 ); +PROVIDE ( toascii = 0x4000c720 ); +PROVIDE ( tolower = 0x40001868 ); +PROVIDE ( toupper = 0x40001884 ); +PROVIDE ( __tzcalc_limits = 0x400018a0 ); +PROVIDE ( __tz_lock = 0x40001a04 ); +PROVIDE ( tzset = 0x40001a1c ); +PROVIDE ( _tzset_r = 0x40001a28 ); +PROVIDE ( __tz_unlock = 0x40001a10 ); +PROVIDE ( ungetc = 0x400590f4 ); +PROVIDE ( _ungetc_r = 0x40058fa0 ); +PROVIDE ( utoa = 0x40056258 ); +PROVIDE ( __utoa = 0x400561f0 ); +PROVIDE ( wcrtomb = 0x40058920 ); +PROVIDE ( _wcrtomb_r = 0x400588d8 ); +PROVIDE ( _wctomb_r = 0x40058f14 ); +PROVIDE ( write = 0x4000181c ); diff --git a/tools/sdk/ld/esp32_out.ld b/tools/sdk/ld/esp32_out.ld index 31bc1ef7..a62f4e47 100644 --- a/tools/sdk/ld/esp32_out.ld +++ b/tools/sdk/ld/esp32_out.ld @@ -20,6 +20,7 @@ * Espressif IoT Development Framework Configuration * */ +/* If BT is not built at all */ MEMORY { /* All these values assume the flash cache is on, and have the blocks this uses subtracted from the length diff --git a/tools/sdk/lib/libapp_trace.a b/tools/sdk/lib/libapp_trace.a index eddf6163..eded79e4 100644 Binary files a/tools/sdk/lib/libapp_trace.a and b/tools/sdk/lib/libapp_trace.a differ diff --git a/tools/sdk/lib/libapp_update.a b/tools/sdk/lib/libapp_update.a index ee262e3f..80ad0cda 100644 Binary files a/tools/sdk/lib/libapp_update.a and b/tools/sdk/lib/libapp_update.a differ diff --git a/tools/sdk/lib/libbootloader_support.a b/tools/sdk/lib/libbootloader_support.a index b8333279..2e802de6 100644 Binary files a/tools/sdk/lib/libbootloader_support.a and b/tools/sdk/lib/libbootloader_support.a differ diff --git a/tools/sdk/lib/libbt.a b/tools/sdk/lib/libbt.a index e72aad97..9c60935f 100644 Binary files a/tools/sdk/lib/libbt.a and b/tools/sdk/lib/libbt.a differ diff --git a/tools/sdk/lib/libbtdm_app.a b/tools/sdk/lib/libbtdm_app.a index df3a38fb..116119ce 100644 Binary files a/tools/sdk/lib/libbtdm_app.a and b/tools/sdk/lib/libbtdm_app.a differ diff --git a/tools/sdk/lib/libcoap.a b/tools/sdk/lib/libcoap.a index 91095822..8700a585 100644 Binary files a/tools/sdk/lib/libcoap.a and b/tools/sdk/lib/libcoap.a differ diff --git a/tools/sdk/lib/libcoexist.a b/tools/sdk/lib/libcoexist.a index e550f10b..e4c9ea72 100644 Binary files a/tools/sdk/lib/libcoexist.a and b/tools/sdk/lib/libcoexist.a differ diff --git a/tools/sdk/lib/libconsole.a b/tools/sdk/lib/libconsole.a new file mode 100644 index 00000000..43c9e6aa Binary files /dev/null and b/tools/sdk/lib/libconsole.a differ diff --git a/tools/sdk/lib/libcore.a b/tools/sdk/lib/libcore.a index 2db0ae88..1435083d 100644 Binary files a/tools/sdk/lib/libcore.a and b/tools/sdk/lib/libcore.a differ diff --git a/tools/sdk/lib/libcxx.a b/tools/sdk/lib/libcxx.a index 150ffde0..401ecc09 100644 Binary files a/tools/sdk/lib/libcxx.a and b/tools/sdk/lib/libcxx.a differ diff --git a/tools/sdk/lib/libdriver.a b/tools/sdk/lib/libdriver.a index a6ddf1eb..06dccf8b 100644 Binary files a/tools/sdk/lib/libdriver.a and b/tools/sdk/lib/libdriver.a differ diff --git a/tools/sdk/lib/libesp32.a b/tools/sdk/lib/libesp32.a index 58871d08..7d68815b 100644 Binary files a/tools/sdk/lib/libesp32.a and b/tools/sdk/lib/libesp32.a differ diff --git a/tools/sdk/lib/libesp_adc_cal.a b/tools/sdk/lib/libesp_adc_cal.a new file mode 100644 index 00000000..962aad2c Binary files /dev/null and b/tools/sdk/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/lib/libethernet.a b/tools/sdk/lib/libethernet.a index 497c32a9..9ced0ef7 100644 Binary files a/tools/sdk/lib/libethernet.a and b/tools/sdk/lib/libethernet.a differ diff --git a/tools/sdk/lib/libexpat.a b/tools/sdk/lib/libexpat.a index 21db7bee..2ae482e4 100644 Binary files a/tools/sdk/lib/libexpat.a and b/tools/sdk/lib/libexpat.a differ diff --git a/tools/sdk/lib/libfatfs.a b/tools/sdk/lib/libfatfs.a index 8ac407ba..2011dd2b 100644 Binary files a/tools/sdk/lib/libfatfs.a and b/tools/sdk/lib/libfatfs.a differ diff --git a/tools/sdk/lib/libfreertos.a b/tools/sdk/lib/libfreertos.a index 277681d4..761dde3f 100644 Binary files a/tools/sdk/lib/libfreertos.a and b/tools/sdk/lib/libfreertos.a differ diff --git a/tools/sdk/lib/libheap.a b/tools/sdk/lib/libheap.a index 05c697e5..bb091941 100644 Binary files a/tools/sdk/lib/libheap.a and b/tools/sdk/lib/libheap.a differ diff --git a/tools/sdk/lib/libjsmn.a b/tools/sdk/lib/libjsmn.a index 7a24dad8..7c7d1bca 100644 Binary files a/tools/sdk/lib/libjsmn.a and b/tools/sdk/lib/libjsmn.a differ diff --git a/tools/sdk/lib/libjson.a b/tools/sdk/lib/libjson.a index 3331358b..6e7e9994 100644 Binary files a/tools/sdk/lib/libjson.a and b/tools/sdk/lib/libjson.a differ diff --git a/tools/sdk/lib/liblog.a b/tools/sdk/lib/liblog.a index e53530e7..9a4deeb8 100644 Binary files a/tools/sdk/lib/liblog.a and b/tools/sdk/lib/liblog.a differ diff --git a/tools/sdk/lib/liblwip.a b/tools/sdk/lib/liblwip.a index d1c611c4..91a6512b 100644 Binary files a/tools/sdk/lib/liblwip.a and b/tools/sdk/lib/liblwip.a differ diff --git a/tools/sdk/lib/libmbedtls.a b/tools/sdk/lib/libmbedtls.a index aaad6545..9908a606 100644 Binary files a/tools/sdk/lib/libmbedtls.a and b/tools/sdk/lib/libmbedtls.a differ diff --git a/tools/sdk/lib/libmdns.a b/tools/sdk/lib/libmdns.a index 164c6088..09aa46b4 100644 Binary files a/tools/sdk/lib/libmdns.a and b/tools/sdk/lib/libmdns.a differ diff --git a/tools/sdk/lib/libmicro-ecc.a b/tools/sdk/lib/libmicro-ecc.a index 64564b8d..2f0924e8 100644 Binary files a/tools/sdk/lib/libmicro-ecc.a and b/tools/sdk/lib/libmicro-ecc.a differ diff --git a/tools/sdk/lib/libnet80211.a b/tools/sdk/lib/libnet80211.a index 2defb4ff..22451429 100644 Binary files a/tools/sdk/lib/libnet80211.a and b/tools/sdk/lib/libnet80211.a differ diff --git a/tools/sdk/lib/libnewlib.a b/tools/sdk/lib/libnewlib.a index b8524e62..2e0cad7f 100644 Binary files a/tools/sdk/lib/libnewlib.a and b/tools/sdk/lib/libnewlib.a differ diff --git a/tools/sdk/lib/libnghttp.a b/tools/sdk/lib/libnghttp.a index e78b55b2..83d630ff 100644 Binary files a/tools/sdk/lib/libnghttp.a and b/tools/sdk/lib/libnghttp.a differ diff --git a/tools/sdk/lib/libnvs_flash.a b/tools/sdk/lib/libnvs_flash.a index 76e778f2..8b26ebf2 100644 Binary files a/tools/sdk/lib/libnvs_flash.a and b/tools/sdk/lib/libnvs_flash.a differ diff --git a/tools/sdk/lib/libopenssl.a b/tools/sdk/lib/libopenssl.a index f4586c77..f7917173 100644 Binary files a/tools/sdk/lib/libopenssl.a and b/tools/sdk/lib/libopenssl.a differ diff --git a/tools/sdk/lib/libphy.a b/tools/sdk/lib/libphy.a old mode 100644 new mode 100755 index 64601102..fbc06687 Binary files a/tools/sdk/lib/libphy.a and b/tools/sdk/lib/libphy.a differ diff --git a/tools/sdk/lib/libpp.a b/tools/sdk/lib/libpp.a index 4d7b74f9..c03937e4 100644 Binary files a/tools/sdk/lib/libpp.a and b/tools/sdk/lib/libpp.a differ diff --git a/tools/sdk/lib/libpthread.a b/tools/sdk/lib/libpthread.a new file mode 100644 index 00000000..711aae10 Binary files /dev/null and b/tools/sdk/lib/libpthread.a differ diff --git a/tools/sdk/lib/librtc.a b/tools/sdk/lib/librtc.a index 30963f55..79f1f99d 100755 Binary files a/tools/sdk/lib/librtc.a and b/tools/sdk/lib/librtc.a differ diff --git a/tools/sdk/lib/libsdmmc.a b/tools/sdk/lib/libsdmmc.a index b5690863..dfb4874e 100644 Binary files a/tools/sdk/lib/libsdmmc.a and b/tools/sdk/lib/libsdmmc.a differ diff --git a/tools/sdk/lib/libsmartconfig.a b/tools/sdk/lib/libsmartconfig.a index 2bbd0b4e..bf674e3e 100644 Binary files a/tools/sdk/lib/libsmartconfig.a and b/tools/sdk/lib/libsmartconfig.a differ diff --git a/tools/sdk/lib/libsoc.a b/tools/sdk/lib/libsoc.a index 95b690e6..0eae0785 100644 Binary files a/tools/sdk/lib/libsoc.a and b/tools/sdk/lib/libsoc.a differ diff --git a/tools/sdk/lib/libspi_flash.a b/tools/sdk/lib/libspi_flash.a index 905526bc..a855393d 100644 Binary files a/tools/sdk/lib/libspi_flash.a and b/tools/sdk/lib/libspi_flash.a differ diff --git a/tools/sdk/lib/libspiffs.a b/tools/sdk/lib/libspiffs.a new file mode 100644 index 00000000..c818e649 Binary files /dev/null and b/tools/sdk/lib/libspiffs.a differ diff --git a/tools/sdk/lib/libtcpip_adapter.a b/tools/sdk/lib/libtcpip_adapter.a index 3cd1a0b5..8c6ceeef 100644 Binary files a/tools/sdk/lib/libtcpip_adapter.a and b/tools/sdk/lib/libtcpip_adapter.a differ diff --git a/tools/sdk/lib/libulp.a b/tools/sdk/lib/libulp.a index c9e2fd82..88336583 100644 Binary files a/tools/sdk/lib/libulp.a and b/tools/sdk/lib/libulp.a differ diff --git a/tools/sdk/lib/libvfs.a b/tools/sdk/lib/libvfs.a index d2cfbaf7..48795a2f 100644 Binary files a/tools/sdk/lib/libvfs.a and b/tools/sdk/lib/libvfs.a differ diff --git a/tools/sdk/lib/libwear_levelling.a b/tools/sdk/lib/libwear_levelling.a index 5c0d5abe..25caf566 100644 Binary files a/tools/sdk/lib/libwear_levelling.a and b/tools/sdk/lib/libwear_levelling.a differ diff --git a/tools/sdk/lib/libwpa.a b/tools/sdk/lib/libwpa.a index c8ce77ed..34572eec 100644 Binary files a/tools/sdk/lib/libwpa.a and b/tools/sdk/lib/libwpa.a differ diff --git a/tools/sdk/lib/libwpa2.a b/tools/sdk/lib/libwpa2.a index 47683d94..75d10620 100644 Binary files a/tools/sdk/lib/libwpa2.a and b/tools/sdk/lib/libwpa2.a differ diff --git a/tools/sdk/lib/libwpa_supplicant.a b/tools/sdk/lib/libwpa_supplicant.a index 94c6a6ed..2e81515a 100644 Binary files a/tools/sdk/lib/libwpa_supplicant.a and b/tools/sdk/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/lib/libwps.a b/tools/sdk/lib/libwps.a index 8ea01aa3..a8325838 100644 Binary files a/tools/sdk/lib/libwps.a and b/tools/sdk/lib/libwps.a differ diff --git a/tools/sdk/lib/libxtensa-debug-module.a b/tools/sdk/lib/libxtensa-debug-module.a index b0c6a9af..e61a5ebd 100644 Binary files a/tools/sdk/lib/libxtensa-debug-module.a and b/tools/sdk/lib/libxtensa-debug-module.a differ diff --git a/tools/sdk/sdkconfig b/tools/sdk/sdkconfig index 0bc14abc..6f4b111a 100644 --- a/tools/sdk/sdkconfig +++ b/tools/sdk/sdkconfig @@ -8,6 +8,7 @@ # CONFIG_TOOLPREFIX="xtensa-esp32-elf-" CONFIG_PYTHON="python" +CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y # # Bootloader config @@ -19,6 +20,7 @@ CONFIG_LOG_BOOTLOADER_LEVEL_NONE=y # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set CONFIG_LOG_BOOTLOADER_LEVEL=0 +CONFIG_BOOTLOADER_SPI_WP_PIN=7 # # Security features @@ -38,9 +40,9 @@ CONFIG_ESPTOOLPY_BAUD_921600B=y CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 CONFIG_ESPTOOLPY_BAUD=921600 CONFIG_ESPTOOLPY_COMPRESSED=y -# CONFIG_FLASHMODE_QIO is not set +CONFIG_FLASHMODE_QIO=y # CONFIG_FLASHMODE_QOUT is not set -CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DIO is not set # CONFIG_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASHMODE="dio" # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set @@ -149,6 +151,7 @@ CONFIG_BT_RESERVE_DRAM=0x10000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 CONFIG_MEMMAP_SMP=y +# CONFIG_SPIRAM_SUPPORT is not set # CONFIG_MEMMAP_TRACEMEM is not set # CONFIG_MEMMAP_TRACEMEM_TWOBANKS is not set # CONFIG_ESP32_TRAX is not set @@ -164,7 +167,13 @@ CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048 CONFIG_MAIN_TASK_STACK_SIZE=4096 CONFIG_IPC_TASK_STACK_SIZE=1024 -CONFIG_NEWLIB_STDOUT_ADDCR=y +CONFIG_TIMER_TASK_STACK_SIZE=4096 +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y # CONFIG_NEWLIB_NANO_FORMAT is not set CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set @@ -208,7 +217,11 @@ CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 # CONFIG_ESP32_XTAL_FREQ_26 is not set CONFIG_ESP32_XTAL_FREQ_AUTO=y CONFIG_ESP32_XTAL_FREQ=0 -CONFIG_WIFI_ENABLED=y +# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set + +# +# Wi-Fi +# CONFIG_SW_COEXIST_ENABLE=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=0 @@ -220,7 +233,6 @@ CONFIG_ESP32_WIFI_AMPDU_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_NVS_ENABLED=y -CONFIG_PHY_ENABLED=y # # PHY @@ -229,7 +241,10 @@ CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP32_PHY_MAX_TX_POWER=20 -CONFIG_ETHERNET=y + +# +# Ethernet +# CONFIG_DMA_RX_BUF_NUM=10 CONFIG_DMA_TX_BUF_NUM=10 CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE=y @@ -278,6 +293,7 @@ CONFIG_FREERTOS_HZ=1000 # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y # CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set @@ -293,6 +309,14 @@ CONFIG_TIMER_TASK_STACK_DEPTH=2048 CONFIG_TIMER_QUEUE_LENGTH=10 # CONFIG_FREERTOS_DEBUG_INTERNALS is not set +# +# Heap memory debugging +# +# CONFIG_HEAP_POISONING_DISABLED is not set +CONFIG_HEAP_POISONING_LIGHT=y +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +# CONFIG_HEAP_TRACING is not set + # # Log output # @@ -323,6 +347,7 @@ CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 CONFIG_TCP_MAXRTX=12 CONFIG_TCP_SYNMAXRTX=6 CONFIG_TCP_MSS=1436 +CONFIG_TCP_MSL=60000 CONFIG_TCP_SND_BUF_DEFAULT=5744 CONFIG_TCP_WND_DEFAULT=5744 CONFIG_TCP_RECVMBOX_SIZE=6 @@ -350,9 +375,77 @@ CONFIG_TCPIP_TASK_STACK_SIZE=2560 # CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 # CONFIG_MBEDTLS_DEBUG is not set -# CONFIG_MBEDTLS_UNSAFE_ACCELERATION is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +# CONFIG_MBEDTLS_HARDWARE_MPI is not set +# CONFIG_MBEDTLS_HARDWARE_SHA is not set CONFIG_MBEDTLS_HAVE_TIME=y # CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y # # OpenSSL @@ -361,12 +454,51 @@ CONFIG_MBEDTLS_HAVE_TIME=y CONFIG_OPENSSL_ASSERT_DO_NOTHING=y # CONFIG_OPENSSL_ASSERT_EXIT is not set +# +# PThreads +# +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 + # # SPI Flash driver # # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set + +# +# tcpip adapter +# +CONFIG_IP_LOST_TIMER_INTERVAL=120 + # # Wear Levelling #