Skip to content

Commit b052edf

Browse files
nzmichaelhstephanosio
authored andcommitted
minichlink: create a recipie to build minichlink for the ch32v003
minichlink is a self contained flasher, debug stub, and terminal for the CH32V003. Signed-off-by: Michael Hope <mlhx@google.com>
1 parent d83d3d0 commit b052edf

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/minichlink/Makefile b/minichlink/Makefile
2+
index 2608380..2a53a1e 100644
3+
--- a/minichlink/Makefile
4+
+++ b/minichlink/Makefile
5+
@@ -1,6 +1,7 @@
6+
TOOLS:=minichlink minichlink.so
7+
8+
-CFLAGS:=-O0 -g3 -Wall -DCH32V003 -I.
9+
+CFLAGS ?= -O0 -g3 -Wall
10+
+CFLAGS += -DCH32V003 -I.
11+
C_S:=minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c nhc-link042.c ardulink.c serial_dev.c pgm-b003fun.c minichgdb.c
12+
13+
# General Note: To use with GDB, gdb-multiarch
14+
@@ -8,19 +9,19 @@ C_S:=minichlink.c pgm-wch-linke.c pgm-esp32s2-ch32xx.c nhc-link042.c ardulink.c
15+
# target remote :2345
16+
17+
ifeq ($(OS),Windows_NT)
18+
- LDFLAGS:=-L. -lpthread -lusb-1.0 -lsetupapi -lws2_32
19+
- CFLAGS:=-Os -s -Wall -D_WIN32_WINNT=0x0600 -DCH32V003 -I.
20+
+ LDFLAGS ?= -L. -lpthread -lusb-1.0 -lsetupapi -lws2_32
21+
+ CFLAGS ?= -Os -s -Wall -D_WIN32_WINNT=0x0600 -DCH32V003 -I.
22+
TOOLS:=minichlink.exe
23+
else
24+
OS_NAME := $(shell uname -s | tr A-Z a-z)
25+
ifeq ($(OS_NAME),linux)
26+
- LDFLAGS:=-lpthread -lusb-1.0 -ludev
27+
+ LDFLAGS += -lpthread -lusb-1.0 -ludev
28+
endif
29+
ifeq ($(OS_NAME),darwin)
30+
- LDFLAGS:=-lpthread -lusb-1.0 -framework CoreFoundation -framework IOKit
31+
- CFLAGS:=-O0 -Wall -Wno-asm-operand-widths -Wno-deprecated-declarations -Wno-deprecated-non-prototype -D__MACOSX__ -DCH32V003 -I.
32+
- INCLUDES:=$(shell pkg-config --cflags-only-I libusb-1.0)
33+
- LIBINCLUDES:=$(shell pkg-config --libs-only-L libusb-1.0)
34+
+ LDFLAGS += -lpthread -lusb-1.0 -framework CoreFoundation -framework IOKit
35+
+ CFLAGS ?= -O0 -Wall -Wno-asm-operand-widths -Wno-deprecated-declarations -Wno-deprecated-non-prototype -D__MACOSX__ -DCH32V003 -I.
36+
+ INCLUDES ?= $(shell pkg-config --cflags-only-I libusb-1.0)
37+
+ LIBINCLUDES ?= $(shell pkg-config --libs-only-L libusb-1.0)
38+
INCS:=$(INCLUDES) $(LIBINCLUDES)
39+
endif
40+
endif
41+
@@ -32,10 +33,10 @@ minichlink.exe : $(C_S)
42+
x86_64-w64-mingw32-gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
43+
44+
minichlink : $(C_S)
45+
- gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS)
46+
+ $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS)
47+
48+
minichlink.so : $(C_S)
49+
- gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS) -shared -fPIC
50+
+ $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS) -shared -fPIC
51+
52+
minichlink.dll : $(C_S)
53+
x86_64-w64-mingw32-gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) $(INCS) -shared -DMINICHLINK_AS_LIBRARY
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SUMMARY = "A free, open mechanism to use the CH-LinkE $4 programming dongle for the CH32V003."
2+
HOMEPAGE = "https://github.com/cnlohr/ch32v003fun"
3+
4+
LICENSE = "MIT"
5+
LIC_FILES_CHKSUM = "file://LICENSE;md5=08d32be0f39cc2231a746a21a7c0cefa"
6+
7+
DEPENDS = "eudev libusb"
8+
9+
BBCLASSEXTEND += "nativesdk"
10+
11+
SRC_URI = "git://github.com/cnlohr/ch32v003fun.git;protocol=https \
12+
file://0001-Use-CFLAGS-LDFLAGS.patch"
13+
SRCREV = "d8fe188769be7821908751b785e09032e6578a7a"
14+
15+
S = "${WORKDIR}/git"
16+
17+
do_compile() {
18+
oe_runmake -C minichlink minichlink
19+
}
20+
21+
do_install() {
22+
install -d ${D}${bindir}
23+
install -m 0755 ${S}/minichlink/minichlink ${D}${bindir}
24+
}

0 commit comments

Comments
 (0)