cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dima2882
Explorer
Explorer
9,016 Views
Registered: ‎03-26-2010

Running Go on Petalinux

Jump to solution
Hi all,

Has anyone successfully run Go - golang - scripts on Petalinux? What's involved in cross-compiling something like that to Petalinux 2014.4?

Thanks!
0 Kudos
1 Solution

Accepted Solutions
rfs613
Scholar
Scholar
16,418 Views
Registered: ‎05-28-2013
It works quite well in fact. Just set GOARCH=arm, and optionally GOARM=7. See http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1 or http://www.goinggo.net/2013/10/cross-compile-your-go-programs.html

The golang compiler produces static binaries, which run nicely on the ARM processor. The only challenge is that the binaries are large (hello world comes in around 8MB) which can be an issue if you only have 16MB of QSPI flash. But from an SD card or USB stick it is workable.

View solution in original post

0 Kudos
4 Replies
balkris
Xilinx Employee
Xilinx Employee
8,978 Views
Registered: ‎08-01-2008
I believe this is not supported yet
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos
rfs613
Scholar
Scholar
16,419 Views
Registered: ‎05-28-2013
It works quite well in fact. Just set GOARCH=arm, and optionally GOARM=7. See http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1 or http://www.goinggo.net/2013/10/cross-compile-your-go-programs.html

The golang compiler produces static binaries, which run nicely on the ARM processor. The only challenge is that the binaries are large (hello world comes in around 8MB) which can be an issue if you only have 16MB of QSPI flash. But from an SD card or USB stick it is workable.

View solution in original post

0 Kudos
rfs613
Scholar
Scholar
8,905 Views
Registered: ‎05-28-2013
A small correction: the size of "hello world" with the current v1.4.2 golang compiler is about 1.6MB when compiled for ARM. Looks like they've managed to shrink the images a bit.
0 Kudos
dima2882
Explorer
Explorer
8,889 Views
Registered: ‎03-26-2010

@rfs613

 go/bin/linux_arm
I went through Chaney's guide and build a cross-compile environment. The ~/go/bin/linux_arm location now has the executables to build the ARM apps on the x86_64 host. I compiled a hello world - that worked when tested, and was cross-compiled to linux-arm as shown in the file properties - but this immediatly segfaulted on the Zedboard running PetaLinux.
 
I realized that my FTP client was silently changing the file, even though it should have been binary. Sending with ftp directly via command line fixed the problem.
 
Thanks rfs613 - knowing that running Go was possible was enough to get it going on my system.
0 Kudos