summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/fitimage.py262
1 files changed, 129 insertions, 133 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index dd177e0b04..00769443e8 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -168,7 +168,6 @@ FIT_DESC = "A model description"
168 dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir) 168 dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
169 self._verify_fitimage_uboot_env(dumpimage_result) 169 self._verify_fitimage_uboot_env(dumpimage_result)
170 170
171
172 def test_sign_fit_image(self): 171 def test_sign_fit_image(self):
173 """ 172 """
174 Summary: Check if FIT image and Image Tree Source (its) are created 173 Summary: Check if FIT image and Image Tree Source (its) are created
@@ -314,6 +313,135 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'"
314 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, 313 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
315 os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], dtb), 'conf-' + dtb) 314 os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], dtb), 'conf-' + dtb)
316 315
316 def test_initramfs_bundle(self):
317 """
318 Summary: Verifies the content of the initramfs bundle node in the FIT Image Tree Source (its)
319 The FIT settings are set by the test case.
320 The machine used is beaglebone-yocto.
321 Expected: 1. The ITS is generated with initramfs bundle support
322 2. All the fields in the kernel node are as expected (matching the
323 conf settings)
324 3. The kernel is included in all the available configurations and
325 its hash is included in the configuration signature
326
327 Product: oe-core
328 Author: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
329 """
330
331 config = """
332DISTRO="poky"
333MACHINE = "beaglebone-yocto"
334INITRAMFS_IMAGE_BUNDLE = "1"
335INITRAMFS_IMAGE = "core-image-minimal-initramfs"
336INITRAMFS_SCRIPTS = ""
337UBOOT_MACHINE = "am335x_evm_defconfig"
338KERNEL_CLASSES = " kernel-fitimage "
339KERNEL_IMAGETYPES = "fitImage"
340UBOOT_SIGN_ENABLE = "1"
341UBOOT_SIGN_KEYNAME = "beaglebonekey"
342UBOOT_SIGN_KEYDIR ?= "${DEPLOY_DIR_IMAGE}"
343UBOOT_DTB_BINARY = "u-boot.dtb"
344UBOOT_ENTRYPOINT = "0x80000000"
345UBOOT_LOADADDRESS = "0x80000000"
346UBOOT_DTB_LOADADDRESS = "0x82000000"
347UBOOT_ARCH = "arm"
348UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
349UBOOT_MKIMAGE_KERNEL_TYPE = "kernel"
350UBOOT_EXTLINUX = "0"
351FIT_GENERATE_KEYS = "1"
352KERNEL_IMAGETYPE_REPLACEMENT = "zImage"
353FIT_KERNEL_COMP_ALG = "none"
354FIT_HASH_ALG = "sha256"
355"""
356 config = self._config_add_uboot_env(config)
357 self.write_config(config)
358
359 # fitImage is created as part of linux recipe
360 bitbake("virtual/kernel")
361
362 bb_vars = get_bb_vars([
363 'DEPLOY_DIR_IMAGE',
364 'FIT_HASH_ALG',
365 'FIT_KERNEL_COMP_ALG',
366 'INITRAMFS_IMAGE',
367 'MACHINE',
368 'UBOOT_ARCH',
369 'UBOOT_ENTRYPOINT',
370 'UBOOT_LOADADDRESS',
371 'UBOOT_MKIMAGE_KERNEL_TYPE'
372 ],
373 'virtual/kernel')
374 fitimage_its_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],
375 "fitImage-its-%s-%s-%s" % (bb_vars['INITRAMFS_IMAGE'], bb_vars['MACHINE'], bb_vars['MACHINE']))
376 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],"fitImage")
377
378 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
379 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
380
381 its_file = open(fitimage_its_path)
382
383 its_lines = [line.strip() for line in its_file.readlines()]
384
385 exp_node_lines = [
386 'kernel-1 {',
387 'description = "Linux kernel";',
388 'data = /incbin/("linux.bin");',
389 'type = "' + str(bb_vars['UBOOT_MKIMAGE_KERNEL_TYPE']) + '";',
390 'arch = "' + str(bb_vars['UBOOT_ARCH']) + '";',
391 'os = "linux";',
392 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";',
393 'load = <' + str(bb_vars['UBOOT_LOADADDRESS']) + '>;',
394 'entry = <' + str(bb_vars['UBOOT_ENTRYPOINT']) + '>;',
395 'hash-1 {',
396 'algo = "' + str(bb_vars['FIT_HASH_ALG']) +'";',
397 '};',
398 '};'
399 ]
400
401 node_str = exp_node_lines[0]
402
403 print ("checking kernel node\n")
404 self.assertIn(node_str, its_lines)
405
406 node_start_idx = its_lines.index(node_str)
407 node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))]
408
409 # Remove the absolute path. This refers to WORKDIR which is not always predictable.
410 re_data = re.compile(r'^data = /incbin/\(.*/linux\.bin"\);$')
411 node = [re.sub(re_data, 'data = /incbin/("linux.bin");', cfg_str) for cfg_str in node]
412
413 self.assertEqual(node, exp_node_lines, "kernel node does not match expectation")
414
415 rx_configs = re.compile("^conf-.*")
416 its_configs = list(filter(rx_configs.match, its_lines))
417
418 for cfg_str in its_configs:
419 cfg_start_idx = its_lines.index(cfg_str)
420 line_idx = cfg_start_idx + 2
421 node_end = False
422 while node_end == False:
423 if its_lines[line_idx] == "};" and its_lines[line_idx-1] == "};" :
424 node_end = True
425 line_idx = line_idx + 1
426
427 node = its_lines[cfg_start_idx:line_idx]
428 print("checking configuration " + cfg_str.rstrip(" {"))
429 rx_desc_line = re.compile(r'^description = ".*Linux kernel.*')
430 self.assertEqual(len(list(filter(rx_desc_line.match, node))), 1, "kernel keyword not found in the description line")
431
432 self.assertIn('kernel = "kernel-1";', node)
433
434 rx_sign_line = re.compile(r'^sign-images = .*kernel.*')
435 self.assertEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed")
436
437 # Verify the signature
438 uboot_tools_bindir = self._setup_uboot_tools_native()
439 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb'))
440
441 # Check if the u-boot boot.scr script is in the fitImage
442 dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
443 self._verify_fitimage_uboot_env(dumpimage_result)
444
317 def test_uboot_fit_image(self): 445 def test_uboot_fit_image(self):
318 """ 446 """
319 Summary: Check if Uboot FIT image and Image Tree Source 447 Summary: Check if Uboot FIT image and Image Tree Source
@@ -522,7 +650,6 @@ UBOOT_FIT_HASH_ALG = "sha256"
522 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, 650 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
523 os.path.join(deploy_dir_image, 'u-boot-spl.dtb')) 651 os.path.join(deploy_dir_image, 'u-boot-spl.dtb'))
524 652
525
526 def test_sign_cascaded_uboot_fit_image(self): 653 def test_sign_cascaded_uboot_fit_image(self):
527 """ 654 """
528 Summary: Check if U-Boot FIT image and Image Tree Source (its) are 655 Summary: Check if U-Boot FIT image and Image Tree Source (its) are
@@ -667,137 +794,6 @@ FIT_SIGN_INDIVIDUAL = "1"
667 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, 794 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
668 os.path.join(deploy_dir_image, 'u-boot-spl.dtb')) 795 os.path.join(deploy_dir_image, 'u-boot-spl.dtb'))
669 796
670
671 def test_initramfs_bundle(self):
672 """
673 Summary: Verifies the content of the initramfs bundle node in the FIT Image Tree Source (its)
674 The FIT settings are set by the test case.
675 The machine used is beaglebone-yocto.
676 Expected: 1. The ITS is generated with initramfs bundle support
677 2. All the fields in the kernel node are as expected (matching the
678 conf settings)
679 3. The kernel is included in all the available configurations and
680 its hash is included in the configuration signature
681
682 Product: oe-core
683 Author: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
684 """
685
686 config = """
687DISTRO="poky"
688MACHINE = "beaglebone-yocto"
689INITRAMFS_IMAGE_BUNDLE = "1"
690INITRAMFS_IMAGE = "core-image-minimal-initramfs"
691INITRAMFS_SCRIPTS = ""
692UBOOT_MACHINE = "am335x_evm_defconfig"
693KERNEL_CLASSES = " kernel-fitimage "
694KERNEL_IMAGETYPES = "fitImage"
695UBOOT_SIGN_ENABLE = "1"
696UBOOT_SIGN_KEYNAME = "beaglebonekey"
697UBOOT_SIGN_KEYDIR ?= "${DEPLOY_DIR_IMAGE}"
698UBOOT_DTB_BINARY = "u-boot.dtb"
699UBOOT_ENTRYPOINT = "0x80000000"
700UBOOT_LOADADDRESS = "0x80000000"
701UBOOT_DTB_LOADADDRESS = "0x82000000"
702UBOOT_ARCH = "arm"
703UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
704UBOOT_MKIMAGE_KERNEL_TYPE = "kernel"
705UBOOT_EXTLINUX = "0"
706FIT_GENERATE_KEYS = "1"
707KERNEL_IMAGETYPE_REPLACEMENT = "zImage"
708FIT_KERNEL_COMP_ALG = "none"
709FIT_HASH_ALG = "sha256"
710"""
711 config = self._config_add_uboot_env(config)
712 self.write_config(config)
713
714 # fitImage is created as part of linux recipe
715 bitbake("virtual/kernel")
716
717 bb_vars = get_bb_vars([
718 'DEPLOY_DIR_IMAGE',
719 'FIT_HASH_ALG',
720 'FIT_KERNEL_COMP_ALG',
721 'INITRAMFS_IMAGE',
722 'MACHINE',
723 'UBOOT_ARCH',
724 'UBOOT_ENTRYPOINT',
725 'UBOOT_LOADADDRESS',
726 'UBOOT_MKIMAGE_KERNEL_TYPE'
727 ],
728 'virtual/kernel')
729 fitimage_its_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],
730 "fitImage-its-%s-%s-%s" % (bb_vars['INITRAMFS_IMAGE'], bb_vars['MACHINE'], bb_vars['MACHINE']))
731 fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'],"fitImage")
732
733 self.assertExists(fitimage_its_path, "%s image tree source doesn't exist" % (fitimage_its_path))
734 self.assertExists(fitimage_path, "%s FIT image doesn't exist" % (fitimage_path))
735
736 its_file = open(fitimage_its_path)
737
738 its_lines = [line.strip() for line in its_file.readlines()]
739
740 exp_node_lines = [
741 'kernel-1 {',
742 'description = "Linux kernel";',
743 'data = /incbin/("linux.bin");',
744 'type = "' + str(bb_vars['UBOOT_MKIMAGE_KERNEL_TYPE']) + '";',
745 'arch = "' + str(bb_vars['UBOOT_ARCH']) + '";',
746 'os = "linux";',
747 'compression = "' + str(bb_vars['FIT_KERNEL_COMP_ALG']) + '";',
748 'load = <' + str(bb_vars['UBOOT_LOADADDRESS']) + '>;',
749 'entry = <' + str(bb_vars['UBOOT_ENTRYPOINT']) + '>;',
750 'hash-1 {',
751 'algo = "' + str(bb_vars['FIT_HASH_ALG']) +'";',
752 '};',
753 '};'
754 ]
755
756 node_str = exp_node_lines[0]
757
758 print ("checking kernel node\n")
759 self.assertIn(node_str, its_lines)
760
761 node_start_idx = its_lines.index(node_str)
762 node = its_lines[node_start_idx:(node_start_idx + len(exp_node_lines))]
763
764 # Remove the absolute path. This refers to WORKDIR which is not always predictable.
765 re_data = re.compile(r'^data = /incbin/\(.*/linux\.bin"\);$')
766 node = [re.sub(re_data, 'data = /incbin/("linux.bin");', cfg_str) for cfg_str in node]
767
768 self.assertEqual(node, exp_node_lines, "kernel node does not match expectation")
769
770 rx_configs = re.compile("^conf-.*")
771 its_configs = list(filter(rx_configs.match, its_lines))
772
773 for cfg_str in its_configs:
774 cfg_start_idx = its_lines.index(cfg_str)
775 line_idx = cfg_start_idx + 2
776 node_end = False
777 while node_end == False:
778 if its_lines[line_idx] == "};" and its_lines[line_idx-1] == "};" :
779 node_end = True
780 line_idx = line_idx + 1
781
782 node = its_lines[cfg_start_idx:line_idx]
783 print("checking configuration " + cfg_str.rstrip(" {"))
784 rx_desc_line = re.compile(r'^description = ".*Linux kernel.*')
785 self.assertEqual(len(list(filter(rx_desc_line.match, node))), 1, "kernel keyword not found in the description line")
786
787 self.assertIn('kernel = "kernel-1";', node)
788
789 rx_sign_line = re.compile(r'^sign-images = .*kernel.*')
790 self.assertEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed")
791
792 # Verify the signature
793 uboot_tools_bindir = self._setup_uboot_tools_native()
794 self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb'))
795
796 # Check if the u-boot boot.scr script is in the fitImage
797 dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
798 self._verify_fitimage_uboot_env(dumpimage_result)
799
800
801 def test_uboot_atf_tee_fit_image(self): 797 def test_uboot_atf_tee_fit_image(self):
802 """ 798 """
803 Summary: Check if U-boot FIT image and Image Tree Source 799 Summary: Check if U-boot FIT image and Image Tree Source