-
Notifications
You must be signed in to change notification settings - Fork 47
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
Arduino IDE compile error with new ESP8266 core 3.0.0 #44
Comments
I can confirm the same for anything using brzo_i2c with v3.0.0. I have used all previous versions of the ESP8266 core (2.7.4 through 2.3.0) and they all work fine with v1.3.3 of the Brzo library. The new v3.0.0 core generates the same error as shown above. |
Probably related to #40. |
Well, I am not an expert on GCC... I don't know what they exactly changed in the tool chain, like compiler switches or so. I am using many registers, so the compiler basically says "no more registers". But why suddenly they run out of registers, I really don't know. Maybe better to ask at arduino core |
I am not an real assembler guy but I can read with datasheet next to code. edit: Maybe this is a non-sense because one cannot use a non-32bit variable to be mapped to a register. gcc not complaining made me confident. diff --git a/examples/ADT7420/ADT7420.ino b/examples/ADT7420/ADT7420.ino
index 66df3b4..64959e8 100644
--- a/examples/ADT7420/ADT7420.ino
+++ b/examples/ADT7420/ADT7420.ino
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Analog Devices ADT7420 Datasheet
// http://www.analog.com/en/products/analog-to-digital-converters/integrated-special-purpose-converters/integrated-temperature-sensors/adt7420.html
-#include "brzo_i2c\brzo_i2c.h"
+#include <brzo_i2c.h>
uint8_t SDA_PIN = 5;
uint8_t SCL_PIN = 4;
diff --git a/src/brzo_i2c.c b/src/brzo_i2c.c
index c797c25..5ac2973 100644
--- a/src/brzo_i2c.c
+++ b/src/brzo_i2c.c
@@ -66,7 +66,9 @@ void ICACHE_RAM_ATTR brzo_i2c_write(uint8_t *data, uint32_t no_of_bytes, bool re
if (i2c_error > 0) return;
uint8_t byte_to_send = i2c_slave_address << 1;
// Assembler Variables
- uint32_t a_set = 0, a_repeated = 0, a_in_value = 0, a_temp1 = 0, a_bit_index = 0;
+ uint8_t a_repeated, a_bit_index = 0;
+ uint16_t a_in_value = 0, a_temp1 = 0;
+ uint32_t a_set = 0;
if (repeated_start == true) a_repeated = 1;
else a_repeated = 0;
asm volatile (
@@ -384,8 +386,9 @@ void ICACHE_RAM_ATTR brzo_i2c_read(uint8_t *data, uint32_t nr_of_bytes, bool rep
// Do not perform an i2c read if a previous i2c command has already failed
if (i2c_error > 0) return;
// Assembler Variables
- uint32_t a_set = 0, a_repeated = 0, a_in_value = 0, a_temp1 = 0, a_temp2 = 0, a_bit_index = 0;
- a_temp2 = 0;
+ uint8_t a_repeated, a_bit_index = 0;
+ uint16_t a_in_value = 0, a_temp1 = 0;
+ uint32_t a_set = 0, a_temp2;
if (repeated_start == true) a_repeated = 1;
else a_repeated = 0;
// a_temp2 holds 7 Bit slave address, with the LSB = 1 for i2c read |
@d-a-v |
@d-a-v : Thanks for your support. In general, I do not mind changing the code ;-) However, I do not yet understand what exactly is the issue here, i.e., why is the compilation no longer possible. @ALL: I need some help here, because I don't have deep knowledge about the tool chain |
BTW: Isn't this line (71) nonsense? |
@v-a-d-e-r This is not really a nonsense. It is a common practice to initialize a variable when declaring it. Also, modern compilers may optimize this and initialize only once in the resulting assembly code if it can be detected that the variable is not used between the two initializations. @v-a-d-e-r What I posted is a diff file. You need to remove lines with @pasko-zh The 3.0.0 esp8266 arduino core release uses gcc-xtensa v10.2. The previous releases were using gcc-xtensa 4.8. Code is compiled with |
@d-a-v ok, thanks for explaining this. It looked a bit curious to me on the first view... ;-) And yes, I did exchange the code, not just adding yours. |
@v-a-d-e-r I was suggesting to remove the /arduino/libraries/Brzo_I2C/brzo_i2c.c: In function 'brzo_i2c_write':
/arduino/libraries/Brzo_I2C/brzo_i2c.c:69:3: error: expected expression before 'uint8_t'
69 | + uint8_t a_repeated, a_bit_index = 0;
| ^~~~~~~ |
Hmm, that what I posted above was just a "copy and paste" from the compiler output... :-/ The '+' is NOT in the source code of course |
Sorry I might have misunderstood |
@d-a-v : Thanks, I will have some thoughts how and where I could reduce the amount of registers. Maybe some words why I did it this way: At the time when I decided to write brzo_i2c, I wanted to push our little esp8266 to the limits, in the sense of clock speed and precision of i2c signals. And I thus wanted to reduce any effects that might lower this, for instance push register values to stack and pop them back again, or allow interrupts, etc. |
It is amazing how people like to push this particular beast further the limits :) |
I compared the compilation speed in Arduino IDE 1.8.15 ESP8266 |
@sh-user Well, the question is what do we get for increased compilation time? Smaller code? Faster code? Do you have some measurements on that? |
Yep, the longer compile time was another reason for reverting to core 2.7.4 for now.... :-/ |
@pasko-zh 4 KB more free heap |
and 16KB more with a new option in the Arduino IDE menu |
@d-a-v how to get 16KB? what option in the Arduino IDE menu? |
Tools>MMU>3rd option |
v3.0.1 of the EPS8266 core was just released, and of course the same issue with compiling exists. Do you think there will be a fix for this in the near future? |
Hey guys, I might have found a fix for this bug: Please take a look at my commit I'm basically just using uint16_t registers and only one uint32_t, because in my understanding of the asm code (which may be absolutely wrong) these remaining registers never store more than 16bit and L16UI returns 16bit. Disclaimer: I have only rudimentary asm knowledge, please don't hit me :D EDIT: The only downside I found is, that |
@wladimir-computin Since you are successfully running your patch, why don't you turn it into a pull-request ? |
Fix for Bug with ESP8266 core >= 3.0.0 and pasko-zh/Brzo I2C = 1.3.2 See: pasko-zh/brzo_i2c#44
Hi there! |
Hi, Any updates on this? thanks. |
works for me on SSD1306 and core 3.0.2 |
Do we have some feedback on @wladimir-computin fix? (besides @ifeghali test) |
It did compile successfully but I had to drop BRZO for some problem I don't remember exactly. My project was finished and board was sent to customer so I can't test it again but I have more boards on my way from China. Will give it another try and let you know. It's going to take a few weeks though. |
Will the PR be accepted? |
/arduino/libraries/Brzo_I2C/brzo_i2c.c: In function 'brzo_i2c_write':
/arduino/libraries/Brzo_I2C/brzo_i2c.c:72:2: error: cannot find a register in class 'RL_REGS' while reloading 'asm'
72 | asm volatile (
| ^~~
/arduino/libraries/Brzo_I2C/brzo_i2c.c:72:2: error: 'asm' operand has impossible constraints
exit status 1
Fehler beim Kompilieren für das Board Generic ESP8266 Module.
Can this be easy fixed? Thanks.
I'm using latest brzo version...
The text was updated successfully, but these errors were encountered: