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_nor_flash_fcb(cpu_params: CpuParams, fcb: bool) -> None:
    """Test unsigned image with FCB NOR FLASH block

    :param cpu_params: processor specific parameters of the test
    :param fcb: True to include FCB block to output image; False to exclude
    """
    image_name = f'{cpu_params.board}_iled_blinky_ext_FLASH'
    # create bootable image object
    app_data = load_binary(cpu_params.data_dir, image_name + '.bin')
    boot_img = BootImgRT(EXT_FLASH_ADDR)
    boot_img.add_image(app_data)
    if fcb:
        boot_img.set_flexspi_fcb(load_binary(cpu_params.data_dir, 'flex_spi.fcb'))
    else:
        boot_img.fcb = PaddingFCB(0, enabled=False)

    # write image to disk and to processor
    suffix = '_unsigned_fcb.bin' if fcb else '_unsigned_nofcb.bin'
    write_image(cpu_params, image_name + suffix, boot_img)
Example #3
0
def test_nor_flash_fcb(cpu_params: CpuParams, fcb: bool) -> None:
    """Test unsigned image with FCB NOR FLASH block

    :param cpu_params: processor specific parameters of the test
    :param fcb: True to include FCB block to output image; False to exclude
    """
    if (cpu_params.id != ID_RT1050) and (cpu_params.id != ID_RT1060):
        return  # this test case is supported only for RT1050 and RT1060

    image_name = f"{cpu_params.board}_iled_blinky_ext_FLASH"
    # create bootable image object
    app_data = load_binary(cpu_params.data_dir, image_name + ".bin")
    boot_img = BootImgRT(EXT_FLASH_ADDR)
    boot_img.add_image(app_data)
    if fcb:
        boot_img.set_flexspi_fcb(
            load_binary(cpu_params.data_dir, "flex_spi.fcb"))
    else:
        boot_img.fcb = PaddingFCB(0, enabled=False)

    # write image to disk and to processor
    suffix = "_unsigned_fcb.bin" if fcb else "_unsigned_nofcb.bin"
    write_image(cpu_params, image_name + suffix, boot_img)