Skip to content

Commit f25d661

Browse files
committed
Reformat Python files
1 parent c183945 commit f25d661

File tree

16 files changed

+33
-43
lines changed

16 files changed

+33
-43
lines changed

ltchiptool/soc/amb/system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from datastruct import DataStruct
77
from datastruct.fields import adapter, alignto, bitfield, field
88

9-
FF_16 = b"\xFF" * 16
9+
FF_16 = b"\xff" * 16
1010

1111

1212
class FlashSpeed(IntEnum):

ltchiptool/soc/ambz/binary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def check_xip_binary(
2424
) -> Optional[Tuple[int, int, bytes]]:
2525
if data[0:8] != header:
2626
return None
27-
if data[16:32] != b"\xFF" * 16:
27+
if data[16:32] != b"\xff" * 16:
2828
return None
2929
length, start = unpack("<II", data[8:16])
3030
return start, length, data[32:]
3131

3232

3333
def check_bootloader_binary(data: bytes) -> Optional[Tuple[int, int, bytes]]:
34-
return check_xip_binary(data, header=b"\x99\x99\x96\x96\x3F\xCC\x66\xFC")
34+
return check_xip_binary(data, header=b"\x99\x99\x96\x96\x3f\xcc\x66\xfc")
3535

3636

3737
class AmebaZBinary(SocInterface, ABC):

ltchiptool/soc/ambz/flash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def flash_sw_reset(self) -> None:
105105
port.baudrate = 115200
106106
sleep(0.1)
107107
# try software reset by writing the family ID, preceded by 55AA
108-
magic_word = b"\x55\xAA" + self.family.id.to_bytes(length=4, byteorder="big")
108+
magic_word = b"\x55\xaa" + self.family.id.to_bytes(length=4, byteorder="big")
109109
port.write(magic_word)
110110
sleep(0.5)
111111
port.baudrate = prev_baudrate
@@ -178,7 +178,7 @@ def flash_get_chip_info(self) -> List[Tuple[str, str]]:
178178
syscfg2 = letoint(data[256 + 512 + 16 + 8 : 256 + 512 + 16 + 8 + 4])
179179

180180
system_data = data[256 + 512 + 16 + 16 : 256 + 512 + 16 + 16 + 128].ljust(
181-
4096, b"\xFF"
181+
4096, b"\xff"
182182
)
183183
system = SystemData.unpack(system_data)
184184

ltchiptool/soc/ambz/util/ambzcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def read_efuse_otp(offset: int = 0) -> bytes:
204204
return (
205205
b"\x02\x48\x01\x4b"
206206
b"\x98\x47\x03\xe0"
207-
b"\x21\x3C\x00\x00" # EFUSE_OTP_Read32B()
207+
b"\x21\x3c\x00\x00" # EFUSE_OTP_Read32B()
208208
) + inttole32(AMBZ_DATA_ADDRESS + offset)
209209

210210
@staticmethod

ltchiptool/soc/ambz/util/ambztool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def read(self, io: IO[bytes], n: int) -> bytes:
108108
# increment saved address
109109
self.address += n
110110
# add padding to force sending N+4 packet size
111-
data = data.ljust(n + 4, b"\xFF")
111+
data = data.ljust(n + 4, b"\xff")
112112
return data
113113

114114

ltchiptool/soc/ambz/util/rtltool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
CMD_XMD = b"\x07" # Go xmodem mode (write RAM/Flash mode)
3030
CMD_EFS = b"\x17" # Erase Flash Sectors
3131
CMD_RBF = b"\x19" # Read Block Flash
32-
CMD_ABRT = b"\x1B" # End xmodem mode (write RAM/Flash mode)
32+
CMD_ABRT = b"\x1b" # End xmodem mode (write RAM/Flash mode)
3333
CMD_GFS = b"\x21" # FLASH Get Status
3434
CMD_SFS = b"\x26" # FLASH Set Status
3535

@@ -283,7 +283,7 @@ def send_xmodem(self, stream, offset, size, retry=3):
283283
if not data: # end of stream
284284
print("send: at EOF")
285285
return False
286-
data = data.ljust(packet_size, b"\xFF")
286+
data = data.ljust(packet_size, b"\xff")
287287
pkt = (
288288
struct.pack("<BBBI", ord(cmd), sequence, 0xFF - sequence, offset)
289289
+ data

ltchiptool/soc/ambz2/binary.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def elf2bin(self, input: str, ota_idx: int) -> List[FirmwareBinary]:
134134
nmap_ota1 = self.board.toolchain.nm(input)
135135

136136
# build the partition table
137-
ptable = PartitionTable(user_data=b"\xFF" * 256)
137+
ptable = PartitionTable(user_data=b"\xff" * 256)
138138
for region, type in config.ptable.items():
139139
offset, length, _ = self.board.region(region)
140140
hash_key = config.keys.hash_keys[region]
@@ -205,11 +205,11 @@ def elf2bin(self, input: str, ota_idx: int) -> List[FirmwareBinary]:
205205
with output.write() as f:
206206
f.write(data)
207207
with out_ptab.write() as f:
208-
ptab = data[ptab_offset:ptab_end].rstrip(b"\xFF")
208+
ptab = data[ptab_offset:ptab_end].rstrip(b"\xff")
209209
ptab = pad_data(ptab, 0x20, 0xFF)
210210
f.write(ptab)
211211
with out_boot.write() as f:
212-
boot = data[boot_offset:boot_end].rstrip(b"\xFF")
212+
boot = data[boot_offset:boot_end].rstrip(b"\xff")
213213
boot = pad_data(boot, 0x20, 0xFF)
214214
f.write(boot)
215215
with out_ota1.write() as f:
@@ -230,15 +230,15 @@ def detect_file_type(
230230
return Detection.make("Realtek AmebaZ2 Flash Image", offset=0)
231231

232232
if (
233-
data[0x40:0x44] != b"\xFF\xFF\xFF\xFF"
233+
data[0x40:0x44] != b"\xff\xff\xff\xff"
234234
and data[0x48] == ImageType.BOOT.value
235235
):
236236
return Detection.make("Realtek AmebaZ2 Bootloader", offset=0x4000)
237237

238238
if (
239-
data[0xE0:0xE8].strip(b"\xFF")
239+
data[0xE0:0xE8].strip(b"\xff")
240240
and data[0xE8] == ImageType.FWHS_S.value
241-
and data[0x1A0:0x1A8].strip(b"\xFF")
241+
and data[0x1A0:0x1A8].strip(b"\xff")
242242
and data[0x1A8] == SectionType.SRAM.value
243243
):
244244
return Detection.make("Realtek AmebaZ2 Firmware", offset=None)

ltchiptool/soc/ambz2/util/models/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from .partitions import Bootloader, Firmware, PartitionTable
2828
from .utils import FF_32
2929

30-
FLASH_CALIBRATION = b"\x99\x99\x96\x96\x3F\xCC\x66\xFC\xC0\x33\xCC\x03\xE5\xDC\x31\x62"
30+
FLASH_CALIBRATION = b"\x99\x99\x96\x96\x3f\xcc\x66\xfc\xc0\x33\xcc\x03\xe5\xdc\x31\x62"
3131

3232

3333
@dataclass

ltchiptool/soc/ambz2/util/models/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from datastruct import Adapter, Context
66

7-
FF_48 = b"\xFF" * 48
8-
FF_32 = b"\xFF" * 32
9-
FF_16 = b"\xFF" * 16
7+
FF_48 = b"\xff" * 48
8+
FF_32 = b"\xff" * 32
9+
FF_16 = b"\xff" * 16
1010

1111
T = TypeVar("T")
1212

ltchiptool/soc/bk72xx/binary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def to_address(offs: int) -> int:
2929
def check_app_code_crc(data: bytes) -> Union[bool, None]:
3030
# b #0x40
3131
# ldr pc, [pc, #0x14]
32-
if data[0:8] == b"\x2F\x07\xB5\x94\x35\xFF\x2A\x9B":
32+
if data[0:8] == b"\x2f\x07\xb5\x94\x35\xff\x2a\x9b":
3333
crc = CRC16.CMS.calc(data[0:32])
3434
crc_found = betoint(data[32:34])
3535
if crc == crc_found:
@@ -183,13 +183,13 @@ def elf2bin(self, input: str, ota_idx: int) -> List[FirmwareBinary]:
183183
with out_ug.write() as ug:
184184
hdr = BytesIO()
185185
ota_bin = ota_data.getvalue()
186-
hdr.write(b"\x55\xAA\x55\xAA")
186+
hdr.write(b"\x55\xaa\x55\xaa")
187187
hdr.write(pad_data(version.encode(), 12, 0x00))
188188
hdr.write(inttobe32(len(ota_bin)))
189189
hdr.write(inttobe32(sum(ota_bin)))
190190
ug.write(hdr.getvalue())
191191
ug.write(inttobe32(sum(hdr.getvalue())))
192-
ug.write(b"\xAA\x55\xAA\x55")
192+
ug.write(b"\xaa\x55\xaa\x55")
193193
ug.write(ota_bin)
194194

195195
# close all files
@@ -218,7 +218,7 @@ def detect_file_type(
218218
return Detection.make_unsupported("Beken Encrypted App")
219219

220220
# raw firmware binary
221-
if data[0:8] == b"\x0E\x00\x00\xEA\x14\xF0\x9F\xE5":
221+
if data[0:8] == b"\x0e\x00\x00\xea\x14\xf0\x9f\xe5":
222222
return Detection.make_unsupported("Raw ARM Binary")
223223

224224
# RBL file for OTA - 'download' partition

0 commit comments

Comments
 (0)