gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 27 forks source link

exit status 1 #15

Closed rgl closed 4 years ago

rgl commented 4 years ago

Exits with exit status 1 without any clue of what might be wrong:

$ gokr-packer -overwrite_boot=/tmp/boot.fat -overwrite_root=/tmp/root.fat github.com/gokrazy/hello
2020/06/20 09:23:36 packer.go:345: installing [github.com/gokrazy/hello]
2020/06/20 09:23:36 gotool.go:68: getting incomplete packages [github.com/gokrazy/gokrazy/cmd/dhcp github.com/gokrazy/gokrazy/cmd/ntp github.com/gokrazy/hello github.com/gokrazy/gokrazy github.com/gokrazy/kernel github.com/gokrazy/firmware]
2020/06/20 09:26:00 write.go:149: writing boot file system
2020/06/20 09:26:00 packer.go:793: exit status 1

My go environment is:

$ go version
go version go1.14.2 linux/amd64

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/rgl/.cache/go-build"
GOENV="/home/rgl/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/rgl/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/rgl/Applications/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/rgl/Applications/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build478674939=/tmp/go-build -gno-record-gcc-switches"
stapelberg commented 4 years ago

Can you update to commit 09a065cae0c7eb715ec86cc7d791c800b84a9bc4 and try again please?

rgl commented 4 years ago

Its now:

$ gokr-packer   -overwrite_boot=/tmp/boot.fat   -overwrite_root=/tmp/root.fat   github.com/gokrazy/hello
2020/06/20 09:58:43 packer.go:345: installing [github.com/gokrazy/hello]
2020/06/20 09:58:46 write.go:149: writing boot file system
2020/06/20 09:58:46 packer.go:793: [go list -f {{ .Dir }} github.com/gokrazy/rpi-eeprom]: exit status 1
stapelberg commented 4 years ago

Are you not using Go module mode yet? If no, you may need to manually go get github.com/gokrazy/rpi-eeprom first.

rgl commented 4 years ago

go 1.14 shouldn't use that mode automatically?

note that I'm not using git clone for getting the repo, as that's not mentioned at https://github.com/gokrazy/gokrazy readme.

stapelberg commented 4 years ago

Please see https://gokrazy.org/quickstart/ for instructions.

rgl commented 4 years ago

Maybe you should also include the command outputs in https://github.com/gokrazy/tools/commit/09a065cae0c7eb715ec86cc7d791c800b84a9bc4?

stapelberg commented 4 years ago

Done in commit faba15fa0802e25d32208d86f401e3a6ba742d2c

rgl commented 4 years ago

Its kinda odd putting that directly into gokr-packer stderr because stdout does not have the same treatment. What I meant was, it should be in go error somehow. Something like (warn: I didn't try this):

    b, err := cmd.Output()
    if err != nil {
        return "", fmt.Errorf("%v: %v output: %v", cmd.Args, err, b)

Or even wrapped in a second error using go1.13-errors wrap?

BTW, the quick start guide should be integrated in the https://github.com/gokrazy/gokrazy repo README or should be explicitly mentioned from there, as it makes the first time user experience a lot smoother.

The quick start guide starts with a somewhat cryptic command to initialize a go.mod. As a first time user I have no idea of what I'm doing and the quick start / readme should put me in the happy path as fast as possible. I would modify the quick start to something alike:

  1. install go
  2. mkdir hello && cd hello && go mod init hello
  3. go get -u github.com/gokrazy/tools/cmd/gokr-packer (or download from the github releases page?)
  4. gokr-packer -overwrite=gokrazy.img -target_storage_bytes=1153441792 github.com/gokrazy/hello github.com/gokrazy/serial-busybox
  5. burn gokrazy.img to an sd-card
  6. boot the pi and watch its serial port (having a text message in the hdmi port would be nice too)

IMHO, having it generate an image instead of directly burning to the sd-card device is a more normal approach for pi users (and it does not require root). After seeing gokrazy working, the user will read the rest of the documentation and will figure out the other ways to create the sd-card.

Can we also have a target_storage_size argument that accepts human sizes (e.g. 2g)?

stapelberg commented 4 years ago

Its kinda odd putting that directly into gokr-packer stderr because stdout does not have the same treatment

And it shouldn’t. But stderr is something we plumb through in all the other exec calls, too, so this change just makes that consistent. I think it’s perfectly fine to do.

BTW, the quick start guide should be integrated in the https://github.com/gokrazy/gokrazy repo

Done.

I updated the quickstart guide in commit 5dbb7728250939c7db3744bca41ea7394f6aff91, thanks for your suggestions.

IMHO, having it generate an image instead of directly burning to the sd-card device is a more normal approach for pi users (and it does not require root)

Having a single command to fully overwrite an SD card is an explicit goal of gokrazy. At least one of the various ways the packer can do privilege elevation tends to work in practice, and I really prefer this process over dealing with SD card images yourself.

Can we also have a target_storage_size argument that accepts human sizes (e.g. 2g)?

It’s easy enough in any shell to specify e.g. $((2*1024*1024*1024)), and that nicely documents whether 2 GiB or 2 GB are meant.

rgl commented 4 years ago

Go it working :-)

But for some reason ntp is failing with:

  1970/01/01 01:00:03 gokrazy: attempt 0, starting [/gokrazy/ntp]
  1970/01/01 01:00:03 ntp.go:51: setting time failed: lookup 0.gokrazy.pool.ntp.org on [::1]:53: read udp [::1]:55262->[::1]:53: read: connection refused
  1970/01/01 01:00:03 privdrop.go:87: exit status 1
  1970/01/01 01:00:03 gokrazy: exit status 1
  1970/01/01 01:00:04 gokrazy: attempt 1, starting [/gokrazy/ntp]
  1970/01/01 01:00:04 ntp.go:51: setting time failed: lookup 0.gokrazy.pool.ntp.org on [::1]:53: read udp [::1]:41891->[::1]:53: read: connection refused
  1970/01/01 01:00:04 privdrop.go:87: exit status 1
  1970/01/01 01:00:04 gokrazy: exit status 1
stapelberg commented 4 years ago

Glad to hear you got it working! Does ntp not eventually recover after the network becomes available?

You should see the timestamps start working at some point in the hello world process.

rgl commented 4 years ago

Ah it does recover! The ntp service never writes a message with the correct date (maybe it should the first time it updates the time?), but hello world does!

rgl commented 4 years ago

Have you noticed the Kernel parameter elevator= does not have any effect anymore. warning?

[    0.000000] Kernel command line: earlyprintk console=tty1 video=HDMI-A-1:1680x1050M@60 dma.dmachans=0x71f5 bcm2709.boardrev=0xc03111 bcm2709.serial=0xf2c24e9c bcm2709.uart_clock=48000000 bcm2709.disk_led_gpio=42 bcm2709.disk_led_active_low=0 smsc95xx.macaddr=DC:A6:32:27:F5:46 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=ttyAMA0,115200 root=PARTUUID=2e18c40c-02 init=/gokrazy/init elevator=deadline rootwait panic=10 panic_on_oops=1
[    0.000000] Kernel parameter elevator= does not have any effect anymore.
stapelberg commented 4 years ago

Ah it does recover! The ntp service never writes a message with the correct date (maybe it should the first time it updates the time?), but hello world does!

ntp now logs a message since https://github.com/gokrazy/gokrazy/commit/546057ad9b1d97c49ae3bc710bbfc277836af0de

Have you noticed the Kernel parameter elevator= does not have any effect anymore. warning?

Thanks, removed in https://github.com/gokrazy/kernel/commit/a472ddd489750fcb7bb022a88a74f1428b6c310a