Пример #1
0
def main() -> None:
    """Main function."""
    # Create Boot Image instance
    img = BootImgRT(address=0x20000000, version=0x40)

    # Add DCD segment
    with open(f"{DATA_DIR}/dcd.txt", "r") as f_txt:
        img.dcd = SegDCD.parse_txt(f_txt.read())

    # Add application segment
    with open(f"{DATA_DIR}/plain_load_ivt_flashloader.bin", "rb") as f_bin:
        img.add_image(data=f_bin.read())

    # Print image info
    print(img.info())

    # Save into file
    with open(f"{DATA_DIR}/flashloader.imx", "wb") as f:
        f.write(img.export())
Пример #2
0
def dcd_from_txt() -> SegDCD:
    """Create DCD from a text (text file)."""
    data = """
        WriteValue    4 0x30340004 0x4F400005
        WriteValue    4 0x30340004 0x4F400005
        WriteValue    4 0x30340004 0x4F400005
        WriteValue    4 0x30340004 0x4F400005
        ClearBitMask  4 0x307900C4 0x00000001
        SetBitMask    4 0x307900C4 0x00000001
        CheckAllClear 4 0x307900C4 0x00000001
        CheckAllClear 4 0x307900C4 0x00000001 5
        CheckAnyClear 4 0x307900C4 0x00000001
        CheckAnyClear 4 0x307900C4 0x00000001 5
        CheckAllSet   4 0x307900C4 0x00000001
        CheckAllSet   4 0x307900C4 0x00000001 5
        CheckAnySet   4 0x307900C4 0x00000001
        CheckAnySet   4 0x307900C4 0x00000001 5
        Nop
    """
    return SegDCD.parse_txt(data)
Пример #3
0
def test_txt_parser_for_empty_input():
    assert SegDCD.parse_txt('') == SegDCD(enabled=True)
Пример #4
0
def test_txt_parser_from_cfg_tools(data_dir, ref_dcd_obj):
    with open(os.path.join(data_dir, 'dcd.txt'), 'r') as f:
        dcd_data = f.read()
    dcd_obj = SegDCD.parse_txt(dcd_data)
    # compare with reference DCD
    assert dcd_obj == ref_dcd_obj
Пример #5
0
def test_txt_parser_for_invalid_input():
    assert SegDCD.parse_txt('InvalidCmd\\\nNextLine') == SegDCD(
        enabled=True)  # test invalid commands are ignored