Merge ~fisterra-team/fisterra/+git/nitrogen6x-gadget:18-classic into ~fisterra-team/fisterra/+git/nitrogen6x-gadget:18-classic-mp
- Git
- lp:~fisterra-team/fisterra/+git/nitrogen6x-gadget
- 18-classic
- Merge into 18-classic-mp
Status: | Needs review |
---|---|
Proposed branch: | ~fisterra-team/fisterra/+git/nitrogen6x-gadget:18-classic |
Merge into: | ~fisterra-team/fisterra/+git/nitrogen6x-gadget:18-classic-mp |
Diff against target: |
500 lines (+412/-0) 14 files modified
Makefile (+47/-0) README.md (+40/-0) boot.scr.in (+81/-0) build.sh (+57/-0) configs/meta-data (+1/-0) configs/network-config (+5/-0) configs/user-data (+4/-0) gadget.yaml (+31/-0) helpers/sources.list.cross (+8/-0) helpers/sources.list.ppa (+2/-0) snap.yaml (+12/-0) snap/hooks/configure (+3/-0) snapcraft.yaml (+97/-0) uboot.env.in (+24/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dave Jones (community) | Approve | ||
ethan.hsieh | Needs Resubmitting | ||
Łukasz Zemczak | Needs Information | ||
jeremyszu | Pending | ||
Steve Langasek | Pending | ||
Patricia Gaughen | Pending | ||
Review via email: mp+371450@code.launchpad.net |
Commit message
Description of the change
jeremyszu (os369510) wrote : | # |
Hi Lukasz,
As previous talk with Dave on IRC, Dave plans to send a PR for integrating pi3 gadge snap to https:/
jeremyszu (os369510) wrote : | # |
Hi Lukasz, Dave,
Hope everything is well with you.
I'm working on integrating gadget snap.
I have a question that is why the boot file only supports 'uboot.env' if bootloader is uboot?
(https:/
For instance, the gadget snap of classic is use 'boot.scr' as boot script and I would like to use 'boot.scr' for both classic and core, but it will fail on core because of missing kernel arguments (snap_core, snap_kernel and snap_menuentry).
- c110be1... by jeremyszu
-
Integrate gadget for both classic and core
1. For Classic,
1.1. Require parts:
- uboot-fw # Uboot firmware
- uboot-bootscript # Boot script
- cloud-init-configs # Cloud-init configs
- devicetrees # Device tree
2. For Core,
2.1. Require parts:
- uboot-fw # Uboot firmware
- uboot-env # Uboot environment
3. gadget.yaml is compitable for both core and classic
4. boot.scr.in should be compitable for both core and classic if required
snap_* kernel arguments could be added in uboot.env (even if
uboot.env.in doesn't exist) or boot.scr.in.
5. snap.yaml was be generated manually.
6. snapcraft.yaml describes all parts those are both classic and core needed
and the build.sh will build their corresponding required parts by
giving --classic or --core.
Łukasz Zemczak (sil2100) wrote : | # |
Hey Jeremy! I have sent the link of this MP to Dave so that he can review it as well. Dave might be able to answer your question regarding using boot.scr for both core and classic. Ideally we'd just want to have boot.scr doing all the work, without the need for uboot.env, but from what I remember there's still something that needs to be changed in snapd to make this transition possible. Anyway, hopefully Dave will provide more input.
In the meantime, I'll review the current state of the MP shortly.
Dave Jones (waveform) wrote : | # |
Just a few possible comments on the boot scripts; I can add more detail on the core/classic boot script situation but have to dash out right now - will reply further when I'm back!
Dave Jones (waveform) wrote : | # |
> I have a question that is why the boot file only supports 'uboot.env' if
> bootloader is uboot?
> (https:/
> cf/bootloader/
> For instance, the gadget snap of classic is use 'boot.scr' as boot script and
> I would like to use 'boot.scr' for both classic and core, but it will fail on
> core because of missing kernel arguments (snap_core, snap_kernel and
> snap_menuentry).
Good question: at present, the A/B boot support in snapd only supports the uboot.env style of boot script, not boot.scr. Hence Core images must use uboot.env, while Classic images can use either style. However, we'd generally prefer Classic use the boot.scr style as firstly that's what Debian upstream use exclusively and what Ubuntu uses for the vast majority of its boot scripts (on Classic).
Ideally, we want to update snapd (during the Core 20 cycle) to support the boot.scr style so that we can move the Core over to using the boot.scr style. This is partially because we'd like to merge the Core and Classic gadgets, but also because I'm uncomfortable with the way the A/B support with uboot is handled (the environment rewrites itself during the boot sequence and I'd much rather have a static boot script with a separate mutable state file). The theoretical boot script would detect whether it's booting a Core or Classic image (most likely by looking for the existence of the aforementioned A/B boot state), and act accordingly (using snap_core et al in the Core case and a fixed boot sequence in the Classic case).
I've got a prototype of this that theoretically works for the Pi, but it's largely untested (and probably won't get any serious attention until we look at the required snapd changes).
Anyway, for the time being I'm afraid that means you've got a choice with regards to this gadget snap:
1) Have a uboot.env script for the Core build, and a boot.scr script for the Classic build. Annoying as this is, this is the option I'd currently pick (and have picked for the pi images).
2) Have a uboot.env script for both Core and Classic. While this might seem easier *now*, I'd advise against this as it'll just mean more work when we start looking at snapd's A/B boot configuration.
- f577e60... by jeremyszu
-
Remove unnecessary variables
1. Correct the source of uboot-imx in Makefile
2. Remove vendor specific variables from boot.scr.in due to this gadget
snap should focus on supporting iMAX6.
3. Correct some typo and unnecessary parameters.
jeremyszu (os369510) wrote : | # |
Hi Dave,
> Ideally, we want to update snapd (during the Core 20 cycle) to support the boot.scr style so that we can move the Core over to using the boot.scr style.
Good news!
> also because I'm uncomfortable with the way the A/B support with uboot is handled (the environment rewrites itself during the boot sequence and I'd much rather have a static boot script with a separate mutable state file).
Yes, that's what I prefer also.
Thus, the boot.scr.in as this MP is designed for both Core and Classic. It *should* works but not yet to test because snapd only supports appending related kernel arguments in "uboot.env.in" (the kernel arguments won't be appended if file not found).
> The theoretical boot script would detect whether it's booting a Core or Classic image
Could you please share more details about how did you implemented it?
I used an ugly condition as "if test -e ${devtype} ${devnum}:2 /boot/$
> 1) Have a uboot.env script for the Core build, and a boot.scr script for the Classic build. Annoying as this is, this is the option I'd currently pick (and have picked for the pi images).
Yes, that is what I did as this MP. (I handled both case separately in snapcrafy.yaml)
However, I remove some unnecessary parts as you commented before.
Please kindly to help to review it.
Many thanks!
Dave Jones (waveform) wrote : | # |
> > The theoretical boot script would detect whether it's booting a Core or
> Classic image
> Could you please share more details about how did you implemented it?
> I used an ugly condition as "if test -e ${devtype} ${devnum}:2
> /boot/$
I'm afraid my method is about as elegant :). Though, instead of testing for the initrd.img I instead test for the existence of my (not-yet-
> > 1) Have a uboot.env script for the Core build, and a boot.scr script for the
> Classic build. Annoying as this is, this is the option I'd currently pick (and
> have picked for the pi images).
> Yes, that is what I did as this MP. (I handled both case separately in
> snapcrafy.yaml)
Sorry I didn't get to this last night - will take a look now!
Dave Jones (waveform) wrote : | # |
The code looks much better, no major objections from me on that. However, I did attempt to prime the gadget as a quick experiment and it wound up throwing an error regarding conflicting boot.scr outputs; more detail in the diff comment below.
jeremyszu (os369510) wrote : | # |
Hi Dave,
For your error, I comment it below.
It seems like your test command is 'sudo snapcraft --target-arch armhf prime'.
For currently design, I use a script to build it separately as README mentioned.
If we don't want to separate the build method for both classic and core then we will need to put everything in one gadget snap together.
(such as cloud-init config and device-tree (device-tree provided by kernel for core) )
I'd leave it as a open question and would like to know your opinion about that.
Dave Jones (waveform) wrote : | # |
Sorry, I'd managed to completely miss the README (too used to dealing with the Pi's images)! The solution for dealing with the disparity between the core and classic images sounds good (for now, as you note; in future once snapd supports boot scripts we can move them closer and potentially remove the requirement to specify a particular part).
Anyway, that resolves the last query I had, so thumbs up from me!
- 3895908... by ethan.hsieh
-
Add necessary variables
ethan.hsieh (ethan.hsieh) wrote : | # |
initrd_high and fdt_high are required for booting
Add initrd_high into boot.scr.in and uboot.env.in.
- 9a1c073... by jeremyszu
-
fix build fail when using snapcraft from snap repo
- 1c8a737... by jeremyszu
-
fix warning from shellcheck
- 1a6382b... by jeremyszu
-
correct args as an array
Unmerged commits
- 1a6382b... by jeremyszu
-
correct args as an array
- 1c8a737... by jeremyszu
-
fix warning from shellcheck
- 9a1c073... by jeremyszu
-
fix build fail when using snapcraft from snap repo
- 3895908... by ethan.hsieh
-
Add necessary variables
- f577e60... by jeremyszu
-
Remove unnecessary variables
1. Correct the source of uboot-imx in Makefile
2. Remove vendor specific variables from boot.scr.in due to this gadget
snap should focus on supporting iMAX6.
3. Correct some typo and unnecessary parameters. - c110be1... by jeremyszu
-
Integrate gadget for both classic and core
1. For Classic,
1.1. Require parts:
- uboot-fw # Uboot firmware
- uboot-bootscript # Boot script
- cloud-init-configs # Cloud-init configs
- devicetrees # Device tree
2. For Core,
2.1. Require parts:
- uboot-fw # Uboot firmware
- uboot-env # Uboot environment
3. gadget.yaml is compitable for both core and classic
4. boot.scr.in should be compitable for both core and classic if required
snap_* kernel arguments could be added in uboot.env (even if
uboot.env.in doesn't exist) or boot.scr.in.
5. snap.yaml was be generated manually.
6. snapcraft.yaml describes all parts those are both classic and core needed
and the build.sh will build their corresponding required parts by
giving --classic or --core. - 3423f93... by ethan.hsieh
-
Init commit
Preview Diff
1 | diff --git a/Makefile b/Makefile |
2 | new file mode 100644 |
3 | index 0000000..0de6317 |
4 | --- /dev/null |
5 | +++ b/Makefile |
6 | @@ -0,0 +1,47 @@ |
7 | +STAGEDIR := $(CURDIR)/stage |
8 | +DESTDIR := $(CURDIR)/install |
9 | + |
10 | +ARCH ?= $(shell dpkg --print-architecture) |
11 | +UBOOT_TARGET := 'nitrogen6q2g' |
12 | +UBOOT_BIN := 'u-boot.imx' |
13 | + |
14 | +SOURCES_HOST ?= "/etc/apt/sources.list" |
15 | +SOURCES_MULTIVERSE := "$(STAGEDIR)/apt/uboot-imx.sources.list" |
16 | + |
17 | +define stage_package |
18 | + (cd $(2)/debs && apt-get download -o Dir::Etc::sourcelist=$(SOURCES_MULTIVERSE) -oAPT::Architecture=$(3) $(1);) |
19 | + dpkg-deb --vextract $$(ls $(2)/debs/$(1)*.deb | tail -1) $(2)/unpack |
20 | +endef |
21 | + |
22 | +preparation: |
23 | + # The only supported architecture is armhf |
24 | + if [ "$(ARCH)" != "armhf" ] ; then \ |
25 | + echo "Build architecture is not supported."; \ |
26 | + exit 1; \ |
27 | + fi |
28 | + mkdir -p $(STAGEDIR) $(DESTDIR) |
29 | +uboot-env: clean preparation uboot.env.in |
30 | + cp uboot.env.in $(STAGEDIR)/ |
31 | + mkenvimage -r -s 131072 -o $(STAGEDIR)/uboot.env $(STAGEDIR)/uboot.env.in |
32 | + make uboot-env-install |
33 | +uboot-fw: clean preparation |
34 | + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3850E699B57D9F62 |
35 | + # Prepare working directories |
36 | + mkdir -p $(STAGEDIR)/apt $(STAGEDIR)/debs $(STAGEDIR)/unpack |
37 | + cp $(SOURCES_HOST) $(SOURCES_MULTIVERSE) |
38 | + # Download u-boot package |
39 | + apt-get update -o Dir::Etc::sourcelist=$(SOURCES_MULTIVERSE) -oAPT::Architecture=$(ARCH) 2>/dev/null |
40 | + # Extract u-boot |
41 | + $(call stage_package,u-boot-imx,$(STAGEDIR),$(ARCH)) |
42 | + # Staging stage |
43 | + mkdir -p $(DESTDIR)/boot-assets |
44 | + make uboot-fw-install |
45 | + |
46 | +uboot-env-install: |
47 | + cp $(STAGEDIR)/uboot.env $(DESTDIR) |
48 | +uboot-fw-install: |
49 | + cp $(STAGEDIR)/unpack/usr/lib/u-boot/$(UBOOT_TARGET)/$(UBOOT_BIN) $(DESTDIR)/boot-assets/$(UBOOT_BIN) |
50 | + |
51 | +clean: |
52 | + rm -rf $(DESTDIR) |
53 | + rm -rf $(STAGEDIR) |
54 | diff --git a/README.md b/README.md |
55 | new file mode 100644 |
56 | index 0000000..068098e |
57 | --- /dev/null |
58 | +++ b/README.md |
59 | @@ -0,0 +1,40 @@ |
60 | +# Nitrogen6x Gadget Tree |
61 | + |
62 | +This repository contains the source for an Ubuntu classic gadget tree for the Nitrogen6x. |
63 | + |
64 | +Building it follow 'Building' section will automatically pull all the required |
65 | +binaries from the Ubuntu archive and stage it to a directory for ubuntu-image |
66 | +to consume. |
67 | + |
68 | +## Gadget Snaps |
69 | + |
70 | +Gadget snaps are a special type of snaps that contain device specific support |
71 | +code and data. You can read more about them in the snapd wiki |
72 | +https://github.com/snapcore/snapd/wiki/Gadget-snap |
73 | + |
74 | +## Gadget Trees |
75 | + |
76 | +Gadget trees are nothing more than gadget snaps before they have been packed |
77 | +into a snap. These compiled gadget trees are used by ubuntu-image in the classic |
78 | +mode when a classic image is to be built using this tool. |
79 | + |
80 | +## Reporting Issues |
81 | + |
82 | +Please report all issues on the Launchpad project page |
83 | +https://bugs.launchpad.net/snap-imx/+filebug |
84 | + |
85 | +We use Launchpad to track issues as this allows us to coordinate multiple |
86 | +projects better than what is available with Github issues. |
87 | + |
88 | +## Building |
89 | + |
90 | +To build the gadget tree, please use: |
91 | +`bash build.sh --core` for building gadget snap for core |
92 | +or |
93 | +`bash build.sh --classic` for building gadget snap for classic |
94 | + |
95 | +## Launchpad Mirror. |
96 | + |
97 | +All commits from the master branch of https://github.com/CanonicalLtd/imx are |
98 | +automatically mirrored by Launchpad to the https://launchpad.net/snap-imx |
99 | +project. |
100 | diff --git a/boot.scr.in b/boot.scr.in |
101 | new file mode 100644 |
102 | index 0000000..6377e5b |
103 | --- /dev/null |
104 | +++ b/boot.scr.in |
105 | @@ -0,0 +1,81 @@ |
106 | +# Load default boot configuration |
107 | +setenv bootargs '' |
108 | +setenv initrd_high 0xffffffff |
109 | +setenv a_base 0x10000000 |
110 | +setenv console ttymxc1 |
111 | +setenv fdt_file imx6q-nitrogen6x.dtb |
112 | +setenv initrd_image initrd.img |
113 | +setenv kernel_image vmlinuz |
114 | +setenv bootcommand bootz |
115 | +setenv distro_bootpart 1 |
116 | +setenv devnum_mmcblk 1 |
117 | +setenv devtype mmc |
118 | +setenv devnum 0 |
119 | + |
120 | +setexpr a_kernel ${a_base} + 0x00800000 |
121 | +setexpr a_fdt ${a_base} + 0x03000000 |
122 | +setexpr a_initrd ${a_base} + 0x03a00000 |
123 | + |
124 | +# Setup files path |
125 | +if test -e ${devtype} ${devnum}:2 /boot/${initrd_image}; then |
126 | + setenv distro_rootfs 2 |
127 | + setexpr b0 ${distro_rootfs} % 0x0a |
128 | + setexpr b1 ${distro_rootfs} / 0x0a |
129 | + setexpr bpart ${b1} * 0x10 |
130 | + setexpr bpart ${bpart} + ${b0} |
131 | + setenv kernel_image vmlinuz |
132 | + setenv loadkernel load ${devtype} ${devnum}:${distro_rootfs} ${a_kernel} /boot/${kernel_image} |
133 | + setenv loadinitrd load ${devtype} ${devnum}:${distro_rootfs} ${a_initrd} /boot/${initrd_image} |
134 | + setenv loadfdt load ${devtype} ${devnum}:${distro_bootpart} ${a_fdt} /dtbs/${fdt_file} |
135 | + setenv mmcroot "/dev/mmcblk${devnum_mmcblk}p${bpart}" |
136 | +else |
137 | + setenv distro_rootfs 1 |
138 | + setenv kernel_image kernel.img |
139 | + setenv loadkernel fatload ${devtype} ${devnum}:${distro_rootfs} ${a_kernel} ${snap_kernel}/${kernel_image} |
140 | + setenv loadinitrd fatload ${devtype} ${devnum}:${distro_rootfs} ${a_initrd} ${snap_kernel}/${initrd_image} |
141 | + setenv loadfdt fatload ${devtype} ${devnum}:${distro_bootpart} ${a_fdt} ${snap_kernel}/dtbs/${fdt_file} |
142 | + setenv snappy_cmdline rng_core.default_quality=700 net.ifnames=0 init=/lib/systemd/systemd ro panic=-1 fixrtc usbcore.autosuspend=-1 |
143 | + setenv mmcroot "/dev/disk/by-label/writable ${snappy_cmdline} snap_core=${snap_core} snap_kernel=${snap_kernel}" |
144 | + if test "${snap_mode}" = "try"; then |
145 | + setenv snap_mode "trying" |
146 | + saveenv |
147 | + if test "${snap_try_core}" != ""; then |
148 | + setenv snap_core "${snap_try_core}" |
149 | + fi |
150 | + if test "${snap_try_kernel}" != ""; then |
151 | + setenv snap_kernel "${snap_try_kernel}" |
152 | + fi |
153 | + elif test "${snap_mode}" = "trying"; then |
154 | + setenv snap_mode "" |
155 | + saveenv |
156 | + fi |
157 | +fi |
158 | + |
159 | +setenv bootargs "${bootargs} console=${console},115200 vmalloc=400M consoleblank=0 rootwait fixrtc root=${mmcroot} clk_ignore_unused" |
160 | + |
161 | +echo "Trying to load ${fdt_file}.." |
162 | +if run loadfdt; then |
163 | + fdt addr ${a_fdt} |
164 | + setenv fdt_high 0xffffffff |
165 | +else |
166 | + echo "Error: Failed to load ${fdt_file}" |
167 | + exit |
168 | +fi |
169 | + |
170 | +echo "Trying to load ${initrd_image}.." |
171 | +if run loadinitrd; then |
172 | + setenv initrd_size ${filesize} |
173 | +else |
174 | + echo "Error: Failed to load ${initrd_image}" |
175 | + exit |
176 | +fi |
177 | + |
178 | +echo "Trying to load ${kernel_image}.." |
179 | +if run loadkernel; then |
180 | + echo "Loading file successful." |
181 | +else |
182 | + echo "Error: Failed to load ${kernel_image}" |
183 | + exit |
184 | +fi |
185 | + |
186 | +${bootcommand} ${a_kernel} ${a_initrd}:${initrd_size} ${a_fdt} |
187 | diff --git a/build.sh b/build.sh |
188 | new file mode 100644 |
189 | index 0000000..9d99ac2 |
190 | --- /dev/null |
191 | +++ b/build.sh |
192 | @@ -0,0 +1,57 @@ |
193 | +#!/bin/bash |
194 | +# |
195 | +# Copyright (C) 2019 Canonical Ltd |
196 | +# |
197 | +# This program is free software: you can redistribute it and/or modify |
198 | +# it under the terms of the GNU General Public License version 3 as |
199 | +# published by the Free Software Foundation. |
200 | +# |
201 | +# This program is distributed in the hope that it will be useful, |
202 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
203 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
204 | +# GNU General Public License for more details. |
205 | +# |
206 | +# You should have received a copy of the GNU General Public License |
207 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
208 | + |
209 | +usage() |
210 | +{ |
211 | + echo "Please use either --core or --classic" |
212 | + exit 255 |
213 | +} |
214 | + |
215 | +core="" |
216 | +classic="" |
217 | +parts=() |
218 | +args=(--target-arch armhf) |
219 | +while [ -n "$1" ]; do |
220 | + case "$1" in |
221 | + --core) |
222 | + core="yes" |
223 | + parts=(core-meta) |
224 | + shift 1;; |
225 | + --classic) |
226 | + classic="yes" |
227 | + parts=(classic-meta) |
228 | + shift 1;; |
229 | + *) |
230 | + usage;; |
231 | + esac |
232 | +done |
233 | + |
234 | +set -x |
235 | + |
236 | +if [ "$(systemd-detect-virt)" != "none" ]; then |
237 | + destructive_mode="--destructive-mode" |
238 | +else |
239 | + destructive_mode="" |
240 | +fi |
241 | + |
242 | +if [ -z "${core}" ] && [ -z "${classic}" ]; then |
243 | + usage |
244 | +elif [ -n "${core}" ] && [ -n "${classic}" ]; then |
245 | + usage |
246 | +fi |
247 | +sudo snapcraft clean "${destructive_mode}" |
248 | +sudo snapcraft "${args[@]}" prime "${parts[@]}" "${destructive_mode}" |
249 | +sudo snapcraft "${args[@]}" pack prime |
250 | diff --git a/configs/meta-data b/configs/meta-data |
251 | new file mode 100644 |
252 | index 0000000..e19f347 |
253 | --- /dev/null |
254 | +++ b/configs/meta-data |
255 | @@ -0,0 +1 @@ |
256 | +instance_id: cloud-image |
257 | diff --git a/configs/network-config b/configs/network-config |
258 | new file mode 100644 |
259 | index 0000000..3570789 |
260 | --- /dev/null |
261 | +++ b/configs/network-config |
262 | @@ -0,0 +1,5 @@ |
263 | +version: 2 |
264 | +ethernets: |
265 | + eth0: |
266 | + dhcp4: true |
267 | + optional: true |
268 | diff --git a/configs/user-data b/configs/user-data |
269 | new file mode 100644 |
270 | index 0000000..8490d04 |
271 | --- /dev/null |
272 | +++ b/configs/user-data |
273 | @@ -0,0 +1,4 @@ |
274 | +#cloud-config |
275 | +password: ubuntu |
276 | +chpasswd: ubuntu |
277 | +ssh_pwauth: True |
278 | diff --git a/gadget.yaml b/gadget.yaml |
279 | new file mode 100644 |
280 | index 0000000..86de078 |
281 | --- /dev/null |
282 | +++ b/gadget.yaml |
283 | @@ -0,0 +1,31 @@ |
284 | +device-tree-origin: kernel |
285 | +device-tree: imx6q-nitrogen6x.dtb |
286 | +volumes: |
287 | + nitrogen6x: |
288 | + schema: mbr |
289 | + bootloader: u-boot |
290 | + structure: |
291 | + - type: 0C |
292 | + filesystem: vfat |
293 | + filesystem-label: system-boot |
294 | + size: 256M |
295 | + content: |
296 | + - source: boot-assets/ |
297 | + target: / |
298 | + - source: boot.scr |
299 | + target: boot.scr |
300 | + - source: configs/ |
301 | + target: / |
302 | + - type: 83 |
303 | + filesystem: ext4 |
304 | + filesystem-label: writable |
305 | + size: 512M |
306 | + role: system-data |
307 | + u-boot-nitrogen6x: |
308 | + structure: |
309 | + - name: u-boot |
310 | + type: bare |
311 | + size: 786432 |
312 | + offset: 1024 |
313 | + content: |
314 | + - image: boot-assets/u-boot.imx |
315 | diff --git a/helpers/sources.list.cross b/helpers/sources.list.cross |
316 | new file mode 100644 |
317 | index 0000000..9a3d575 |
318 | --- /dev/null |
319 | +++ b/helpers/sources.list.cross |
320 | @@ -0,0 +1,8 @@ |
321 | +deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main universe multiverse restricted |
322 | +deb-src [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic main universe multiverse restricted |
323 | +deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main universe multiverse restricted |
324 | +deb-src [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main universe multiverse restricted |
325 | +deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main universe multiverse restricted |
326 | +deb-src [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main universe multiverse restricted |
327 | +deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-proposed main universe multiverse restricted |
328 | +deb-src [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ bionic-proposed main universe multiverse restricted |
329 | diff --git a/helpers/sources.list.ppa b/helpers/sources.list.ppa |
330 | new file mode 100644 |
331 | index 0000000..e60381e |
332 | --- /dev/null |
333 | +++ b/helpers/sources.list.ppa |
334 | @@ -0,0 +1,2 @@ |
335 | +deb [arch=armhf] http://ppa.launchpad.net/shrirang-bagul/hwe/ubuntu bionic main |
336 | +deb-src [arch=armhf] http://ppa.launchpad.net/shrirang-bagul/hwe/ubuntu bionic main |
337 | diff --git a/snap.yaml b/snap.yaml |
338 | new file mode 100644 |
339 | index 0000000..ff227ee |
340 | --- /dev/null |
341 | +++ b/snap.yaml |
342 | @@ -0,0 +1,12 @@ |
343 | +name: nitrogen6x |
344 | +version: 18 |
345 | +summary: Nitrogen6x support package |
346 | +description: 'Support files for booting Boundary devices Nitrogen6x |
347 | + |
348 | + ' |
349 | +type: gadget |
350 | +base: core18 |
351 | +architectures: |
352 | +- armhf |
353 | +confinement: strict |
354 | +grade: stable |
355 | diff --git a/snap/gui/icon.png b/snap/gui/icon.png |
356 | new file mode 100644 |
357 | index 0000000..6aa523a |
358 | Binary files /dev/null and b/snap/gui/icon.png differ |
359 | diff --git a/snap/hooks/configure b/snap/hooks/configure |
360 | new file mode 100755 |
361 | index 0000000..38371e1 |
362 | --- /dev/null |
363 | +++ b/snap/hooks/configure |
364 | @@ -0,0 +1,3 @@ |
365 | +#!/bin/sh |
366 | + |
367 | +# do nothing for now |
368 | diff --git a/snapcraft.yaml b/snapcraft.yaml |
369 | new file mode 100644 |
370 | index 0000000..16bd3cf |
371 | --- /dev/null |
372 | +++ b/snapcraft.yaml |
373 | @@ -0,0 +1,97 @@ |
374 | +name: nitrogen6x |
375 | +version: "18" |
376 | +summary: Nitrogen6x support package |
377 | +description: | |
378 | + Support files for booting Boundary devices Nitrogen6x |
379 | +type: gadget |
380 | +base: core18 |
381 | +architectures: |
382 | + - armhf |
383 | +confinement: strict |
384 | +grade: stable |
385 | +parts: |
386 | + core-meta: |
387 | + plugin: nil |
388 | + source: . |
389 | + after: |
390 | + - uboot-fw |
391 | + - uboot-env |
392 | + override-build: | |
393 | + mkdir $SNAPCRAFT_PART_INSTALL/configs |
394 | + mkdir $SNAPCRAFT_PART_INSTALL/boot-assets |
395 | + touch $SNAPCRAFT_PART_INSTALL/boot.scr |
396 | + mkdir -p $SNAPCRAFT_PART_INSTALL/meta |
397 | + cp gadget.yaml $SNAPCRAFT_PART_INSTALL/meta |
398 | + cp snap.yaml $SNAPCRAFT_PART_INSTALL/meta |
399 | + classic-meta: |
400 | + plugin: nil |
401 | + source: . |
402 | + after: |
403 | + - uboot-fw |
404 | + - uboot-bootscript |
405 | + - cloud-init-configs |
406 | + - devicetrees |
407 | + override-build: | |
408 | + mkdir -p $SNAPCRAFT_PART_INSTALL/meta |
409 | + cp gadget.yaml $SNAPCRAFT_PART_INSTALL/meta |
410 | + cp snap.yaml $SNAPCRAFT_PART_INSTALL/meta |
411 | + cloud-init-configs: |
412 | + plugin: nil |
413 | + override-build: | |
414 | + cp -a configs -r $SNAPCRAFT_PART_INSTALL/ |
415 | + uboot-bootscript: |
416 | + plugin: nil |
417 | + override-build: | |
418 | + mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d boot.scr.in $SNAPCRAFT_PART_INSTALL/boot.scr |
419 | + build-packages: |
420 | + - u-boot-tools |
421 | + uboot-env: |
422 | + source: . |
423 | + plugin: nil |
424 | + override-build: | |
425 | + fakeroot make ARCH=$(dpkg-architecture -t$SNAPCRAFT_ARCH_TRIPLET -qDEB_HOST_ARCH) \ |
426 | + uboot-env |
427 | + cp -a install/* $SNAPCRAFT_PART_INSTALL/ |
428 | + override-prime: | |
429 | + snapcraftctl prime |
430 | + ln -s uboot.env uboot.conf |
431 | + build-packages: |
432 | + - u-boot-tools |
433 | + - fakeroot |
434 | + - dpkg-dev |
435 | + uboot-fw: |
436 | + source: . |
437 | + plugin: nil |
438 | + override-build: | |
439 | + use_test_ppa="true" |
440 | + if [ "$(arch)" = "x86_64" ]; then |
441 | + echo "Cross-compilation detected, using pre-defined sources.list." |
442 | + OPTIONAL_ARGUMENTS="SOURCES_HOST=\"./helpers/sources.list.cross\"" |
443 | + fi |
444 | + if [ ! -z "$use_test_ppa" ]; then |
445 | + echo "Use test ppa for u-boot-imx package using pre-defined sources.list.ppa" |
446 | + OPTIONAL_ARGUMENTS="SOURCES_HOST=\"./helpers/sources.list.ppa\"" |
447 | + fi |
448 | + fakeroot make ARCH=$(dpkg-architecture -t$SNAPCRAFT_ARCH_TRIPLET -qDEB_HOST_ARCH) \ |
449 | + ${OPTIONAL_ARGUMENTS:-} uboot-fw |
450 | + cp -a install/* $SNAPCRAFT_PART_INSTALL/ |
451 | + build-packages: |
452 | + - fakeroot |
453 | + - dpkg-dev |
454 | + devicetrees: |
455 | + plugin: nil |
456 | + source: . |
457 | + override-build: | |
458 | + PACKAGES="http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/binary-armhf/Packages.gz" |
459 | + PKGPATH="$(wget -q -O- $PACKAGES|zcat|grep Filename |\ |
460 | + grep linux-modules-4.15 | grep -ve lpae|tail -1| sed 's/^Filename: //')" |
461 | + wget http://ports.ubuntu.com/ubuntu-ports/$PKGPATH |
462 | + dpkg -x $(basename $PKGPATH) unpack/ |
463 | + mkdir -p $SNAPCRAFT_PART_INSTALL/boot-assets/dtbs |
464 | + cp -a unpack/lib/firmware/*/device-tree/imx6q-nitrogen6* $SNAPCRAFT_PART_INSTALL/boot-assets/dtbs |
465 | + rm -rf unpack |
466 | + build-packages: |
467 | + - coreutils |
468 | + - dctrl-tools |
469 | + - sed |
470 | + - wget |
471 | diff --git a/uboot.env.in b/uboot.env.in |
472 | new file mode 100644 |
473 | index 0000000..08e5070 |
474 | --- /dev/null |
475 | +++ b/uboot.env.in |
476 | @@ -0,0 +1,24 @@ |
477 | +arch=arm |
478 | +baudrate=115200 |
479 | +stderr=serial,lcd |
480 | +stdin=serial,usbkbd |
481 | +stdout=serial,lcd |
482 | +fdt_file=imx6q-nitrogen6x.dtb |
483 | +kernel_file=kernel.img |
484 | +initrd_file=initrd.img |
485 | +fdt_addr_r=0x13000000 |
486 | +kernel_addr_r=0x10800000 |
487 | +ramdisk_addr_r=0x13800000 |
488 | +initrd_addr_r=0x13a00000 |
489 | +initrd_high=0xffffffff |
490 | +fdt_high=0xffffffff |
491 | +loadfdt=fatload mmc 0:1 ${fdt_addr_r} ${snap_kernel}/dtbs/${fdt_file} |
492 | +loadfiles=run loadkernel; run loadinitrd; run loadfdt |
493 | +loadinitrd=fatload mmc 0:1 ${initrd_addr_r} ${snap_kernel}/${initrd_file}; setenv initrd_size ${filesize} |
494 | +loadkernel=fatload mmc 0:1 ${kernel_addr_r} ${snap_kernel}/${kernel_file} |
495 | +snappy_boot=if test "${snap_mode}" = "try"; then setenv snap_mode "trying"; saveenv; if test "${snap_try_core}" != ""; then setenv snap_core "${snap_try_core}"; fi; if test "${snap_try_kernel}" != ""; then setenv snap_kernel "${snap_try_kernel}"; fi; elif test "${snap_mode}" = "trying"; then setenv snap_mode ""; saveenv; fi; run loadfiles; setenv mmcroot "/dev/disk/by-label/writable ${snappy_cmdline} snap_core=${snap_core} snap_kernel=${snap_kernel}"; run mmcargs; bootz ${kernel_addr_r} ${initrd_addr_r}:${initrd_size} ${fdt_addr_r} |
496 | +snappy_cmdline=rng_core.default_quality=700 net.ifnames=0 init=/lib/systemd/systemd ro panic=-1 fixrtc usbcore.autosuspend=-1 |
497 | +mmcargs=setenv bootargs "console=ttymxc1,115200 consoleblank=0 clk_ignore_unused root=${mmcroot}" |
498 | +snappy_mode= |
499 | +uenvcmd=echo ENVCMD; run snappy_boot |
500 | +bootcmd=run uenvcmd |
I am slightly confused here.
First of all, and this regards both this 18-classic and the 18 branch of the gadget tree, but I was wondering if it was really needed to have different code for classic and core?
So currently we do something like that for the pi3, but this is a left-over from the times where the snappy team was working on the gadgets. Ideally we'd want to have one repository and branch for both core and classic. Meaning, one gadget code that could be built with `make` (or `snapcraft prime`) to get a compiled gadget tree to be used for building a classic image and, in the same way, just running `snapcraft` to build a gadget snap to be used for core. Currently we have those two separate branches because we're still working on 'integrating' those two into one code-base. It's a bit difficult with pi3 because we already have users using the old gadget snaps, and due to some design decisions, switching both core and classic to one common gadget requires some migration effort.
But for new platforms, I would prefer if we could do it the 'right way' and have just one gadget repository that would work for both core and classic cases. Would that be possible?
Also, it feels to me that these branches might be missing something! So for instance for a 'classic' gadget tree, I would expect to find a Makefile. In the best case I would like to see both the core and classic gadget code to provide a Makefile and use it to pull all the needed packages from the archives and install them in the right places. But this branch for instance has no Makefile. The snapcraft.yaml doesn't seem to have the 'gadget' target here for instance.
So basically, in the perfect scenario, we would want to have one gadget repository/branch that would work and have all that's needed for core and classic. Once one pulls the branch, as mentioned earlier, a `snapcraft` call on it should create a working snap and, for now, a call to `make` should result in a built gadget tree for ubuntu-image to consume. Basically `snapcraft` should use the Makefile as well + some additional steps that would be needed to get the snap prepared.
I understand the biggest challenge might be having one bootscript (uboot.env or boot.scr) that would support both core and classic. Dave from our team is working on that for pi3, so best if you could poke him for some advice. If it's not easily possible for some reason, I guess we could provide both boot.scr and uboot.env in the gadget repository and then just decide which one to use depending whether snapcraft is run or not.