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

How to run this? It just fails for me #13

Closed leecher1337 closed 9 months ago

leecher1337 commented 1 year ago

Running Python programs is always a PITA...

c:\Users\******\Documents\bk7231tools-1.2.5>pipenv run python bk7231tools -d COM4 emylo.bin
Creating a virtualenv for this project...
Pipfile: c:\Users\******\Documents\bk7231tools-1.2.5\Pipfile
Using C:/Users/******/AppData/Local/Programs/Python/Python37-32/python.exe (3.7.2) to create virtualenv...
[==  ] Creating virtual environment...created virtual environment CPython3.7.2.final.0-32 in 10158ms
  creator CPython3Windows(dest=c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=c:\Users\******\AppData\Local\pypa\virtualenv)
    added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Successfully created virtual environment!
Virtualenv location: c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR
Creating a Pipfile for this project...
c:\Users\******\Documents\bk7231tools-1.2.5>pipenv install bk7231tools
Installing bk7231tools...
Adding bk7231tools to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
           Building requirements...
Resolving dependencies...
Success!
Updated Pipfile.lock (973856)!
Installing dependencies from Pipfile.lock (973856)...
  ================================ 0/0 - 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
c:\Users\******\Documents\bk7231tools-1.2.5>pipenv run bk7231tools
Traceback (most recent call last):
  File "c:\Users\******\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\Users\******\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\Scripts\bk7231tools.EXE\__main__.py", line 4, in <module>
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\__init__.py", line 1, in <module>
    from .__main__ import cli
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\__main__.py", line 13, in <module>
    from bk7231tools.analysis.storage import TuyaStorage
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\analysis\storage.py", line 42, in <module>
    class TuyaStorage:
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\analysis\storage.py", line 249, in TuyaStorage
    def sf_find_index(self, name: str):
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\analysis\goto.py", line 195,in with_goto
    _patch_code(func_or_code.__code__),
  File "c:\Users\******\.virtualenvs\bk7231tools-1.2.5-IVKcV7HR\lib\site-packages\bk7231tools\analysis\goto.py", line 169,in _patch_code
    raise SyntaxError("Jump into different block")
SyntaxError: Jump into different block

No idea what is wrong with it, it just fails on loading the TuyaStorage class, as it seems?

kuba2k2 commented 1 year ago

Do you need to use virtualenv for that? You can simply install this from PyPI, without even cloning the GitHub repo. Your Python version (3.7) is a bit old, that's one reason why it can work improperly.

leecher1337 commented 1 year ago

Thank you for your fast reply. Seems to have been version related, so I installed Python 3.11 and then it worked. However, I'm missing a documentation on the project's page stating the minimum required Python Version, did I miss something in the docs?

kuba2k2 commented 1 year ago

Maybe it's missing. I didn't test the storage decryption on Python 3.7.

kuba2k2 commented 9 months ago

@leecher1337 v1.5.0 of bk7231tools doesn't use goto anymore. Futhermore, the storage decryption class is rewritten from ground up, and is more reliable.