developing applications for beagle bone black, raspberry pi and soc single board arm computers with...
DESCRIPTION
Slides presented at October 2014 Seattle Go MeetupTRANSCRIPT
![Page 1: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/1.jpg)
RyanRyanCoxasciiarmor.com
Building Go applications for SoC ARM boards
Gophers, Beagles, Hummingboards and Pi
![Page 2: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/2.jpg)
ARM
![Page 3: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/3.jpg)
![Page 4: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/4.jpg)
https://stackoverflow.com/questions/14794460/how-does-the-arm-architecture-differ-from-x86
![Page 5: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/5.jpg)
![Page 6: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/6.jpg)
ARM Holdings plcStrategic Report 2013
2
O PERATIO NAL HIGHLIGHTS
ACHIEVING MO RE
10 billion ARM-based chips ARM’s customers reported that they had shipped more than 10 billion ARM-based chips into everything from phones and tablets to smart sensors and servers. This takes the cumulative total of ARM-based chips shipped to over 50 billion
400 million ARM-based chips with MaliTM graphics ARM’s Mali graphics processor brings games and user interfaces to life with stunning 3D graphics
121 licences 50 companies signed 121 licences. By the end of 2013 ARM has signed more than 1,000 licences with 348 companies.
1st ARMv8-based chip shipped The ARMv8-A architecture adds 64-bit computing, amongst other advances, and is suitable for a wide range of devices from mobile phones to servers.
1st ARM big.LITTLETM technology-based chip shipped big.LITTLE technology further improves performance in energy-ef cient computing devices, and first shipped in the Samsung Exynos family of chips
ARM hired net 441 full-time employees in 2013 More than 70% of these new employees joined our R&D teams
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
![Page 7: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/7.jpg)
ARM Holdings plcStrategic Report 2013
2
O PERATIO NAL HIGHLIGHTS
ACHIEVING MO RE
10 billion ARM-based chips ARM’s customers reported that they had shipped more than 10 billion ARM-based chips into everything from phones and tablets to smart sensors and servers. This takes the cumulative total of ARM-based chips shipped to over 50 billion
400 million ARM-based chips with MaliTM graphics ARM’s Mali graphics processor brings games and user interfaces to life with stunning 3D graphics
121 licences 50 companies signed 121 licences. By the end of 2013 ARM has signed more than 1,000 licences with 348 companies.
1st ARMv8-based chip shipped The ARMv8-A architecture adds 64-bit computing, amongst other advances, and is suitable for a wide range of devices from mobile phones to servers.
1st ARM big.LITTLETM technology-based chip shipped big.LITTLE technology further improves performance in energy-ef cient computing devices, and first shipped in the Samsung Exynos family of chips
ARM hired net 441 full-time employees in 2013 More than 70% of these new employees joined our R&D teams
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
10Bn
400M
121
1st
1st
64Bit
441
20nm
![Page 8: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/8.jpg)
https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures
Manufacturer Freescale
SoC i.MX6
ARMFamily Cortex-A
ARMCore A9
ARMArchitecture ARMv7
![Page 9: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/9.jpg)
Designer Apple
Manufacturer Samsung
SoC A5
ARMFamily Cortex-A
ARM Architecture ARMv7
ARMCore A9
![Page 10: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/10.jpg)
Single Board Computers
![Page 11: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/11.jpg)
Why?• Cost• Form Factor• Power• Access to IO• Linux• Familiar tool chain• Fanless ( quiet )• Prototyping for custom fab
https://www.kickstarter.com/projects/partyrobotics/bartendro-a-cocktail-dispensing-robot
![Page 12: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/12.jpg)
![Page 13: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/13.jpg)
Arduino Raspberry Pi B+ BBB Rev C HummingBoard i2ex
Arch 8bit 32bit 32bit 32bit
Processor AtmelATmega328
Broadcom BCM2835 ARM11
TI AM335xCortex A8
Freescalei.MX6 Dual A9
Cores 1 1 1 2
RAM 2k 512M 512M 1GB
ROM 32k microSD 4GB microSD
Clock 8Mhz 700Mhz 1GHz 1Ghz
GPIO 14 27 69 8
USB --- 4 1 2
Cost $30 $40 $55 $100
![Page 14: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/14.jpg)
![Page 15: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/15.jpg)
http://codeascraft.com/2014/06/24/device-lab-checkout-rfid-style/
![Page 16: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/16.jpg)
http://www.digitalspirit.org/blog/index.php/post/2014/09/30/Le-poulailler-connect%C3%A9
More Projects: http://hackaday.io/projects/tag/raspberry%20pi/page/8
Le poulailler connecté
• Prise de photos infrarouges, détection des œufs• Prise de température / luminosité / capteur mouvement / capteurs d'ouverture• Surveillance de la température, de la tension d'alimentation et du courant consommé• Alertes via Twitter et SMS (API Free Mobile)
![Page 17: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/17.jpg)
Go Tool Chain
![Page 18: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/18.jpg)
Why Go for ARM SoC?• Excellent cross compilation tool chain• Native compilation / No VM• Diverse and growing libraries usable as-is• Support for unsigned ints ( uint8 / uint16 ... )
![Page 19: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/19.jpg)
~/armtest $ GOARCH=386 GOOS=linux go build~/armtest $ file armtestarmtest: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
~/armtest $ GOARCH=amd64 GOOS=darwin go build~/armtest $ file armtestarmtest: Mach-O 64-bit executable x86_64
Parallellize builds and more:https://github.com/mitchellh/gox
brew install go --cross-compile-common or --cross-compile-all
$ hg clone -u release https://code.google.com/p/go$ cd go/src$ ./all.bash
![Page 20: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/20.jpg)
~/armtest $ GOARCH=amd64 GOOS=windows go build~/armtest $ file armtest.exearmtest.exe: PE32+ executable for MS Windows (console) Mono/.Net assembly
~/armtest $ GOARCH=arm GOOS=linux GOARM=7 go build~/armtest $ file armtestarmtest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped
https://golang.org/doc/install/source#environment
![Page 22: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/22.jpg)
![Page 23: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/23.jpg)
BL ,math/rand.Float32(SB) BL ,_sfloat(SB) MOVF 4(R13),F2 MOVF F2,"".f1-48(SP) PCDATA $1,$0 BL ,math/rand.Float32(SB) BL ,_sfloat(SB) MOVF "".f1-48(SP),F4 MOVF 4(R13),F2 ADDF F2,F4,F1 MOVF F1,F3 MULF F2,F4,F1 MOVF F1,F2
BL,math/rand.Float32(SB)...MOVF 4(R13),F2MOVF F2,"".f1-48(SP)PCDATA $1,$0BL,math/rand.Float32(SB)...MOVF "".f1-48(SP),F4MOVF 4(R13),F2ADDF F2,F4,F1MOVF F1,F3MULF F2,F4,F1MOVF F1,F2
$ GOOS=linux GOARCH=arm GOARM=5 go build -gcflags -S 2> arm5.s$ GOOS=linux GOARCH=arm GOARM=7 go build -gcflags -S 2> arm7.s
![Page 24: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/24.jpg)
http://plan9.bell-labs.com/sys/doc/asm.htmlhttp://www.doxsey.net/blog/go-and-assembly/
https://golang.org/doc/asm
The most important thing to know about Go's assembler is that it is not a direct representation of the underlying machine ... the compiler emits a kind of incompletely defined instruction set, in binary form, which the linker then completes. ... In general, machine-specific operations tend to appear as themselves, while more general concepts like memory move and subroutine call and return are more abstract. The details vary with architecture, and we apologize for the imprecision; the situation is not well-defined.
![Page 25: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/25.jpg)
bl 57dc4 <math/rand.Float32> bl 40744 <_sfloat> vldr s8, [sp, #36] ; 0x24 vldr s4, [sp, #4] vadd.f32 s2, s8, s4 vmov.f32 s6, s2 vmul.f32 s2, s8, s4 vmov.f32 s4, s2 vmov.f32 s10, s6
bl 531c4 <math/rand.Float32>...vldr s8, [sp, #36] ; 0x24vldr s4, [sp, #4]vadd.f32 s2, s8, s4vmov.f32 s6, s2vmul.f32 s2, s8, s4vmov.f32 s4, s2vmov.f32 s10, s6
$ gobjdump -D -s xv5 > 5.s$ gobjdump -D -s xv7 > 7.s
![Page 26: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/26.jpg)
BuildflagsUse to specify• integration / unit tests• architecture / OS• platform ( BBB, Rpi,. .. )
// +build bbb
$ go build -tag bbb
// +build linux darwin
// +build 386
(linux OR darwin) AND 386
http://golang.org/pkg/go/build/
![Page 27: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/27.jpg)
embd
![Page 28: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/28.jpg)
http://www.thoughtworks.com/insights/blog/introducing-embd-superheroic-embedded-programming-frameworkhttps://www.youtube.com/watch?v=cAh3pyHJXxQ&list=UUogI7Xgvtd8cDMKkwj0p47g
![Page 29: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/29.jpg)
• GPIO• PWM• i2c• SPI• Sensors• Platform• MIT License• Idiomatic• Docs / Examples• Concurrent
![Page 30: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/30.jpg)
![Page 31: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/31.jpg)
i2c
![Page 32: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/32.jpg)
Sending 10101010 plus ack 0http://support.saleae.com/hc/en-us/articles/200730905-Learn-I2C-Inter-Integrated-Circuit
The original spec allowed for only 100kHz communications, and provided only for 7-bit addresses, limiting the number of devices on the bus to 112 (there are several reserved addresses, which will never be used for valid I2C addresses). In 1992, the first public specification was published, adding a 400kHz fast-mode as well as an expanded 10-bit address space.
![Page 33: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/33.jpg)
![Page 34: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/34.jpg)
i2c Driver Creation • Get a breakout board• Find datasheet• Inspect drivers for other platforms ( warning:
licenses )• Determine subset of features to implement• Setup Breadboard• Verify functionality via i2cdetect / i2cget / i2cset• Code up in Go
![Page 35: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/35.jpg)
architecture
HardwareHardware
InterfaceInterface
ApplicationApplication
Josh Bleecher - https://www.youtube.com/watch?v=a4BQRUpQoe8
No syscallsNo IOCTLsNo cgo
+ kmods
Standard IPC mechanismsSockets
GO RPCZeroMQ
Protocol BuffersThrift OS / KernelOS / Kernel
Custom PCBCOTS
embdgobotcustom
![Page 36: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/36.jpg)
ex: litebrite
![Page 37: Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with Go](https://reader038.vdocuments.mx/reader038/viewer/2022110122/55988fb91a28ab4b578b4590/html5/thumbnails/37.jpg)
Link Dumphttps://www.sparkfun.com/http://adafruit.com/http://hackaday.com/https://www.tindie.com/http://www.amazon.com/Practical-Electronics-Inventors-Third-Edition-
ebook/dp/B00BAR2YGKhttps://www.youtube.com/watch?v=GJX0BRUagCg