Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-C2 doesn't honor WIFI_PROMIS_FILTER_MASK_FCSFAIL filter mask (IDFGH-9408) #10777

Closed
3 tasks done
doragasu opened this issue Feb 16, 2023 · 2 comments
Closed
3 tasks done
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@doragasu
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.0

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32C2-12 Devkit

Power Supply used.

USB

What is the expected behavior?

When enabling RX promiscuous mode with WIFI_PROMIS_FILTER_MASK_FCSFAIL filter mask, FCS failed packets are also received.

What is the actual behavior?

FCS failed packets are never received.

Steps to reproduce.

Build and flash the following program on an ESP32 chip. It will receive FCS failed packets on channel 1 successfully. Then build and flash the same program on a ESP32-C2 chip. It will not receive FCS failed packets.

#include <string.h>
#include <esp_wifi.h>
#include <esp_log.h>
#include <esp_event.h>
#include <nvs_flash.h>

#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/event_groups.h>

#define TAG "sniffer"

static void sniffer_cb(void* buf, wifi_promiscuous_pkt_type_t type)
{
	wifi_promiscuous_pkt_t* rx = (wifi_promiscuous_pkt_t*)buf;
	const int len = rx->rx_ctrl.sig_len;
	const uint32_t state = rx->rx_ctrl.rx_state;

	if (0x41 == state) {
		ESP_LOGI(TAG, "Got FCS failed frame, type: %d, len: %d", type, len);
	} else {
		ESP_LOGI(TAG, "Discarding frame with rx_state = 0x%lx", state);
	}
}

static void sniffer_task(void* pvParameters)
{
	wifi_promiscuous_filter_t sniffer_filter = {0};

	sniffer_filter.filter_mask |= WIFI_PROMIS_FILTER_MASK_MISC;
	sniffer_filter.filter_mask |= WIFI_PROMIS_FILTER_MASK_DATA_MPDU;
	sniffer_filter.filter_mask |= WIFI_PROMIS_FILTER_MASK_FCSFAIL;

	ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(sniffer_cb));
	ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&sniffer_filter));
	ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
	ESP_ERROR_CHECK(esp_wifi_set_channel(1, 0));
	vTaskDelete(NULL);
}

static void initialise_wifi(void)
{
	ESP_ERROR_CHECK(esp_netif_init());
	ESP_ERROR_CHECK(esp_event_loop_create_default());

	wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
	ESP_ERROR_CHECK(esp_wifi_init(&cfg));
	ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));

	ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));
	ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
}

void app_main()
{
	ESP_ERROR_CHECK(nvs_flash_init());
	initialise_wifi();
	xTaskCreate(&sniffer_task, "sniffer_task", 2048, NULL, 10, NULL);
}

Debug Logs.

On the ESP32-C2 chip during program run you only get the "Discarding frame" messages:


sniffer: Discarding frame with rx_state = 0x0

On the ESP32 chip you get these and the FCS failed frame messages:

I (18346) sniffer: Got FCS failed frame, type: 2, len: 1740
I (18346) sniffer: Got FCS failed frame, type: 2, len: 3667
I (18386) sniffer: Got FCS failed frame, type: 2, len: 1972
I (18386) sniffer: Got FCS failed frame, type: 2, len: 2165
I (18396) sniffer: Got FCS failed frame, type: 2, len: 3719
I (18396) sniffer: Got FCS failed frame, type: 2, len: 1859
I (18406) sniffer: Got FCS failed frame, type: 2, len: 1517
I (18426) sniffer: Discarding frame with rx_state = 0x0


### More Information.

_No response_
@doragasu doragasu added the Type: Bug bugs in IDF label Feb 16, 2023
@github-actions github-actions bot changed the title ESP32-C2 doesn't honor WIFI_PROMIS_FILTER_MASK_FCSFAIL filter mask ESP32-C2 doesn't honor WIFI_PROMIS_FILTER_MASK_FCSFAIL filter mask (IDFGH-9408) Feb 16, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 16, 2023
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Apr 2, 2024
@zhangyanjiaoesp
Copy link
Collaborator

@doragasu Sorry to reply late. I have found the root cause, you should to change the XTAL to 26MHz (default is 40MHz) in the menuconfig for ESP32C2.
image

By the way, you can use esptool to check the chip version of your device: esptool.py -p /dev/ttyUSB0 chip_id, the output like this:

esptool.py v4.7.0
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-C2
Chip is ESP32-C2 (revision v1.1)
Features: WiFi, BLE
Crystal is 26MHz
MAC: 10:97:bd:f1:a2:7c
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-C2 has no Chip ID. Reading MAC instead.
MAC: 10:97:bd:f1:a2:7c
Hard resetting via RTS pin...

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: In Progress Work is in progress labels Apr 2, 2024
@zhangyanjiaoesp
Copy link
Collaborator

@doragasu After changing the XTAL to 26MHz, the esp32c2 can sniffer, but the FCS error packet still can't be received, I'm debugging on this, will solve it ASAP.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels May 16, 2024
espressif-bot pushed a commit that referenced this issue May 21, 2024
1. fix(wifi): fixed sniffer dump fcs error packets fail

Closes #10777

2. fix(wifi): fixed the espnow priv parameter get error

Closes #13693
espressif-bot pushed a commit that referenced this issue Jun 6, 2024
1. fix(wifi): fixed sniffer dump fcs error packets fail

Closes #10777

2. fix(wifi): fixed the espnow priv parameter get error

Closes #13693
Closes #13880
espressif-bot pushed a commit that referenced this issue Jun 13, 2024
1. fix(wifi): fixed sniffer dump fcs error packets fail

Closes #10777

2. fix(wifi): fixed the espnow priv parameter get error

Closes #13693
espressif-bot pushed a commit that referenced this issue Jun 13, 2024
1. fix(wifi): fixed sniffer dump fcs error packets fail

Closes #10777

2. fix(wifi): fixed the espnow priv parameter get error

Closes #13693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants