Merge pull request #4997 from esphome/bump-2023.6.2

2023.6.2
This commit is contained in:
Jesse Hills 2023-06-23 22:47:41 +12:00 committed by GitHub
commit b806eb6a61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 36 deletions

View file

@ -16,8 +16,7 @@ from esphome.const import (
KEY_TARGET_PLATFORM,
)
from esphome.core import CORE, coroutine_with_priority, EsphomeError
from esphome.helpers import mkdir_p, write_file
import esphome.platformio_api as api
from esphome.helpers import mkdir_p, write_file, copy_file_if_changed
from .const import KEY_BOARD, KEY_PIO_FILES, KEY_RP2040, rp2040_ns
@ -193,25 +192,20 @@ def generate_pio_files() -> bool:
pio_path = CORE.relative_build_path(f"src/pio/{key}.pio")
mkdir_p(os.path.dirname(pio_path))
write_file(pio_path, data)
_LOGGER.info("Assembling PIO assembly code")
retval = api.run_platformio_cli(
"pkg",
"exec",
"--package",
"earlephilhower/tool-pioasm-rp2040-earlephilhower",
"--",
"pioasm",
pio_path,
pio_path + ".h",
)
includes.append(f"pio/{key}.pio.h")
if retval != 0:
raise EsphomeError("PIO assembly failed")
write_file(
CORE.relative_build_path("src/pio_includes.h"),
"#pragma once\n" + "\n".join([f'#include "{include}"' for include in includes]),
)
dir = os.path.dirname(__file__)
build_pio_file = os.path.join(dir, "build_pio.py.script")
copy_file_if_changed(
build_pio_file,
CORE.relative_build_path("build_pio.py"),
)
return True

View file

@ -0,0 +1,47 @@
"""
Custom pioasm compiler script for platformio.
(c) 2022 by P.Z.
Sourced 2023/06/23 from https://gist.github.com/hexeguitar/f4533bc697c956ac1245b6843e2ef438
Modified by jesserockz 2023/06/23
"""
from os.path import join
import glob
import sys
import subprocess
# pylint: disable=E0602
Import("env") # noqa
from SCons.Script import ARGUMENTS
platform = env.PioPlatform()
PROJ_SRC = env["PROJECT_SRC_DIR"]
PIO_FILES = glob.glob(join(PROJ_SRC, "**", "*.pio"), recursive=True)
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
if PIO_FILES:
if verbose:
print("==============================================")
print("PIO ASSEMBLY COMPILER")
try:
PIOASM_DIR = platform.get_package_dir("tool-pioasm-rp2040-earlephilhower")
except:
print("tool-pioasm-rp2040-earlephilhower not supported on your system!")
sys.exit()
PIOASM_EXE = join(PIOASM_DIR, "pioasm")
if verbose:
print("PIO files found:")
for filename in PIO_FILES:
if verbose:
print(f" {filename}")
subprocess.run([PIOASM_EXE, "-o", "c-sdk", filename, f"{filename}.h"])
if verbose:
print("==============================================")

View file

@ -0,0 +1,40 @@
import platform
import esphome.codegen as cg
DEPENDENCIES = ["rp2040"]
PIOASM_REPO_VERSION = "1.5.0-b"
PIOASM_REPO_BASE = f"https://github.com/earlephilhower/pico-quick-toolchain/releases/download/{PIOASM_REPO_VERSION}"
PIOASM_VERSION = "pioasm-2e6142b.230216"
PIOASM_DOWNLOADS = {
"linux": {
"aarch64": f"aarch64-linux-gnu.{PIOASM_VERSION}.tar.gz",
"armv7l": f"arm-linux-gnueabihf.{PIOASM_VERSION}.tar.gz",
"x86_64": f"x86_64-linux-gnu.{PIOASM_VERSION}.tar.gz",
},
"windows": {
"amd64": f"x86_64-w64-mingw32.{PIOASM_VERSION}.zip",
},
"darwin": {
"x86_64": f"x86_64-apple-darwin14.{PIOASM_VERSION}.tar.gz",
"arm64": f"x86_64-apple-darwin14.{PIOASM_VERSION}.tar.gz",
},
}
async def to_code(config):
# cg.add_platformio_option(
# "platform_packages",
# [
# "earlephilhower/tool-pioasm-rp2040-earlephilhower",
# ],
# )
file = PIOASM_DOWNLOADS[platform.system().lower()][platform.machine().lower()]
cg.add_platformio_option(
"platform_packages",
[f"earlephilhower/tool-pioasm-rp2040-earlephilhower@{PIOASM_REPO_BASE}/{file}"],
)
cg.add_platformio_option("extra_scripts", ["pre:build_pio.py"])

View file

@ -127,6 +127,7 @@ def time_to_cycles(time_us):
CONF_PIO = "pio"
AUTO_LOAD = ["rp2040_pio"]
CODEOWNERS = ["@Papa-DMan"]
DEPENDENCIES = ["rp2040"]
@ -265,9 +266,3 @@ async def to_code(config):
time_to_cycles(config[CONF_BIT1_LOW]),
),
)
cg.add_platformio_option(
"platform_packages",
[
"earlephilhower/tool-pioasm-rp2040-earlephilhower",
],
)

View file

@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2023.6.1"
__version__ = "2023.6.2"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = (

View file

@ -2,6 +2,16 @@
namespace esphome {
static bool is_leap_year(uint32_t year) { return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); }
static uint8_t days_in_month(uint8_t month, uint16_t year) {
static const uint8_t DAYS_IN_MONTH[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t days = DAYS_IN_MONTH[month];
if (month == 2 && is_leap_year(year))
return 29;
return days;
}
size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) {
struct tm c_tm = this->to_c_tm();
return ::strftime(buffer, buffer_len, format, &c_tm);
@ -158,14 +168,4 @@ template<typename T> bool increment_time_value(T &current, uint16_t begin, uint1
return false;
}
static bool is_leap_year(uint32_t year) { return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); }
static uint8_t days_in_month(uint8_t month, uint16_t year) {
static const uint8_t DAYS_IN_MONTH[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t days = DAYS_IN_MONTH[month];
if (month == 2 && is_leap_year(year))
return 29;
return days;
}
} // namespace esphome

View file

@ -8,10 +8,6 @@ namespace esphome {
template<typename T> bool increment_time_value(T &current, uint16_t begin, uint16_t end);
static bool is_leap_year(uint32_t year);
static uint8_t days_in_month(uint8_t month, uint16_t year);
/// A more user-friendly version of struct tm from time.h
struct ESPTime {
/** seconds after the minute [0-60]