mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
commit
c053a33fe8
10 changed files with 90 additions and 34 deletions
|
@ -96,16 +96,16 @@ def get_board(core_obj=None):
|
||||||
def get_download_types(storage_json):
|
def get_download_types(storage_json):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"title": "Modern format",
|
"title": "Factory format (Previously Modern)",
|
||||||
"description": "For use with ESPHome Web and other tools.",
|
"description": "For use with ESPHome Web and other tools.",
|
||||||
"file": "firmware-factory.bin",
|
"file": "firmware.factory.bin",
|
||||||
"download": f"{storage_json.name}-factory.bin",
|
"download": f"{storage_json.name}.factory.bin",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Legacy format",
|
"title": "OTA format (Previously Legacy)",
|
||||||
"description": "For use with ESPHome Flasher.",
|
"description": "For OTA updating a device.",
|
||||||
"file": "firmware.bin",
|
"file": "firmware.ota.bin",
|
||||||
"download": f"{storage_json.name}.bin",
|
"download": f"{storage_json.name}.ota.bin",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -17,17 +17,19 @@ from SCons.Script import ARGUMENTS
|
||||||
|
|
||||||
# Copy over the default sdkconfig.
|
# Copy over the default sdkconfig.
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
if path.exists("./sdkconfig.defaults"):
|
if path.exists("./sdkconfig.defaults"):
|
||||||
os.makedirs(".temp", exist_ok=True)
|
os.makedirs(".temp", exist_ok=True)
|
||||||
shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
|
shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
|
||||||
|
|
||||||
|
|
||||||
def esp32_create_combined_bin(source, target, env):
|
def esp32_create_combined_bin(source, target, env):
|
||||||
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
|
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Generating combined binary for serial flashing")
|
print("Generating combined binary for serial flashing")
|
||||||
app_offset = 0x10000
|
app_offset = 0x10000
|
||||||
|
|
||||||
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
|
||||||
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
|
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
|
||||||
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
chip = env.get("BOARD_MCU")
|
chip = env.get("BOARD_MCU")
|
||||||
|
@ -62,5 +64,14 @@ def esp32_create_combined_bin(source, target, env):
|
||||||
else:
|
else:
|
||||||
subprocess.run(["esptool.py", *cmd])
|
subprocess.run(["esptool.py", *cmd])
|
||||||
|
|
||||||
|
|
||||||
|
def esp32_copy_ota_bin(source, target, env):
|
||||||
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
|
||||||
|
|
||||||
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=E0602
|
# pylint: disable=E0602
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin) # noqa
|
||||||
|
|
|
@ -6,10 +6,18 @@ Import("env") # noqa
|
||||||
|
|
||||||
def esp8266_copy_factory_bin(source, target, env):
|
def esp8266_copy_factory_bin(source, target, env):
|
||||||
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin")
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
|
||||||
|
|
||||||
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
|
|
||||||
|
|
||||||
|
def esp8266_copy_ota_bin(source, target, env):
|
||||||
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
|
||||||
|
|
||||||
shutil.copyfile(firmware_name, new_file_name)
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=E0602
|
# pylint: disable=E0602
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_ota_bin) # noqa
|
||||||
|
|
|
@ -60,7 +60,7 @@ void HOT IRAM_ATTR GPIOOneWireBus::write_bit_(bool bit) {
|
||||||
// recovery time: t_rec: min=1µs
|
// recovery time: t_rec: min=1µs
|
||||||
// ds18b20 appears to read the bus after roughly 14µs
|
// ds18b20 appears to read the bus after roughly 14µs
|
||||||
uint32_t delay0 = bit ? 6 : 60;
|
uint32_t delay0 = bit ? 6 : 60;
|
||||||
uint32_t delay1 = bit ? 54 : 5;
|
uint32_t delay1 = bit ? 59 : 5;
|
||||||
|
|
||||||
// delay A/C
|
// delay A/C
|
||||||
delayMicroseconds(delay0);
|
delayMicroseconds(delay0);
|
||||||
|
|
|
@ -47,10 +47,16 @@ def set_core_data(config):
|
||||||
def get_download_types(storage_json):
|
def get_download_types(storage_json):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"title": "UF2 format",
|
"title": "UF2 factory format",
|
||||||
"description": "For copying to RP2040 over USB.",
|
"description": "For copying to RP2040 over USB.",
|
||||||
"file": "firmware.uf2",
|
"file": "firmware.uf2",
|
||||||
"download": f"{storage_json.name}.uf2",
|
"download": f"{storage_json.name}.factory.uf2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "OTA format",
|
||||||
|
"description": "For OTA updating a device.",
|
||||||
|
"file": "firmware.ota.bin",
|
||||||
|
"download": f"{storage_json.name}.ota.bin",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -160,6 +166,8 @@ async def to_code(config):
|
||||||
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
|
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
|
||||||
cg.add_define("ESPHOME_VARIANT", "RP2040")
|
cg.add_define("ESPHOME_VARIANT", "RP2040")
|
||||||
|
|
||||||
|
cg.add_platformio_option("extra_scripts", ["post:post_build.py"])
|
||||||
|
|
||||||
conf = config[CONF_FRAMEWORK]
|
conf = config[CONF_FRAMEWORK]
|
||||||
cg.add_platformio_option("framework", "arduino")
|
cg.add_platformio_option("framework", "arduino")
|
||||||
cg.add_build_flag("-DUSE_ARDUINO")
|
cg.add_build_flag("-DUSE_ARDUINO")
|
||||||
|
@ -225,4 +233,10 @@ def generate_pio_files() -> bool:
|
||||||
|
|
||||||
# Called by writer.py
|
# Called by writer.py
|
||||||
def copy_files() -> bool:
|
def copy_files() -> bool:
|
||||||
|
dir = os.path.dirname(__file__)
|
||||||
|
post_build_file = os.path.join(dir, "post_build.py.script")
|
||||||
|
copy_file_if_changed(
|
||||||
|
post_build_file,
|
||||||
|
CORE.relative_build_path("post_build.py"),
|
||||||
|
)
|
||||||
return generate_pio_files()
|
return generate_pio_files()
|
||||||
|
|
23
esphome/components/rp2040/post_build.py.script
Normal file
23
esphome/components/rp2040/post_build.py.script
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
# pylint: disable=E0602
|
||||||
|
Import("env") # noqa
|
||||||
|
|
||||||
|
|
||||||
|
def rp2040_copy_factory_uf2(source, target, env):
|
||||||
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.uf2")
|
||||||
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.uf2")
|
||||||
|
|
||||||
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
|
|
||||||
|
|
||||||
|
def rp2040_copy_ota_bin(source, target, env):
|
||||||
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
|
||||||
|
|
||||||
|
shutil.copyfile(firmware_name, new_file_name)
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=E0602
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_factory_uf2) # noqa
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_ota_bin) # noqa
|
|
@ -694,15 +694,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
info.netmask = network::IPAddress(255, 255, 255, 0);
|
info.netmask = network::IPAddress(255, 255, 255, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_dhcpc_stop(s_ap_netif);
|
err = esp_netif_dhcps_stop(s_ap_netif);
|
||||||
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
|
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_set_ip_info(s_ap_netif, &info);
|
err = esp_netif_set_ip_info(s_ap_netif, &info);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,20 +712,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
start_address += 99;
|
start_address += 99;
|
||||||
lease.start_ip = start_address;
|
lease.start_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
||||||
start_address += 100;
|
start_address += 10;
|
||||||
lease.end_ip = start_address;
|
lease.end_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
||||||
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
|
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_dhcps_start(s_ap_netif);
|
err = esp_netif_dhcps_start(s_ap_netif);
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -716,12 +716,12 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
|
|
||||||
if (wifi_softap_dhcps_status() == DHCP_STARTED) {
|
if (wifi_softap_dhcps_status() == DHCP_STARTED) {
|
||||||
if (!wifi_softap_dhcps_stop()) {
|
if (!wifi_softap_dhcps_stop()) {
|
||||||
ESP_LOGV(TAG, "Stopping DHCP server failed!");
|
ESP_LOGW(TAG, "Stopping DHCP server failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
|
if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
|
||||||
ESP_LOGV(TAG, "Setting SoftAP info failed!");
|
ESP_LOGE(TAG, "Setting SoftAP info failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,17 +735,17 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
start_address += 99;
|
start_address += 99;
|
||||||
lease.start_ip = start_address;
|
lease.start_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
||||||
start_address += 100;
|
start_address += 10;
|
||||||
lease.end_ip = start_address;
|
lease.end_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
||||||
if (!wifi_softap_set_dhcps_lease(&lease)) {
|
if (!wifi_softap_set_dhcps_lease(&lease)) {
|
||||||
ESP_LOGV(TAG, "Setting SoftAP DHCP lease failed!");
|
ESP_LOGE(TAG, "Setting SoftAP DHCP lease failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lease time 1440 minutes (=24 hours)
|
// lease time 1440 minutes (=24 hours)
|
||||||
if (!wifi_softap_set_dhcps_lease_time(1440)) {
|
if (!wifi_softap_set_dhcps_lease_time(1440)) {
|
||||||
ESP_LOGV(TAG, "Setting SoftAP DHCP lease time failed!");
|
ESP_LOGE(TAG, "Setting SoftAP DHCP lease time failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,13 +755,13 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
uint8_t mode = 1;
|
uint8_t mode = 1;
|
||||||
// bit0, 1 enables router information from ESP8266 SoftAP DHCP server.
|
// bit0, 1 enables router information from ESP8266 SoftAP DHCP server.
|
||||||
if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
|
if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
|
||||||
ESP_LOGV(TAG, "wifi_softap_set_dhcps_offer_option failed!");
|
ESP_LOGE(TAG, "wifi_softap_set_dhcps_offer_option failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!wifi_softap_dhcps_start()) {
|
if (!wifi_softap_dhcps_start()) {
|
||||||
ESP_LOGV(TAG, "Starting SoftAP DHCPS failed!");
|
ESP_LOGE(TAG, "Starting SoftAP DHCPS failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -823,15 +823,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
info.netmask = network::IPAddress(255, 255, 255, 0);
|
info.netmask = network::IPAddress(255, 255, 255, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_dhcpc_stop(s_ap_netif);
|
err = esp_netif_dhcps_stop(s_ap_netif);
|
||||||
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
|
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_set_ip_info(s_ap_netif, &info);
|
err = esp_netif_set_ip_info(s_ap_netif, &info);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,20 +841,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
start_address += 99;
|
start_address += 99;
|
||||||
lease.start_ip = start_address;
|
lease.start_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
|
||||||
start_address += 100;
|
start_address += 10;
|
||||||
lease.end_ip = start_address;
|
lease.end_ip = start_address;
|
||||||
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
|
||||||
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
|
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_netif_dhcps_start(s_ap_netif);
|
err = esp_netif_dhcps_start(s_ap_netif);
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err);
|
ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,12 +887,12 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
|
||||||
|
|
||||||
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
|
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGV(TAG, "esp_wifi_set_config failed! %d", err);
|
ESP_LOGE(TAG, "esp_wifi_set_config failed! %d", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
|
if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
|
||||||
ESP_LOGV(TAG, "wifi_ap_ip_config_ failed!");
|
ESP_LOGE(TAG, "wifi_ap_ip_config_ failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2024.6.0b3"
|
__version__ = "2024.6.0b4"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|
Loading…
Reference in a new issue