Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d2xx cannot be cross compiled with CGO enabled with soft float #1

Closed
lutzky opened this issue May 30, 2021 · 13 comments
Closed

d2xx cannot be cross compiled with CGO enabled with soft float #1

lutzky opened this issue May 30, 2021 · 13 comments

Comments

@lutzky
Copy link

lutzky commented May 30, 2021

My build uses devices (specifically ssd1306) and works fine with v3.6.10. However, upgrading to v3.6.11 adds a dependency of periph.io/x/d2xx v0.0.1, which causes build failures on WSL. I'm cross-compiling like so:

export CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARM=6 GOARCH=arm
go build main.go

...and get the following errors:

# periph.io/x/d2xx
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftd2xx.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftd2xx.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftd2xx-private.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftd2xx-private.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(Event.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(Event.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(usb_control.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(usb_control.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(bulk_in.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(bulk_in.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(device-list.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(device-list.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(idtable.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(idtable.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ee.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ee.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232r.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232r.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232h.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee232h.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee2232.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee2232.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee2232h.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee2232h.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee4232h.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(ftee4232h.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(fteeftx.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(fteeftx.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(serialno.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(serialno.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(core.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(core.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(descriptor.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(descriptor.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(io.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(io.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(hotplug.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(hotplug.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(sync.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(sync.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(linux_usbfs.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(linux_usbfs.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(linux_netlink.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(linux_netlink.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(config.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(config.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(baud.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(baud.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(fte2data.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(fte2data.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(threads_posix.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(threads_posix.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(poll_posix.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(poll_posix.o)
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: error: ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(eedata.o) uses VFP register arguments, $WORK/b164/_cgo_.o does not
/usr/lib/gcc-cross/arm-linux-gnueabi/9/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ../go/pkg/mod/periph.io/x/[email protected]/third_party/libftd2xx_linux_arm6hf_v1.4.6.a(eedata.o)
collect2: error: ld returned 1 exit status

To Reproduce
Steps to reproduce the behavior:

  1. Write the following program (yes, the one from the issue template suffices)
package main

import (
  "periph.io/x/host/v3"
)

func main() {
  host.Init()
}
  1. Build it like so:
export CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARM=6 GOARCH=arm
go build main.go
  1. See errors above.

Expected behavior
Should at least build successfully, like it did in v3.6.10.

Platform (please complete the following information):

  • OS: WSL2 running Ubuntu 20.04.2 LTS
  • Board: Irrelevant, cross-compiling (eventual target is RPi0 fwiw)
  • Device: Irrelevant (eventual targets is ssd1306)

Additional context
n/a

@maruel
Copy link
Member

maruel commented May 30, 2021

Thanks for the report, will check this ASAP.

@maruel
Copy link
Member

maruel commented May 30, 2021

I think it's because you are using a toolchain built with emulated floating point. Can you confirm?

@maruel maruel transferred this issue from periph/devices May 30, 2021
@maruel maruel changed the title devices v3.6.11 causes d2xx build failures on WSL2 d2xx cannot be cross compiled with CGO enabled with soft float May 30, 2021
@maruel
Copy link
Member

maruel commented May 30, 2021

Moved issue to where the problem lies.
Renamed issue with my current hypothesis.

Do you need to support RPi Zero / RPi1? If not, can you try to build with arm=7?

@maruel
Copy link
Member

maruel commented May 30, 2021

Maybe something like CCFLAG=-mfloat-abi=hard
I never cross compiled with CGO enabled myself, so I can't say for sure.
From what I read, all Raspberry Pis (including RPi0) support hard float. Sorry I missed in my previous comment that you did specify RPi Zero.

@maruel
Copy link
Member

maruel commented May 30, 2021

  • Got Ubuntu 20.04 on Windows 10
  • Ran:
wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.16.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
mkdir foo
cd foo
go mod init main
echo -e 'package main\nimport "periph.io/x/host/v3"\nfunc main() { host.Init() }' > main.go
go get periph.io/x/host/[email protected]
# Complains about gcc not found
sudo apt install gcc-arm-linux-gnueabihf
export CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARM=6 GOARCH=arm
go get periph.io/x/host/[email protected]
go build main.go

arm-linux-gnueabihf-gcc works for compilation. Can you try this instead of arm-linux-gnueabi-gcc and see if the executable runs? It'd be nice to add this to the website, it's quite an edge case but still it'd be nice to document.
Otherwise I can fallback to including the softfloat library but that would make it slower.

maruel added a commit to periph/bootstrap that referenced this issue May 31, 2021
It is much easier than I thought thanks to @lutzky who gave the initial
guidance at periph/d2xx#1

To choose your own compiler, set $CC before calling.

To disable cgo, set CGO_ENABLED=0 before calling.
@lutzky
Copy link
Author

lutzky commented May 31, 2021

To confirm this is not a WSL issue, I checked on a plain Ubuntu box (Ubuntu 20.10, kernel 5.8.0-48-generic #54-Ubuntu x86_64) - same output.

Building with gcc-arm-linux-gnueabihf: WAlthough the build does work, the executable fails to run on the target system. strace says the following on my full program (which tries to control an ssd1306):

[...]
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPC, si_addr=0x67222} ---
+++ killed by SIGILL +++
Illegal instruction

...and the following on the minimal program (which just does a host.Init()):

[...]
write(2, "fatal: systemstack called from u"..., 51fatal: systemstack called from unexpected goroutine) = 51
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++
Segmentation fault

The target system in question is a Raspberri Pi Zero-W running 5.10.17+ #1403 armv6l.

...this might mean that periph/bootstrap@288e17f is incorrect.

@maruel
Copy link
Member

maruel commented May 31, 2021

As an immediate workaround to unblock you, you can selectively load drivers to skip periph.io/x/host/v3/ftdi. Here's pseudo code:

import (
  "log"

  "periph.io/x/conn/v3/driver/driverreg"

  _ "periph.io/x/host/v3/bcm238x"
  _ "periph.io/x/host/v3/rpi"
  _ "periph.io/x/host/v3/sysfs"
)

func main() {
  if _, err := driverreg.Init(); err != nil {
    log.Fatal(err)
  }
  // ...
}

I'll do a test on a RPiZW later.

@maruel
Copy link
Member

maruel commented May 31, 2021

FTR, I did a test on a FT232h on a RPi3 thus it used the static library just fine. So it looks like bcm2385 specific.

@lutzky
Copy link
Author

lutzky commented May 31, 2021

To be clear, I'm not blocked, it's just a hobby project and v3.6.10 is perfectly fine. I just think it's super-useful for people to be able to cross-compile this stuff when targeting RPi0. Happy to help test solutions.

@maruel
Copy link
Member

maruel commented May 31, 2021

I want to fix this as I want to make sure that things work going forward. I just tested on a Raspberry Pi Zero Wireless on Raspbian Buster Linux raspberrypi-446b 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l GNU/Linux and confirmed that it segfaults. That surprised me.

Do you need cgo specifically for your project? I'm inclined to document that cgo is unsupported in this specific configuration as I can't imagine a reason someone would connect a FTDI chip on these... I'll add a build tag to optionally disable the driver, something like no_d2xx so at least there's an escape hatch going forward.

It's increasingly hard to buy a RPiZ and RPiZW. Many stores list them as out of stock or still limit to one board per order (or requires folks to buy a kit even when not needed). It's sad, I like the form factor.

@lutzky
Copy link
Author

lutzky commented May 31, 2021

Ah, interesting! I indeed do not need cgo for this project. I had it enabled because I cargo-culted my build script from another project which uses https://github.com/d2r2/go-dht (which does need cgo). While that particular project no longer uses a display (it exports to prometheus instead), it did previously use an ssd1306 display. So that would be an example of a project which would both requrire cgo and periph's ssd1306 library.

Indeed the worst part here is I don't think I'm using d2xx for anything, I had to look up what it's for. I think the cgo compatibility issue isn't new - just the dependency on d2xx. I apologize if I put this issue in the wrong repository.

I'm happy RPis are produced relatively near to my part of the world, pimoroni and pihut have plenty of stock; the form factor is indeed lovely.

@maruel
Copy link
Member

maruel commented Jun 1, 2021

Nothing in periph currently requires cgo beside https://periph.io/x/host/v3/ftdi. And only ftdi loads d2xx. You can use the ssd1306 package without cgo.

Commit a5d3841 includes the no_d2xx build tag to work around the problem. I'll do a release later and will roll into the other packages.

@maruel maruel closed this as completed Jun 1, 2021
@lutzky
Copy link
Author

lutzky commented Jun 1, 2021

Can confirm, building with -tag no_d2xx succeeds and runs on rpi-zero.

Readers might note that this required running the following first:

go get periph.io/x/[email protected]

Thank you for adding this functionality!

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

No branches or pull requests

2 participants