diff options
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/fitimage.py | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py index b39f2622df..31116979ef 100644 --- a/meta/lib/oeqa/selftest/cases/fitimage.py +++ b/meta/lib/oeqa/selftest/cases/fitimage.py | |||
| @@ -161,10 +161,23 @@ class FitImageTestCase(OESelftestTestCase): | |||
| 161 | 161 | ||
| 162 | @staticmethod | 162 | @staticmethod |
| 163 | def _get_dtb_files(bb_vars): | 163 | def _get_dtb_files(bb_vars): |
| 164 | """Return a list of devicetree names | ||
| 165 | |||
| 166 | The list should be used to check the dtb and conf nodes in the FIT image or its file. | ||
| 167 | In addition to the entries from KERNEL_DEVICETREE, the external devicetree and the | ||
| 168 | external devicetree overlay added by the test recipe bbb-dtbs-as-ext are handled as well. | ||
| 169 | """ | ||
| 164 | kernel_devicetree = bb_vars.get('KERNEL_DEVICETREE') | 170 | kernel_devicetree = bb_vars.get('KERNEL_DEVICETREE') |
| 171 | all_dtbs = [] | ||
| 172 | dtb_symlinks = [] | ||
| 165 | if kernel_devicetree: | 173 | if kernel_devicetree: |
| 166 | return [os.path.basename(dtb) for dtb in kernel_devicetree.split()] | 174 | all_dtbs += [os.path.basename(dtb) for dtb in kernel_devicetree.split()] |
| 167 | return [] | 175 | # Support only the test recipe which provides 1 devicetree and 1 devicetree overlay |
| 176 | pref_prov_dtb = bb_vars.get('PREFERRED_PROVIDER_virtual/dtb') | ||
| 177 | if pref_prov_dtb == "bbb-dtbs-as-ext": | ||
| 178 | all_dtbs += ["am335x-bonegreen-ext.dtb", "BBORG_RELAY-00A2.dtbo"] | ||
| 179 | dtb_symlinks.append("am335x-bonegreen-ext-alias.dtb") | ||
| 180 | return (all_dtbs, dtb_symlinks) | ||
| 168 | 181 | ||
| 169 | def _is_req_dict_in_dict(self, found_dict, req_dict): | 182 | def _is_req_dict_in_dict(self, found_dict, req_dict): |
| 170 | """ | 183 | """ |
| @@ -379,6 +392,7 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 379 | 'KERNEL_DEVICETREE', | 392 | 'KERNEL_DEVICETREE', |
| 380 | 'KERNEL_FIT_LINK_NAME', | 393 | 'KERNEL_FIT_LINK_NAME', |
| 381 | 'MACHINE', | 394 | 'MACHINE', |
| 395 | 'PREFERRED_PROVIDER_virtual/dtb', | ||
| 382 | 'UBOOT_ARCH', | 396 | 'UBOOT_ARCH', |
| 383 | 'UBOOT_ENTRYPOINT', | 397 | 'UBOOT_ENTRYPOINT', |
| 384 | 'UBOOT_LOADADDRESS', | 398 | 'UBOOT_LOADADDRESS', |
| @@ -452,7 +466,7 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 452 | ['/', 'images', 'kernel-1', 'signature-1'], | 466 | ['/', 'images', 'kernel-1', 'signature-1'], |
| 453 | ] | 467 | ] |
| 454 | """ | 468 | """ |
| 455 | dtb_files = FitImageTestCase._get_dtb_files(bb_vars) | 469 | dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars) |
| 456 | fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] | 470 | fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] |
| 457 | fit_uboot_env = bb_vars['FIT_UBOOT_ENV'] | 471 | fit_uboot_env = bb_vars['FIT_UBOOT_ENV'] |
| 458 | initramfs_image = bb_vars['INITRAMFS_IMAGE'] | 472 | initramfs_image = bb_vars['INITRAMFS_IMAGE'] |
| @@ -470,9 +484,9 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 470 | if initramfs_image and initramfs_image_bundle != "1": | 484 | if initramfs_image and initramfs_image_bundle != "1": |
| 471 | images.append('ramdisk-1') | 485 | images.append('ramdisk-1') |
| 472 | 486 | ||
| 473 | # configuration nodes | 487 | # configuration nodes (one per DTB and also one per symlink) |
| 474 | if dtb_files: | 488 | if dtb_files: |
| 475 | configurations = [ 'conf-' + conf for conf in dtb_files ] | 489 | configurations = [ 'conf-' + conf for conf in dtb_files + dtb_symlinks] |
| 476 | else: | 490 | else: |
| 477 | configurations = [ 'conf-1' ] | 491 | configurations = [ 'conf-1' ] |
| 478 | 492 | ||
| @@ -548,7 +562,7 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 548 | 562 | ||
| 549 | def _get_req_sections(self, bb_vars): | 563 | def _get_req_sections(self, bb_vars): |
| 550 | """Generate a dictionary of expected sections in the output of dumpimage""" | 564 | """Generate a dictionary of expected sections in the output of dumpimage""" |
| 551 | dtb_files = FitImageTestCase._get_dtb_files(bb_vars) | 565 | dtb_files, dtb_symlinks = FitImageTestCase._get_dtb_files(bb_vars) |
| 552 | fit_hash_alg = bb_vars['FIT_HASH_ALG'] | 566 | fit_hash_alg = bb_vars['FIT_HASH_ALG'] |
| 553 | fit_sign_alg = bb_vars['FIT_SIGN_ALG'] | 567 | fit_sign_alg = bb_vars['FIT_SIGN_ALG'] |
| 554 | fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] | 568 | fit_sign_individual = bb_vars['FIT_SIGN_INDIVIDUAL'] |
| @@ -584,11 +598,20 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 584 | } | 598 | } |
| 585 | # Create a configuration section for each DTB | 599 | # Create a configuration section for each DTB |
| 586 | if dtb_files: | 600 | if dtb_files: |
| 587 | for dtb in dtb_files: | 601 | for dtb in dtb_files + dtb_symlinks: |
| 588 | req_sections['conf-' + dtb] = { | 602 | # Assume that DTBs with an "-alias" in its name are symlink DTBs created e.g. by the |
| 589 | "Kernel": "kernel-1", | 603 | # bbb-dtbs-as-ext test recipe. Make the configuration node pointing to the real DTB. |
| 590 | "FDT": 'fdt-' + dtb, | 604 | real_dtb = dtb.replace("-alias", "") |
| 591 | } | 605 | # dtb overlays do not refer to a kernel (yet?) |
| 606 | if dtb.endswith('.dtbo'): | ||
| 607 | req_sections['conf-' + dtb] = { | ||
| 608 | "FDT": 'fdt-' + real_dtb, | ||
| 609 | } | ||
| 610 | else: | ||
| 611 | req_sections['conf-' + dtb] = { | ||
| 612 | "Kernel": "kernel-1", | ||
| 613 | "FDT": 'fdt-' + real_dtb, | ||
| 614 | } | ||
| 592 | if initramfs_image and initramfs_image_bundle != "1": | 615 | if initramfs_image and initramfs_image_bundle != "1": |
| 593 | req_sections['conf-' + dtb]['Init Ramdisk'] = "ramdisk-1" | 616 | req_sections['conf-' + dtb]['Init Ramdisk'] = "ramdisk-1" |
| 594 | else: | 617 | else: |
| @@ -635,7 +658,12 @@ class KernelFitImageTests(FitImageTestCase): | |||
| 635 | self.assertEqual(sign_algo, req_sign_algo, 'Signature algorithm for %s not expected value' % section) | 658 | self.assertEqual(sign_algo, req_sign_algo, 'Signature algorithm for %s not expected value' % section) |
| 636 | sign_value = values.get('Sign value', None) | 659 | sign_value = values.get('Sign value', None) |
| 637 | self.assertEqual(len(sign_value), fit_sign_alg_len, 'Signature value for section %s not expected length' % section) | 660 | self.assertEqual(len(sign_value), fit_sign_alg_len, 'Signature value for section %s not expected length' % section) |
| 638 | dtb_path = os.path.join(deploy_dir_image, section.replace('conf-', '')) | 661 | dtb_file_name = section.replace('conf-', '') |
| 662 | dtb_path = os.path.join(deploy_dir_image, dtb_file_name) | ||
| 663 | # External devicetrees created by devicetree.bbclass are in a subfolder and have priority | ||
| 664 | dtb_path_ext = os.path.join(deploy_dir_image, "devicetree", dtb_file_name) | ||
| 665 | if os.path.exists(dtb_path_ext): | ||
| 666 | dtb_path = dtb_path_ext | ||
| 639 | self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, dtb_path, section) | 667 | self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, dtb_path, section) |
| 640 | else: | 668 | else: |
| 641 | # Image nodes always need a hash which gets indirectly signed by the config signature | 669 | # Image nodes always need a hash which gets indirectly signed by the config signature |
| @@ -696,6 +724,27 @@ FIT_DESC = "A model description" | |||
| 696 | self._test_fitimage(bb_vars) | 724 | self._test_fitimage(bb_vars) |
| 697 | 725 | ||
| 698 | 726 | ||
| 727 | def test_fit_image_ext_dtb_dtbo(self): | ||
| 728 | """ | ||
| 729 | Summary: Check if FIT image and Image Tree Source (its) are created correctly. | ||
| 730 | Expected: 1) its and FIT image are built successfully | ||
| 731 | 2) The its file contains also the external devicetree overlay | ||
| 732 | 3) Dumping the FIT image indicates the devicetree overlay | ||
| 733 | """ | ||
| 734 | config = """ | ||
| 735 | # Enable creation of fitImage | ||
| 736 | MACHINE = "beaglebone-yocto" | ||
| 737 | KERNEL_IMAGETYPES += " fitImage " | ||
| 738 | KERNEL_CLASSES = " kernel-fitimage " | ||
| 739 | # Add a devicetree overlay which does not need kernel sources | ||
| 740 | PREFERRED_PROVIDER_virtual/dtb = "bbb-dtbs-as-ext" | ||
| 741 | """ | ||
| 742 | config = self._config_add_uboot_env(config) | ||
| 743 | self.write_config(config) | ||
| 744 | bb_vars = self._fit_get_bb_vars() | ||
| 745 | self._test_fitimage(bb_vars) | ||
| 746 | |||
| 747 | |||
| 699 | def test_sign_fit_image_configurations(self): | 748 | def test_sign_fit_image_configurations(self): |
| 700 | """ | 749 | """ |
| 701 | Summary: Check if FIT image and Image Tree Source (its) are created | 750 | Summary: Check if FIT image and Image Tree Source (its) are created |
