duff2013 / ulptool

Program the esp32 ULP coprocessor in Arduino
275 stars 69 forks source link

fsys.write() expecting string but parameter is byte #62

Open swaraj429 opened 4 years ago

swaraj429 commented 4 years ago

platform: linux python 2.7.16 Traceback (most recent call last): File "/home/swaraj/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 503, in main(sys.argv[1:]) File "/home/swaraj/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 102, in main build_ulp(PATHS, ulp_files, board_options, True) File "/home/swaraj/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 230, in build_ulp fsym.write(out) TypeError: write() argument must be str, not bytes exit status 1 Error compiling for board ESP32 Dev Module.

PauloFernandoSF commented 4 years ago

I have a similar error. Platform:linux Python:3.7.7 Esp core:1.0.4

Traceback (most recent call last): File "/home/paulo/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 560, in main(sys.argv[1:]) File "/home/paulo/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 106, in main build_ulp(PATHS, ulp_files, board_options, True) File "/home/paulo/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 160, in build_ulp error_string = cmd[0] + '\r' + err TypeError: can only concatenate str (not "bytes") to str

duff2013 commented 4 years ago

@swaraj429 I'm not sure whats the issue can you post the whole error you are seeing?

@PauloFernandoSF only python 2.7 is supported currently, can you use that instead and report back any errors?

PauloFernandoSF commented 4 years ago

Thanks, i've changed do Python 2.7 and worked!

O1dAlex commented 4 years ago

I've modified script - now it works with python 3.

This particular error corrected in line 233 - file 'fsym' should be open in binary mode: with open(file_names_constant['sym'],"wb") as fsym: OR in line 234 by converting 'out' to string: fsym.write(out.decode("utf-8"))

swaraj429 commented 4 years ago

@swaraj429 I'm not sure whats the issue can you post the whole error you are seeing? @PauloFernandoSF only python 2.7 is supported currently, can you use that instead and report back any errors?

that's all the error I got

Vincent-Stragier commented 3 years ago

@swaraj429,

In the platform.local.txt (read the readme to find its location), could you change python to python2:

## ulp build tool
compiler.s.cmd=python "{tools.ulptool.path}{tools.ulptool.cmd}"

to:

## ulp build tool
compiler.s.cmd=python2 "{tools.ulptool.path}{tools.ulptool.cmd}"

I think in the newest Linux version, python is actually Python 3.

Regards, Vincent

nightlyteacups commented 3 years ago

Having the same issue as @PauloFernandoSF had right now. Python 3.8.5, 1.0.6 core, Arduino 1.8.13, Win. Gonna downgrade Python to 2.7 and check again.

UPD. Yep, fixed on Python 2.7.18

yeckel commented 3 years ago

I'm observing a similar issue when there is an ASM compile issue. Like typo or other problem. The compiler is not reporting where and what bug you have in the code, but instead: TypeError: can only concatenate str (not "bytes") to str

Vincent-Stragier commented 3 years ago

I'm observing a similar issue when there is an ASM compile issue. Like typo or other problem. The compiler is not reporting where and what bug you have in the code, but instead: TypeError: can only concatenate str (not "bytes") to str

It's probably the still issue. Which version of Python are you using? And can you paste the full error code?

yeckel commented 3 years ago

Python 3.8.5 at Ubuntu 20.04, I've added "hi" into the ASM code:

Traceback (most recent call last):
  File "/home/libor/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 560, in <module>
    main(sys.argv[1:])
  File "/home/libor/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 106, in main
    build_ulp(PATHS, ulp_files, board_options, True)
  File "/home/libor/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py", line 140, in build_ulp
    error_string = cmd[0] + '\r' + err
TypeError: can only concatenate str (not "bytes") to str
exit status 1
Error compiling for board TTGO LoRa32-OLED V1.
Vincent-Stragier commented 3 years ago

Can you change the err to err.decode('utf-8') at the line 140 in the file "/home/libor/.arduino15/packages/esp32/tools/ulptool/src/esp32ulp_build_recipe.py"? From what I see, err is a bytes array.

yeckel commented 3 years ago

Sure, and it helped!

adc.ulp.pS: Assembler messages:/esp32/tools/ulptool/src/esp32ulp-elf-binutils/bin/esp32ulp-elf-as -al=adc.ulp.lst -W -o adc.ulp.o adc.ulp.pS
adc.ulp.pS:19: Error: syntax error. Input text was hi.
adc.ulp.pS:19: Error: 

exit status 1
Error compiling for board ESP32 Wrover Module.

probably all 4 remaining error_string = cmd[0] + '\r' + err could be changed too.

Vincent-Stragier commented 3 years ago

Glad it helped. And yes, the remaining lines can be changed.