Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Board ARM Computers with...

Preview:

DESCRIPTION

Slides presented at October 2014 Seattle Go Meetup

Citation preview

RyanRyanCoxasciiarmor.com

ryan.a.cox@gmail.com

Building Go applications for SoC ARM boards

Gophers, Beagles, Hummingboards and Pi

ARM

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

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

https://en.wikipedia.org/wiki/List_of_ARM_microarchitectures

Manufacturer Freescale

SoC i.MX6

ARMFamily Cortex-A

ARMCore A9

ARMArchitecture ARMv7

Designer Apple

Manufacturer Samsung

SoC A5

ARMFamily Cortex-A

ARM Architecture ARMv7

ARMCore A9

Single Board Computers

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

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

http://codeascraft.com/2014/06/24/device-lab-checkout-rfid-style/

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)

Go Tool Chain

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 ... )

~/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

~/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

https://code.google.com/p/go-wiki/wiki/GoArm

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

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.

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

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/

embd

http://www.thoughtworks.com/insights/blog/introducing-embd-superheroic-embedded-programming-frameworkhttps://www.youtube.com/watch?v=cAh3pyHJXxQ&list=UUogI7Xgvtd8cDMKkwj0p47g

• GPIO• PWM• i2c• SPI• Sensors• Platform• MIT License• Idiomatic• Docs / Examples• Concurrent

i2c

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.

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

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

ex: litebrite

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

THANK YOU

RyanRyanCoxasciiarmor.com

ryan.a.cox@gmail.com