tamago | https://github.com/usbarmory/tamago
Copyright (c) WithSecure Corporation
Andrea Barisani
andrea@inversepath.com
Andrej Rosano
andrej@inversepath.com
TamaGo is a framework that enables compilation and execution of unencumbered Go applications on bare metal AMD64/ARM/RISC-V processors.
The usbarmory package provides support for the USB armory Single Board Computer.
For more information about TamaGo see its repository and project wiki.
For the underlying driver support for this board see package imx6ul.
The package API documentation can be found on pkg.go.dev.
SoC | Board | SoC package | Board package |
---|---|---|---|
NXP i.MX6ULZ/i.MX6UL | USB armory Mk II | imx6ul | usbarmory/mk2 |
NXP i.MX6ULL/i.MX6UL | USB armory Mk II LAN | imx6ul | usbarmory/mk2 |
Go applications are simply required to import, the relevant board package to ensure that hardware initialization and runtime support take place:
import (
_ "github.com/usbarmory/tamago/board/usbarmory/mk2"
)
Build the TamaGo compiler (or use the latest binary release):
wget https://github.com/usbarmory/tamago-go/archive/refs/tags/latest.zip
unzip latest.zip
cd tamago-go-latest/src && ./all.bash
cd ../bin && export TAMAGO=`pwd`/go
Go applications can be compiled as usual, using the compiler built in the previous step, but with the addition of the following flags/variables:
GOOS=tamago GOARM=7 GOARCH=arm ${TAMAGO} build -ldflags "-T 0x80010000 -R 0x1000" main.go
An example application, targeting the USB armory Mk II platform, is available.
The following build tags allow application to override the package own definition of external functions required by the runtime:
linkramsize
: excluderamSize
frommem.go
linkprintk
: excludeprintk
fromconsole.go
The example application
provides reference usage and a Makefile target for automatic creation of an ELF
as well as imx
image for flashing.
Follow these instructions
using the built imx
image.
The standard output can be accessed through the
debug accessory
and the following picocom
configuration:
picocom -b 115200 -eb /dev/ttyUSB2 --imap lfcrlf
The application can be debugged with GDB over JTAG using openocd
(version >
0.11.0) and the following gdbinit
debugging helper:
target remote localhost:3333
set remote hardware-breakpoint-limit 6
set remote hardware-watchpoint-limit 4
Example:
# start openocd daemon
openocd -f interface/ftdi/jtagkey.cfg -f target/imx6ul.cfg -c "adapter speed 1000"
# connect to the OpenOCD command line
telnet localhost 4444
# debug with GDB
arm-none-eabi-gdb -x gdbinit example
Hardware breakpoints can be set in the usual way:
hb ecdsa.Verify
continue
The target can be executed under emulation as follows:
qemu-system-arm \
-machine mcimx6ul-evk -cpu cortex-a7 -m 512M \
-nographic -monitor none -serial null -serial stdio \
-kernel example -semihosting
The emulated target can be debugged with GDB by adding the -S -s
flags to the
previous execution command, this will make qemu waiting for a GDB connection
that can be launched as follows:
arm-none-eabi-gdb -ex "target remote 127.0.0.1:1234" example
Breakpoints can be set in the usual way:
b ecdsa.Verify
continue
tamago | https://github.com/usbarmory/tamago
Copyright (c) WithSecure Corporation
These source files are distributed under the BSD-style license found in the LICENSE file.
The TamaGo logo is adapted from the Go gopher designed by Renee French and licensed under the Creative Commons 3.0 Attributions license. Go Gopher vector illustration by Hugo Arganda.