Skip to content

Commit

Permalink
Bump esp-idf to 5.2, fix issues with const mg_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
alufers committed Mar 12, 2024
1 parent 51f2ab5 commit 58d4a71
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 51 deletions.
2 changes: 1 addition & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ in rec {
export IDF_TOOLS_PATH=${esp-idf}/.espressif
export IWYU_LLVM_ROOT_PATH=${llvmPackages.libclang.lib}
export PATH=$IDF_PATH/tools:$PATH
export IDF_PYTHON_ENV_PATH=$IDF_TOOLS_PATH/python_env/idf5.1_py3.10_env
export IDF_PYTHON_ENV_PATH=$IDF_TOOLS_PATH/python_env/idf5.2.1_py3.10_env
'';
};

Expand Down
18 changes: 15 additions & 3 deletions nix/esp-idf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ let
doCheck = false;
propagatedBuildInputs = with python310Packages; [ setuptools wheel ];
};
pyclang = python310Packages.buildPythonPackage rec {
pname = "pyclang";
version = "0.4.2";
src = python310Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-vuDZ5yEhyDpCmkXoC+Gr2X5vMK5B46HnktcvBONjxXM=";
};
doCheck = false;
};

toolchain = pkgs.callPackage ./toolchain.nix { };
idf-python-env = (pkgs.python310.withPackages (p:
with p; [
Expand All @@ -136,17 +146,18 @@ let
esp-idf-size
esp-idf-panic-decoder
filelock
pyclang
]));
in stdenv.mkDerivation rec {
pname = "esp-idf";
version = "5.1";
version = "5.2.1";
src = fetchFromGitHub {
owner = "espressif";
repo = "esp-idf";
rev = "482a8fb2d78e3b58eb21b26da8a5bedf90623213";
rev = "a322e6bdad4b6675d4597fb2722eea2851ba88cb";
fetchSubmodules = true;
name = pname;
sha256 = "sha256-uEf3/3NPH+E39VgQ02AbxTG7nmG5bQlhwk/WcTeAUfg=";
sha256 = "sha256-0WwDcasG7JjRJIaZyjWTobKhZXUi4pcSHFMtTbBJE1g=";
};

patches = [ ./neutralize-python-dependency-checks.patch ];
Expand Down Expand Up @@ -184,6 +195,7 @@ in stdenv.mkDerivation rec {
mkdir -p $out/sdk $out/.espressif/python_env/idf${version}_py3.10_env/bin
ln -s $(readlink -e $(which python3)) $out/.espressif/python_env/idf${version}_py3.10_env/bin/python
touch $out/.espressif/espidf.constraints.v${version}.txt
touch $out/.espressif/espidf.constraints.v5.2.txt
cp -r sdk/* $out/sdk
# no .git, inject version
Expand Down
8 changes: 4 additions & 4 deletions nix/toolchain.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ let

platformHash = {
# espressif release name -> sha256 hash
"x86_64-linux-gnu" = "sha256-TS4C70fxqTpNz9uuzUhq36q0wOJt7qLBjWOFUn85+GQ=";
"x86_64-linux-gnu" = "sha256-uufaI+qFFvt+QmQPRCDE3R6/1kGJoU/DMNc+Fzs6A4s=";
"aarch64-linux-gnu" = "sha256-niEaGCtuoDlqQcePUvUdlk54df4nTqnIERG/DbyQxRY=";
"arm-linux-gnueabi" = "sha256-Ld2R+5i3mzAEK3kY7vYM8Qx71bHahT6Dtl8pO5beyAA=";
"arm-linux-gnueabihf" = "sha256-poOkaFVdy8ts4yoZCEIRDW+FPU1hBNYc8Lyd1Qxr4eY=";
"i686-linux-gnu" = "sha256-KSsZ6mGGUIqSP7b9AQOXfgAdTrjneDbH49bObl+n0wU=";
"x86_64-apple-darwin" = "sha256-sJ2H/bHcMs0dcYk1Bl75MbEBoU32sXvlZ0jlJkCVW/8=";
"aarch64-apple-darwin" = "sha256-9QrKsrIW6UddxTE7PktCTLxw0KvSO6GBiv9KAZFl2o4=";
"aarch64-apple-darwin" = "sha256-aHJD5cvvt88FYD7/vdb95XaflNr/flGfW75h9DxMDvY=";
};
platform = platforms.${stdenv.system};

Expand All @@ -31,10 +31,10 @@ in

stdenv.mkDerivation rec {
pname = "esp32-toolchain";
version = "12.2.0_20230208";
version = "13.2.0_20230928";

src = fetchurl {
url = "https://github.com/espressif/crosstool-NG/releases/download/esp-${version}/xtensa-esp32-elf-${version}-${platform}.tar.xz";
url = "https://github.com/espressif/crosstool-NG/releases/download/esp-${version}/xtensa-esp-elf-${version}-${platform}.tar.xz";
sha256 = toolchainHash;
};

Expand Down
2 changes: 1 addition & 1 deletion src/core/external/bell
Submodule bell updated from e8928c to 206c99
17 changes: 12 additions & 5 deletions src/core/main/app/HTTPDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,24 @@ void HTTPDispatcher::initialize() {

this->server->registerWS(
"/repl",
[this](struct mg_connection* conn, char* data, size_t dataSize) {
[this](const struct mg_connection* conn, char* data, size_t dataSize) {
// Convert the data to a string
std::string dataString(data, dataSize);

// Post the event to the event bus
auto event = std::make_unique<VmRawCommandEvent>(dataString);
this->ctx->eventBus->postEvent(std::move(event));
},
[this](struct mg_connection* conn, bell::BellHTTPServer::WSState state) {
[this](const struct mg_connection* conn,
bell::BellHTTPServer::WSState state) {
switch (state) {
case bell::BellHTTPServer::WSState::READY: {
EUPH_LOG(debug, TAG, "REPL websocket connection open");
std::scoped_lock lock(this->websocketConnectionsMutex);
this->replWebsocketConnections.push_back(conn);
// Drop constness here, because civetweb calls callbacks with const pointers
// but we need to store the connection for later use
this->replWebsocketConnections.push_back(
(struct mg_connection*)conn);
break;
}
case bell::BellHTTPServer::WSState::CLOSED: {
Expand Down Expand Up @@ -124,12 +128,15 @@ void HTTPDispatcher::initialize() {
auto event = std::make_unique<VmWebsocketEvent>(dataString);
this->ctx->eventBus->postEvent(std::move(event));
},
[this](struct mg_connection* conn, bell::BellHTTPServer::WSState state) {
[this](const struct mg_connection* conn,
bell::BellHTTPServer::WSState state) {
switch (state) {
case bell::BellHTTPServer::WSState::READY: {
EUPH_LOG(debug, TAG, "Websocket connection open");
std::scoped_lock lock(this->websocketConnectionsMutex);
this->websocketConnections.push_back(conn);
// Drop constness here, because civetweb calls callbacks with const pointers
// but we need to store the connection for later use
this->websocketConnections.push_back((struct mg_connection*)conn);
break;
}
case bell::BellHTTPServer::WSState::CLOSED: {
Expand Down
2 changes: 1 addition & 1 deletion src/targets/esp32/dependencies.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dependencies:
component_hash: null
source:
type: idf
version: 5.1.2
version: 5.2.1
manifest_hash: 35e50ca765476aec0a600ab2d6d2249a58255f42634e2a9e0c0662d8df838242
target: esp32
version: 1.0.0
Loading

0 comments on commit 58d4a71

Please sign in to comment.