Flashing Sony Spresense

Hello,

I’ve flashed other boards (e.g. Himax) previously but I’m stumbling at the gate to flash a Sony Spresense board. I’ve confirmed that the mainboard is working properly by running a select few Arduino example sketches. Unfortunately, I cannot flash the Spresense mainboard using the instructions for the board. The output in my terminal window from running the flash script is:

$ ./flash_linux.sh
Checking Python dependencies...
Checking Python dependencies OK

Flashing board... 

Using device /dev/ttyUSB0
>>> Install files ...
install -b 921600
Install /home/reza/Downloads/IoT/Spresense/sony-spresense/edge_impulse_firmware.spk
|0%-----------------------------50%------------------------------100%|
Traceback (most recent call last):
  File "/home/reza/Downloads/IoT/Spresense/sony-spresense/flash_writer.py", line 716, in <module>
    sys.exit(main())
  File "/home/reza/Downloads/IoT/Spresense/sony-spresense/flash_writer.py", line 684, in main
    writer.install_files(ConfigArgs.PACKAGE_NAME, "install")
  File "/home/reza/Downloads/IoT/Spresense/sony-spresense/flash_writer.py", line 592, in install_files
    modem.send(bin)
  File "/home/reza/Downloads/IoT/Spresense/sony-spresense/xmodem.py", line 532, in send
    if isinstance(callback, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
$

The folder has the following files:

$ ls
edge_impulse_firmware.spk  flash_mac.command  flash_writer.py  xmodem.py
flash_linux.sh             flash_windows.bat  __pycache__
$

What are the steps that I can undertake to resolve the AttributeError message? Thanks.

Kind regards.

Hi @baqwas,

Are you using Python 3.10 by any chance? If so I’d recommend switching to v3.9 and try again.

Aurelien

Using:

>>> sys.version
'3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]'

With /usr/bin/python3.9, the output is:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

It would be helpful to know if this issue (probably Python version related) will be assigned to someone for a fix. If not, please let me know so that I can fry other fish. Understand there may other higher priority tasks that supersede the resolution of this issue for a single time constrained user. Thanks.

Kind regards.

Hello @baqwas,

I just tried with my env (Python 3.7) and it worked.

Checking Python dependencies...
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/Users/luisomoreau/.pyenv/versions/3.7.10/bin/python3 -m pip install --upgrade pip' command.
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/Users/luisomoreau/.pyenv/versions/3.7.10/bin/python3 -m pip install --upgrade pip' command.
Checking Python dependencies OK

Flashing board... 

Using device /dev/cu.usbserial-141120
>>> Install files ...
install -b 115200
Install /Users/luisomoreau/Downloads/sony-spresense (2)/edge_impulse_firmware.spk
|0%-----------------------------50%------------------------------100%|
######################################################################

410880 bytes loaded.
Package validation is OK.
Saving package to "nuttx"
updater# sync
updater# Restarting the board ...
reboot

Flashed your Sony Spresense development board.
To set up your development with Edge Impulse, run 'edge-impulse-daemon'
To run your impulse on your development board, run 'edge-impulse-run-impulse'

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...       2 completed.

[Process completed]

Do you have a python version manager so you can try with Pyton 3.7?

Best,

Louis

Thanks, @louis!

Unfortunately, I don’t have v3.7 on my desktop but I’ll look around. Tried v3.6 (it didn’t work and reported a different error message).

Wonder how difficult it would be to upgrade the utility to v3.10? Is it open sourced?

Kind regards.

Hello @baqwas,

Yes it is open source, you can find the source code of the firmware here: https://github.com/edgeimpulse/firmware-sony-spresense

Best,

Louis

Try stepping down the baud rate (921600) in the shell script file too. I believe that was the trick that worked for me.

1 Like

From python version 3.10 the collection package removed deprecate call to collections.Callable() We’ve addressed the issue and this will be soon in production.

Arjan