From 640b3aacdad9893e491b88d5739a9273146e6dd1 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Wed, 9 Aug 2023 21:47:34 +0200 Subject: [PATCH] Support patch-based synthesis. (#4) This should be easier to follow and keep up to date. --- tools/main.toit | 27 +++++ .../esp32-eth-clk-out17/sdkconfig.defaults | 100 ------------------ .../sdkconfig.defaults.patch | 5 + .../esp32s3-spiram-octo/sdkconfig.defaults | 81 -------------- .../sdkconfig.defaults.patch | 4 + 5 files changed, 36 insertions(+), 181 deletions(-) delete mode 100644 variants/esp32-eth-clk-out17/sdkconfig.defaults create mode 100644 variants/esp32-eth-clk-out17/sdkconfig.defaults.patch delete mode 100644 variants/esp32s3-spiram-octo/sdkconfig.defaults create mode 100644 variants/esp32s3-spiram-octo/sdkconfig.defaults.patch diff --git a/tools/main.toit b/tools/main.toit index f5e3b9c..a3ed26b 100644 --- a/tools/main.toit +++ b/tools/main.toit @@ -5,6 +5,7 @@ import cli import host.file import host.directory +import host.pipe import writer show Writer import .gist as gist import .git @@ -162,15 +163,37 @@ variant_synthesize --chip=chip --ui=ui +apply_directory_patch_ --patch_path/string --directory/string --strip/int=1: + patch := file.read_content patch_path + args := ["patch", "-d", directory] + if strip > 0: + args.add "-p$strip" + stream := pipe.to args + writer := Writer stream + writer.write patch + writer.close + +apply_file_patch_ --patch_path/string --file_path/string: + patch := file.read_content patch_path + args := ["patch", file_path] + stream := pipe.to args + writer := Writer stream + writer.write patch + writer.close + ensure_main_ dir/string --toit_root/string --chip/string: if file.is_directory "$dir/main": return main_path := toit_main_path_for_ --chip=chip copy_directory --from="$toit_root/$main_path" --to="$dir/main" + if file.is_file "$dir/main.patch": + apply_directory_patch_ --patch_path="$dir/main.patch" --directory=dir ensure_partitions_ dir/string --toit_root/string --chip/string: if file.is_file "$dir/partitions.csv": return partition_path := toit_partition_path_for_ --chip=chip copy_file --from="$toit_root/$partition_path" --to="$dir/partitions.csv" + if file.is_file "$dir/partitions.csv.patch": + apply_file_patch_ --patch_path="$dir/partitions.csv.patch" --file_path="$dir/partitions.csv" ensure_sdkconfig_ dir/string --toit_root/string --chip/string: if file.is_file "$dir/sdkconfig" or file.is_file "$dir/sdkconfig.defaults": return @@ -180,8 +203,12 @@ ensure_sdkconfig_ dir/string --toit_root/string --chip/string: if file.is_file "$toit_root/$sdk_config_path": copy_file --from="$toit_root/$sdk_config_path" --to="$dir/sdkconfig" + if file.is_file "$dir/sdkconfig.patch": + apply_file_patch_ --patch_path="$dir/sdkconfig.patch" --file_path="$dir/sdkconfig" if file.is_file "$toit_root/$sdk_config_defaults_path": copy_file --from="$toit_root/$sdk_config_defaults_path" --to="$dir/sdkconfig.defaults" + if file.is_file "$dir/sdkconfig.defaults.patch": + apply_file_patch_ --patch_path="$dir/sdkconfig.defaults.patch" --file_path="$dir/sdkconfig.defaults" create_cmakelists_ dir/string --toit_root/string --sdk_path/string --chip/string --ui/cli.Ui: if file.is_file "$dir/CMakeLists.txt": diff --git a/variants/esp32-eth-clk-out17/sdkconfig.defaults b/variants/esp32-eth-clk-out17/sdkconfig.defaults deleted file mode 100644 index 66abe4f..0000000 --- a/variants/esp32-eth-clk-out17/sdkconfig.defaults +++ /dev/null @@ -1,100 +0,0 @@ -# CONFIG_APP_COMPILE_TIME_DATE is not set -CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y -CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y -CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y -CONFIG_BT_ENABLED=y -CONFIG_BTDM_CTRL_BLE_MAX_CONN=2 -CONFIG_BTDM_CTRL_PINNED_TO_CORE_1=y -# CONFIG_BTDM_CTRL_MODEM_SLEEP is not set -# CONFIG_BTDM_BLE_SCAN_DUPL is not set -CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=50 -CONFIG_BT_NIMBLE_ENABLED=y -CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y -CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y -CONFIG_BT_NIMBLE_MAX_CONNECTIONS=2 -CONFIG_BT_NIMBLE_MAX_BONDS=4 -CONFIG_BT_NIMBLE_MAX_CCCDS=3 -CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y -CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y -CONFIG_BT_NIMBLE_NVS_PERSIST=y -CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="toit" -CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0x0 -CONFIG_BT_NIMBLE_ACL_BUF_COUNT=10 -# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set -CONFIG_UART_ISR_IN_IRAM=y -CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32_SPIRAM_SUPPORT=y -CONFIG_SPIRAM_IGNORE_NOTFOUND=y -CONFIG_SPIRAM_USE_CAPS_ALLOC=y -# CONFIG_SPIRAM_CACHE_LIBNUMPARSER_IN_IRAM is not set -# CONFIG_SPIRAM_CACHE_LIBCHAR_IN_IRAM is not set -# CONFIG_SPIRAM_CACHE_LIBFILE_IN_IRAM is not set -# CONFIG_SPIRAM_CACHE_LIBSTR_IN_IRAM is not set -# CONFIG_ESP32_DEBUG_OCDAWARE is not set -# CONFIG_ESP32_BROWNOUT_DET is not set -CONFIG_ESP32_XTAL_FREQ_AUTO=y -# CONFIG_ADC_CAL_EFUSE_TP_ENABLE is not set -# CONFIG_ADC_CAL_LUT_ENABLE is not set -# CONFIG_ETH_RMII_CLK_INPUT is not set -CONFIG_ETH_RMII_CLK_OUTPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0 is not set -CONFIG_ETH_RMII_CLK_OUT_GPIO=17 -CONFIG_ETH_SPI_ETHERNET_DM9051=y -CONFIG_ETH_SPI_ETHERNET_W5500=y -CONFIG_ETH_USE_OPENETH=y -# CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set -# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set -CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set -# CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE is not set -# CONFIG_ESP_INT_WDT is not set -# CONFIG_ESP_TASK_WDT is not set -CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16 -# CONFIG_ESP32_WIFI_NVS_ENABLED is not set -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y -# CONFIG_ESP32_WIFI_IRAM_OPT is not set -# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set -CONFIG_FMB_TIMER_PORT_ENABLED=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=3 -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024 -CONFIG_FREERTOS_ISR_STACKSIZE=2096 -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y -# CONFIG_LOG_COLORS is not set -CONFIG_LWIP_LOCAL_HOSTNAME="toit" -# CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES is not set -CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y -CONFIG_LWIP_TCP_SYNMAXRTX=6 -CONFIG_LWIP_TCP_MSS=1410 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5640 -CONFIG_LWIP_TCP_WND_DEFAULT=5640 -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2560 -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=7800 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=3700 -# CONFIG_MBEDTLS_HARDWARE_MPI is not set -CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y -CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK=y -# CONFIG_MBEDTLS_SSL_PROTO_TLS1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 is not set -CONFIG_MBEDTLS_SSL_PROTO_DTLS=n -CONFIG_MBEDTLS_POLY1305_C=y -CONFIG_MBEDTLS_CHACHA20_C=y -CONFIG_MBEDTLS_CHACHAPOLY_C=y -# CONFIG_MQTT_PROTOCOL_311 is not set -# CONFIG_MQTT_TRANSPORT_SSL is not set -# CONFIG_MQTT_TRANSPORT_WEBSOCKET is not set -CONFIG_OPENSSL_ASSERT_DO_NOTHING=y -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 -CONFIG_SPI_FLASH_VERIFY_WRITE=y -CONFIG_SPI_FLASH_LOG_FAILED_WRITE=y -CONFIG_SPI_FLASH_WARN_SETTING_ZERO_TO_ONE=y -# CONFIG_WIFI_PROV_BLE_BONDING is not set -CONFIG_FATFS_LFN_HEAP=y -# CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is not set -# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set diff --git a/variants/esp32-eth-clk-out17/sdkconfig.defaults.patch b/variants/esp32-eth-clk-out17/sdkconfig.defaults.patch new file mode 100644 index 0000000..d7af863 --- /dev/null +++ b/variants/esp32-eth-clk-out17/sdkconfig.defaults.patch @@ -0,0 +1,5 @@ +41a42,45 +> # CONFIG_ETH_RMII_CLK_INPUT is not set +> CONFIG_ETH_RMII_CLK_OUTPUT=y +> # CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0 is not set +> CONFIG_ETH_RMII_CLK_OUT_GPIO=17 diff --git a/variants/esp32s3-spiram-octo/sdkconfig.defaults b/variants/esp32s3-spiram-octo/sdkconfig.defaults deleted file mode 100644 index ed673e0..0000000 --- a/variants/esp32s3-spiram-octo/sdkconfig.defaults +++ /dev/null @@ -1,81 +0,0 @@ -# CONFIG_APP_COMPILE_TIME_DATE is not set -CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y -CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y -CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y -CONFIG_BT_ENABLED=y -CONFIG_BT_NIMBLE_ENABLED=y -CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT=y -CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y -CONFIG_BT_NIMBLE_MAX_CONNECTIONS=2 -CONFIG_BT_NIMBLE_MAX_BONDS=4 -CONFIG_BT_NIMBLE_MAX_CCCDS=3 -CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y -CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y -CONFIG_BT_NIMBLE_NVS_PERSIST=y -CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="toit" -CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0x0 -CONFIG_BT_NIMBLE_ACL_BUF_COUNT=10 -# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set -CONFIG_UART_ISR_IN_IRAM=y -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S3_SPIRAM_SUPPORT=y -CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_IGNORE_NOTFOUND=y -CONFIG_SPIRAM_USE_CAPS_ALLOC=y -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y -# CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set -CONFIG_ETH_SPI_ETHERNET_DM9051=y -CONFIG_ETH_SPI_ETHERNET_W5500=y -# CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set -# CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE is not set -# CONFIG_ESP_INT_WDT is not set -# CONFIG_ESP_TASK_WDT is not set -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 -CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16 -CONFIG_ESP32_WIFI_RX_BA_WIN=6 -# CONFIG_ESP32_WIFI_NVS_ENABLED is not set -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y -# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set -CONFIG_FMB_TIMER_PORT_ENABLED=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=3 -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024 -CONFIG_FREERTOS_ISR_STACKSIZE=2096 -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y -CONFIG_LOG_DEFAULT_LEVEL_ERROR=y -# CONFIG_LOG_COLORS is not set -CONFIG_LWIP_LOCAL_HOSTNAME="toit" -# CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES is not set -CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y -CONFIG_LWIP_TCP_SYNMAXRTX=6 -CONFIG_LWIP_TCP_MSS=1410 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5640 -CONFIG_LWIP_TCP_WND_DEFAULT=5640 -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2560 -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=7800 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=3700 -# CONFIG_MBEDTLS_HARDWARE_MPI is not set -CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y -CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK=y -# CONFIG_MBEDTLS_SSL_PROTO_TLS1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 is not set -CONFIG_MBEDTLS_SSL_PROTO_DTLS=n -CONFIG_MBEDTLS_POLY1305_C=y -CONFIG_MBEDTLS_CHACHA20_C=y -CONFIG_MBEDTLS_CHACHAPOLY_C=y -# CONFIG_MQTT_PROTOCOL_311 is not set -# CONFIG_MQTT_TRANSPORT_SSL is not set -# CONFIG_MQTT_TRANSPORT_WEBSOCKET is not set -CONFIG_OPENSSL_ASSERT_DO_NOTHING=y -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 -CONFIG_SPI_FLASH_VERIFY_WRITE=y -CONFIG_SPI_FLASH_LOG_FAILED_WRITE=y -CONFIG_SPI_FLASH_WARN_SETTING_ZERO_TO_ONE=y -# CONFIG_WIFI_PROV_BLE_BONDING is not set -CONFIG_FATFS_LFN_HEAP=y diff --git a/variants/esp32s3-spiram-octo/sdkconfig.defaults.patch b/variants/esp32s3-spiram-octo/sdkconfig.defaults.patch new file mode 100644 index 0000000..e27280f --- /dev/null +++ b/variants/esp32s3-spiram-octo/sdkconfig.defaults.patch @@ -0,0 +1,4 @@ +26c26 +< CONFIG_SPIRAM_MODE_QUAD=y +--- +> CONFIG_SPIRAM_MODE_OCT=y