tuya-cloudcutter / bk7231tools

This is a collection of tools to interact with and analyze artifacts for BK7231 MCUs
MIT License
38 stars 6 forks source link

TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' #7

Closed twobeseen closed 1 year ago

twobeseen commented 1 year ago

I tried bk7231tools out today for the first time.

I succesfully read out the 2MB flash out of my BK7231N into dumpX.bin files multiple times, then tried to write the flash with current OpenBeken BIN (OpenBK7231N_QIO_1.14.86.bin) from https://github.com/openshwprojects/OpenBK7231T_App. This is the command and the error:

root@raspberrypi:/home/myusername# bk7231tools write_flash -B -d /dev/serial0 -s 0 -S 0 ./OpenBK7231N_QIO_1.14.86.bin Connected! Chip info: 0x7231c / Flash ID: eb 60 15 / Protocol: FULL
Traceback (most recent call last):
  File "/usr/local/bin/bk7231tools", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/bk7231tools/__main__.py", line 404, in cli
    args.handler(device, args)
  File "/usr/local/lib/python3.9/dist-packages/bk7231tools/__main__.py", line 273, in write_flash
    if args.start + args.length > 0x200000:
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

Also tried OpenBK7231N_UG_1.14.86.bin because it is said this file should be one for tuya-cloudcutter (don't know the differences).

Because I didn't had a clue what went wrong i then gave up with bk7231tools and tried https://github.com/OpenBekenIOT/hid_download_py which worked for me.

Maybe you can fix or tell me what went wrong?

notkmhn commented 1 year ago

This was a bug with an older version. Could you please make sure you have the latest versions of bk7231tools installed. Run pip install --upgrade bk7231tools, then ensure you have version 1.0.2 by running pip show bk7231tools

twobeseen commented 1 year ago

Thanks for your quick reply, I didn't try pip install --upgrade, but only "pip show" and saw, that I have already V1.0.2 installed. root@raspberrypi:/home/myusername# pip show bk7231tools Name: bk7231tools Version: 1.0.2 Summary: Tools to interact with and analyze artifacts for BK7231 MCUs Home-page: None Author: Khaled Nassar Author-email: kmhnassar@gmail.com License: MIT Location: /usr/local/lib/python3.9/dist-packages Requires: pyserial Required-by:

At the moment I am not ready to tryout flashing again because I am happy with my current tuya device flashed to OpenBeken, but I will try to assist as good as I can. Maybe you have some "dry-run" feature?

kuba2k2 commented 1 year ago

Right, I forgot to release the new version with the bugfix - sorry for the confusion. It has been corrected now, and v1.0.3 should be available to download.

Regarding dry-run: it is implemented in the core serial protocol class, but it's not accessible on the CLI (making it accessible would require a lot of rewriting, mainly because it waits for chip connection upon starting).

twobeseen commented 1 year ago

thanks, can't tryout right now but maybe will in the future.