Skip to content

Instantly share code, notes, and snippets.

View erikcorry's full-sized avatar
🐯
Toit like a toiger

Erik Corry erikcorry

🐯
Toit like a toiger
View GitHub Profile

Memory use, performance, and Toit pixel display.

(March 2024).

Some applications using pixel displays may run out of memory, especially if you are running on a small ESP32 with no external PSRAM. This is especially the case if you are using the small jaguar server on the device for fast edit-compile-run development cycles.

/// Simple pretty-printer for JSON-compatible objects (maps, lists, strings,
/// numbers, booleans, and null).
pretty-print data --indent/string="" --prefix/string?=null --suffix/string?="" -> none:
str := json.stringify data
if str.size < 80:
print "$(prefix or indent)$str$suffix"
return
if data is Map:
print "$(prefix or indent){"
i := 0
#
# Automatically generated file. DO NOT EDIT.
# Espressif IoT Development Framework (ESP-IDF) Project Configuration
#
CONFIG_SOC_BROWNOUT_RESET_SUPPORTED="Not determined"
CONFIG_SOC_TWAI_BRP_DIV_SUPPORTED="Not determined"
CONFIG_SOC_DPORT_WORKAROUND="Not determined"
CONFIG_SOC_CAPS_ECO_VER_MAX=301
CONFIG_SOC_ADC_SUPPORTED=y
CONFIG_SOC_DAC_SUPPORTED=y
@erikcorry
erikcorry / esp-idf-march-august.diff
Created August 16, 2023 14:30
IRAM sizes esp-idf march 2023 to august
--- rolled-sizes.txt 2023-08-16 16:23:09.982969715 +0200
+++ unrolled-sizes.txt 2023-08-16 16:22:34.159637286 +0200
@@ -1,33 +1,33 @@
Total sizes:
-Used static DRAM: 49824 bytes ( 74756 remain, 40.0% used)
- .data size: 22008 bytes
- .bss size: 27816 bytes
-Used static IRAM: 132298 bytes ( -1226 remain, 100.9% used) Overflow detected!
- .text size: 131271 bytes
+Used static DRAM: 50092 bytes ( 74488 remain, 40.2% used)
@erikcorry
erikcorry / Save session data.diff
Created July 21, 2023 13:31
Save session data between TLS connecitons.
Author: Kasper Lund <kasper@toit.io>
Date: Mon Jun 12 13:14:22 2023 +0200
Store TLS session data in RTC memory (#715)
diff --git a/src/service/brokers/http/connection.toit b/src/service/brokers/http/connection.toit
index 35ad787..e5b9888 100644
--- a/src/service/brokers/http/connection.toit
+++ b/src/service/brokers/http/connection.toit
@@ -6,9 +6,9 @@ import http
diff --git a/examples/bubble_sort.toit b/examples/bubble_sort.toit
index 0ceee960..d28172d0 100644
--- a/examples/bubble_sort.toit
+++ b/examples/bubble_sort.toit
@@ -11,8 +11,8 @@ main:
bubble_sort a:
size := a.size
- for i := 0; i < size; i++:
+ for i := ..size:
diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h
index 40177512c..efa1f78bb 100644
--- a/include/mbedtls/compat-1.3.h
+++ b/include/mbedtls/compat-1.3.h
@@ -2390,6 +2390,7 @@
#define ssl_set_sni mbedtls_ssl_conf_sni
#define ssl_set_transport mbedtls_ssl_conf_transport
#define ssl_set_truncated_hmac mbedtls_ssl_conf_truncated_hmac
+#define ssl_set_record_size_limit mbedtls_ssl_conf_record_size_limit
#define ssl_set_verify mbedtls_ssl_conf_verify
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 058e61b..c16551d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,7 +127,7 @@ if ("${TOIT_SYSTEM_NAME}" MATCHES "esp32")
set(MBEDTLS_C_FLAGS "-DMBEDTLS_CONFIG_FILE=\\\"mbedtls/esp_config.h\\\"")
else()
# These constants should stay in sync with the ones in the sdkconfig file of the ESP32 toolchain.
- set(MBEDTLS_C_FLAGS "-DMBEDTLS_SSL_IN_CONTENT_LEN=8100 -DMBEDTLS_SSL_OUT_CONTENT_LEN=3700 -DMBEDTLS_PLATFORM_MEMORY=1")
+ set(MBEDTLS_C_FLAGS "-DMBEDTLS_SSL_IN_CONTENT_LEN=8100 -DMBEDTLS_SSL_RECORD_SIZE_LIMIT=1 -DMBEDTLS_SSL_DEBUG_ALL=1 -DDEBUG_TLS=1 -DMBEDTLS_SSL_OUT_CONTENT_LEN=3700 -DMBEDTLS_PLATFORM_MEMORY=1")
// Copyright (C) 2021 Toitware ApS.
// Use of this source code is governed by a Zero-Clause BSD license that can
// be found in the EXAMPLES_LICENSE file.
import http
import net
import net.x509
import certificate_roots
main:
@erikcorry
erikcorry / extend_blit.toit
Created April 1, 2022 09:06
Sign-extend and duplicate 16 bit values in Toit using blit
import bitmap show blit
import expect show *
/**
Takes a byte array of little endian 16 bit values.
Returns a new byte array of little endian 32 bit values, sign extended.
For each input 16 bit value there are two (copied) 32 bit output values.
*/
expand input/ByteArray -> ByteArray:
output := ByteArray input.size * 4