StevenMHernandez / ESP32-CSI-Tool

Extract Channel State Information from WiFi-enabled ESP32 Microcontroller. Active and Passive modes available. (https://stevenmhernandez.github.io/ESP32-CSI-Tool/)
https://stevenmhernandez.github.io/ESP32-CSI-Tool/
MIT License
275 stars 74 forks source link

Determine which baud rates work well across platforms (Mac, Windows, Linux) (i.e. "baud rate 1552000 does not work") #5

Open zjc17 opened 3 years ago

zjc17 commented 3 years ago

Hardware: NodeMCU ESP32 version

Connecting..... Chip is ESP32D0WDQ5 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: a8:03:2a:68:69:bc Uploading stub... Running stub... Stub running... Changing baud rate to 1552000 Changed. Configuring flash size...

A fatal error occurred: Failed to write target memory. Only got 1 byte status response. make: *** [flash] Error 2

StevenMHernandez commented 3 years ago

Have you tried any other baud rates? Does flashing the esp32 work in general?

zjc17 commented 3 years ago

Have you tried any other baud rates? Does flashing the esp32 work in general?

baud rate 115200 works and other buad rates can be used to flash but the output is wrong, even if I've set the same rate to read the serial port...

StevenMHernandez commented 3 years ago

To help solve this, I need more information. I need to know more details about the problem including what steps you tried to solve the issue (Did you find anybody else with a similar problem with the esp32?). From my perspective, I am looking at the problem blind. You mention that the output is "wrong", but there are many ways that the output could be wrong. What is wrong about the output with baud rate of 115200?

Thanks.

zjc17 commented 3 years ago

To help solve this, I need more information. I need to know more details about the problem including what steps you tried to solve the issue (Did you find anybody else with a similar problem with the esp32?). From my perspective, I am looking at the problem blind. You mention that the output is "wrong", but there are many ways that the output could be wrong. What is wrong about the output with baud rate of 115200?

Thanks.

It works when I use baud rate of 115200. But for other baud rates, the output is garbled, it should be that the baud rate setting does not take effect, causing the encoding and parsing error

StevenMHernandez commented 3 years ago

Oh ok. We have been seeing this issue. Do you happen to use a windows computer? I am unable to test with windows myself. Can you try with a baud rate of 1500000 and report back? Alternatively, try 1000000.

roger- commented 3 years ago

1552000 failed for me too during flashing (in Ubuntu):

Running stub...
Stub running...
Changing baud rate to 1552000
Changed.
Configuring flash size...

A fatal error occurred: Timed out waiting for packet header

I assumed at first you meant 115200 (which does work).

StevenMHernandez commented 3 years ago

On linux, I have tried 1500000 and it seems to work. If this is true (maybe you can confirm?), I should update the readme to match.

roger- commented 3 years ago

Nope, same issue.

Any reason for the higher baud rate? It flashes and runs with 115200 (but I'm having other issues getting CSI data).

StevenMHernandez commented 3 years ago

Higher baud rate is useful to allow more data through serial. More data throughput ensure that CSI frames aren't dropped due to buffer overflow issues. (In general this translates to: higher baud rate means more CSI throughput as discussed in our paper http://www.people.vcu.edu/~ebulut/wowmom20-WiFiSensing.pdf)

How many places did you set the baud rate? There should be 3 distinct places in make menuconfig where you set this value.

Are you sure the time out is not related to you needing to press and hold the "FLASH" button. Some ESP32s require this extra step (https://randomnerdtutorials.com/solved-failed-to-connect-to-esp32-timed-out-waiting-for-packet-header/)

roger- commented 3 years ago

I think I set the baud in all the right places. My dev board flashes correctly at other rates, not sure if it that issue is baud dependent.

I also just upgraded to the latest IDF because I was getting a weird message before (wpa: PTK has been installed, it may be an attack) that might be a bug in the recommended IDF.

StevenMHernandez commented 3 years ago

Actually when I was using the higher baud rate on Linux, I was using stty (as allowed here: https://github.com/wertarbyte/coreutils/blob/master/src/stty.c#L1772). But maybe it won't work with the ESP-IDF. You can try one of the lower values until it works: 1152000, 921600, and 576000 are good candidates I think

I don't know about the PTK thing. What version of IDF did you upgrade to?

roger- commented 3 years ago

Thanks I'll give it another shot and see.

I upgraded to the latest stable version (4.1). The changes were trivial, think I just had to comment out an include statement.

The PTK thing might have been related to a KRACK mitigation bug, I read. Might not have been necessary to upgrade though.

zjc17 commented 3 years ago

One more thing... The packet rate is at about only 25 every second, even if I commented on the delay part in sockets_component.h. I used the default csi output format to write into the serial port. Is it caused by the low baud rate or other reason ( I'm not good at ROS development and thanks for your help again

StevenMHernandez commented 3 years ago

@Jiachen-Zhang You are correct. You will need high baud rate for high packet rate. Your welcome, I am glad you are working with my tool :)

zjc17 commented 3 years ago

I was able to change the different baud rate by keep Serial flasher config > 'make monitor' baud rate be 115200 and then successfully flash into it!

I think I can use make monitor after flashing and with changeing this parameter (As I read the serial port by python with the same baud rate 921600

StevenMHernandez commented 3 years ago

I need to figure out what baud rate works best across platforms. It sounds like 921600 worked in this case, but will other people have problems with that? After figuring out a better baud rate, the documentation should be updated to reflect the new value.

merkurer commented 2 years ago

hi everyone. can someone contact me from instagram for this project. i need help and i have some questions. I am computer engineering student and i want to work with csi data. i have an esp-wroom-32 device. I followed all the instructions but i couldn't flash. Instagram: merkurer

xiaokangkang6 commented 1 year ago

Higher baud rate is useful to allow more data through serial. More data throughput ensure that CSI frames aren't dropped due to buffer overflow issues. (In general this translates to: higher baud rate means more CSI throughput as discussed in our paper http://www.people.vcu.edu/~ebulut/wowmom20-WiFiSensing.pdf)

How many places did you set the baud rate? There should be 3 distinct places in make menuconfig where you set this value.

Are you sure the time out is not related to you needing to press and hold the "FLASH" button. Some ESP32s require this extra step (https://randomnerdtutorials.com/solved-failed-to-connect-to-esp32-timed-out-waiting-for-packet-header/)

Excuse me, which three places, I only see two places to fill in 1552000.

StevenMHernandez commented 1 year ago

@xiaokangkang6 I think the information from that message is old (the message was from 2021). In the current version of esp-idf, it should only be two places. You are correct. Please see (https://github.com/StevenMHernandez/ESP32-CSI-Tool/#configuration-esp-idf)

I will also mentioned that the old method was make menuconfig and the current method is idf.py menuconfig.

satya2891 commented 1 year ago

@StevenMHernandez

  1. How to reduce the number of packets recieved?
  2. By changing the tickrate it affects the packets recieved? Can u pls clarify this. Currently I am getting at around 1000 packets / min. I want to reduce it to 100 - 200.
mtijan commented 8 months ago

@StevenMHernandez

hai, i can not found this Component config > Common ESP32-related > Channel for console output > Custom UART

i just find Component config > Common ESP-related >

there is something wrong or not i don't know, but i use version (v4.4) of ESP-IDF.

mtijan commented 5 months ago

i'm know what is problem, but i've question, how do I set the sample rate for esp32, is it by changing the

Component config > FreeRTOS > Tick rate (Hz) > 1000

thanks