esputil: new recipe. (#10273)

This commit is contained in:
OscarL
2024-07-17 14:45:23 -03:00
committed by GitHub
parent 82cc8949c8
commit c4bbc25c58
2 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
SUMMARY="ESP flashing utility"
DESCRIPTION="esputil is a command line tool for managing Espressif devices. It is a replacement \
for esptool.py. esputil is part of https://github.com/cpq/mdk. It is written in C and is \
available as a no-dependency static binary for Mac, Linux, Windows (and now Haiku :-P)"
HOMEPAGE="https://github.com/cpq/esputil"
COPYRIGHT="2021-2022 Cesanta"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/cpq/esputil/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="c717188885df6759f3a7a239aa72addcbc7dbf7d6a7af5161530cbd6c38cb5d8"
PATCHES="esputil-$portVersion.patchset"
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
commandBinDir=$prefix/bin
commandSuffix=
fi
PROVIDES="
esputil$secondaryArchSuffix = $portVersion
cmd:esputil$commandSuffix = $portVersion
"
REQUIRES="
haiku$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
"
BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix
cmd:make
"
BUILD()
{
EXTRA_CFLAGS=-lnetwork make
}
INSTALL()
{
mkdir -p $commandBinDir
cp -a esputil $commandBinDir
}

View File

@@ -0,0 +1,46 @@
From e4ed04b4f3c76b26ed15632030a7814dae3a98f5 Mon Sep 17 00:00:00 2001
From: Oscar Lesta <oscar.lesta@gmail.com>
Date: Fri, 29 Mar 2024 17:04:18 -0300
Subject: Small fixes for Haiku.
- Changed default port.
- Limited range of baudrates.
- Disabled definition of ALIGN macro (not used anyway).
To compile use: `EXTRA_CFLAGS=-lnetwork make`
diff --git a/esputil.c b/esputil.c
index f88ed75..b46bd52 100644
--- a/esputil.c
+++ b/esputil.c
@@ -54,7 +54,9 @@ typedef enum { false = 0, true = 1 } bool;
#include <unistd.h>
#endif
+#ifndef __HAIKU__
#define ALIGN(a, b) (((a) + (b) -1) / (b) * (b))
+#endif
// https://datatracker.ietf.org/doc/html/rfc1055
enum { END = 192, ESC = 219, ESC_END = 220, ESC_ESC = 221 };
@@ -349,7 +351,7 @@ static speed_t termios_baud(int baud) {
case 57600: return B57600;
case 115200: return B115200;
case 230400: return B230400;
-#ifndef __APPLE__
+#if ! defined(__APPLE__) && ! defined(__HAIKU__)
case 460800: return B460800;
case 500000: return B500000;
case 576000: return B576000;
@@ -1027,6 +1029,8 @@ int main(int argc, const char **argv) {
if (ctx.port == NULL) ctx.port = "COM99"; // Non-existent default port
#elif defined(__APPLE__)
if (ctx.port == NULL) ctx.port = "/dev/cu.usbmodem";
+#elif defined(__HAIKU__)
+ if (ctx.port == NULL) ctx.port = "/dev/ports/usb0";
#else
if (ctx.port == NULL) ctx.port = "/dev/ttyUSB0";
#endif
--
2.45.2