aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Gonçalves <nunojpg@gmail.com>2023-06-20 16:54:16 +0100
committerNuno Goncalves <nunojpg@gmail.com>2023-10-08 17:40:50 +0100
commit597df3585fae16ac1e8a64b839c7159a907e70af (patch)
treed7aef9c69c3d86757948875f274613f21bab9048
parent3e9b2d85f04c770a5f3e8bdc3065467ef976dea4 (diff)
esp2net: add Espressif ESP chip USB-Network proxy
Signed-off-by: Nuno Gonçalves <nunojpg@gmail.com>
-rw-r--r--net/esp2net/Makefile48
-rw-r--r--net/esp2net/files/esp2net.config4
-rwxr-xr-xnet/esp2net/files/esp2net.init32
3 files changed, 84 insertions, 0 deletions
diff --git a/net/esp2net/Makefile b/net/esp2net/Makefile
new file mode 100644
index 000000000..8e0dcbeac
--- /dev/null
+++ b/net/esp2net/Makefile
@@ -0,0 +1,48 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=esp2net
+PKG_RELEASE:=1
+
+PKG_LICENSE:=GPL-2.0-only
+PKG_MAINTAINER:=Nuno Gonçalves <nunojpg@gmail.com>
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=https://github.com/nunojpg/esp2net.git
+PKG_SOURCE_DATE:=2023-06-20
+PKG_SOURCE_VERSION:=be514c7a50bd8f3aac146ba267856d66cad1abd9
+PKG_MIRROR_HASH:=bb2d180887c14ee3e6bec51ccaae195274a09e4be108a7e69e2126df5245c0b7
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/esp2net
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Espressif ESP chip network monitor and flash proxy
+ DEPENDS:=+libstdcpp
+endef
+
+define Package/esp2net/description
+ Allows to flash a Espressif chip connected to this device.
+ The functionality is identical to "esp_rfc2217_server.py" but without Python.
+ Typically you want also to install one or more USB serial drivers:
+ * kmod-usb-serial-cp210x
+ * kmod-usb-serial-ftdi
+ * kmod-usb-serial-ch341
+ * kmod-usb-acm
+endef
+
+define Package/esp2net/install
+ $(INSTALL_DIR) $(1)/usr/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/esp2net $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/esp2net.init $(1)/etc/init.d/esp2net
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_CONF) ./files/esp2net.config $(1)/etc/config/esp2net
+endef
+
+define Package/esp2net/conffiles
+/etc/config/esp2net
+endef
+
+$(eval $(call BuildPackage,esp2net))
diff --git a/net/esp2net/files/esp2net.config b/net/esp2net/files/esp2net.config
new file mode 100644
index 000000000..1059f2bb1
--- /dev/null
+++ b/net/esp2net/files/esp2net.config
@@ -0,0 +1,4 @@
+config esp2net
+ option uart '/dev/ttyUSB0'
+ option port '5001'
+ option disabled 1
diff --git a/net/esp2net/files/esp2net.init b/net/esp2net/files/esp2net.init
new file mode 100755
index 000000000..437923f85
--- /dev/null
+++ b/net/esp2net/files/esp2net.init
@@ -0,0 +1,32 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+START=95
+STOP=01
+
+CONFIGURATION=esp2net
+SECTION=esp2net
+
+parse_esp2net()
+{
+ local uart
+ local port
+ local disabled
+ config_get uart "${1}" uart
+ config_get port "${1}" port
+ config_get_bool disabled "${1}" disabled 0
+ [ "$disabled" -eq 1 ] && return;
+ procd_open_instance
+ procd_set_param respawn 3600 5 5
+ procd_set_param command /usr/sbin/esp2net "$uart" "$port"
+ procd_set_param file /etc/config/esp2net
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+ procd_close_instance
+}
+
+start_service() {
+ config_load "${CONFIGURATION}"
+ config_foreach parse_esp2net "${SECTION}"
+}