Exemplo n.º 1
0
def test_multiple_images_with_relocation_table(data_dir):
    """Test image that contains multiple binary images and relocation table
    :param data_dir: absolute path, where test data are located
    """
    with open(os.path.join(data_dir, 'multicore', "testfffffff.bin"),
              "rb") as f:
        img_data = f.read()
    with open(os.path.join(data_dir, 'multicore', "normal_boot.bin"),
              "rb") as f:
        img1_data = f.read()
    with open(os.path.join(data_dir, 'multicore', "special_boot.bin"),
              "rb") as f:
        img2_data = f.read()

    with open(os.path.join(data_dir, 'multicore', "rt5xxA0.json"), "rb") as f:
        trust_zone_data = json.loads(f.read())['trustZonePreset']

    table = MultipleImageTable()
    table.add_entry(MultipleImageEntry(img1_data, 0x80000))
    table.add_entry(MultipleImageEntry(img2_data, 0x80600))

    mbi = MasterBootImage(app=img_data,
                          app_table=table,
                          load_addr=0,
                          image_type=MasterBootImageType.CRC_RAM_IMAGE,
                          trust_zone=TrustZone.custom('rt5xx',
                                                      trust_zone_data))

    assert _compare_image(mbi, os.path.join(data_dir, 'multicore'),
                          'expected_output.bin')
Exemplo n.º 2
0
def test_multiple_images_with_relocation_table(data_dir):
    """Test image that contains multiple binary images and relocation table
    :param data_dir: absolute path, where test data are located
    """
    with open(os.path.join(data_dir, "multicore", "testfffffff.bin"),
              "rb") as f:
        img_data = f.read()
    with open(os.path.join(data_dir, "multicore", "normal_boot.bin"),
              "rb") as f:
        img1_data = f.read()
    with open(os.path.join(data_dir, "multicore", "special_boot.bin"),
              "rb") as f:
        img2_data = f.read()

    with open(os.path.join(data_dir, "multicore", "rt5xxA0.json"), "rb") as f:
        trust_zone_data = json.loads(f.read())["trustZonePreset"]

    table = MultipleImageTable()
    table.add_entry(MultipleImageEntry(img1_data, 0x80000))
    table.add_entry(MultipleImageEntry(img2_data, 0x80600))

    mbi = Mbi_CrcRamRtxxx(
        app=img_data,
        app_table=table,
        load_addr=0,
        trust_zone=TrustZone.custom("rt5xx", trust_zone_data),
    )

    assert _compare_image(mbi, os.path.join(data_dir, "multicore"),
                          "expected_output.bin")