Exemplo n.º 1
0
 def _add_state_sectors(self) -> None:
     wl_state_data = WLFATFS.WL_STATE_T_DATA.build(
         dict(
             pos=0,
             max_pos=self.plain_fat_sectors + WLFATFS.DUMMY_SECTORS_COUNT,
             move_count=0,
             access_count=0,
             max_count=self._update_rate,
             block_size=self.sector_size,
             version=self._version,
             device_id=self._device_id or generate_4bytes_random(),
         ))
     crc = crc32(list(wl_state_data), WLFATFS.UINT32_MAX)
     wl_state_crc = Int32ul.build(crc)
     wl_state = wl_state_data + wl_state_crc
     self.fatfs_binary_image += WLFATFS.WL_STATE_COPY_COUNT * (
         (wl_state +
          (self.sector_size - WLFATFS.WL_STATE_HEADER_SIZE) * b'\xff') +
         (self.wl_state_sectors - 1) * self.sector_size * b'\xff')
Exemplo n.º 2
0
    def _add_config_sector(self) -> None:
        wl_config_data = WLFATFS.WL_CONFIG_T_DATA.build(
            dict(start_addr=0,
                 full_mem_size=self.partition_size,
                 page_size=self.sector_size,
                 sector_size=self.sector_size,
                 updaterate=self._update_rate,
                 wr_size=16,
                 version=self._version,
                 temp_buff_size=self._temp_buff_size))

        crc = crc32(list(wl_config_data), WLFATFS.UINT32_MAX)
        wl_config_crc = Int32ul.build(crc)

        # adding three 4 byte zeros to align the structure
        wl_config = wl_config_data + wl_config_crc + Int32ul.build(
            0) + Int32ul.build(0) + Int32ul.build(0)

        self.fatfs_binary_image += (
            wl_config +
            (self.sector_size - WLFATFS.WL_CONFIG_HEADER_SIZE) * b'\xff')