Example #1
0
def test_sdhc(cpu_params: CpuParams, image_name: str, tgt_address: int,
              dcd: Optional[str], plain0_signed1_encr2: int) -> None:
    """ Test creation of unsigned image

    :param cpu_params: processor specific parameters of the test
    :param image_name: filename of the source image; without file extension; without board prefix
    :param tgt_address: address, where the image will be located in the memory (start address of the memory)
    :param dcd: file name of the DCD file to be included in the image; None if no DCD needed
    :param plain0_signed1_encr2: 0 for unsigned; 1 for signed; 2 for encrypted
    """
    image_name = cpu_params.board + '_' + image_name
    # create bootable image object
    app_data = load_binary(cpu_params.data_dir, image_name + '.bin')
    boot_img = BootImgRT(tgt_address, BootImgRT.IVT_OFFSET_OTHER)
    boot_img.fcb = PaddingFCB(0, enabled=False)
    if dcd:
        boot_img.add_dcd_bin(load_binary(cpu_params.data_dir, dcd))

    if plain0_signed1_encr2 == 0:
        boot_img.add_image(app_data)
        suffix = '_sdhc_unsigned.bin'
    elif plain0_signed1_encr2 == 1:
        _to_authenticated_image(cpu_params, boot_img, app_data, 0)
        suffix = '_sdhc_signed.bin'
    elif plain0_signed1_encr2 == 2:
        _to_authenticated_image(cpu_params, boot_img, app_data, 0)
        suffix = '_sdhc_encrypted.bin'
    else:
        assert False

    # write image to disk and to processor
    write_image(cpu_params, image_name + suffix, boot_img)
Example #2
0
def test_unsigned(cpu_params: CpuParams, image_name: str, tgt_address: int, dcd: Optional[str]) -> None:
    """ Test creation of unsigned image

    :param cpu_params: processor specific parameters of the test
    :param image_name: filename of the source image; without file extension; without {board} prefix
    :param tgt_address: address, where the image will be located in the memory (start address of the memory)
    :param dcd: file name of the DCD file to be included in the image; None if no DCD needed
    """
    image_name = cpu_params.board + '_' + image_name
    # create bootable image object
    app_data = load_binary(cpu_params.data_dir, image_name + '.bin')
    boot_img = BootImgRT(tgt_address)
    boot_img.add_image(app_data)
    if dcd:
        boot_img.add_dcd_bin(load_binary(cpu_params.data_dir, dcd))

    # write image to disk and to processor
    write_image(cpu_params, image_name + '_unsigned.bin', boot_img)