[Solved] ESP32 on the MATRIX Voice - Deploy Failed to Connect

Following the Get Started w/ESP32 on the MATRIX Voice tutorial on hackster.io, I am able to complete all steps except the last, where I get the following error:

$ make deploy

**************************************************************
Programming the ESP32 in MATRIX Voice through the Raspberry PI
**************************************************************
pi@192.168.1.118's password:
-----------------------------------
esptool.py wrapper for MATRIX Voice
-----------------------------------
esptool.py v2.2.1
Connecting........_____....._____....._____....._____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet ('\x00')

Hello @OrsonAround

Could you run: sudo dpkg -l | grep matrixio and show us the result. Also please keep close any software to open the /dev/ttyS0.

I’m looking forward to your answer.

Regards,

Kevin Patino

Thanks, AFAIK there shouldn’t be anything else using /dev/ttyS0

Here is the output

pi@raspberrypi:~ $ dpkg -l | grep matrixio
ii  libmatrixio-creator-hal:armhf     0.1.4                             armhf        Hardware Abstraction Layer for MATRIX.
ii  libmatrixio-creator-hal-dev       0.1.4                             armhf        Hardware Abstraction Layer for MATRIX (headers)
ii  libmatrixio-malos:armhf           0.1.2                             armhf        Libraries of MATRIX abstraction layer for MOS
ii  libmatrixio-protos:armhf          0.1.1                             armhf        Protocolbuffers for MATRIX abstraction layer
ii  matrixio-creator-init             0.4.0                             armhf        Install scripts that can program the MATRIX Creator FPGA and SAM3 IMU.
ii  matrixio-malos                    0.2.2                             armhf        Allows queries to MATRIX Creator hardware via ZMQ.
ii  matrixio-openocd                  1.0.1                             armhf        Open on-chip JTAG debug solution for ARM and MIPS systems
ii  matrixio-protobuf                 3.4.0                             armhf        Protocol Buffers - Google's data interchange format. (From GRPC 3.4.0)
ii  matrixio-xc3sprog                 1.1.1                             armhf        Spartan3, XCF and CPLD JTAG programmer and other utilities.

Wasn’t sure how to make sure /dev/ttyS0 wasn’t already in use, but have done some further research today and it doesn’t seem to be.

$ ps -ef | grep tty
root       688     1  0 12:11 tty1     00:00:00 /sbin/agetty --noclear tty1 linu           x
pi        3853  2205  0 22:59 pts/0    00:00:00 grep --color=auto tty


$ sudo lsof /dev/ttyS0
$ sudo lsof /dev/tty*
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd-l 338 root   14u   CHR    4,6      0t0 1046 /dev/tty6
hciattach 613 root    3u   CHR 204,64      0t0 1156 /dev/ttyAMA0
agetty    688 root    0u   CHR    4,1      0t0 1041 /dev/tty1
agetty    688 root    1u   CHR    4,1      0t0 1041 /dev/tty1
agetty    688 root    2u   CHR    4,1      0t0 1041 /dev/tty1

Hello @OrsonAround,

The communication between ESP32 and Raspberry PI is with Serial Port. In this case, we are using the /dev/ttyS0, as you show me, the /dev/ttyS0 has not be activated. This activation should be done by the matrixio-creator-init package. Let us review it and test. I will share with you our findings and how to resolve this issue.

Thank You,

Regards

Kevin Patino

/dev/ttyS0 does appear with both of these commands when make deploy is running.

 sudo lsof /dev/ttyS0
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    esptool.p 995   pi    6u   CHR   4,64      0t0 1157 /dev/ttyS0


     $ ps -ef | grep tty
root       571     1  0 12:31 tty1     00:00:00 /sbin/agetty --noclear tty1 linu                                                                                                                                                            x
pi        1069  1058  0 12:48 ?        00:00:00 sshd: pi@notty
pi        1071  1069  0 12:48 ?        00:00:00 bash -c tar xf - -C /tmp;sudo vo                                                                                                                                                            ice_esp32_reset;voice_esptool --chip esp32 --port /dev/ttyS0 --baud 115200 --bef                                                                                                                                                            ore default_reset --after hard_reset write_flash -u --flash_mode dio --flash_fre                                                                                                                                                            q 40m --flash_size detect 0x1000 /tmp/build/bootloader/bootloader.bin 0x10000 /t                                                                                                                                                            mp/build/mic_energy.bin 0x8000 /tmp/build/partitions_singleapp.bin
pi        1081  1071  0 12:48 ?        00:00:00 /bin/bash /usr/bin/voice_esptool                                                                                                                                                             --chip esp32 --port /dev/ttyS0 --baud 115200 --before default_reset --after har                                                                                                                                                            d_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size detect 0x1                                                                                                                                                            000 /tmp/build/bootloader/bootloader.bin 0x10000 /tmp/build/mic_energy.bin 0x800                                                                                                                                                            0 /tmp/build/partitions_singleapp.bin
pi        1084  1081  3 12:48 ?        00:00:00 /usr/bin/python /usr/local/bin/e                                                                                                                                                            sptool.py --chip esp32 --port /dev/ttyS0 --baud 115200 --before default_reset --                                                                                                                                                            after hard_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size d                                                                                                                                                            etect 0x1000 /tmp/build/bootloader/bootloader.bin 0x10000 /tmp/build/mic_energy.                                                                                                                                                            bin 0x8000 /tmp/build/partitions_singleapp.bin
pi        1096   597  0 12:48 pts/0    00:00:00 grep --color=auto tty

Hello @OrsonAround,

We already released a new version of matrixio-creator-init, run the following commands in your raspberry pi:

# Update packages and install
sudo apt-get update
sudo apt-get upgrade

Then we need to test if the FPGA is already programmed, test with:

pi@voice:~ $ /usr/share/matrixlabs/matrixio-devices/fpga_info 
IDENTIFY = 6032bad2
VERSION = 10004

You should obtain this response. Then You could test your ESP32 with the following command:

pi@voice:~ $ voice_esp32_enable && esptool.py -p "/dev/ttyS0" flash_id
esptool.py v2.2
Connecting....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting...

You should obtain a response like it.

Let me know how the test is going.

Regards,

Kevin Patino.

Thanks, but unfortunately no success. Upgraded, rebooted and ran commands, but still have the same error. I did notice my output shows esptool.py as v2.2.1 whereas yours shows v2.2

pi@raspberrypi:~ $ /usr/share/matrixlabs/matrixio-devices/fpga_info
IDENTIFY = 6032bad2
VERSION = 10004
pi@raspberrypi:~ $ voice_esp32_enable && esptool.py -p “/dev/ttyS0” flash_id
esptool.py v2.2.1
Connecting…

A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (’\x00’)

@OrsonAround,

Your MATRIX Voice is the version without ESP32 :pensive: .

Thank You,

Kevin Patino

All the tty_s_ on my Raspberry, no ttyS0.

/dev/tty /dev/tty19 /dev/tty3 /dev/tty40 /dev/tty51 /dev/tty62
/dev/tty0 /dev/tty2 /dev/tty30 /dev/tty41 /dev/tty52 /dev/tty63
/dev/tty1 /dev/tty20 /dev/tty31 /dev/tty42 /dev/tty53 /dev/tty7
/dev/tty10 /dev/tty21 /dev/tty32 /dev/tty43 /dev/tty54 /dev/tty8
/dev/tty11 /dev/tty22 /dev/tty33 /dev/tty44 /dev/tty55 /dev/tty9
/dev/tty12 /dev/tty23 /dev/tty34 /dev/tty45 /dev/tty56 /dev/ttyAMA0
/dev/tty13 /dev/tty24 /dev/tty35 /dev/tty46 /dev/tty57 /dev/ttyMATRIX0
/dev/tty14 /dev/tty25 /dev/tty36 /dev/tty47 /dev/tty58 /dev/ttyprintk
/dev/tty15 /dev/tty26 /dev/tty37 /dev/tty48 /dev/tty59
/dev/tty16 /dev/tty27 /dev/tty38 /dev/tty49 /dev/tty6
/dev/tty17 /dev/tty28 /dev/tty39 /dev/tty5 /dev/tty60
/dev/tty18 /dev/tty29 /dev/tty4 /dev/tty50 /dev/tty61

What do I set in make menuconfig / serial ?

Tried present example:
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyS0: [Errno 2] No such file or directory: ‘/dev/ttyS0’

I am trying to flash this one https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/a2dp_source . I have no clue how make deploy is not there as I guess there is no point in setting RPI_HOST. Do I need to wrap it somehow?

Used and included this in Makefile.
https://raw.githubusercontent.com/matrix-io/matrixio_hal_esp32/502bc1c37521b4d0557942b5a68ac8f623fa06b7/make/deploy.mk

Looking into pairing config. If you kow where I should look, let me know.

Hello @parseb,

Did you install matrixio-creator-init?

Could you try: sudo apt install matrixio-creator-init it configure your raspbian in order to use the ttyS0.

Now, you have configured the debug console.

Regards,

Kevin Patino

Anything different Raspbery pi 2+? (I assume the assumption of rpi 3)