def padding_space(h, pgsz: int, space_data: bytes) -> list: 
    """Padding each data block with `space_data` to let block size fit pgsz * N.
    
    Args:
        h (list): response from `asaloader.ihex.parse`.
        pgsz (int): page size, e.g. 256, 512.
        space_data (bytes): the byte data used to padding.
    
    Returns:
        list: data blocks
    """
    res = []
    for sect in h:
        sect_addr = sect['address']
        sect_data = sect['data']

        # 起始位置若不在 pgsz * N 上
        # 往前補 0xFF
        if sect_addr % pgsz != 0:
            n = sect_addr // pgsz
            l = sect_addr - pgsz * n
            sect_addr = pgsz * n
            a = bytes([0xff for i in range(l)])
            sect_data = a + sect_data
        
        # 結束位置 + 1 若不在 pgsz * N 上
        # 往後補 0xFF
        if (sect_addr + len(sect_data)) % pgsz != 0:
            n = (sect_addr + len(sect_data)) // pgsz
            l = pgsz * (n + 1) - (sect_addr + len(sect_data))
            a = bytes([0xff for i in range(l)])
            sect_data = sect_data + a

        res += [{
            'address': sect_addr,
            'data': sect_data
        }]
    
    return res