Raspberry Pi3 architecture

1,348 views
Skip to first unread message

Pablo Rozas-Larraondo

unread,
Feb 29, 2016, 7:07:27 PM2/29/16
to golang-nuts
I've just read about the new raspberry Pi3 which comes with a 64 bit processor. Does anyone know if this new version is compatible with the official Go linux/ARMv6 binary release? Is ARM Cortex-53 compatible with ARM v6?

Thanks,
Pablo

Dave Cheney

unread,
Feb 29, 2016, 7:26:27 PM2/29/16
to golang-nuts
All 64bit arm processors are ARMv8. Go has supported linux/arm64 since Go 1.5

Pablo Rozas-Larraondo

unread,
Feb 29, 2016, 8:01:35 PM2/29/16
to golang-nuts
Thanks for the clarification Dave. So, we can say that Go is now officially supported on Raspberries too! :-D

Dave Cheney

unread,
Feb 29, 2016, 8:23:38 PM2/29/16
to golang-nuts
I'll know by the end of the week hopefully, I just ordered my RPi3 last night.

I'm very confident that cross compilation will work, but building the go distro, ./all.bash will probably not work without some tweaks as the amount of ram the RPi3 comes with is not sufficient for a 32bit build, so a 64bit build sounds like a stretch.

Aram Hăvărneanu

unread,
Mar 1, 2016, 5:40:34 AM3/1/16
to Pablo Rozas-Larraondo, golang-nuts
Both the arm and arm64 Go ports work on arm64 little-endian Linux
devices, like the new Pi3. I recommend arm64.

Note that the arm64 port should work even with a 32-bit Linux
userland, like the Pi3 currently ships.

--
Aram Hăvărneanu

Fabian Wickborn

unread,
Mar 1, 2016, 6:47:03 AM3/1/16
to golang-nuts, p.rozas....@gmail.com
My Pi3 arrived a couple of hours ago. I installed the latest Raspbian image ot a SD Card and booted the Pi3 with it. After setting up networking and SSH pubkey auth I wanted to give Go a testdrive. It did not work out.

 ~/foo$ ls
main.go
~/foo$ cat main.go
package main

import "fmt"
import "runtime"

func main() {
        fmt.Println("Hello world", runtime.GOARCH, runtime.GOOS, runtime.GOROOT())
}
~/foo$ GOARCH=arm64 go build
~/foo$ file foo
foo: ELF 64-bit LSB  executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped
~/foo$ scp foo pi3:
foo                                                               100% 2335KB   2.3MB/s   00:01
~/foo$ ssh pi3 
pi@pi3:~ $ ./foo
-bash: ./foo: cannot execute binary file: Exec format error
pi@pi3:~ $ uname -a
Linux pi3 4.1.18-v7+ #846 SMP Thu Feb 25 14:22:53 GMT 2016 armv7l GNU/Linux


It seems that Raspbian still treats the Pi3 still as an armv7l, does this have any influence on the accepted ELF formats? Compiling with GOARM=7 GOARCH=arm works fine.

Thanks,
Fabian

Dave Cheney

unread,
Mar 1, 2016, 6:53:02 AM3/1/16
to golang-nuts, p.rozas....@gmail.com
That's disapointing, my RPi3 will be here next week (apparently). I'll take a look then, who knows what they have done with the userland.

Dave Cheney

unread,
Mar 1, 2016, 6:56:00 AM3/1/16
to golang-nuts, p.rozas....@gmail.com
Can you pipe /cat/cpuinfo into a gist and post it somewhere. Thanks.

Fabian Wickborn

unread,
Mar 1, 2016, 7:03:58 AM3/1/16
to golang-nuts

Aram Hăvărneanu

unread,
Mar 1, 2016, 7:17:31 AM3/1/16
to Fabian Wickborn, golang-nuts, Pablo Rozas-Larraondo
It appears that you have a 32-bit kernel. I am surprised this is the
default kernel. You need a 64-bit kernel with ELF64 support.

--
Aram Hăvărneanu

Fabian Wickborn

unread,
Mar 1, 2016, 7:24:39 AM3/1/16
to golang-nuts
Thanks, Aram! It's probably for backwards compatibility with previous boards. I used the Raspbian Jessie Lite image, and there is no distinguishing between the Pi versions when downloading that image.

Dave Cheney

unread,
Mar 1, 2016, 7:25:18 AM3/1/16
to golang-nuts
As aram noted, that looks a lot like a raspberry pi 2, BCM2709. Can you reboot and capture all the juicy stuff from dmesg.

Aram Hăvărneanu

unread,
Mar 1, 2016, 7:29:26 AM3/1/16
to Dave Cheney, golang-nuts
That is definitely a rPI 2. The rPI3 has a BCM2837, you have a BCM2709.

--
Aram Hăvărneanu

Konstantin Khomoutov

unread,
Mar 1, 2016, 7:32:02 AM3/1/16
to Fabian Wickborn, golang-nuts
I'm not at all an expert, but the output lists BCM2709 (which is
ARMv7) as the device's SoC, while Pi 3 appears to be based on BCM2837
whose family is BCM2710, which is ARMv8. I'm looking at the "Hardware
specification" section in [1].

1. https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi

Fabian Wickborn

unread,
Mar 1, 2016, 7:36:01 AM3/1/16
to golang-nuts
https://www.element14.com/community/community/raspberry-pi/blog/2016/02/29/the-most-comprehensive-raspberry-pi-comparison-benchmark-ever describes the same phenomenon, the Pi3 is detected as BCM2709.

dmesg lists the board ID as Pi3, I am going to upload a gist for that later. lscpu lists the speed with 1200MHz.

Aram Hăvărneanu

unread,
Mar 1, 2016, 7:55:58 AM3/1/16
to Fabian Wickborn, golang-nuts
So Linux lies in /proc/cpuinfo output. I guess you can't ever know
what Linux will do these days.

Anyway, please post the kernel configuration somewhere.

--
Aram Hăvărneanu

Fabian Wickborn

unread,
Mar 1, 2016, 8:05:22 AM3/1/16
to golang-nuts
I updated https://gist.github.com/fawick/d142633de52b31d0dade with the output from dmesg as well as /proc/config.gz

Dave Cheney

unread,
Mar 1, 2016, 8:09:37 AM3/1/16
to golang-nuts
Thanks. The best explanation I can see is the raspbian distribution is running a 64 bit processor in 32 bit mode, so you should treat this machine as GOARM=7. 

I can see why they would have done this, ARMv8 instructions are 32bit, twice as large as the normal thumb2 instruction set that ARMv6/7 distros use, and that will put a lot of pressure on the 1gb of ram in the machine. 

Aram Hăvărneanu

unread,
Mar 1, 2016, 8:10:57 AM3/1/16
to Fabian Wickborn, golang-nuts
I see. You need a 64-bit kernel. It's flabbergasting why they don't
ship a 64-bit kernel with a 32-bit userland.

--
Aram Hăvărneanu

Aram Hăvărneanu

unread,
Mar 1, 2016, 8:11:35 AM3/1/16
to Dave Cheney, golang-nuts
On Tue, Mar 1, 2016 at 2:09 PM, Dave Cheney <da...@cheney.net> wrote:
> I can see why they would have done this, ARMv8 instructions are 32bit, twice
> as large as the normal thumb2 instruction set that ARMv6/7 distros use, and
> that will put a lot of pressure on the 1gb of ram in the machine.

They could have shipped a 64-bit kernel with a 32-bit userland.

--
Aram Hăvărneanu

Dave Cheney

unread,
Mar 1, 2016, 8:15:44 AM3/1/16
to Aram Hăvărneanu, golang-nuts

Nah, I don't think so, the memory ranges reported early on are 32 bit. Same with /proc/cpuinfo

Aram Hăvărneanu

unread,
Mar 1, 2016, 8:17:13 AM3/1/16
to Dave Cheney, golang-nuts
On Tue, Mar 1, 2016 at 2:15 PM, Dave Cheney <da...@cheney.net> wrote:
> Nah, I don't think so, the memory ranges reported early on are 32 bit. Same
> with /proc/cpuinfo

No, I meant they *should have* shipped a 64-bit kernel with 32-bit
userland. That way you get all the compatibility with old software,
you use little memory, and you have the ability to run 64-bit
binaries.

--
Aram Hăvărneanu

Aldrin Leal

unread,
Mar 1, 2016, 8:18:40 AM3/1/16
to golang-nuts
It is. They want to maintain just a single raspbian image overall (Remember it's just the first 64-bit Pi, and it was surpassed by Pine 64 by a few weeks)
On Tue, Mar 1, 2016 at 7:24 AM, Fabian Wickborn <dsimf...@gmail.com> wrote:
Thanks, Aram! It's probably for backwards compatibility with previous boards. I used the Raspbian Jessie Lite image, and there is no distinguishing between the Pi versions when downloading that image.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Cheney

unread,
Mar 1, 2016, 8:19:05 AM3/1/16
to Aram Hăvărneanu, golang-nuts

No argument there, I cannot see how this odd arrangement would be less work in the long run.

Aram Hăvărneanu

unread,
Mar 1, 2016, 8:21:50 AM3/1/16
to Aldrin Leal, golang-nuts
On Tue, Mar 1, 2016 at 2:17 PM, Aldrin Leal <ald...@leal.eng.br> wrote:
> It is. They want to maintain just a single raspbian image overall (Remember
> it's just the first 64-bit Pi, and it was surpassed by Pine 64 by a few
> weeks)

They can ship the same image, and use 32-bit by default, while adding
a 64-bit kernel in the repository, so then users can just install it
easily, without having to compile it themselves.

--
Aram Hăvărneanu

mjy

unread,
Mar 1, 2016, 9:13:40 AM3/1/16
to golang-nuts
Am Dienstag, 1. März 2016 02:23:38 UTC+1 schrieb Dave Cheney:

I'm very confident that cross compilation will work, but building the go distro, ./all.bash will probably not work without some tweaks as the amount of ram the RPi3 comes with is not sufficient for a 32bit build, so a 64bit build sounds like a stretch.


I've been successfully building current devel versions every couple of days for a while now on a Pi 2 by simply changing this line in cmd/dist/util.go (from 4 to 2):

var maxbg = 2 /* maximum number of jobs to run at once */


-mjy 

Martin Capitanio

unread,
Mar 3, 2016, 12:01:04 PM3/3/16
to golang-nuts, ald...@leal.eng.br
I've got mine today :-)

Scraping the RPi forum reveals that actually loading the right kernel image
is not the problem. The GPU can load the right kernel
depending on hardware (currently they can load an ARMv6 and ARMv7 image).
You could already also switch the CPU in the AArch64 mode:
https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=137963

The bad news: their proprietary kernel parts are 32 bit only
and they don't want invest their time to fix that.  I don't believe you could
switch the CPU to AArch64 just for the Go runtime, also unless somebody
puts his C hat on and fixes their kernel, RPi3 remains just about 30% faster
AAarch32 RPi2 :(

RPi3:

go-tip version
go version devel +596df24 Thu Mar 3 09:09:16 2016 +0000 linux/arm

Board: 4 x ARMv7 cores available, ondemand governor (Pi3 rev 1.2, BCM2837 SoC with 1GB RAM by Sony)
Memory: 1008MB (split 976MB ARM, 32MB GPU) plus 953MB Swap
HW Block: |   ARM   |  Core  |  H264  |    SDRAM    |
Min Freq: |  600MHz | 250MHz |   0MHz |    450MHz   |
Max Freq: | 1200MHz | 400MHz | 300MHz |    450MHz   |
Voltages: |         0, 1.3625V        | +1, 1.2250V |
   Other: temp_limit=85
Firmware: Feb 25 2016 14:25:47, version dea971b793dd6cf89133ede5a8362eb77e4f4ade (clean) (release)

cd /opt/gotip/src
git clean -fdx ..
export GOROOT_BOOTSTRAP=/opt/go16
/usr/bin/time -v  ./all.bash

...

##### ../misc/cgo/testshared
ok      _/opt/gotip/misc/cgo/testshared    74.534s
##### ../test/bench/go1
ok      _/opt/gotip/test/bench/go1    12.125s

ALL TESTS PASSED

    Command being timed: "./all.bash"
    User time (seconds): 4362.70
    System time (seconds): 262.92
    Percent of CPU this job got: 310%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 24:48.00
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 321084
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 310
    Minor (reclaiming a frame) page faults: 23412638
    Voluntary context switches: 3680464
    Involuntary context switches: 2845769
    Swaps: 0
    File system inputs: 199648
    File system outputs: 631912
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0



RPi2:

Board: 4 x ARMv7 cores available, ondemand governor (Pi2 Model B rev 1.1, BCM2836 SoC with 1GB RAM by Sony)
Memory: 1008MB (split 976MB ARM, 32MB GPU) plus 953MB Swap
HW Block: |   ARM   |  Core  |  H264  |    SDRAM    |
Min Freq: |  600MHz | 250MHz |   0MHz |    483MHz   |
Max Freq: | 1000MHz | 500MHz | 300MHz |    483MHz   |
Voltages: |         0, 1.3125V        | +2, 1.2500V |
   Other: temp_limit=85
Firmware: Feb 25 2016 14:25:47, version dea971b793dd6cf89133ede5a8362eb77e4f4ade (clean) (release)

...

##### ../misc/cgo/testshared
ok      _/opt/gotip/misc/cgo/testshared    116.848s
##### ../test/bench/go1
ok      _/opt/gotip/test/bench/go1    23.867s

ALL TESTS PASSED
    Command being timed: "./all.bash"
    User time (seconds): 6233.10
    System time (seconds): 505.62
    Percent of CPU this job got: 315%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 35:35.45
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 317840
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 492
    Minor (reclaiming a frame) page faults: 23409604
    Voluntary context switches: 4294535
    Involuntary context switches: 3438746
    Swaps: 0
    File system inputs: 286568
    File system outputs: 632328
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0

str...@gmail.com

unread,
Mar 14, 2016, 4:00:36 PM3/14/16
to golang-nuts
Dear Dave,

I plan to have golang 1.6 on my fresh rpi3.
Could you please give me a hint how to do it in most optimal way?

Best regards,
Sz

Dave Cheney

unread,
Mar 14, 2016, 4:12:50 PM3/14/16
to golang-nuts, str...@gmail.com
Hello,

That's easy, use the official linux/arm tarball from https://golang.org/

Thanks
Reply all
Reply to author
Forward
0 new messages