@@ -195,93 +195,76 @@ create_image() {
195
195
rm -f " ${img} "
196
196
truncate -s ${img_size} " ${img} "
197
197
198
- if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " cros" ]; then
199
- # Setup as described in the u-boot documentation at doc/README.chromium
200
- cgpt create " ${img} "
201
- cgpt add -b 34 -s 32768 -P 1 -S 1 -t kernel " ${img} "
202
- local rootfs_size=$( cgpt show " $img " | awk ' /Sec GPT table/ { print $1 }' )
203
- (( rootfs_size -= 32802 ))
204
- cgpt add -b 32802 -s " ${rootfs_size} " -t rootfs " ${img} "
205
- cgpt boot -p " ${img} "
206
-
207
- # Set resize marker
198
+ (
199
+ if [ " ${EIB_PLATFORM} " == " pinebookpro" ]; then
200
+ # Rockchip's boot partition starts at 32768
201
+ # http://opensource.rock-chips.com/wiki_Partitions#Default_storage_map
202
+ echo -n " start=32768, "
203
+ else
204
+ # Empty space up to 1mb (for GPT, and for uboot on ARM)
205
+ echo -n " start=2048, "
206
+ fi
207
+
208
+ case " ${EIB_ARCH} " in
209
+ i386|amd64)
210
+ # EFI system partition
211
+ echo " size=${esp_size} MiB, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
212
+ if [[ " ${EIB_IMAGE_SDBOOT} " != " true" ]]; then
213
+ # GRUB BIOS BOOT partition
214
+ echo " size=1MiB, type=21686148-6449-6E6F-744E-656564454649"
215
+ fi
216
+ ;;
217
+ esac
218
+
219
+ # Raspberry Pi'ss GPU starts the boot process by loading bootloader blobs
220
+ # from the first partition which must be VFAT.
221
+ if [ " ${EIB_PLATFORM: 0: 3} " == " rpi" ]; then
222
+ # BOOT Partition
223
+ echo " size=100MiB, type=c"
224
+ fi
225
+
226
+ if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " dos" ]; then
227
+ part_type=" 83"
228
+ else
229
+ # Partition Type GUIDs
230
+ # https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
231
+ case " ${EIB_ARCH} " in
232
+ i386|amd64)
233
+ # Root Partition (x86-64)
234
+ part_type=" 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709"
235
+ ;;
236
+ arm64)
237
+ # Root Partition (64-bit ARM)
238
+ part_type=" b921b045-1df0-41c3-af44-4c6f280d3fae"
239
+ ;;
240
+ * )
241
+ echo " Unrecognized architecture ${EIB_ARCH} " >&2
242
+ return 1
243
+ ;;
244
+ esac
245
+ fi
246
+
208
247
if [[ " ${EIB_IMAGE_ROOTFS_RESIZE} " == " true" ]]; then
209
- local rootfs_attrs=" GUID:55"
248
+ # Remaining space is root fs, with special the special 55 attr as a
249
+ # marker indicating the partition should be resized later
250
+ # attrs=... is unused for DOS partition table so it's safe to leave it here
251
+ rootfs_attrs=" GUID:55"
210
252
fi
211
253
212
- # Mark the partition where /boot is as LegacyBIOSBootable as required by
213
- # the distro booting protocol (see doc/README.distro)
214
- sfdisk --part-attrs " ${img} " 2 " ${rootfs_attrs} LegacyBIOSBootable"
215
- else
216
- (
217
- if [ " ${EIB_PLATFORM} " == " pinebookpro" ]; then
218
- # Rockchip's boot partition starts at 32768
219
- # http://opensource.rock-chips.com/wiki_Partitions#Default_storage_map
220
- echo -n " start=32768, "
221
- else
222
- # Empty space up to 1mb (for GPT, and for uboot on ARM)
223
- echo -n " start=2048, "
224
- fi
225
-
226
- case " ${EIB_ARCH} " in
227
- i386|amd64)
228
- # EFI system partition
229
- echo " size=${esp_size} MiB, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
230
- # GRUB BIOS BOOT partition
231
- echo " size=1MiB, type=21686148-6449-6E6F-744E-656564454649"
232
- ;;
233
- esac
234
-
235
- # Raspberry Pi'ss GPU starts the boot process by loading bootloader blobs
236
- # from the first partition which must be VFAT.
237
- if [ " ${EIB_PLATFORM: 0: 3} " == " rpi" ]; then
238
- # BOOT Partition
239
- echo " size=100MiB, type=c"
240
- fi
241
-
242
- if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " dos" ]; then
243
- part_type=" 83"
244
- else
245
- # Partition Type GUIDs
246
- # https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
247
- case " ${EIB_ARCH} " in
248
- i386|amd64)
249
- # Root Partition (x86-64)
250
- part_type=" 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709"
251
- ;;
252
- arm64)
253
- # Root Partition (64-bit ARM)
254
- part_type=" b921b045-1df0-41c3-af44-4c6f280d3fae"
255
- ;;
256
- * )
257
- echo " Unrecognized architecture ${EIB_ARCH} " >&2
258
- return 1
259
- ;;
260
- esac
261
- fi
262
-
263
- if [[ " ${EIB_IMAGE_ROOTFS_RESIZE} " == " true" ]]; then
264
- # Remaining space is root fs, with special the special 55 attr as a
265
- # marker indicating the partition should be resized later
266
- # attrs=... is unused for DOS partition table so it's safe to leave it here
267
- rootfs_attrs=" GUID:55"
268
- fi
269
-
270
- if [[ " ${EIB_PLATFORM: 0: 3} " == " rpi" ]]; then
271
- # Make u-boot find the bootable partition which is rootfs for Raspberry Pi
272
- echo -n " bootable "
273
- fi
274
-
275
- # We need to escape attrs= otherwise sfdisk complains when passing an empty string
276
- echo " type=${part_type} , attrs=\" ${rootfs_attrs} \" "
277
-
278
- ) | sfdisk --force --label " ${EIB_IMAGE_PARTITION_TABLE} " " ${img} "
279
-
280
- if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " dos" ] && [ " ${EIB_IMAGE_ROOTFS_RESIZE} " == " true" ]; then
281
- # With the latest 'sfdisk' we are not allowed anymore to create a 0B partition
282
- # Bypass this limitation directly hacking into the MBR to set the marker
283
- printf " \xdd" | dd of=${img} bs=1 count=1 seek=498 conv=notrunc
284
- fi
254
+ if [[ " ${EIB_PLATFORM: 0: 3} " == " rpi" ]]; then
255
+ # Make u-boot find the bootable partition which is rootfs for Raspberry Pi
256
+ echo -n " bootable "
257
+ fi
258
+
259
+ # We need to escape attrs= otherwise sfdisk complains when passing an empty string
260
+ echo " type=${part_type} , attrs=\" ${rootfs_attrs} \" "
261
+
262
+ ) | sfdisk --force --label " ${EIB_IMAGE_PARTITION_TABLE} " " ${img} "
263
+
264
+ if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " dos" ] && [ " ${EIB_IMAGE_ROOTFS_RESIZE} " == " true" ]; then
265
+ # With the latest 'sfdisk' we are not allowed anymore to create a 0B partition
266
+ # Bypass this limitation directly hacking into the MBR to set the marker
267
+ printf " \xdd" | dd of=${img} bs=1 count=1 seek=498 conv=notrunc
285
268
fi
286
269
287
270
img_loop=$( losetup -f --show " ${img} " )
@@ -292,9 +275,14 @@ create_image() {
292
275
293
276
case " ${EIB_ARCH} " in
294
277
i386|amd64)
295
- esp_loop=${img_loop} p1
296
- bios_boot_loop=${img_loop} p2
297
- root_loop=${img_loop} p3
278
+ if [[ " ${EIB_IMAGE_SDBOOT} " == " true" ]]; then
279
+ esp_loop=${img_loop} p1
280
+ root_loop=${img_loop} p2
281
+ else
282
+ esp_loop=${img_loop} p1
283
+ bios_boot_loop=${img_loop} p2
284
+ root_loop=${img_loop} p3
285
+ fi
298
286
ext4_opts=" dir_index,^huge_file"
299
287
ESP=" ${ROOT} " /boot/efi
300
288
if [[ " ${EIB_IMAGE_SDBOOT} " = " true" ]]; then
@@ -306,7 +294,7 @@ create_image() {
306
294
* )
307
295
# On ARM disable 64bit ext4 option
308
296
ext4_opts=" dir_index,^huge_file,^64bit"
309
- if [ " ${EIB_IMAGE_PARTITION_TABLE} " == " cros " ] || [ " ${ EIB_PLATFORM: 0: 3}" == " rpi" ]; then
297
+ if [ " ${EIB_PLATFORM: 0: 3} " == " rpi" ]; then
310
298
boot_loop=${img_loop} p1
311
299
root_loop=${img_loop} p2
312
300
else
@@ -399,45 +387,44 @@ EOF
399
387
esac
400
388
;;
401
389
i386|amd64)
402
- # MBR bootloader install
403
- > " ${DEPLOY} " /img
404
- mount --bind " ${img} " " ${DEPLOY} " /img
405
- mount --bind " ${ROOT} " /boot " ${DEPLOY} " /boot
406
- mount --bind /dev " ${DEPLOY} " /dev
407
- mount --bind /proc " ${DEPLOY} " /proc
408
- mount --bind /sys " ${DEPLOY} " /sys
409
-
410
- # Install the real MBR bootloader
411
- chroot " ${DEPLOY} " /usr/sbin/grub-install \
412
- --modules=" ext2 part_msdos part_gpt search" \
413
- --directory=/usr/lib/grub/i386-pc \
414
- --config=/usr/lib/grub/conf/grub_embedded_bios.cfg \
415
- /img
416
-
417
- # Copy grub.cfg
418
- cp " ${DEPLOY} /usr/lib/grub/conf/grub.cfg" " ${DEPLOY} /boot/grub/grub.cfg"
419
-
420
- if [ " $EIB_IMAGE_BOOT_ZIP " == " true" ]; then
421
- local boot_zip_dir=${EIB_TMPDIR} /boot_zip
422
- mkdir " ${boot_zip_dir} "
423
-
424
- # Generate GRUB standalone images and eosldr
425
- " ${EIB_HELPERSDIR} " /create-grub-images " ${DEPLOY} " " ${boot_zip_dir} "
426
-
427
- # Capture second-stage config and modules
428
- cp -a " ${DEPLOY} /boot/grub" " ${boot_zip_dir} "
429
- fi
430
-
431
- " ${EIB_HELPERSDIR} " /kill-chroot-procs " ${DEPLOY} "
432
- umount " ${DEPLOY} " /{boot,dev,img,proc,sys}
433
- rm -f " ${DEPLOY} " /img
434
-
435
- # UEFI bootloader install
436
- if [[ " ${EIB_IMAGE_SDBOOT} " = " true" ]]; then
390
+ if [[ " ${EIB_IMAGE_SDBOOT} " == " true" ]]; then
437
391
# PAYG uses systemd-boot, install only that
438
392
mkdir -p " ${ESP} /EFI/BOOT/"
439
393
cp -r " ${DEPLOY} /usr/lib/systemd/boot/efi/systemd-bootx64.efi" " ${ESP} /EFI/BOOT/BOOTX64.efi"
440
394
else
395
+ # MBR bootloader install
396
+ > " ${DEPLOY} " /img
397
+ mount --bind " ${img} " " ${DEPLOY} " /img
398
+ mount --bind " ${ROOT} " /boot " ${DEPLOY} " /boot
399
+ mount --bind /dev " ${DEPLOY} " /dev
400
+ mount --bind /proc " ${DEPLOY} " /proc
401
+ mount --bind /sys " ${DEPLOY} " /sys
402
+
403
+ # Install the real MBR bootloader
404
+ chroot " ${DEPLOY} " /usr/sbin/grub-install \
405
+ --modules=" ext2 part_msdos part_gpt search" \
406
+ --directory=/usr/lib/grub/i386-pc \
407
+ --config=/usr/lib/grub/conf/grub_embedded_bios.cfg \
408
+ /img
409
+
410
+ # Copy grub.cfg
411
+ cp " ${DEPLOY} /usr/lib/grub/conf/grub.cfg" " ${DEPLOY} /boot/grub/grub.cfg"
412
+
413
+ if [ " $EIB_IMAGE_BOOT_ZIP " == " true" ]; then
414
+ local boot_zip_dir=${EIB_TMPDIR} /boot_zip
415
+ mkdir " ${boot_zip_dir} "
416
+
417
+ # Generate GRUB standalone images and eosldr
418
+ " ${EIB_HELPERSDIR} " /create-grub-images " ${DEPLOY} " " ${boot_zip_dir} "
419
+
420
+ # Capture second-stage config and modules
421
+ cp -a " ${DEPLOY} /boot/grub" " ${boot_zip_dir} "
422
+ fi
423
+
424
+ " ${EIB_HELPERSDIR} " /kill-chroot-procs " ${DEPLOY} "
425
+ umount " ${DEPLOY} " /{boot,dev,img,proc,sys}
426
+ rm -f " ${DEPLOY} " /img
427
+
441
428
# Standard endless system - grub, shim, all that kind of thing
442
429
cp -r " ${DEPLOY} " /usr/lib/efi_binaries/EFI " ${ESP} "
443
430
fi
0 commit comments