Page 1 of 1

esp_crc16_be not available in 4.0, what can I use instead?

Posted: Sun Oct 25, 2020 3:48 am
by matthew798
I am using platformio with IDF v4.0, and the appropriate arduino libraries as a component.

I am hacking and slashing away at the Blufi demo, and have finally gotten my phone to communicate with the esp. I did, however have to do this:

Code: Select all

uint16_t blufi_crc_checksum(uint8_t iv8, uint8_t *data, int len)
{
    /* This iv8 ignore, not used */
    return 1; //esp_crc16_be(0, data, len);
}
Obviously this will prevent the blufi flow from working, I did it to get around this error temporarily:
esp_crc.h: No such file or directory
From what I gather, esp_crc16_be is not available in IDF v4.0. What can I use instead? I think that this function uses the internal crypto hardware (???) so rolling my own crc function is not a nice solution.

I did find one in rom/crc.h but this causes a whole bunch of weird problems when included. We can get into that if this is my only option.

Re: esp_crc16_be not available in 4.0, what can I use instead?

Posted: Mon Oct 26, 2020 1:51 am
by ESP-Marius
esp_crc16_be is simply a wrapper function around the rom function crc16_be, so you can safely use this rom function directly.

Which Blufi demo are you actually looking/hacking at? The blufi example in 4.0 has the correct crc function for that release:

Code: Select all

uint16_t blufi_crc_checksum(uint8_t iv8, uint8_t *data, int len)
{
    /* This iv8 ignore, not used */
    return crc16_be(0, data, len);
}
Note that there is no CRC hardware accelerators on the ESP32, so the rom function still calculates the crc sum in software.