github.com/f-secure-foundry/tamago@v0.0.0-20220307101044-d73fcdd7f11b/board/nxp/mx6ullevk/README.md (about) 1 TamaGo - bare metal Go for ARM SoCs - MCIMX6ULL-EVK support 2 =========================================================== 3 4 tamago | https://github.com/f-secure-foundry/tamago 5 6 Copyright (c) F-Secure Corporation 7 https://foundry.f-secure.com 8 9 ![TamaGo gopher](https://github.com/f-secure-foundry/tamago/wiki/images/tamago.svg?sanitize=true) 10 11 Authors 12 ======= 13 14 Andrea Barisani 15 andrea.barisani@f-secure.com | andrea@inversepath.com 16 17 Andrej Rosano 18 andrej.rosano@f-secure.com | andrej@inversepath.com 19 20 Introduction 21 ============ 22 23 TamaGo is a framework that enables compilation and execution of unencumbered Go 24 applications on bare metal ARM System-on-Chip (SoC) components. 25 26 The [mx6ullevk](https://github.com/f-secure-foundry/tamago/tree/master/board/nxp/mx6ullevk) 27 package provides support for the [MCIMX6ULL-EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/evaluation-kit-for-the-i-mx-6ull-and-6ulz-applications-processor:MCIMX6ULL-EVK) development board. 28 29 Documentation 30 ============= 31 32 For more information about TamaGo see its 33 [repository](https://github.com/f-secure-foundry/tamago) and 34 [project wiki](https://github.com/f-secure-foundry/tamago/wiki). 35 36 For the underlying driver support for this board see package 37 [imx6](https://github.com/f-secure-foundry/tamago/tree/master/soc/imx6). 38 39 The package API documentation can be found on 40 [pkg.go.dev](https://pkg.go.dev/github.com/f-secure-foundry/tamago). 41 42 Supported hardware 43 ================== 44 45 | SoC | Board | SoC package | Board package | 46 |---------------|------------------------------------------------------------------------|---------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| 47 | NXP i.MX6ULL | [MCIMX6ULL-EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/evaluation-kit-for-the-i-mx-6ull-and-6ulz-applications-processor:MCIMX6ULL-EVK) | [imx6](https://github.com/f-secure-foundry/tamago/tree/master/soc/imx6) | [mx6ullevk](https://github.com/f-secure-foundry/tamago/tree/master/board/nxp/mx6ullevk) | 48 49 Compiling 50 ========= 51 52 Go applications are simply required to import, the relevant board package to 53 ensure that hardware initialization and runtime support takes place: 54 55 ```golang 56 import ( 57 _ "github.com/f-secure-foundry/tamago/board/nxp/mx6ullevk" 58 ) 59 ``` 60 61 Build the [TamaGo compiler](https://github.com/f-secure-foundry/tamago-go) 62 (or use the [latest binary release](https://github.com/f-secure-foundry/tamago-go/releases/latest)): 63 64 ``` 65 wget https://github.com/f-secure-foundry/tamago-go/archive/refs/tags/latest.zip 66 unzip latest.zip 67 cd tamago-go-latest/src && ./all.bash 68 cd ../bin && export TAMAGO=`pwd`/go 69 ``` 70 71 Go applications can be compiled as usual, using the compiler built in the 72 previous step, but with the addition of the following flags/variables and 73 ensuring that the required SoC and board packages are available in `GOPATH`: 74 75 ``` 76 GO_EXTLINK_ENABLED=0 CGO_ENABLED=0 GOOS=tamago GOARM=7 GOARCH=arm \ 77 ${TAMAGO} build -ldflags "-T 0x80010000 -E _rt0_arm_tamago -R 0x1000" 78 ``` 79 80 An example application, targeting the MCIMX6ULL-EVK platform, 81 is [available](https://github.com/f-secure-foundry/tamago-example). 82 83 Executing and debugging 84 ======================= 85 86 The [example application](https://github.com/f-secure-foundry/tamago-example) 87 provides reference usage and a Makefile target for automatic creation of an ELF 88 as well as `imx` image for flashing. 89 90 Native hardware: imx image on microSD 91 ------------------------------------- 92 93 Copy the built `imx` image to a microSD as follows: 94 95 ``` 96 sudo dd if=<path to imx file> of=/dev/sdX bs=1M conv=fsync 97 ``` 98 *IMPORTANT*: /dev/sdX must be replaced with your microSD device (not eventual 99 microSD partitions), ensure that you are specifying the correct one. Errors in 100 target specification will result in disk corruption. 101 102 Ensure the `SW601` boot switches on the processor board are set to microSD boot 103 mode: 104 105 | switch | position | 106 |--------|----------| 107 | 1 | OFF | 108 | 2 | OFF | 109 | 3 | ON | 110 | 4 | OFF | 111 112 113 Native hardware: existing bootloader 114 ------------------------------------ 115 116 Copy the built ELF binary on an external microSD card then launch it from the 117 U-Boot console as follows: 118 119 ``` 120 ext2load mmc 1:1 0x90000000 example 121 bootelf -p 0x90000000 122 ``` 123 124 For non-interactive execution modify the U-Boot configuration accordingly. 125 126 Standard output 127 --------------- 128 129 The standard output can be accessed through the debug console found 130 on micro USB connector J1901 and the following `picocom` configuration: 131 132 ``` 133 picocom -b 115200 -eb /dev/ttyUSB0 --imap lfcrlf 134 ``` 135 136 Debugging 137 --------- 138 139 The application can be debugged with GDB over JTAG using `openocd` (version > 140 0.11.0) and the `gdbinit` debugging helper published 141 [here](https://github.com/f-secure-foundry/tamago/tree/master/_dev). 142 143 ``` 144 # start openocd daemon 145 openocd -f interface/ftdi/jtagkey.cfg -f target/imx6ul.cfg -c "adapter speed 1000" 146 147 # connect to the OpenOCD command line 148 telnet localhost 4444 149 150 # debug with GDB 151 arm-none-eabi-gdb -x gdbinit example 152 ``` 153 154 Hardware breakpoints can be set in the usual way: 155 156 ``` 157 hb ecdsa.Verify 158 continue 159 ``` 160 161 QEMU 162 ---- 163 164 The target can be executed under emulation as follows: 165 166 ``` 167 qemu-system-arm \ 168 -machine mcimx6ul-evk -cpu cortex-a7 -m 512M \ 169 -nographic -monitor none -serial null -serial stdio -net none \ 170 -kernel example -semihosting -d unimp 171 ``` 172 173 The emulated target can be debugged with GDB by adding the `-S -s` flags to the 174 previous execution command, this will make qemu waiting for a GDB connection 175 that can be launched as follows: 176 177 ``` 178 arm-none-eabi-gdb -ex "target remote 127.0.0.1:1234" example 179 ``` 180 181 Breakpoints can be set in the usual way: 182 183 ``` 184 b ecdsa.Verify 185 continue 186 ``` 187 188 License 189 ======= 190 191 tamago | https://github.com/f-secure-foundry/tamago 192 Copyright (c) F-Secure Corporation 193 194 These source files are distributed under the BSD-style license found in the 195 [LICENSE](https://github.com/f-secure-foundry/tamago/blob/master/LICENSE) file. 196 197 The TamaGo logo is adapted from the Go gopher designed by Renee French and 198 licensed under the Creative Commons 3.0 Attributions license. Go Gopher vector 199 illustration by Hugo Arganda.