5 Replies Latest reply on Feb 11, 2014 11:02 AM by rmm200

    Missing avr/pgmspace.h

    Clayton Hofrock

      I have a radioshack camera shield. The example code from their website has in include for avr/pgmspace.h. It appears that there is no equivalent for the x86?

       

      Is there something else I could use?

       

      Link to the support files:

           RadioShack Camera Board for Arduino Now Available | RadioShack techspecs

        • 1. Re: Missing avr/pgmspace.h
          byron

          Correct. AVR references Atmel AVR and is specific to the AVR chips, not x86. This is kind of the trouble with moving off AVR and to x86 or ARM since alot of the libraries written were designed specifically for AVR / Arduino. Unfortunately, you will have to port it. It would be helpful to have a guide on porting libraries for those of us without C backgrounds, but the gist of porting it is to replace the AVR portions (dealing with memory) to strict Wired / C.

           

          A quick scan through the sketch you reference doesn't show any specific usage of avr/pgmspace.h, so you might be able to just remove it. It does however use the SD libraries, in their full. I think the Galileo only supports a small portion of the SD library. You might try just porting the SD library usage in the sketch and see if that works for you.

          1 of 1 people found this helpful
          • 2. Re: Missing avr/pgmspace.h
            KurtE

            Just ran into this, trying out the Galileo on some of my own code.

             

            Suggestion:

            Do like some other non-avr Arduino setups have done and create a file avr/pgmspace.h inside of your include directory.

             

            With the chipkit (pic32) version of the IDE (MPIDE), they created a dummy file that did not do anything, other than to define that it was loaded.  On this platform, detecting it was on this platform and defining my own versions of the pgm_ macros like the Teensy did.

             

            With the Teensy addition to the Arduino IDE, they also created a file at this location, that simply defined some(all?) of the main pgm_ macros, knowing there is only one memory space.  Example:

            #define pgm_read_byte(addr) (*(const unsigned char *)(addr))

             

            I did something similar when I ported some of my own code over to run on some other Linux boxes such as the Raspberry Pi.  This allows me to continue to share most of the code on the different platforms.

             

            Next up, see what defines are in place so I can detect I am building for the Galileo and try to fix. 

            1 of 1 people found this helpful
            • 3. Re: Missing avr/pgmspace.h
              Mikal.Hart

              +1 on KurtE's answer, which is similar to one I posted on another forum a couple of days ago:

               

              Here's perhaps a better solution that avoids having to doctor third-party libraries: use an alternative implementation of pgmspace.h.  Here is a version borrowed from the Teensy3 Arduino distribution.  The CPU in the Teensy3, like the x86, doesn't have separate instruction/data address spaces--the so-called "Harvard Architecture" of the AVR micros.  So its implementation of pgmspace.h simply casts it all away, making pgm_read_byte_near, for example, a simple pointer dereference.

              Instructions:

              At this point you should be able to compile code that depends on #include <avr/pgmspace.h>

              1 of 1 people found this helpful
              • 4. Re: Missing avr/pgmspace.h
                Clayton Hofrock

                Thank You. I was hoping someone smarter than me could create a dummy pgmspace file.

                 

                I think this will add compatibility for many of the Arduino libraries that are out there.

                • 5. Re: Missing avr/pgmspace.h
                  rmm200

                  Thanks Mikal. I have not needed it yet - but I know I will - so I grabbed a copy. Kudos to the Teensy3 folks - and to you for making it available.