Skip to content

Enable build of ch32fun and minichlink on FreeBSD#790

Closed
adventureloop wants to merge 2 commits intocnlohr:masterfrom
adventureloop:freebsd-port
Closed

Enable build of ch32fun and minichlink on FreeBSD#790
adventureloop wants to merge 2 commits intocnlohr:masterfrom
adventureloop:freebsd-port

Conversation

@adventureloop
Copy link
Copy Markdown

No description provided.

Comment thread ch32fun/ch32fun.mk
ifneq ($(shell $(WHICH) riscv64-unknown-elf-gcc 2>$(NULLDEV)),)
PREFIX_DEFAULT:=riscv64-unknown-elf
else ifneq ($(shell $(WHICH) riscv32-unknown-elf-gcc 2>$(NULLDEV)),)
PREFIX_DEFAULT:=riscv32-unknown-elf
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to have another fallback

Comment thread ch32fun/ch32fun.mk

clangd :
make clean
$(MAKE) clean
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a MAKE?=make earlier? so on old Windows Make versions it still works?

Comment thread minichlink/Makefile

minichlink : $(C_S) $(H_S) Makefile
gcc -o $@ $(C_S) $(LDFLAGS) $(CFLAGS) $(INCS)
cc -o $@ $(C_S) $(LDFLAGS) $(CFLAGS) $(INCS)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not work on some Windows crossdev systems.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, I will add platform detection

Comment thread minichlink/minichlink.c
{
fprintf( stderr, "Found WCH Link\n" );
}
#ifndef __FreeBSD__
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to add support for these. Disabling functionality on specific platforms should only be done as a later "I give up"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esp32 and b0003 need "hidapi_thread_pthread.h" which isn't provided by the port (package basically) right now. The header doesn't seem to be in the public hidapi interface, I'm not sure if other platforms package this with their hidapi package, I need to get a debian machine to check.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you are referring to. hidapi.c/.h is provided alongside minichlink. They contain all of hidapi on all supported platforms.

Comment thread ch32fun/ch32fun.c
@adventureloop
Copy link
Copy Markdown
Author

Ah ha, I got it by updating hidapi in minichlink and pulling in the missing header.

I'll create a different review for that, do you know if a hidapi update is safe?

@cnlohr
Copy link
Copy Markdown
Owner

cnlohr commented Nov 27, 2025

Ah ha, I got it by updating hidapi in minichlink and pulling in the missing header.

I'll create a different review for that, do you know if a hidapi update is safe?

There should be no additional header. the provided hidapi.h/.c are fully merged for all platforms.

@cnlohr
Copy link
Copy Markdown
Owner

cnlohr commented Mar 17, 2026

I think? this has been resolved by #872 and #873

@cnlohr cnlohr closed this Mar 17, 2026
@tsutsui
Copy link
Copy Markdown
Contributor

tsutsui commented Mar 17, 2026

I think? this has been resolved by #872 and #873

Unfortunately, I'm afraid NetBSD and FreeBSD have completely different APIs for USB hid devices.

However it looks there is a pull request to add FreeBSD's hidraw support to upstream hidapi,
libusb/hidapi#730
so it would be better to use a newer hidapi library (from FreeBSD ports etc.) with the new FreeBSD-native APIs so that no need to tweak libusb portion (like hidapi_thread_pthread.h) in locally pulled ch32fun/minichlink/hidapi.c.

@adventureloop
Copy link
Copy Markdown
Author

Cool thanks for that pointer, I will follow that upstream

@cnlohr
Copy link
Copy Markdown
Owner

cnlohr commented Mar 23, 2026

If someone wants to update our hidapi, I'm happy to let that one through!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants