Skip to content
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

'printf_P' was not declared in this scope #19

Open
facetime88 opened this issue Sep 22, 2017 · 9 comments
Open

'printf_P' was not declared in this scope #19

facetime88 opened this issue Sep 22, 2017 · 9 comments

Comments

@facetime88
Copy link

This works perfect in arduino mega. But when I use it in arduino due, there are several 'printf_P' error:

AES.cpp:532:46: error: 'printf_P' was not declared in this scope

@spaniakos
Copy link
Owner

in AES.h there is the header code that defines functions missing in boards.

#if defined(__ARDUINO_X86__) || (defined (__linux) || defined (linux)) #undef PROGMEM #define PROGMEM __attribute__(( section(".progmem.data") )) #define pgm_read_byte(p) (*(p)) typedef unsigned char byte; #define printf_P printf #define PSTR(x) (x) #else #include <avr/pgmspace.h> #endif
you have to add your board code to the line
#if defined(__ARDUINO_X86__) || (defined (__linux) || defined (linux))
so it is like
#if defined(__ARDUINO_X86__) || (defined (__linux) || defined (linux)) || defined(YOUR_BOARD_CODE)
and I think it will be fine.

@spaniakos
Copy link
Owner

my bad the file is : AES_config.h

the code you need for due is : defined(SAM3X8E) and is an ARM device
but I need to know if the Arduino due is an AVR or non-AVR board
I assume you try with the above solution and check if everything works as intended or not and tell me.

add this:
|| ( defined(arm) && defined(SAM3X8E) )

as Arduino due is an arm device but the device specific code is SAM3X8E

@facetime88
Copy link
Author

facetime88 commented Sep 29, 2017

Hi,

I have tried the 3 combinations:

|| defined(arm)
|| defined(SAM3X8E)
|| ( defined(arm) && defined(SAM3X8E) )

The error still shows up. Since seems I don't use to call the printArray function, is that okay if I just commented out each line of "printf_P(PSTR..." in AES.cpp?

@spaniakos
Copy link
Owner

you can try , but there will be other errors as well.
link me your AES_config.h to my email : spaniakos@gmail.com
and I will try to make a modified version (blind coding)

@facetime88
Copy link
Author

facetime88 commented Sep 30, 2017

Hi,

This is my file
For now, I am commenting out the printf lines in printArray functions. And it seems not giving any error so far.
Thank you.

@FrancMunoz
Copy link
Contributor

Hi!

To make it work in Arduino MKRGSM 1400, and I guess all arduino ARM family I've changed the following:

Note I've only tested in MKGSM.

So, in Base64.h:

#include "Base64.h"

#if defined(__AVR__) || defined(__arm__)
	#include <avr/pgmspace.h>
#else
	#include <pgmspace.h>
#endif

...

And in AES_Config.h (whole file):

/* code was modified by george spanos <spaniakos@gmail.com>
 * 16/12/14
 */

#ifndef __AES_CONFIG_H__
#define __AES_CONFIG_H__

//defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRZERO) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWIFI1010)
#if (defined(__linux) || defined(linux)) && !(defined(__ARDUINO_X86__) || defined(__arm__))
  #define AES_LINUX
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <sys/time.h>
  #include <unistd.h>
#else
  #include <Arduino.h>
#endif

#include <stdint.h>
#include <string.h>

//defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRZERO) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWIFI1010)
#if defined(__ARDUINO_X86__) || defined(__arm__) || (defined (__linux) || defined (linux))
  #undef PROGMEM
  #define PROGMEM __attribute__(( section(".progmem.data") ))
  #define pgm_read_byte(p) (*(p))
  typedef unsigned char byte;
  #define printf_P printf
  #define PSTR(x) (x)
#else
  #if (defined(__AVR__))
    #include <avr/pgmspace.h>
  #else
    #include <pgmspace.h>
  #endif
#endif

#define N_ROW                   4
#define N_COL                   4
#define N_BLOCK   (N_ROW * N_COL)
#define N_MAX_ROUNDS           14
#define KEY_SCHEDULE_BYTES ((N_MAX_ROUNDS + 1) * N_BLOCK)
#define SUCCESS (0)
#define FAILURE (-1)

#endif

@spaniakos maybe you want to include it or I could do a PR... just tell.

@spaniakos
Copy link
Owner

i would like to check it on my boards as well.
can you do a PR?
also this is the correct way to do it, as it will show you are a contributor as well :)

@FrancMunoz
Copy link
Contributor

Sure! let me know if there's any issue with __arm__ define to find out another to fit...

@spaniakos
Copy link
Owner

moving to pull request conv.

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

3 participants