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

The same project fails to build on other computers (IDFGH-13774) (VSC-1497) #1322

Closed
3 tasks done
Tinyu-Zhao opened this issue Sep 26, 2024 · 4 comments
Closed
3 tasks done
Assignees

Comments

@Tinyu-Zhao
Copy link
Contributor

Tinyu-Zhao commented Sep 26, 2024

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.

ESP-IDF v5.4-dev-3201-g46acfdce96

Operating System used.

macOS

How did you build your project?

VS Code IDE

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

None

What is the expected behavior?

Compiles normally without errors.

What is the actual behavior?

I encountered an error when trying to build an old IDF project on my new computer(M2 Chip), but it compiled fine on my previous Intel chip macOS.

When I tried to use the VSCode plugin for ESP-IDF, I got an error

I suspected it was a vscode setup issue, so I tried using idf.py build from the command line, and got the same error as when using the VSCode plugin.

/Users/tinyu/Developer/Develop/OneBtn-AppDemo/components/sths34pf80/sths34pf80.c: In function 'sths34pf80_init':
/Users/tinyu/Developer/Develop/OneBtn-AppDemo/components/sths34pf80/sths34pf80.c:105:30: error: assignment to 'stmdev_write_ptr' {aka 'long int (*)(void *, unsigned char,  const unsigned char *, short unsigned int)'} from incompatible pointer type 'esp_err_t (*)(void *, uint8_t,  const uint8_t *, uint16_t)' {aka 'int (*)(void *, unsigned char,  const unsigned char *, short unsigned int)'} [-Wincompatible-pointer-types]
  105 |     me->stmdev_ctx.write_reg = i2c_write;
      |                              ^
/Users/tinyu/Developer/Develop/OneBtn-AppDemo/components/sths34pf80/sths34pf80.c:106:30: error: assignment to 'stmdev_read_ptr' {aka 'long int (*)(void *, unsigned char,  unsigned char *, short unsigned int)'} from incompatible pointer type 'esp_err_t (*)(void *, uint8_t,  uint8_t *, uint16_t)' {aka 'int (*)(void *, unsigned char,  unsigned char *, short unsigned int)'} [-Wincompatible-pointer-types]
  106 |     me->stmdev_ctx.read_reg  = i2c_read;
      |                              ^
/Users/tinyu/Developer/Develop/OneBtn-AppDemo/components/sths34pf80/sths34pf80.c:140:41: error: passing argument 1 of 'sths34pf80_set_odr' from incompatible pointer type [-Wincompatible-pointer-types]
  140 |     int32_t odrErr = sths34pf80_set_odr(&me->stmdev_ctx, STHS34PF80_ODR_AT_1Hz);
      |                                         ^~~~~~~~~~~~~~~
      |                                         |
      |                                         stmdev_ctx_t *

The actual code is

typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, const uint8_t *, uint16_t);
typedef int32_t (*stmdev_read_ptr)(void *, uint8_t, uint8_t *, uint16_t);
typedef void (*stmdev_mdelay_ptr)(uint32_t millisec);

typedef struct
{
  /** Component mandatory fields **/
  stmdev_write_ptr  write_reg;
  stmdev_read_ptr   read_reg;
  /** Component optional fields **/
  stmdev_mdelay_ptr   mdelay;
  /** Customizable optional pointer **/
  void *handle;
} stmdev_ctx_t;

esp_err_t sths34pf80_init(sths34pf80_t *const me, i2c_bus_handle_t i2c_bus_handle, uint8_t dev_addr)
{
    ESP_LOGI(TAG, "Initializing STHS34PF80 instance...");

    /* Add device to I2C bus */

    me->i2c_dev = i2c_bus_device_create(i2c_bus_handle, dev_addr, 400000);
    if (me->i2c_dev == NULL) {
        ESP_LOGE(TAG, "Failed to add device to I2C bus");
    } else {
        ESP_LOGI(TAG, "sths34pf80 create success");
    }

    // i2c_device_config_t i2c_dev_conf = {.scl_speed_hz = 400000, .device_address = dev_addr >> 1};
    // if (i2c_master_bus_add_device(i2c_bus_handle, &i2c_dev_conf, &me->i2c_dev) != ESP_OK) {
    //     ESP_LOGE(TAG, "Failed to add device to I2C bus");
    //     return ret;
    // }

    /* Fill driver interface */
    me->stmdev_ctx.write_reg = i2c_write;
    me->stmdev_ctx.read_reg  = i2c_read;
    me->stmdev_ctx.handle    = me->i2c_dev;
    me->stmdev_ctx.mdelay    = delay_ms;
}

static esp_err_t i2c_read(void *handle, uint8_t reg_addr, uint8_t *reg_data, uint16_t data_len)
{
    i2c_bus_device_handle_t i2c_dev = (i2c_bus_device_handle_t)handle;
    return i2c_bus_read_bytes(i2c_dev, reg_addr, data_len, reg_data);
}

When I hover the mouse over uint8_t, it will prompt me.
image

But when I Go to uint8_t Definition, it will prompt me.
image

I suspect the compiler is pointing to the wrong file: /Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/_types/_uint8_t.h
image

Steps to reproduce.

Use vscode esp-idf plugin or idf.py build project

Build or installation Logs.

error_log.txt
normal_log.txt

More Information.

No response

@github-actions github-actions bot changed the title The same project fails to build on other computers The same project fails to build on other computers (IDFGH-13774) Sep 26, 2024
@espressif-bot espressif-bot assigned fhrbata and unassigned fhrbata Sep 26, 2024
@Alvin1Zhang Alvin1Zhang transferred this issue from espressif/esp-idf Sep 30, 2024
@github-actions github-actions bot changed the title The same project fails to build on other computers (IDFGH-13774) The same project fails to build on other computers (IDFGH-13774) (VSC-1497) Sep 30, 2024
@brianignacio5
Copy link
Collaborator

It seems that the error log is using the toolchain /Users/tinyu/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20240906/riscv32-esp-elf/bin/riscv32-esp-elf-gcc while normal log is using /Users/tinyu/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/riscv32-esp-elf-gcc

Also Python used is different for both cases: /Users/tinyu/.espressif/python_env/idf5.4_py3.9_env/bin/python for error.log and /Users/tinyu/.espressif/python_env/idf5.4_py3.12_env/bin/python for normal log.

I would suggest review that both ESP-IDF setup to match version (with doctor command for example) with the intended ESP-IDF version from your application code.

@Tinyu-Zhao
Copy link
Contributor Author

It seems that the error log is using the toolchain /Users/tinyu/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20240906/riscv32-esp-elf/bin/riscv32-esp-elf-gcc while normal log is using /Users/tinyu/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin/riscv32-esp-elf-gcc

Also Python used is different for both cases: /Users/tinyu/.espressif/python_env/idf5.4_py3.9_env/bin/python for error.log and /Users/tinyu/.espressif/python_env/idf5.4_py3.12_env/bin/python for normal log.

I would suggest review that both ESP-IDF setup to match version (with doctor command for example) with the intended ESP-IDF version from your application code.

Thank you for your reply, I will try again.

@brianignacio5
Copy link
Collaborator

Any updates on this @Tinyu-Zhao ?

@Tinyu-Zhao
Copy link
Contributor Author

Any updates on this @Tinyu-Zhao ?

Thank you for your help, the problem is solved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants