-
Notifications
You must be signed in to change notification settings - Fork 6
/
fwup.conf
258 lines (222 loc) · 8.13 KB
/
fwup.conf
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Firmware configuration file for the Beaglebone Black
# Default paths if not specified via the commandline
define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
# This configuration file will create an image that
# has an MBR and the following 3 partitions:
#
# +----------------------------+
# | MBR |
# +----------------------------+
# | Boot partition (FAT32) |
# | u-boot.img |
# | uenv.txt |
# | zImage |
# +----------------------------+
# | p1*: Rootfs A (squashfs) |
# +----------------------------+
# | p1*: Rootfs B (squashfs) |
# +----------------------------+
# | p2: Application (FAT32) |
# +----------------------------+
# | p3: Provision (FAT32) |
# +----------------------------+
#
# The p1 partition points to whichever of Rootfs A or B that
# is active.
define(BOOT0_OFFSET, 16) # 16 blocks * 512byte/block = 8092 byte offset, per H3 requirements
# The boot partition contains u-boot.img, zImage, and has
# room for a debug uEnv.txt if desired
define(BOOT_PART_OFFSET, 2048)
define(BOOT_PART_COUNT, 30720)
# Let the rootfs have room to grow up to 256 MiB and align
# it to the nearest 1 MB boundary
define(ROOTFS_A_PART_OFFSET, 32768)
define(ROOTFS_A_PART_COUNT, 131072) # 64mb
define(ROOTFS_B_PART_OFFSET, 163840)
define(ROOTFS_B_PART_COUNT, 131072) # 64mb
# Application partition
define(APP_PART_OFFSET, 294912)
define(APP_PART_COUNT, 131072) # 64mb
# Provision partition
define(PROV_PART_OFFSET, 425984)
define(PROV_PART_COUNT, 20480) # 10mb
# Firmware metadata
meta-product = "Nerves Firmware"
meta-description = ""
meta-version = ${NERVES_SDK_VERSION}
meta-platform = "nanopi_neo"
meta-architecture = "arm"
meta-author = "David Hanson" # but mostly copied from Frank Hunleth
# File resources are listed in the order that they are included in the .fw file
# This is important, since this is the order that they're written on a firmware
# update due to the event driven nature of the update system.
file-resource u-boot.img {
host-path = "${NERVES_SYSTEM}/images/u-boot.img"
}
file-resource boot.scr {
host-path = "${NERVES_SYSTEM}/images/boot.scr"
}
file-resource zImage {
host-path = "${NERVES_SYSTEM}/images/zImage"
}
file-resource sun8i-h3-orangepi-pc.dtb {
host-path = "${NERVES_SYSTEM}/images/sun8i-h3-orangepi-pc.dtb"
}
file-resource rootfs.img {
host-path = ${ROOTFS}
}
file-resource sunxi-spl.bin {
host-path = "${NERVES_SYSTEM}/images/u-boot-sunxi-with-spl.bin"
}
mbr mbr-a {
partition 0 {
block-offset = ${BOOT_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = 0xc # FAT32
boot = true
}
partition 1 {
block-offset = ${ROOTFS_A_PART_OFFSET}
block-count = ${ROOTFS_A_PART_COUNT}
type = 0x83 # Linux
}
partition 2 {
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = 0xc # FAT32
}
partition 3 {
block-offset = ${PROV_PART_OFFSET}
block-count = ${PROV_PART_COUNT}
type = 0xc # FAT32
}
}
mbr mbr-b {
partition 0 {
block-offset = ${BOOT_PART_OFFSET}
block-count = ${BOOT_PART_COUNT}
type = 0xc # FAT32
boot = true
}
partition 1 {
block-offset = ${ROOTFS_B_PART_OFFSET}
block-count = ${ROOTFS_B_PART_COUNT}
type = 0x83 # Linux
}
partition 2 {
block-offset = ${APP_PART_OFFSET}
block-count = ${APP_PART_COUNT}
type = 0xc # FAT32
}
partition 3 {
block-offset = ${PROV_PART_OFFSET}
block-count = ${PROV_PART_COUNT}
type = 0xc # FAT32
}
}
# This firmware task writes everything to the destination media
task complete {
# Only match if not mounted
require-unmounted-destination = true
# Everything that gets written can be verified on the fly.
# This speeds things up, since we don't care about detecting
# errors before data gets written.
verify-on-the-fly = true
on-init {
mbr_write(mbr-a)
fat_mkfs(${BOOT_PART_OFFSET}, ${BOOT_PART_COUNT})
fat_setlabel(${BOOT_PART_OFFSET}, "BOOT")
}
#on-resource MLO { fat_write(${BOOT_PART_OFFSET}, "MLO") }
on-resource u-boot.img { fat_write(${BOOT_PART_OFFSET}, "u-boot.img") }
on-resource boot.scr { fat_write(${BOOT_PART_OFFSET}, "boot.scr") }
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage") }
on-resource sun8i-h3-orangepi-pc.dtb { fat_write(${BOOT_PART_OFFSET}, "sun8i-h3-orangepi-pc.dtb") }
on-resource sunxi-spl.bin {
raw_write(${BOOT0_OFFSET})
}
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
on-finish {
# Initialize the app partition last so that the boot
# partition can be written in one go.
fat_mkfs(${APP_PART_OFFSET}, ${APP_PART_COUNT})
fat_setlabel(${APP_PART_OFFSET}, "APPDATA")
fat_mkfs(${PROV_PART_OFFSET}, ${PROV_PART_COUNT})
fat_setlabel(${PROV_PART_OFFSET}, "PROVDATA")
}
}
task upgrade.a {
# This task upgrades the A partition
require-partition1-offset = ${ROOTFS_B_PART_OFFSET}
# Since the upgrade won't run until it has been finalized, it's ok
# to write data as it is read.
verify-on-the-fly = true
on-init {
# Erase any old saved files from previous upgrades
fat_rm(${BOOT_PART_OFFSET}, "zImage.pre")
fat_rm(${BOOT_PART_OFFSET}, "boot.scr.pre")
}
# Write the new firmware and Linux images, but don't
# commit them. That way if the user aborts midway, we
# still are using the original firmware.
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage.new") }
on-resource boot.scr { fat_write(${BOOT_PART_OFFSET}, "boot.scr.new") }
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_A_PART_OFFSET})
}
on-finish {
# Switch over to boot the new firmware
mbr_write(mbr-a)
fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr", "boot.scr.pre")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb", "am335x-boneblack.dtb.pre")
fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr.new", "boot.scr")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new", "am335x-boneblack.dtb")
}
on-error {
# Clean up in case something goes wrong
fat_rm(${BOOT_PART_OFFSET}, "zImage.new")
#fat_rm(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new")
fat_rm(${BOOT_PART_OFFSET}, "boot.scr.new")
}
}
task upgrade.b {
# This task upgrades the B partition
require-partition1-offset = ${ROOTFS_A_PART_OFFSET}
# Since the upgrade won't run until it has been finalized, it's ok
# to write data as it is read.
verify-on-the-fly = true
on-init {
fat_rm(${BOOT_PART_OFFSET}, "zImage.pre")
#fat_rm(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.pre")
fat_rm(${BOOT_PART_OFFSET}, "boot.scr.pre")
}
on-resource zImage { fat_write(${BOOT_PART_OFFSET}, "zImage.new") }
on-resource boot.scr { fat_write(${BOOT_PART_OFFSET}, "boot.scr.new") }
#on-resource am335x-boneblack.dtb { fat_write(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new") }
on-resource rootfs.img {
# write to the first rootfs partition
raw_write(${ROOTFS_B_PART_OFFSET})
}
on-finish {
# Switch over to boot the new firmware
mbr_write(mbr-b)
fat_mv(${BOOT_PART_OFFSET}, "zImage", "zImage.pre")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr", "boot.scr.pre")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb", "am335x-boneblack.dtb.pre")
fat_mv(${BOOT_PART_OFFSET}, "zImage.new", "zImage")
fat_mv(${BOOT_PART_OFFSET}, "boot.scr.new", "boot.scr")
#fat_mv(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new", "am335x-boneblack.dtb")
}
on-error {
# Clean up in case something goes wrong
fat_rm(${BOOT_PART_OFFSET}, "zImage.new")
#fat_rm(${BOOT_PART_OFFSET}, "am335x-boneblack.dtb.new")
fat_rm(${BOOT_PART_OFFSET}, "boot.scr.new")
}
}