maximkulkin / esp-homekit-demo

Demo of Apple HomeKit accessory server library
MIT License
807 stars 233 forks source link

Compiling ESP32 LED : Missing hwrand.h? #436

Open HSkul opened 1 year ago

HSkul commented 1 year ago

I'm at a loss as how to fix what appears to be a path issue when trying to compile esp32/led demo program. When I run make -C examples/esp32/led all (menuconfig runs fine) I end up getting the following error:

CC examples/esp32/led/build/wolfssl/wolfssl-4.1.0/src/bio.o In file included from ~/esp-homekit-demo/components/common/wolfssl/wolfssl-4.1.0/wolfssl/wolfcrypt/settings.h:199, from ~/esp-homekit-demo/components/common/wolfssl/wolfssl-4.1.0/src/bio.c:22: ~/esp-homekit-demo/components/common/wolfssl/user_settings.h:4:10: fatal error: esp/hwrand.h: No such file or directory

hwrand.h only comes with esp-open-rtos which I do have installed, but as far as I understand it is only for esp8266. So I'm at a loss on what I have missed in the installation.

BTW, I'm using version 4.2 of esp-idf as version 5.0 gave me errors that the esp-idf/make folder contents was missing (the make folder was completely missing in that version so I'm not sure if it installed correctly or just incompatible).

Thanks,

H

renandw commented 1 year ago

I am using .../wolfssl/user_settings.h version from the esp32-homekitcamera repository.

#ifndef wolfcrypt_user_settings_h
#define wolfcrypt_user_settings_h

#ifdef ESP_IDF

#define WOLFSSL_ESPIDF

#include <esp_system.h>

static inline int hwrand_generate_block(uint8_t *buf, size_t len) {
    int i;
    for (i=0; i+4 < len; i+=4) {
        *((uint32_t*)buf) = esp_random();
        buf += 4;
    }
    if (i < len) {
        uint32_t r = esp_random();
        while (i < len) {
            *buf++ = r;
            r >>= 8;
            i++;
        }
    }

    return 0;
}

#else

#include <esp/hwrand.h>

static inline int hwrand_generate_block(uint8_t *buf, size_t len) {
    hwrand_fill(buf, len);
    return 0;
}

#define MP_LOW_MEM

#define FREERTOS
#define WC_NO_HARDEN
#define NO_WOLFSSL_DIR
#define SINGLE_THREADED
#define WOLFSSL_LWIP
#define NO_INLINE

#define NO_WOLFSSL_MEMORY
#define NO_WOLFSSL_SMALL_STACK

#endif

#define CUSTOM_RAND_GENERATE_BLOCK hwrand_generate_block

#endif