mirror of https://github.com/wolfSSL/wolfssl.git
Fix Arduino progmem print, AVR WOLFSSL_USER_IO
parent
1b240e2cbc
commit
1f88ab58c1
|
@ -25,9 +25,33 @@
|
||||||
/* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
|
/* Function to allow wolfcrypt to use Arduino Serial.print for debug messages.
|
||||||
* See wolfssl/wolfcrypt/logging.c */
|
* See wolfssl/wolfcrypt/logging.c */
|
||||||
|
|
||||||
|
#if defined(__AVR__)
|
||||||
|
#include <avr/pgmspace.h> /* Required for PROGMEM handling on AVR */
|
||||||
|
#endif
|
||||||
|
|
||||||
int wolfSSL_Arduino_Serial_Print(const char* const s)
|
int wolfSSL_Arduino_Serial_Print(const char* const s)
|
||||||
{
|
{
|
||||||
/* Reminder: Serial.print is only available in C++ */
|
/* Reminder: Serial.print is only available in C++ */
|
||||||
Serial.println(F(s));
|
int is_progmem = 0;
|
||||||
|
|
||||||
|
#if defined(__AVR__)
|
||||||
|
const char* t;
|
||||||
|
t = s;
|
||||||
|
|
||||||
|
/* Safely check if `s` is in PROGMEM, 0x8000 is typical for AVR flash */
|
||||||
|
if (reinterpret_cast<uint16_t>(t) >= 0x8000) {
|
||||||
|
while (pgm_read_byte(t)) {
|
||||||
|
Serial.write(pgm_read_byte(t++));
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
is_progmem = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Print normally for non-AVR boards or RAM-stored strings */
|
||||||
|
if (!is_progmem) {
|
||||||
|
Serial.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -262,6 +262,11 @@ if [ "$THIS_DIR" = "ARDUINO" ]; then
|
||||||
# Copy examples
|
# Copy examples
|
||||||
mkdir -p ".${ROOT_SRC_DIR}"/examples
|
mkdir -p ".${ROOT_SRC_DIR}"/examples
|
||||||
|
|
||||||
|
EXAMPLES_DIR_REAL_PATH=$(realpath ".${EXAMPLES_DIR}")
|
||||||
|
echo "Source WOLFSSL_EXAMPLES_ROOT=$WOLFSSL_EXAMPLES_ROOT"
|
||||||
|
echo "Destination EXAMPLES_DIR=.${EXAMPLES_DIR}"
|
||||||
|
echo "EXAMPLES_DIR_REAL_PATH=${EXAMPLES_DIR_REAL_PATH}"
|
||||||
|
|
||||||
if [ -n "$WOLFSSL_EXAMPLES_ROOT" ]; then
|
if [ -n "$WOLFSSL_EXAMPLES_ROOT" ]; then
|
||||||
echo "Copy template example...."
|
echo "Copy template example...."
|
||||||
mkdir -p ".${EXAMPLES_DIR}"/template/wolfssl_library/src
|
mkdir -p ".${EXAMPLES_DIR}"/template/wolfssl_library/src
|
||||||
|
@ -294,6 +299,9 @@ if [ "$THIS_DIR" = "ARDUINO" ]; then
|
||||||
else
|
else
|
||||||
NO_ARDUINO_EXAMPLES=1
|
NO_ARDUINO_EXAMPLES=1
|
||||||
fi
|
fi
|
||||||
|
echo "Examples copied to .${EXAMPLES_DIR}"
|
||||||
|
echo "ls ${EXAMPLES_DIR_REAL_PATH}"
|
||||||
|
ls "${EXAMPLES_DIR_REAL_PATH}"
|
||||||
else
|
else
|
||||||
echo "ERROR: You must be in the IDE/ARDUINO directory to run this script"
|
echo "ERROR: You must be in the IDE/ARDUINO directory to run this script"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -92,9 +92,13 @@
|
||||||
#elif defined(WOLFSSL_SERVER_EXAMPLE)
|
#elif defined(WOLFSSL_SERVER_EXAMPLE)
|
||||||
#define NO_WOLFSSL_CLIENT
|
#define NO_WOLFSSL_CLIENT
|
||||||
#elif defined(WOLFSSL_TEMPLATE_EXAMPLE)
|
#elif defined(WOLFSSL_TEMPLATE_EXAMPLE)
|
||||||
|
#define NO_TLS
|
||||||
|
#define WOLFCRYPT_ONLY
|
||||||
#define NO_WOLFSSL_SERVER
|
#define NO_WOLFSSL_SERVER
|
||||||
#define NO_WOLFSSL_CLIENT
|
#define NO_WOLFSSL_CLIENT
|
||||||
#elif defined(WOLFSSL_AES_CTR_EXAMPLE)
|
#elif defined(WOLFSSL_AES_CTR_EXAMPLE)
|
||||||
|
#define NO_TLS
|
||||||
|
#define WOLFCRYPT_ONLY
|
||||||
#define NO_WOLFSSL_SERVER
|
#define NO_WOLFSSL_SERVER
|
||||||
#define NO_WOLFSSL_CLIENT
|
#define NO_WOLFSSL_CLIENT
|
||||||
#define WOLFSSL_AES
|
#define WOLFSSL_AES
|
||||||
|
|
|
@ -316,6 +316,7 @@
|
||||||
|
|
||||||
/* board-specific */
|
/* board-specific */
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
|
#define WOLFSSL_USER_IO
|
||||||
#define WOLFSSL_NO_SOCK
|
#define WOLFSSL_NO_SOCK
|
||||||
#define NO_WRITEV
|
#define NO_WRITEV
|
||||||
#elif defined(__arm__)
|
#elif defined(__arm__)
|
||||||
|
|
Loading…
Reference in New Issue