-
Notifications
You must be signed in to change notification settings - Fork 55
/
fwup.conf
157 lines (136 loc) · 3.93 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
#
# Example UBI setup
#
# Note this layout mimics the layout of CHIP www.getchip.com. Be sure you understand the
# risks associated with keeping U-Boot in RAW NAND Flash partition. Often a NOR flash is
# preferable for U-BOOT
#
#
# NAND Flash Device
# +----------------------------+
# | /dev/mtd0: spl |
# +----------------------------+
# | /dev/mtd1: spl backup |
# +----------------------------+
# | /dev/mtd2: uboot |
# +----------------------------+
# | /dev/mtd3: uboot env |
# +----------------------------+
# | /dev/mtd4: UBI |
# +----------------------------+
# UBI Partitions ()
# +----------------------------+
# | /dev/ubi0_0: kernel a |
# +----------------------------+
# | /dev/ubi0_1: dtb a |
# +----------------------------+
# | /dev/ubi0_2: kernel b |
# +----------------------------+
# | /dev/ubi0_3: dtb b |
# +----------------------------+
# | /dev/ubi0_4: rootfs a |
# +----------------------------+
# | /dev/ubi0_5: rootfs b |
# +----------------------------+
# | /dev/ubi0_6: data |
# +----------------------------+
# (Sizes are in 512 byte blocks)
define(SPL_A_OFFSET, 0)
define(SPL_A_PART_COUNT, 8192)
define-eval(SPL_B_OFFSET, "${SPL_A_PART_OFFSET} + ${SPL_A_PART_OFFSET}")
define(SPL_B_COUNT, 8192)
define-eval(UBOOT_PART_OFFSET, "${SPL_B_PART_OFFSET} + ${SPL_B_PART_OFFSET}")
define(UBOOT_PART_COUNT, 8192)
define-eval(UBOOT_ENV_PART_OFFSET, "${UBOOT_PART_OFFSET} + ${UBOOT_PART_OFFSET}")
define(UBOOT_ENV_PART_COUNT, 8192)
define-eval(UBI_PART_OFFSET, "${UBOOT_ENV_PART_OFFSET} + ${UBOOT_ENV_PART_COUNT}")
define(UBI_PART_COUNT, 8355840)
define(ROOTFS, "${NERVES_SYSTEM}/images/rootfs.squashfs")
define(UBIFS_ARGS, "-m 2048 -e 126976 -c 3186")
define(UBI_ARGS, "-m 2048 -p 128KiB")
# This is relative to /dev/mtdblock3
uboot-environment uboot-env {
block-offset = 0
block-count = ${UBOOT_ENV_PART_COUNT}
}
file-resource uboot {
host-path = "u-boot"
}
file-resource zImage {
host-path = "zImage"
}
file-resource zImage-dtb {
host-path = "zImage-machine.dtb"
}
file-resource ubi.ini {
host-path = "ubi.ini"
}
file-resource rootfs.img {
host-path = "${ROOTFS}"
}
task complete {
on-init {
execute("mkdir _tmp")
execute("mkdir _tmp/ubifs")
}
on-resource uboot {
raw_write(${UBOOT_A_PART_OFFSET})
}
on-resource ubi.ini {
path_write("_tmp/ubi.ini")
}
on-resource rootfs.img {
path_write("_tmp/combined.squashfs")
}
on-resource zImage {
path_write("_tmp/zImage")
}
on-resource zImage-dtb {
path_write("_tmp/zImage-machine.dtb")
}
on-finish {
# Create an the UBIFS for Data
execute("mkfs.ubifs -F -r _tmp/ubifs ${UBIFS_ARGS} -o _tmp/ubifs.img")
# Create the full UBI Image
execute("ubinize -v ${UBI_ARGS} -o ubi.img _tmp/ubi.ini")
# Cleanup
execute("rm -Rf _tmp")
}
}
#
# Note: To upgrade, you must pass the mtdblock device of u-boot
#
# fwup -a -d /dev/mtdblock3 -i myfirmware.fw -t upgrade
#
# This is because there is no "full" mtd device. Each partition
# must be accessed individually
task upgrade.a {
require-uboot-variable(uboot-env, "active_partition", 1)
on-resource zImage {
pipe_write("ubiupdatevol /dev/ubi0_0 -s ${FWUP_SIZE_zImage} -")
}
on-resource zImage-dtb {
pipe_write("ubiupdatevol /dev/ubi0_1 -s ${FWUP_SIZE_zImage_dtb} -")
}
on-resource rootfs.img {
pipe_write("ubiupdatevol /dev/ubi0_4 -s ${FWUP_SIZE_rootfs_img} -")
}
on-finish {
uboot_setenv(uboot-env, "active_partition", 0)
}
}
task upgrade.b {
require-uboot-variable(uboot-env, "active_partition", 0)
on-resource zImage {
pipe_write("ubiupdatevol /dev/ubi0_2 -s ${FWUP_SIZE_zImage} -")
}
on-resource zImage-dtb {
pipe_write("ubiupdatevol /dev/ubi0_3 -s ${FWUP_SIZE_zImage_dtb} -")
}
on-resource rootfs.img {
pipe_write("ubiupdatevol /dev/ubi0_5 -s ${FWUP_SIZE_rootfs_img} -")
}
on-finish {
uboot_setenv(uboot-env, "active_partition", 1)
}
}