JelmerT / cc2538-bsl

Python cross-platform script to upload firmware via the serial boot loader onto the CC13xx, CC2538 and CC26xx SoC.
BSD 3-Clause "New" or "Revised" License
534 stars 181 forks source link

ERROR: int() can't convert non-string with explicit base #172

Open McP4nth3r opened 7 months ago

McP4nth3r commented 7 months ago

I'm using the SONOFF Zigbee 3.0 USB Dongle Plus,Zigbee Gateway TI CC2652P + CP2102N Zigbee USB Stick,Zigbee Hub for ZHA in Home Assistant or Zigbee2MQTT,Open HAB etc. i want to flash the newsest firmware with your python script and became this error:


sonoff
Opening port COM6, baud 500000
Reading data from .\CC1352P2_CC2652P_launchpad_coordinator_20230507.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.1 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:2E:1E:06:48
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F988
    Write done
Verifying by comparing CRC32 calculations.
    Verified (match: 0xe83aa727)
ERROR: int() can't convert non-string with explicit base```
frober commented 7 months ago

I've the same issue.

mathiasth commented 7 months ago

Same issue here as well, with the same stick. Thanks in advance!

peterwake commented 7 months ago

Me too!

faustiano commented 7 months ago

Same

bolovanos commented 7 months ago

https://github.com/JelmerT/cc2538-bsl/issues/171

Fixed in https://github.com/JelmerT/cc2538-bsl/pull/168 , but hasn't been merged yet. You can fix this in the Python file yourself by changing the line shown here: https://github.com/JelmerT/cc2538-bsl/commit/24c9010a570a324a64e79452af4b17b9a5a3d88e

Same. Python 3.11.9 (windows 11 64bit) SONOFF Zigbee 3.0 USB Dongle Plus ZBDongle-P

python cc2538-bsl.py -p COM8 -e -v -w --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20221226.hex sonoff Opening port COM8, baud 500000 Reading data from CC1352P2_CC2652P_launchpad_coordinator_20221226.hex Your firmware looks like an Intel Hex file Connecting to target... CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8 Primary IEEE Address: xx:xx:xx:xx:xx:xx:xx:xx Performing mass erase Erasing all main bank flash sectors Erase done Writing 360448 bytes starting at address 0x00000000 Write 104 bytes at 0x00057F980 Write done Verifying by comparing CRC32 calculations. Verified (match: 0xa9dc145d) ERROR: int() can't convert non-string with explicit base

In my case I failed even with uartLog.py and Flash Programmer 2 described in flashing instruction.

Be careful with that latest (20230507) it has some issues and 496.

frober commented 7 months ago

Thanks @bolovanos , with the patch for the cc2538-bsl.py it works for me (Python 3.9.1, Win10 64bit).

D:\Fhem\Zigbee\cc2538-bsl-master>python cc2538-bsl.py -p COM3 -evw --bootloader-sonoff-usb .\CC1352P2_CC2652P_launchpad_coordinator_20221226.hex
sonoff
Opening port COM3, baud 500000
Reading data from .\CC1352P2_CC2652P_launchpad_coordinator_20221226.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.1 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: ......
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done
Verifying by comparing CRC32 calculations.
    Verified (match: 0xa9dc145d)
AndreasBeyer commented 7 months ago

I used also the https://github.com/JelmerT/cc2538-bsl/pull/168 patch and worked like a charm on Windows 11 Pro N, Python 3.10.7 and SONOFF Zigbee 3.0 USB Dongle Plus, TI CC2652P + CP2102(N)

mdeweerd commented 7 months ago

I got the same result, applied python -m trace -t <REGULAR COMMAND>, amended the code to find that inaddr is None in the following code (in ValueError):

# Convert the entered IEEE address into an integer
def parse_ieee_address(inaddr):
    try:
        return int(inaddr, 16)
    except ValueError:
        sys.stdout.write(f"ValueError: IEEE address is reported as {inaddr!r}")
# Convert the entered IEEE address into an integer
def parse_ieee_address(inaddr):
    try:
        return int(inaddr, 16)
    except ValueError:
        sys.stdout.write(f"ValueError: IEEE address is reported as {inaddr!r}")

I'll try the patch as well.

SKART1 commented 6 months ago

The problem looks like in new behaviour of arg parser library which return None insead of 0 as default

Patch looks like correct for modern python versions.

IMHO it is better explicitly write types of fields in parameters model to allow linter to find such cases

EszKnop commented 6 months ago

I had the same issue and the abovementioned fix worked for me

H1ghSyst3m commented 5 months ago

Was the code already patched? I am using Python 3.12.3 and I still got get error.

(venv) ➜  cc2538-bsl sudo python3 cc2538-bsl.py -ewv -p /dev/ttyUSB0 --bootloader-sonoff-usb ./CC1352P2_CC2652P_launchpad_coordinator_20221226.hex 
sonoff
Opening port /dev/ttyUSB0, baud 500000
Reading data from ./CC1352P2_CC2652P_launchpad_coordinator_20221226.hex
Your firmware looks like an Intel Hex file
Connecting to target...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00:12:4B:00:2C:44:F7:31
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0xa9dc145d)
ERROR: int() can't convert non-string with explicit base
afiedler commented 5 months ago

It hasn't been applied. It's a one-liner though in https://github.com/JelmerT/cc2538-bsl/pull/168. Easy to make a local change to the script. With that, I confirmed it's working with Python 3.12.2.

defanator commented 4 months ago

Just caught this one with SONOFF ZBDongle-P; fix from https://github.com/JelmerT/cc2538-bsl/pull/168 helped.

alfs commented 3 months ago

I had the same problem. Google led me here. Patch in #164 resolved the problem, thanks.

esand commented 3 months ago

Same issue as others doing a standard -ewv. If I'm looking at the code correctly, if I were doing only -ewv and got this error at the end after the CRC check, I shouldn't have to worry, right? It seems everything is working, and I didn't need to change the IEEE address.

srett commented 2 months ago

Same issue here. Fixed via

if args.ieee_address != 0 and args.ieee_address != None: