espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.63k stars 7.28k forks source link

mz_crc32 becomes undefined in esp32c2 (IDFGH-8737) #10177

Closed nopnop2002 closed 1 year ago

nopnop2002 commented 1 year ago

Answers checklist.

General issue report

The following code builds correctly on any of esp32/esp32s2/esp32s3/esp32c3. But esp32c2 gives an error.

#include <stdio.h>
#include <string.h>
#include "esp32/rom/miniz.h"

void app_main()
{
    uint8_t buf[64];
    memset(buf, 0, sizeof(buf));
    mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)(buf), 4);
}
$ idf.py --version
ESP-IDF v5.0-beta1-824-ga8ef7570ca

$ idf.py set-target esp32c2

$ idf.py build

/home/nop/rtos/miniz/build/../main/main.c:14: undefined reference to `mz_crc32'
$ grep -rn mz_crc32 esp-idf/components/esp_rom/*
esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld:185:PROVIDE ( mz_crc32 = 0x4005ee88 );
esp-idf/components/esp_rom/esp32c3/ld/esp32c3.rom.ld:69:mz_crc32 = 0x400000c4;
esp-idf/components/esp_rom/esp32h2/ld/rev1/esp32h2.rom.ld:74:mz_crc32 = 0x400000c0;
esp-idf/components/esp_rom/esp32s2/ld/esp32s2.rom.ld:428:PROVIDE ( mz_crc32 = 0x40002f58 );
esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.ld:71:mz_crc32 = 0x40000798;
esp-idf/components/esp_rom/include/esp32s3/rom/miniz.h:88:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32s3/rom/miniz.h:89:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32s3/rom/miniz.h:298:#define crc32                 mz_crc32
esp-idf/components/esp_rom/include/esp32h2/rom/miniz.h:89:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32h2/rom/miniz.h:90:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32h2/rom/miniz.h:299:#define crc32                 mz_crc32
esp-idf/components/esp_rom/include/esp32/rom/miniz.h:89:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32/rom/miniz.h:90:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32/rom/miniz.h:300:  #define crc32                 mz_crc32
esp-idf/components/esp_rom/include/esp32s2/rom/miniz.h:89:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32s2/rom/miniz.h:90:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32s2/rom/miniz.h:300:  #define crc32                 mz_crc32
esp-idf/components/esp_rom/include/esp32c3/rom/miniz.h:89:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32c3/rom/miniz.h:90:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32c3/rom/miniz.h:299:#define crc32                 mz_crc32
esp-idf/components/esp_rom/include/esp32c2/rom/miniz.h:94:// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
esp-idf/components/esp_rom/include/esp32c2/rom/miniz.h:95:mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
esp-idf/components/esp_rom/include/esp32c2/rom/miniz.h:304:#define crc32                 mz_crc32
suda-morris commented 1 year ago

Good catch, I checked the ROM code and found that the mz_crc32 now equals to crc32_le. We will update the rom/include/esp32c2/rom/miniz.h to reflect that change.