In fact I've found #define PB2 in avr-libc package
I'm using ubuntu 8.10 and as avr is broken, i use ubuntu 9.04 (jaunty) packages, that are:
ii avr-libc 1:1.6.2.cvs20080610-2 Standard C library for Atmel AVR development
ii binutils-avr 2.18-4ubuntu1 Binary utilities supporting Atmel's AVR targ
ii gcc-avr 1:4.3.2-1 The GNU C compiler (cross compiler for avr)
Anyone has ever compiled whatever SD lib for a 328p ? (all sd lib are based on roland lib)
In fact this problem concerns avr and roland lib, arduino has nothing to do in it
I can compile with no problem the lib of rolande for an ATmega168, but no way for a 328p, because of the lack of PB2 defined, as it's used in sd_raw_config.h
Sorry for disturbance, i contact directly Roland Riegel
But as I said, i still have 2 errors when compiling fat.c in arduino (but the lib compiles perfectly now with 328p with the Makefile) :
fat.cpp: In function 'uint8_t fat_dir_entry_read_callback(uint8_t*, offset_t, void*)':
fat.cpp:1491: error: invalid conversion from 'void*' to 'fat_read_dir_callback_arg*'
fat.cpp: In function 'offset_t fat_get_fs_free(const fat_fs_struct*)':
fat.cpp:2250: error: 'UINTPTR_MAX' was not declared in this scope
If anyone has an idea to how to resolve these last 2 errors, I would be very interested !!
PB2 is normally defined in the hierarchy of files included via <avr/io.h>;
In the 168 case, this includes <avr/iom168.h>, which includes <avr/iomx8.h> (definitions common to all Atmega*8), which actually defines PB2.
For the 328, assuming you have a recent compiler installed, the equivalent <avr/iom328.h> does NOT include <avr/iomx8.h>, nor does it define PB2. I don't know why.
I've been trying to figure this out, too. The value of UINTPTR_MAX is defined in:
..\hardware\tools\avr\avr\include\stdint.h
and this file is included by Roland's fat.h file. So, it's puzzling to me that this value is not picked up by the compiler...
I'd like to know the correct way to fix this but, in the end, I got the code to compile by replacing the value with 0xFFFE, which is what I believe the compiled value of UINTPTR_MAX - 1 would be.
BTW, on the issue of why PB2 is not defined for the 328P, it appears that the include file io.h has a series of conditionals, like this:
#elif defined (AVR_ATmega328P)
include <avr/iom328p.h>
... #elif defined (AVR_ATmega168)
include <avr/iom168.h>
that select the proper include file based on the processor type. The file avr/iom168.h #includes avr/iomx8.h which, in turn, contains #defines for both PINBn and PBn values. However, the file avr/iom328p.h seems to contain only #defines for PINBn values.
It appears that the design of the avr/iom328p.h makes it more of a standalone file that includes definitions for both pins and fuses whereas the avr/iom168.h defines fuse values and then includes avr/iomx8.h to define the pins.
However, I notice that there is also a file named avr/iom168p.h that is in the same combined style as avr/iom328p.h. But, apparently, this file is not selected when compiling for a 168-based Arduino. I'm new to the AVR family, so I find this all a bit confusing, but perhaps it makes sense to someone else...
Since I also converted Roland's .c files to .cpp to get them to compile and link, it looks like this change broke the ability to reference the values in stdint.h. So, to fix it, I added a:
That is, no more use PB2, but PINB2 instead, and it compiles
No-- don't do that. PB2 is meant to represent output, while PINB2 is meant to represent input. Change it to PORTB2 or just to the number '2' but DO NOT change it to PINB2.
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:13: error: 'byte' does not name a type
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:16: error: 'byte' does not name a type
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void setup()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:22: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:23: error: 'delay' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void loop()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:39: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:41: error: 'incomingByte' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int sample()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:61: error: 'byte' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:61: error: expected `;' before 'low'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:62: error: expected `;' before 'high'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:63: error: expected `;' before 'inByte'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:65: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:72: error: 'inByte' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:75: error: 'analogRead' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:76: error: 'DEC' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:80: error: 'low' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:81: error: 'high' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:86: error: 'tempBytes' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:94: error: 'delay' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int readDisk()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:106: error: 'byte' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:106: error: expected `;' before 'low'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:107: error: expected `;' before 'high'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:108: error: expected `;' before 'info'
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:111: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:114: error: 'info' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:119: error: 'low' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:120: error: 'high' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:124: error: 'DEC' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void printWelcome()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:132: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int print_disk_info()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:153: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:155: error: 'HEX' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:161: error: 'DEC' was not declared in this scope
any ideas?
how about if anyone has the library with modifications that I can download so I know I didn't mess up what I was supposed to patch?
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void setup()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:23: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:24: error: 'delay' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void loop()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:40: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int sample()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:66: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:76: error: 'analogRead' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:77: error: 'DEC' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:95: error: 'delay' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int readDisk()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:112: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:125: error: 'DEC' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'void printWelcome()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:133: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp: In function 'int print_disk_info()':
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:154: error: 'Serial' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:156: error: 'HEX' was not declared in this scope
/home/sirus/arduino/hardware/libraries/SDcard/arduino sd card example.cpp:162: error: 'DEC' was not declared in this scope
thanks for the reply but there is no change. also the IDE seems to be really really really buggy. I can only save a sketch once and then it gets set to read only. trying to save again gives me an error message. going into windows explorer and changing the permissions doesnt work as the ide sets them right back to read only. every time i have to save a new sketch to a new directory and delete the old one. my IDE doesnt even resize correctly I get black bars. I've tried on 3 different computers. 1 ubuntu and 2 windows 7. is 17 just a buggy build? should i go to 16?
i think i have the pb2 and portb2 stuff figured out but what cant it figure out what Serial HEX DEC and that stuff is? works with simple sketches but now when i try to build anything complicated like this
Grab sd_raw.c sd_raw.h, sd_raw_config.h
rename sd_raw.c to sd_raw.cpp
Place those 3 files in a new libraries file. Mine looks like this "C:\Program Files (x86)\arduino-0017\hardware\libraries\sdcard"
And all 3 are in the "sdcard" dir.