1# Zircon on Khadas VIM2 Board
2
3This document describes running Zircon on the Khadas VIM2 board.
4Additional documentation can be found at [docs.khadas.com](http://docs.khadas.com/)
5
6When describing the location of buttons, pins and other items on the board,
7we will refer to the side with the USB, ethernet and HDMI connectors as the front of the board
8and the opposite side the back of the board.
9
10## Heat Sink
11
12Before you start, you need a heat sink. A passive chip heat sink will allow you
13to run 2 cores out of 8 at full speed before reaching 80C, the critical
14temperature at which cores have to be throttled down.
15
16## Setup
17
18- USB C port: Connect to host. Provides power and `fastboot`.
19- Ethernet: Connect cable directly to board (do not use a USB ethernet adapter).
20- HDMI: Optional. Connects to display.
21- Serial Console: Optional but very useful. See next section.
22
23## Serial Console
24
25The debug UART for the serial console is exposed on the 40 pin header at the back of the board.
26You may use a 3.3v FTDI USB to serial cable to access the serial console.
27On the front row of the header:
28
29- 2nd from right: TX (Yellow wire)
30- 3rd from right: RX (Orange wire)
31- 4th from right: Ground (Black wire)
32
33For FTDI serial cables with black, white, red and green wires, use this:
34
35- 2nd from right: TX (White wire)
36- 3rd from right: RX (Green wire)
37- 4th from right: Ground (Black wire)
38
39In [this diagram](http://docs.khadas.com/vim1/GPIOPinout.html) of the 40 pin header,
40these correspond to pins 17 through 19.
41
42## Buttons
43
44The VIM2 has 3 buttons on the left side of the board. On the board schematic, SW1 (switch closest to the USB plug) is the reset switch. SW3 (farthest away from the USB plug on the schematic) can be used for entering flashing mode. If SW3 is held down while the board is reset or power cycled , the bootloader will enter flashing mode instead of booting the kernel normally.
45
46## VIM2 Bootloader
47
48Booting Zircon on the VIM2 requires a custom bootloader.
49
50### [Googlers only]
51Within Google, this can be found at [go/vim2-bootloader](http://go/vim2-bootloader). Download the .bin file and follow the instructions in the document.
52
53If you are not at Google, hang on until we make this publicly available.
54
55To find out what version of the bootloader you have, grep for "fuchsia-bootloader"
56in the kernel boot log. You should see something like: "cmdline: fuchsia-bootloader=0.04"
57
58## Building Zircon
59
60```
61make -j32 arm64
62```
63
64Be sure you've already set up your network before proceeding to the next step.
65
66## Flashing Zircon
67
68First enter fastboot mode by holding down SW3 (leftmost button), pressing SW1 (rightmost button) quickly and keeping pressing SW3 for a few seconds.
69
70If you are working from the zircon layer, cd to the zircon directory and run:
71
72```
73scripts/flash-vim2 -m
74```
75
76The device should boot into zedboot by default.
77
78If you are working from the garnet layer of above, run the following:
79
80```
81fx flash vim2 --pave
82```
83
84In order to get into zedboot you can reboot into the recovery:
85
86```
87dm reboot-recovery
88```
89
90Alternatively, you can get to zedboot by resetting your vim2 by pressing SW1(rightmost button) quickly and keeping pressing SW2 for a few seconds.
91
92### netbooting
93
94To netboot zircon, enter zedboot and run the following under the zircon directory:
95
96```
97scripts/netboot-zircon ./build-arm64
98```
99
100To netboot garnet, run the following under the fuchsia directory:
101
102```
103fx set arm64 --netboot && fx full-build && fx netboot -1
104```
105
106You should be able to see "Issued boot command to ..." message printed out if this step is successful.
107
108### Paving
109
110Paving is available from garnet layers and above. Run the following under the fuchsia directory:
111
112```
113fx set arm64 && fx full-build && fx pave -1
114```
115
116### Fuchsia logo
117
118To update the boot splash screen to be the Fuchsia logo, do this in fastboot mode:
119```
120fastboot flash logo kernel/target/arm64/board/vim2/firmware/logo.img
121```
122