thunderace / Esp8266-Arduino-Makefile

Makefile to build arduino code for ESP8266/ESP32x under linux (tested on debian X64)
34 stars 20 forks source link

Compiling C as C++ breaks linker provides #6

Closed chuckwagoncomputing closed 7 years ago

chuckwagoncomputing commented 7 years ago

Maybe I'm doing something wrong, but I had to comment out the CXX compile line and decomment the CC line to prevent errors. I'm using code from cnlohr's ws2812 project which uses rom_i2c_writeReg_Mask, which is a symbol defined in eagle.rom.addr.v6.ld. Compiling as C++ broke that somehow. I'm not clear on how the linker and compiler work together there, maybe someone else could explain it. I suppose it would be possible to use extern, but upstream esp8266_peri.h needs rom_i2c_writeReg_Mask as well, so for me the best solution was to compile C code with regular old gcc.

thunderace commented 7 years ago

Do you have a full project for tests?

chuckwagoncomputing commented 7 years ago

Here's a MNWE.


#define i2c_bbpll                                 0x67
#define i2c_bbpll_en_audio_clock_out            4
#define i2c_bbpll_en_audio_clock_out_msb        7
#define i2c_bbpll_en_audio_clock_out_lsb        7
#define i2c_bbpll_hostid                           4

#define i2c_writeReg_Mask(block, host_id, reg_add, Msb, Lsb, indata)  rom_i2c_writeReg_Mask(block, host_id, reg_add, Msb, Lsb, indata)
#define i2c_writeReg_Mask_def(block, reg_add, indata) \
      i2c_writeReg_Mask(block, block##_hostid,  reg_add,  reg_add##_msb,  reg_add##_lsb,  indata)
#endif

void setup() {
 i2c_writeReg_Mask_def(i2c_bbpll, i2c_bbpll_en_audio_clock_out, 1);
}

void loop() {}
thunderace commented 7 years ago

You're right. The last commit restore c files comilation with gcc. But, if your code is located in a .ino file, the problem is still here.

Closed.