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

x/exp/io/spi: SPI on mipsle uses wrong IOCTL #26026

Closed
svenschwermer opened this issue Jun 23, 2018 · 5 comments
Closed

x/exp/io/spi: SPI on mipsle uses wrong IOCTL #26026

svenschwermer opened this issue Jun 23, 2018 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@svenschwermer
Copy link

What version of Go are you using (go version)?

go version go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="mipsle"
GOBIN=""
GOCACHE="/Users/sven/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="linux"
GOPATH="/Users/sven/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
GOMIPS="softfloat"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -mabi=32 -march=mips32 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_j/ly_hzzjx5vjd2qbzd8qd2bch0000gn/T/go-build245470376=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I used golang.org/x/exp/io/spi to write to an SPI device on a MIPS (32 bit, little endian) target.

The IOCTL used for writing the data (in spi.(*devfsConn).Tx) is wrong. The returned error message is inappropriate ioctl for device. strace prints ioctl(3, _IOC(_IOC_READ, 0x6b, 0, 0x20), 0x8c33efc) = -1 ENOTTY (Not a tty) instead of ioctl(3, SPI_IOC_MESSAGE(32), 0x8933f20) = 2.

If I'm not mistaken, the IOCTLs are offset on MIPS targets. See https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/ioctl.h and https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/ioctl.h#L32

@ALTree ALTree changed the title SPI on mipsle uses wrong IOCTL x/exp/io/spi: SPI on mipsle uses wrong IOCTL Jun 23, 2018
@gopherbot gopherbot added this to the Unreleased milestone Jun 23, 2018
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 23, 2018
@ianlancetaylor
Copy link
Contributor

CC @rakyll

@svenschwermer
Copy link
Author

Here is a proposal for a fix: svenschwermer/golang.org-x-exp@8026287
This should also fix #16551.

@rakyll
Copy link
Contributor

rakyll commented Jul 9, 2018

/cc @maruel

@maruel
Copy link
Contributor

maruel commented Jul 23, 2018

Thanks. I filed google/periph#263 to correctly handle this in periph.io.

We don't plan to modify exp/io anymore.

@ALTree
Copy link
Member

ALTree commented Sep 7, 2020

Since x/exp/io is no longer developed and essentially frozen, I'm closing this issue.

@ALTree ALTree closed this as completed Sep 7, 2020
@golang golang locked and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants