Pages: 1 [2]   Go Down
Author Topic: Library Problem With IDE V1.5.1r2 And Due  (Read 8636 times)
0 Members and 1 Guest are viewing this topic.
Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arctic_Eddie:

The file avr/io.h contains definitions for registers that are available only on AVR architecture.
If your project needs that include it means that you're using some feature available only on AVR hardware (and should be rewritten to use an equivalent SAM3X feature if you want to make it run on the Due).

One check that you can do is:

remove the #include <avr/io.h> from your biggest project, try to compile it for Mega, and look where it fails: these are the places that needs to be ported.

C
Logged

C.

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The call to avr/io.h was shown in the compiler error statement as coming from line 25 in twi.c. I added my work-around using the __SAM3X8E__ trick just assuming that sam/pio.h was the equivalent. However, the trick partially worked but sam/pio.h was not found. There are going to be a lot of hardware discrepancies where AVR calls don't work. Since I don't know what the Due equivalent will be, I'll just have to wait until someone else sorts this problem out satisfactorily. There is also a problem with paths in the IDE. When I supply the absolute path to a .H file, it still says it can't find it. Maybe a sketch won't work because it's AVR specific but it should at least find it. All of the #include errors are coming from within included libraries and not my sketch. Some of the substitute files for the Due haven't been created yet so I'm at a stand-still. I'll continue with the Mega and watch the forum for future progress.

Thanks for the help from all contributors.
Logged

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand, but my point was that the avr/io.h equivalent for ARM doesn't exist and its not going to exist. You'll never find a "sam/pio.h" that works as a drop-in replacement for avr/io.h, because it can't be done.

The call to avr/io.h was shown in the compiler error statement as coming from line 25 in twi.c.

This is strange because the Wire library is one of the first library that was ported to Due, and I saw many reports from users that used it successfully.
Are you using the Wire library found in arduino-1.5.1?
Logged

C.

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My V1.5.1r2 has two copies in the unzipped folder. One is in avr/libraries and the other is in sam/libraries. Both are dated 11/23/12. There is also an original in Documents/Arduino/libraries. I assume the compiler knows which one to use since I've told it to compile for the Due. The same sketch works if I select the Mega board. When I use a more complete path to Wire.h it says file or folder not found.

#include <sam/libraries/Wire/Wire.h>
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The compiler is looking for the old version.

C:\Users\xxxx\Documents\Arduino\libraries\Wire\utility\twi.c:25: fatal error: avr/io.h: No such file or directory
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Wire.h file in sam has this in the heading but the compiler is looking elsewhere. Sure seems like lots of users are seeing path errors in the IDE.

 * TwoWire.h - TWI/I2C library for Arduino Due
 * Copyright (c) 2011 Cristian Maglie <c dot maglie at bug dot st>.
 * All rights reserved.
Logged

Forum Administrator
Milano, Italy
Offline Offline
Sr. Member
*****
Karma: 23
Posts: 292
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The compiler is looking for the old version.

C:\Users\xxxx\Documents\Arduino\libraries\Wire\utility\twi.c:25: fatal error: avr/io.h: No such file or directory

The IDE prioritize the libraries found in {sketchbook_folder}\libraries. Try to move the Wire folder in sketchbook elsewhere, and the IDE should find the correct library (the one inside sam/libraries).
Logged

C.

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I eliminate the one in {sketchbook_folder}\libraries, will the compiler find the right one in sam or avr according to board selection. Will this damage my ability to use V1.0.3 for other boards.
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Moving the Wire library from the sketch folder to some other place, eliminates the avr/io.h error. The sketch still compiles when selecting the Mega. However, now I get another error about a missing item, square. Including math.h does not solve the problem. There is still a path problem when selecting the Due.

C:\Users\xxxxx\Documents\Arduino\libraries\PlainFFT\PlainFFT.cpp:143: error: 'square' was not declared in this scope
Logged

Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My scheme shown above did not work entirely. It did prove that the Due board is named "__SAM3X8E__" as it looked for sam/pio.h. However, it did not find that file either so the solution will not work.

Hope this thread is not dead yet....

pio.h is located in this folder:
Code:
~/arduino-1.5.4/hardware/arduino/sam/system/libsam/include/

I am also facing mentioned issue, where IDE not compling due to "missing" header files.

I tried also linking pio.h > /avr/io.h but without success....
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having the same problem. Is there no library that can be included for the Due that allows for IO pin manipulation?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've also got this problem,   using Arduino 1.5.6.r2     trying to use the wire library with a Due board   
I get the
C:\Users\xxxx\Documents\Arduino\libraries\Wire\utility\twi.c:25: fatal error: avr/io.h: No such file or directory
error.

Yet, other people have reported that they can use the wire   i2c  protocol  with a due board.   I have noticed that those who resolved the problem were using Ubuntu or some flavor of linux       i'm Windows user.   Currently i am running this on my laptop running Windows 7.       

I need to figure it out.   
Logged

Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 522
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So far-using Windows 7-the Wire library for SAM runs OK in my DUE (both controllers TWI0 and TWI1).  The twi.c file you mention belongs to AVR. That's why is linked with avr/io.h. I know it because the AVR TWI is located under a utility folder unlike the SAM TWI which is under \libsam\source.  This happens after import the Wire library using IDE 1.0.X.
Solution: Close your IDE 1.5.X, delete the Wire folder from your ...\Arduino\libraries\, open again yout IDE 1.5.X and run your sketch. Regards!

EDIT: If you need to use the AVR Wire library, just run your sketch (you don't need to import the library). This works for me with 1.04 and newer.
« Last Edit: March 21, 2014, 07:18:47 pm by Palliser » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Palliser -
Thanks,   I read to delete or move, the directory,  which i did and it didn't find the wire.h at all.   But,  now  i realize i had about 4-5 ide-sketches open, so closing one didn't release the library.  Closed them all and reopened -  finally it is now using the due library.   You would think the arduino programmers would have taken care of this sometime back as i see this is an old and on-going issue with trying to work with the due (and now Gallileo - people report the same prob).   
Logged

Pages: 1 [2]   Go Up
Jump to: