-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhikey-uc16-readme.txt
177 lines (117 loc) · 4.51 KB
/
hikey-uc16-readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
Hikey Ubuntu Core 16 Guide
Prepare enviroment
------------------
- install ubuntu xenial 16.04 and install below packages:
$ apt-get install snapcraft parted kpartx \
dosfstools squashfs-tools android-tools-fsutils \
gcc-aarch64-linux-gnu \
python3-parted
- install the latest ubuntu-image tools from git:
$ git clone https://github.com/CanonicalLtd/ubuntu-image
$ cd ubuntu-image
$ sudo python3 setup.py install
Get source of hikey snaps
-------------------------
- Export PATH to build UC16 image
$ export UC16_PATH=/path/snap
- Get hikey meta:
$ cd $UC16_PATH
$ git clone https://github.com/LeMaker-HiKey/hikey_meta_uc16.git
- Get hikey kernel snap:
$ cd $UC16_PATH
$ git clone https://github.com/LeMaker-HiKey/hikey_linux_uc16.git
- Get hikey gadget snap:
$ cd $UC16_PATH
$ git clone https://github.com/LeMaker-HiKey/hikey_gadget_snap_uc16.git
Build and install u-boot to hikey
---------------------------------
Because ubuntu core only supports u-boot on arm platform, but hikey now uses UEFI as its default
bootloader, we have to switch hikey to u-boot.
- Get mainline u-boot source:
$ cd $UC16_PATH
$ git clone https://github.com/LeMaker-HiKey/hikey_u-boot.git u-boot
$ cd u-boot
$ git checkout -b hikey_snappy.test origin/hikey_snappy
- Get other source code:
$ cd $UC16_PATH
$ git clone https://github.com/96boards/edk2.git
$ git clone https://github.com/96boards/arm-trusted-firmware.git
$ git clone https://github.com/96boards/burn-boot.git
$ git clone https://github.com/96boards/l-loader.git
And follow u-boot/board/hisilicon/hikey/README to compile and burn to hikey board.
Note: before generate l-load.bin. please modify generate_ptable.sh, replace "system" with
"writable" in the following line.
sgdisk -n -E -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
After all are done successfully, we have a hikey board running u-boot.
Build hikey kernel snap
-----------------------
- Build the kernel snap:
$ cd $UC16_PATH
$ cd hikey_linux_uc16
$ git checkout -b snappy_v4.4-release origin/snappy_v4.4-release
$ snapcraft --target-arch arm64 snap
$ ls hikey-kernel_4.4.0_arm64.snap
$ cp hikey-kernel_4.4.0_arm64.snap ../
Build hikey gadget snap
-----------------------
- Build the gadget snap:
$ cd $UC16_PATH
$ rm -rf hikey_gadget_snap_uc16/.git
$ snapcraft snap hikey_gadget_snap_uc16
If we want to change uboot.env, please use mkenvimage to re-generate uboot.env
after modify hikey_gadget_snap_uc16/uboot.env.in:
$ ./u-boot/tools/mkenvimage -s 0x20000 -o hikey_gadget_snap_uc16/uboot.env \
-r hikey_gadget_snap_uc16/uboot.env.in
Create a model assertion
------------------------
- Create a json file:
$ cd $UC16_PATH
$ emacs hikey.json
write the content as below into the hikey.json
$ cat hikey.json
{
"type": "model",
"authority-id": "BgrPuBQAD1Q5FznHMaoJpRp9vOQ7dQZw",
"brand-id": "BgrPuBQAD1Q5FznHMaoJpRp9vOQ7dQZw",
"series": "16",
"model": "hikey",
"architecture": "arm64",
"gadget": "hikey-snappy-gadget",
"kernel": "hikey-kernel",
"timestamp": "2016-12-21T13:41:20+00:00"
}
About the explanation for the content, please refer to:
http://docs.ubuntu.com/core/en/guides/build-device/board-enablement#the-model-assertion
- Sign the model assertion
$ cat hikey.json | snap sign -k whkey &> hikey.model
Please refer to the above URL to be familiar with the sign process.
Build Ubuntu Core image
------------------
$ cd $UC16_PATH
$ sudo ubuntu-image -c stable \
--extra-snaps ./hikey-snappy-gadget_16.04-1_arm64.snap \
--extra-snaps ./hikey-kernel_4.4.0_arm64.snap \
-o hikey-uc16.img hikey.model
Burn Ubuntu Core image to SD card
----------------------------
Insert a sd card to PC linux and burn UC16 image to SD card:
$ sudo dd if=hikey-uc16.img of=/dev/sdx bs=32M
Please replace /dev/sdx with your SD card device file.
Burn Ubuntu Core rootfs to EMMC FLASH
--------------------------------
- Generate writable image from Ubuntu Core image:
$ cd $UC16_PATH
$ mkdir writable
$ sudo kpartx -av hikey-uc16.img
$ sudo mount /dev/mapper/loop0p2 writable
$ sudo make_ext4fs -L writable -l 1500M -s writable.img writable/
$ sudo umount writable
$ sudo kpartx -d hikey-uc16.img
Note:
1. loop0p2 is the loop device of the second partition of hikey-uc16.img, it should
be replaced with your loop device of kpartx mapping.
- Burn writable image to EMMC FLASH:
$ cd $UC16_PATH
$ sudo ./burn-boot/hisi-idt.py -d /dev/ttyUSB1 --img1=l-loader/l-loader.bin
$ sudo fastboot flash ptable l-loader/ptable-linux-8g.img
$ sudo fastboot flash writable writable.img