Skip to content

Commit ec0ed82

Browse files
authored
Merge pull request #1267 from kernelkit/post-post-image
Move to a post post-image world Signed-off-by: Joachim Wiberg <[email protected]>
2 parents 9def1e6 + bac11da commit ec0ed82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1274
-925
lines changed

board/aarch64/board.mk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/*/*.mk))
12

23
.PHONY: board-enable-qemu-uboot
34
board-enable-qemu-uboot:
@@ -19,13 +20,6 @@ board-enable-qemu-uboot:
1920
'$$(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/extras.config' \
2021
--enable TARGET_UBOOT_FORMAT_DTB
2122

22-
.PHONY: board-enable-sparx-fit
23-
board-enable-sparx-fit:
24-
@$(call IXMSG,"Enabling SparX-5i compatible FIT options")
25-
@BR2_PREFIX= ./utils/config --file $(BR2_CONFIG) \
26-
--enable FIT_IMAGE \
27-
--set-str FIT_KERNEL_LOAD_ADDR "0x7 0x00000000"
28-
2923
.PHONY: board-sparx-flash-uboot
3024
board-sparx-flash-uboot: $(BINARIES_DIR)/u-boot.bin
3125
@grep -q 'BR2_TARGET_UBOOT_BOARD_DEFCONFIG="mscc_fireant_pcb135_emmc"' $(BR2_CONFIG) || \

board/board.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
include $(BR2_EXTERNAL_INFIX_PATH)/board/common/common.mk
12
include $(BR2_EXTERNAL_INFIX_PATH)/board/ix-board.mk
2-
include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/board/*/*/*.mk))
3+
-include $(BR2_EXTERNAL_INFIX_PATH)/board/$(patsubst "%",%,$(BR2_ARCH))/board.mk

board/common/Config.in

Lines changed: 16 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
menuconfig SIGN_ENABLED
2-
bool "Image Signing"
3-
default y
4-
5-
choice
6-
prompt "Signing key source"
7-
depends on SIGN_ENABLED
8-
default SIGN_SRC_DIR
9-
10-
config SIGN_SRC_DIR
11-
bool "Directory"
1+
menu "Images"
122

13-
config SIGN_SRC_PKCS11
14-
bool "PKCS#11 URL"
3+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rootfs/Config.in"
4+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in"
5+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in"
6+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-gns3a/Config.in"
7+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in"
8+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-dl-release/Config.in"
9+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-readme/Config.in"
1510

16-
endchoice
11+
endmenu
1712

18-
config SIGN_KEY
19-
string "Signing key"
20-
depends on SIGN_ENABLED
21-
default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development" if SIGN_SRC_DIR
13+
config QEMU_SCRIPTS
14+
bool "QEMU scripts"
15+
default y
16+
help
17+
Install QEMU scripts and related files in the images
18+
directory, which can be used to launch virtual Infix
19+
instances.
2220

2321
menuconfig TRUSTED_KEYS
2422
bool "Trusted keys for image"
25-
depends on SIGN_ENABLED
2623
help
2724
Keys that will be accepted for this image
2825

29-
3026
config TRUSTED_KEYS_DEVELOPMENT
3127
bool "Development key"
3228
depends on TRUSTED_KEYS
@@ -39,130 +35,3 @@ config TRUSTED_KEYS_DEVELOPMENT_PATH
3935
config TRUSTED_KEYS_EXTRA_PATH
4036
string "Path to extra keys to include in image"
4137
depends on TRUSTED_KEYS
42-
43-
menuconfig DISK_IMAGE
44-
bool "Disk image"
45-
help
46-
Compose a full disk image with redundant Linux OS partitions,
47-
configuration partition, etc.
48-
49-
This is useful when:
50-
- Bringing up a blank system during manufacturing
51-
- Creating a GNS3 appliance
52-
- Developing/debugging issues in the boot process in QEMU
53-
54-
menuconfig DISK_IMAGE_SIZE
55-
string "Image size"
56-
depends on DISK_IMAGE
57-
default "512M"
58-
help
59-
Create a disk image of this size. A K/M/G suffix may be used
60-
to multiply by powers of 1024. Suffixes like KB/MB/GB may be
61-
used to multiply by powers of 1000. The image will be split
62-
proportionally to fit the two rootfs, a kernel, a writable
63-
/cfg and /var partiotions.
64-
65-
Minimum supported size is 512M.
66-
67-
choice
68-
prompt "Bootloader"
69-
depends on DISK_IMAGE
70-
default DISK_IMAGE_BOOT_EFI if BR2_x86_64
71-
default DISK_IMAGE_BOOT_NONE
72-
73-
config DISK_IMAGE_BOOT_NONE
74-
bool "None"
75-
help
76-
Do not create any bootloader partition in the disk image.
77-
78-
config DISK_IMAGE_BOOT_EFI
79-
bool "EFI"
80-
help
81-
Create a boot partition from a directory containing an EFI
82-
boot application, e.g. GRUB.
83-
84-
config DISK_IMAGE_BOOT_BIN
85-
bool "Binary"
86-
help
87-
Create a boot partition from a raw image containing the boot
88-
application, e.g. U-Boot.
89-
90-
endchoice
91-
92-
config DISK_IMAGE_BOOT_DATA
93-
string "Bootloader data"
94-
depends on DISK_IMAGE
95-
depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN
96-
default "${BINARIES_DIR}/efi-part/EFI" if BR2_x86_64
97-
help
98-
Path to the directory or file holding the bootloader data.
99-
100-
config DISK_IMAGE_BOOT_OFFSET
101-
hex "Bootloader offset"
102-
depends on DISK_IMAGE
103-
depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN
104-
default 0x8000
105-
help
106-
Offset at which the bootloader partition is placed. Remember
107-
to make sure that the GPT still fits at the start of the
108-
image.
109-
110-
config DISK_IMAGE_RELEASE_URL
111-
string "Infix URL"
112-
depends on DISK_IMAGE
113-
depends on !BR2_TARGET_ROOTFS_SQUASHFS
114-
default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz"
115-
help
116-
In situations where Infix itself is not being built, but a
117-
disk image is, i.e. when building a bootloader: place this
118-
Infix release in the primary and secondary partitions.
119-
120-
menuconfig GNS3_APPLIANCE
121-
bool "GNS3 Appliance"
122-
select DISK_IMAGE
123-
default y
124-
help
125-
Create a GNS3 appliance description that, together with the
126-
disk image, can be imported into GNS3.
127-
128-
config GNS3_APPLIANCE_RAM
129-
int "Reserved RAM (MiB)"
130-
depends on GNS3_APPLIANCE
131-
default "192"
132-
help
133-
Amount of host RAM reserved for an appliance instance.
134-
135-
Minimum supported size is 192M.
136-
137-
config GNS3_APPLIANCE_IFNUM
138-
int "Number of interfaces"
139-
depends on GNS3_APPLIANCE
140-
default "1"
141-
help
142-
Number of Ethernet interfaces to create for an appliance instance.
143-
144-
menuconfig FIT_IMAGE
145-
bool "Traditional FIT image"
146-
help
147-
Create a "regular" FIT image where the kernel and DTBs are
148-
stored in the FIT rather than inside the rootfs (like it
149-
normally is in Infix).
150-
151-
This is useful when trying out Infix on targets whose
152-
bootloader might not be capable of booting a raw Squash, but
153-
is able to handle an FIT.
154-
155-
config FIT_ARCH
156-
string
157-
depends on FIT_IMAGE
158-
default "arm64" if BR2_aarch64
159-
160-
config FIT_KERNEL_LOAD_ADDR
161-
string "Kernel load address"
162-
depends on FIT_IMAGE
163-
164-
config SDCARD_AUX
165-
bool "Create SD-card aux partition"
166-
help
167-
Create and populate aux.ext4 with rootfs.itbh and rauc.status
168-
For use with a static genimage.cfg for, e.g., SD-cards.

board/common/common.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ifeq ($(SIGN_ENABLED),y)
1+
include $(BR2_EXTERNAL_INFIX_PATH)/board/common/image/image.mk
2+
include $(BR2_EXTERNAL_INFIX_PATH)/board/common/qemu/qemu.mk
3+
4+
ifeq ($(TRUSTED_KEYS),y)
25
include $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/uboot.mk
36

47
TRUSTED_KEYS=$(TRUSTED_KEYS_DEVELOPMENT_PATH) $(TRUSTED_KEYS_EXTRA_PATH)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config IMAGE_ITB_AUX
2+
bool "aux partition"
3+
depends on IMAGE_ITB_ROOTFS
4+
select BR2_PACKAGE_HOST_UBOOT_TOOLS
5+
select BR2_PACKAGE_HOST_GENIMAGE
6+
help
7+
Create and populate auxiliary partition, aux.ext4, with
8+
metadata needed by U-Boot and RAUC to operate properly on
9+
systems using ITB images. This may then be included as a
10+
partition in a larger disk image.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
boot="${1}"
6+
squash="${BINARIES_DIR}"/rootfs.squashfs
7+
itbh="${BINARIES_DIR}"/rootfs.itbh
8+
aux="${BINARIES_DIR}"/aux.ext4
9+
10+
mkdir -p "${WORKDIR}"/aux
11+
rm -rf "${WORKDIR}"/tmp
12+
mkdir -p "${WORKDIR}"/tmp
13+
14+
cp -f "${itbh}" "${WORKDIR}"/aux/primary.itbh
15+
cp -f "${itbh}" "${WORKDIR}"/aux/secondary.itbh
16+
17+
tstamp=$(date -u +%FT%TZ)
18+
rootsha=$(sha256sum "${squash}" | cut -d" " -f1)
19+
rootsize=$(stat -c %s "${squash}")
20+
cat <<EOF >"${WORKDIR}"/aux/rauc.status
21+
[slot.rootfs.0]
22+
bundle.compatible=${COMPATIBLE}
23+
bundle.version=${VERSION}
24+
status=ok
25+
sha256=${rootsha}
26+
size=${rootsize}
27+
installed.timestamp=$tstamp
28+
installed.count=1
29+
activated.timestamp=$tstamp
30+
activated.count=1
31+
32+
[slot.rootfs.1]
33+
bundle.compatible=${COMPATIBLE}
34+
bundle.version=${VERSION}
35+
status=ok
36+
sha256=${rootsha}
37+
size=${rootsize}
38+
installed.timestamp=$tstamp
39+
installed.count=1
40+
activated.timestamp=$tstamp
41+
activated.count=1
42+
EOF
43+
44+
case "${boot}" in
45+
uboot)
46+
cat <<EOF | mkenvimage -s 0x4000 -o "${WORKDIR}"/aux/uboot.env -
47+
BOOT_ORDER=primary secondary net
48+
BOOT_primary_LEFT=1
49+
BOOT_secondary_LEFT=1
50+
BOOT_net_LEFT=1
51+
EOF
52+
;;
53+
grub)
54+
mkdir -p "${WORKDIR}"/aux/grub
55+
cp -f "${PKGDIR}"/grub.cfg "${PKGDIR}"/grubenv "${WORKDIR}"/aux/grub
56+
;;
57+
*)
58+
echo "UNSUPPORTED BOOTLOADER ${boot}" >&2
59+
exit 1
60+
esac
61+
62+
cat <<EOF >"${WORKDIR}"/genimage.cfg
63+
image $(basename ${aux}) {
64+
mountpoint = "/"
65+
size = 8M
66+
67+
ext4 {
68+
label = "aux"
69+
use-mke2fs = true
70+
features = "^metadata_csum,^metadata_csum_seed,uninit_bg"
71+
extraargs = "-m 0 -i 4096"
72+
}
73+
}
74+
75+
# Silence genimage warnings
76+
config {}
77+
EOF
78+
79+
genimage \
80+
--loglevel 1 \
81+
--tmppath "${WORKDIR}"/tmp \
82+
--rootpath "${WORKDIR}"/aux \
83+
--inputpath "${WORKDIR}" \
84+
--outputpath "$(dirname ${aux})" \
85+
--config "${WORKDIR}"/genimage.cfg
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
set timeout="1"
2+
3+
load_env ORDER DEBUG
4+
5+
if [ -z "$ORDER" ]; then
6+
set ORDER="primary secondary"
7+
fi
8+
9+
set ORDER="$ORDER reboot"
10+
11+
for slot in $ORDER; do
12+
if [ -z "$default" ]; then
13+
set default="$slot"
14+
else
15+
# Contrary to what the documentation says, GRUB (2.06) does
16+
# not support using titles or IDs in the fallback variable, so
17+
# we translate to indices.
18+
if [ "$slot" = "primary" ]; then
19+
set fallback="$fallback 0"
20+
elif [ "$slot" = "secondary" ]; then
21+
set fallback="$fallback 1"
22+
elif [ "$slot" = "net" ]; then
23+
set fallback="$fallback 2"
24+
elif [ "$slot" = "reboot" ]; then
25+
set fallback="$fallback 3"
26+
fi
27+
fi
28+
done
29+
30+
if [ "$DEBUG" ]; then
31+
set log="debug"
32+
else
33+
set log="loglevel=4"
34+
fi
35+
36+
# From board/common/rootfs/etc/partition-uuid
37+
search -p 107ae911-a97b-4380-975c-7ce1a2dde1e0 --set primary
38+
search -p 352bd9b2-2ca9-44e2-bdc7-edbc87ba1e02 --set secondary
39+
40+
export primary
41+
export secondary
42+
43+
submenu "primary" "$log" {
44+
set slot="$1"
45+
set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 root=PARTLABEL=$slot $2"
46+
set root="($primary)"
47+
source /boot/grub/grub.cfg
48+
}
49+
50+
submenu "secondary" "$log" {
51+
set slot="$1"
52+
set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 root=PARTLABEL=$slot $2"
53+
set root="($secondary)"
54+
source /boot/grub/grub.cfg
55+
}
56+
57+
submenu "net" "$log" {
58+
net_dhcp
59+
60+
if [ "$net_efinet0_dhcp_next_server" -a "$net_efinet0_dhcp_boot_file" ]; then
61+
set initrd=(tftp,$net_efinet0_dhcp_next_server)/$net_efinet0_dhcp_boot_file
62+
loopback initrd $initrd
63+
set root=(initrd)
64+
65+
set slot="$1"
66+
set append="console=ttyS0 console=hvc0 usbcore.authorized_default=2 qroot=/dev/ram0 ramdisk_size=65536 $2"
67+
source /boot/grub/grub.cfg
68+
else
69+
if [ -z "$net_efinet0_dhcp_next_server" ]; then
70+
echo "No TFTP server supplied in DHCP response"
71+
fi
72+
if [ -z "$net_efinet0_dhcp_boot_file" ]; then
73+
echo "No bootfile supplied in DHCP response"
74+
fi
75+
fi
76+
}
77+
78+
submenu "reboot" {
79+
reboot
80+
}

0 commit comments

Comments
 (0)