Skip to content

Commit 297a306

Browse files
authored
add esp32-devel (#10570)
1 parent 9f8a611 commit 297a306

4 files changed

Lines changed: 277 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package("esp32-arduino-libs")
2+
set_kind("library")
3+
set_homepage("https://github.com/espressif/arduino-esp32")
4+
set_description("Prebuilt ESP-IDF libraries, headers, linker scripts and flag sets for the Arduino ESP32 core")
5+
set_license("LGPL-2.1-or-later")
6+
7+
-- one archive per chip, the release version is the arduino-esp32 core version
8+
add_configs("chip", {description = "Set the target ESP chip.", default = "esp32", type = "string",
9+
values = {"esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"}})
10+
11+
local checksums = {
12+
["3.3.11"] = {
13+
esp32 = "f7d70b98d83482ef9065f13e9dbe21f8c1292f0dc6e6ee9f1970b3b2e5ea894f",
14+
esp32s2 = "584a2fa2d6e8d9de35233b506bdb60d1492b0fb6de8fa4e7560eb2a3b04aa74a",
15+
esp32s3 = "fec76794708694120c6ec803cdbfc7dcd36286ea22b7d38097b7909bbd19f7b5",
16+
esp32c3 = "887067748467a002d9354dc2a14cfd233528e6d89a0b5178db90ba4224e17e5d",
17+
esp32c5 = "9760dcb7a92306ce169025c74afae104a65c4221f6b1d92c69369748b9cb91f6",
18+
esp32c6 = "dd7374dabadeced8259ea67c331faa7588afbbed92c2727e7b8c5201f6762ee0",
19+
esp32h2 = "8a73008ee70bc5a9255798e7732208a533f7d931fa54a2289e5f2c7eed822126",
20+
esp32p4 = "315868de4dc8cd78fb1b77e07355c605a296abd40ac9d51e78d2b8bd1c61f737"
21+
},
22+
["3.3.10"] = {
23+
esp32 = "2fbdcf06cef1bff7fb24ca368886ec1678ef67f4a9615f3967d5ce1287557212",
24+
esp32s2 = "7b6077df9f242b765c8f298270b02f463b17129fdde0700a29338988cf4a921e",
25+
esp32s3 = "edee967acfbdba03e8baef75d28564e0b74ee10daa640639174b1ae935763302",
26+
esp32c3 = "a08e1fd34c4be94bf4cfb5589b5a0a5f2908d0392153a0686fd193647bc022f8",
27+
esp32c5 = "d5981ad02d9358ab7ceb47ae261521c009b46ab2f6ad5ba7d697346e0f3d66b0",
28+
esp32c6 = "4b9fc7a3ac55af5ac8461302c7129ebcc7a6a4598dbacfb75989fff04d04be7b",
29+
esp32h2 = "a9706f9c0c66b96864488d48d9377bcb2a46889352df464175ad4b1c17a83e68",
30+
esp32p4 = "27df1e01518a030b53f7855ee7993cb6ea1d02e4c4848632645ffa2a24ef0155"
31+
}
32+
}
33+
34+
on_source(function (package)
35+
local chip = package:config("chip")
36+
package:set("urls", "https://github.com/espressif/arduino-esp32/releases/download/$(version)/" .. chip .. "-libs-$(version).zip")
37+
for version, chips in pairs(checksums) do
38+
package:add("versions", version, chips[chip])
39+
end
40+
end)
41+
42+
on_install(function (package)
43+
os.vcp("*", package:installdir())
44+
end)
45+
46+
on_test(function (package)
47+
local installdir = package:installdir()
48+
assert(os.isfile(path.join(installdir, "sdkconfig")))
49+
assert(os.isdir(path.join(installdir, "flags")))
50+
assert(os.isdir(path.join(installdir, "ld")))
51+
assert(os.isdir(path.join(installdir, "lib")))
52+
end)

packages/e/esp32-devel/xmake.lua

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package("esp32-devel")
2+
set_kind("toolchain")
3+
set_homepage("https://www.espressif.com/en/products/socs")
4+
set_description("ESP32 development kit, binds the cross toolchain, prebuilt sdk and flash tool of the selected board")
5+
6+
-- the xtensa cores and the risc-v cores need different gcc cross toolchains
7+
local toolchains = {
8+
esp32 = "xtensa-esp-elf",
9+
esp32s2 = "xtensa-esp-elf",
10+
esp32s3 = "xtensa-esp-elf",
11+
esp32c3 = "riscv32-esp-elf",
12+
esp32c5 = "riscv32-esp-elf",
13+
esp32c6 = "riscv32-esp-elf",
14+
esp32h2 = "riscv32-esp-elf",
15+
esp32p4 = "riscv32-esp-elf"
16+
}
17+
18+
add_configs("board", {description = "Set the target ESP32 board.", default = "esp32", type = "string",
19+
values = {"esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"}})
20+
add_configs("sdk", {description = "Bind the prebuilt esp-idf sdk libraries.", default = true, type = "boolean"})
21+
add_configs("flash", {description = "Bind the flash tool.", default = true, type = "boolean"})
22+
23+
on_load(function (package)
24+
local board = package:config("board")
25+
local toolchain = toolchains[board]
26+
assert(toolchain, "package(esp32-devel): unsupported board(%s)!", board)
27+
package:add("deps", toolchain)
28+
if package:config("flash") then
29+
package:add("deps", "esptool")
30+
end
31+
if package:config("sdk") then
32+
package:add("deps", "esp32-arduino-libs", {configs = {chip = board}})
33+
end
34+
end)
35+
36+
on_install("windows|x64", "@linux", "@macosx", function (package)
37+
local board = package:config("board")
38+
package:addenv("ESP32_BOARD", board)
39+
package:addenv("ESP32_GCC_PREFIX", toolchains[board] .. "-")
40+
local sdk = package:dep("esp32-arduino-libs")
41+
if sdk then
42+
package:addenv("ESP32_SDK_DIR", sdk:installdir())
43+
end
44+
end)
45+
46+
on_test(function (package)
47+
local board = package:config("board")
48+
local gcc = toolchains[board] .. "-gcc"
49+
if is_host("windows") then
50+
gcc = gcc .. ".exe"
51+
end
52+
os.vrunv(gcc, {"--version"})
53+
if package:config("flash") then
54+
os.vrunv("esptool", {"version"})
55+
end
56+
end)

packages/e/esptool/xmake.lua

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package("esptool")
2+
set_kind("binary")
3+
set_homepage("https://github.com/espressif/esptool")
4+
set_description("Espressif SoC serial bootloader utility, used to flash and image ESP chips")
5+
set_license("GPL-2.0-or-later")
6+
7+
local variants = {
8+
windows = {
9+
x86_64 = {suffix = "windows-amd64.zip", versions = {
10+
["5.3.1"] = "2b4a73c45db27426685896f64ce3e557f63a64f43cc100cb65c0cc3486af96d3",
11+
["5.2.0"] = "ef0522120afb5e8e673d68726c32e0de416990fc62dc313191721edeb0a74fc6",
12+
["5.1.0"] = "f68a8f7728adfc59cd60f9424928199e76eac66372c7bdc23898aa32753a437a"
13+
}}
14+
},
15+
linux = {
16+
x86_64 = {suffix = "linux-amd64.tar.gz", versions = {
17+
["5.3.1"] = "e9cc641f8e4a0b644b52836d7a6b59f3c6d3261213c5ccc41f8f3c3035d06aa4",
18+
["5.2.0"] = "0a9f6c913fccfacac9261eb2acd8060010db5933c18c8e47cb32377eaa7202a3",
19+
["5.1.0"] = "49d572d50f6b1f089d1d81d3bd3bd357fbcc40f4f8fd4874f2dc51ad534abb01"
20+
}},
21+
arm64 = {suffix = "linux-aarch64.tar.gz", versions = {
22+
["5.3.1"] = "dd2613cdc8e73d1200a3daff2025ff51daa5bbdb3a352fe35d6b7377891aecc8",
23+
["5.2.0"] = "a3a0fc13ada8d69dddbdfff1c765fa0b88fb578a83d02315be9c15fefa6ca58e",
24+
["5.1.0"] = "d2b60d4570cd4919b87eddcbeaab2e0411548b5aab865c234aed8ecc8e5403ac"
25+
}},
26+
armhf = {suffix = "linux-armv7.tar.gz", versions = {
27+
["5.3.1"] = "54a2f902acf47dd4542c1ed6958eb9442fe818a16a7ecfaeaab57b872e7e8460",
28+
["5.2.0"] = "dbf92966eb6ad5f4d068d8b2461f534b15219cb405083a38d26519284e91b73a",
29+
["5.1.0"] = "e22ecb0293fe73c80d0a5fd05873f9ea49a68985b16991cf5980d2b90c8c7276"
30+
}}
31+
},
32+
macosx = {
33+
x86_64 = {suffix = "macos-amd64.tar.gz", versions = {
34+
["5.3.1"] = "f8ec4fcaf7d79845a0e8ad60b24be9f584d8fe03f341b5ad4ec0df0ec855e670",
35+
["5.2.0"] = "dcb6c38cb10e1d7ca5ce658687e4abe47dfda22284857673b55cae010ff5f5ee",
36+
["5.1.0"] = "c485511e0906cb1e0277c5eecff1c4a77b89d76d0c940b685dc9fce2fad4b242"
37+
}},
38+
arm64 = {suffix = "macos-arm64.tar.gz", versions = {
39+
["5.3.1"] = "f63f7203d88cfe4c17aea34d6cf82769458ce204e49a05816c6384c2d299e6ca",
40+
["5.2.0"] = "2b45270273ff96b6394bd6e317b153cf4a42869ca917d2bcebafc9a3cdac0e1e",
41+
["5.1.0"] = "5d5aab5b64b10dc5001cfa96b5bfa48393ae561e6d797c41a1fdd3f5d3843d03"
42+
}}
43+
}
44+
}
45+
46+
local arch = os.arch()
47+
local plat
48+
if is_host("windows") then
49+
plat = "windows"
50+
arch = arch == "x64" and "x86_64" or arch
51+
elseif is_host("linux") then
52+
plat = "linux"
53+
if arch:startswith("armv") then
54+
arch = "armhf"
55+
end
56+
elseif is_host("macosx") then
57+
plat = "macosx"
58+
end
59+
60+
if plat and variants[plat] and variants[plat][arch] then
61+
local variant = variants[plat][arch]
62+
set_urls("https://github.com/espressif/esptool/releases/download/v$(version)/esptool-v$(version)-" .. variant.suffix)
63+
for v, h in pairs(variant.versions) do
64+
add_versions(v, h)
65+
end
66+
end
67+
68+
on_install("windows|x64", "@linux", "@macosx", function (package)
69+
os.vcp("*|README.md|LICENSE", package:installdir("bin"))
70+
end)
71+
72+
on_test(function (package)
73+
os.vrunv("esptool", {"version"})
74+
end)
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package("riscv32-esp-elf")
2+
set_kind("toolchain")
3+
set_homepage("https://github.com/espressif/crosstool-NG")
4+
set_description("crosstool-NG with support for RISC-V (esp32c*/esp32h*/esp32p4)")
5+
set_license("GPL-3.0-with-GCC-exception")
6+
7+
local variants = {
8+
windows = {
9+
x86_64 = {suffix = "x86_64-w64-mingw32.zip", versions = {
10+
["15.2.0"] = "c61488aa15f49146aae918267110f775a52c3cef3844cbf261f475ef97523c3d",
11+
["14.2.0"] = "74d1d2a018eea6705fa34d6c5387729b85843cb829a58b287cc6074a92f7184f"
12+
}},
13+
x86 = {suffix = "i686-w64-mingw32.zip", versions = {
14+
["15.2.0"] = "a52d9c855f1771527d2a6b6a6012ddff3f17bb5c937830b163aa8418177c86da",
15+
["14.2.0"] = "2a49a8dd4c6a59c1781c2ef59151e7cb5a2c677808904fe116d652f1dd6fef03"
16+
}}
17+
},
18+
linux = {
19+
x86_64 = {suffix = "x86_64-linux-gnu.tar.xz", versions = {
20+
["15.2.0"] = "ace5aae6afe98f754947be043d40173e2e22ace57754b11a394b7238eefa01cf",
21+
["14.2.0"] = "c0aee981f159a00cd33d4dd03a8b8e1d0c486f27815314c5c77f66aa92e703e9"
22+
}},
23+
x86 = {suffix = "i586-linux-gnu.tar.xz", versions = {
24+
["15.2.0"] = "8dc31a97c008bf80d0c0b20b5960c522d9552f77a79ffd60e3ae6b1329cd68ef",
25+
["14.2.0"] = "516b1716bee4025eb08379ee2744af6477787bb9c1ddb62f3f9465f8da67b263"
26+
}},
27+
arm64 = {suffix = "aarch64-linux-gnu.tar.xz", versions = {
28+
["15.2.0"] = "90cccb3ef035f016836dd7c292528b27333a716d42b9361a68005d178c0f70bf",
29+
["14.2.0"] = "5603027f6b0ffe1a06898ac17bb773071845088f8302f00bd80739ab08b5b96c"
30+
}},
31+
armel = {suffix = "arm-linux-gnueabi.tar.xz", versions = {
32+
["15.2.0"] = "5603d18a0534ab5c2faca672ac890ad5b57727e55c6734adf6584aa73844f112",
33+
["14.2.0"] = "6f84a1859b929382c4f427f7aa1a053412ca328a9394b3380aff13f637d733b7"
34+
}},
35+
armhf = {suffix = "arm-linux-gnueabihf.tar.xz", versions = {
36+
["15.2.0"] = "61b2feebfe14c5f2a7966ccec0c1c7ed2e2840d260671730f376aa92323b1338",
37+
["14.2.0"] = "52a282402b853905f2d18ef02b5d36c0b708f7e6f6886aecec26543b0705bcc1"
38+
}}
39+
},
40+
macosx = {
41+
x86_64 = {suffix = "x86_64-apple-darwin.tar.xz", versions = {
42+
["15.2.0"] = "6d4709eadf4c66aecb51c0ff9c7b068eefa6ecec37aa7817f172c9f735318e73",
43+
["14.2.0"] = "5322b2c94ab9fcb26582d58bb4f78cb527bdea60314ce956d7d88140c3ef6af7"
44+
}},
45+
arm64 = {suffix = "aarch64-apple-darwin.tar.xz", versions = {
46+
["15.2.0"] = "0869d1083532c631808543dd802885f02dbe1bb3bd640be0dee827e82ded768d",
47+
["14.2.0"] = "00d10c738f0493bc650c47cc67af800f0d6b827700504887a47e00c98ae121d5"
48+
}}
49+
}
50+
}
51+
52+
local arch = os.arch()
53+
local plat
54+
if is_host("windows") then
55+
plat = "windows"
56+
arch = arch == "x64" and "x86_64" or arch
57+
elseif is_host("linux") then
58+
plat = "linux"
59+
-- os.arch() reports the raw host arch, e.g. i386/armv7a
60+
if arch == "i386" or arch == "i686" then
61+
arch = "x86"
62+
elseif arch:startswith("armv") then
63+
arch = "armhf"
64+
end
65+
elseif is_host("macosx") then
66+
plat = "macosx"
67+
end
68+
69+
if plat and variants[plat] and variants[plat][arch] then
70+
local variant = variants[plat][arch]
71+
set_urls("https://github.com/espressif/crosstool-NG/releases/download/esp-$(version)/riscv32-esp-elf-$(version)-" .. variant.suffix, {
72+
version = function (version)
73+
local versions_date = {
74+
["15.2.0"] = "20251204",
75+
["14.2.0"] = "20251208"
76+
}
77+
return format("%s_%s", version, versions_date[tostring(version)])
78+
end
79+
})
80+
for v, h in pairs(variant.versions) do
81+
add_versions(v, h)
82+
end
83+
end
84+
85+
on_install("windows|!arm*", "@linux", "@macosx", function(package)
86+
os.cp("*", package:installdir())
87+
end)
88+
89+
on_test(function (package)
90+
local gcc = "riscv32-esp-elf-gcc"
91+
if is_host("windows") then
92+
gcc = gcc .. ".exe"
93+
end
94+
os.vrunv(gcc, {"--version"})
95+
end)

0 commit comments

Comments
 (0)