Skip to content

Library compile error when using Arduino CI #2

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

Closed
jgfoster opened this issue Oct 25, 2020 · 5 comments
Closed

Library compile error when using Arduino CI #2

jgfoster opened this issue Oct 25, 2020 · 5 comments

Comments

@jgfoster
Copy link
Member

The command bundle exec arduino_ci_remote.rb --skip-unittests shows that all the examples compile fine in the Arduino IDE. But when I run bundle exec arduino_ci_remote.rb --skip-compilation I get error: cannot take the address of an rvalue of type 'int' (see below).

DDRE comes from #define DDRE _SFR_IO8(0x0D) which uses #define _SFR_IO8(io_addr) (io_addr). So, it appears that the code is trying to do something like
volatile uint8_t* ddr = &0x0D;,
which does seem odd. Perhaps 0x0D is supposed to be an address?

@ianfixes, @per1234, do you have any advice?

Note that this is where I ran into #186.

Last command:  $ g++ -std=c++0x -o /Users/jfoster/Documents/Arduino/libraries/SD/unittest_test.cpp.bin -DARDUINO=100 -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address -D__AVR_ATmega2560__ -DARDUINO_CI -D__AVR__ -I/Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino -I/Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest -I/Users/jfoster/Documents/Arduino/libraries/SD/src -I/Users/jfoster/Documents/Arduino/libraries/SD/src/utility /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/Arduino.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/Godmode.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/stdlib.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest/ArduinoUnitTests.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/File.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/SD.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2Card.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdVolume.cpp /Users/jfoster/Documents/Arduino/libraries/SD/test/test.cpp

In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/File.cpp:15:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/SD.h:20:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdFat.h:29:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2Card.h:26:
/Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2PinMap.h:78:4: error: cannot take the address of an rvalue of type 'int'
  {&DDRE, &PINE, &PORTE, 0},  // E0  0
   ^~~~~
@jgfoster
Copy link
Member Author

I think this may be related to Arduino CI #120. I've been able to work around the problem with some code proposed there.

@ianfixes
Copy link

Looks like fun. The bug in my code is likely here: https://github.com/Arduino-CI/arduino_ci/blob/master/cpp/arduino/avr/io.h#L99

#define _SFR_IO8(io_addr) (io_addr) // this macro is all we need from the sfr file

DDRE points to this macro in various board definitions:

#define DDRE    _SFR_IO8(0x0D)

Which results in my implementation produces this nonsense for &DDRE: &(0x0D).

According to this forum post that should really be based on these 2 macros:

#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)

So my initial thought is that this can be fixed with some type of cast, possibly involving a reference to a statically-allocated array. I'll have to think more about that, and definitely add a unit test to prevent regressing it.

@ianfixes ianfixes added bug Something isn't working and removed bug Something isn't working labels Oct 26, 2020
@ianfixes
Copy link

Just to be clear here, was this issue supposed to be opened against SD and not arduino_ci?

@jgfoster
Copy link
Member Author

I started here because I wasn't sure where the problem was and because I thought that even if the problem was in arduino_ci I would need to implement a work-around. So, maybe this should stay open to track the fix in the framework so I can remove my "hack".

@jgfoster
Copy link
Member Author

Seems to be working fine with 0.4.0.

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

No branches or pull requests

2 participants