How to Add customized chirpstack-application-server binary to Gateway OS

Hi @brocaar,

I have modified the code of chirpstack-application-server according to our requirements & have build a new binary.

In Gateway OS, I tried replacing the binary present in /opt/chirpstack-application-server/chirpstack-application-server with the binary that I created but when I try to execute it, it showed *error: cannot execute binary. illegal exec format*

Can you please give insights on how to add this new & customized chirpstack-application-server binary to chirpstack-gateway-os ?

Thank you!

@pooja.mittal, how you are building the new binary? Which type of architecture? Based on your information it looks like the binary generated won’t work if you generated using another type of architecture that it’s not arm. As Chirpstack Gateway OS will be installed in a Pi that contains an ARM core, then you must build application-server for that architecture.

The way Chirpsack Gateway OS includes in application-server can be inspected in the chirpstack-application-server recipe folder:

From there you can observe that application-server package will be build from this SRC_URI https://artifacts.chirpstack.io/downloads/chirpstack-application-server/chirpstack-application-server_${PV}_linux_armv5.tar.gz where ${PV} is reference to 3.8.0 ialong with other local files as the .toml configuration you may use. Hence, in this sense, what I could recommend is instead of fetching from the artifacts that @brocaar provides, create your own recipe overwriting the application-server one so that Yocto can generate the ipk package and then install that in your OS instance with opkg.

1 Like

Hi, @sophiekovalevsky, thank you for such a quick reply.

You’re right, I was not compiling binary for armv7 but rather for x86_64 GNU/Linux.

But as you said,

for this to happen, I still need to add a chirpstack-application-server_3.8.0_linux_armv7.tar.gz , (although modified/customized) to the chirpstack-application-server_3.8.0.bb file.

How would I build a customized binary for armv7? Is there chirpstack-application-server source code for armv7?

Or, can we cross compile chirpstack-application-server from amd64 to armv7?

GOOS=linux GOARCH=amd64 GOARM=7 go build $(GO_EXTRA_BUILD_ARGS) -ldflags "-s -w -X main.version=$(VERSION)" -o build/chirpstack-application-server cmd/chirpstack-application-server/main.go

1 Like

@pooja.mittal, there are several ways you can do this. However, the fastest and simplest solution that I can think of would be cross-compile from your hostname and then provide to Yocto the final artifacts.

In this sense, you can make use of go-releaser. Under the hood, it will manage the flags that you will need to compile application-server for ARM along with other extra great features that comes with it. There is a .goreleaser.yml file that you can analyze as a starting point.

Once you have generated the pre-compiled binary, then provide the path where Yocto should look for this source in SRC_URI and that’s it. Hope that helps. :slight_smile:

1 Like

Thank you so much @sophiekovalevsky and @sagarpatel, your answers helped me resolve my problems. :slightly_smiling_face:

This topic can now be considered closed !

3 Likes

@pooja.mittal, so glad that it worked out.

1 Like