I am currently facing an issue while attempting to upload an SSL certificate to a WiFiNiNA-W102 Module using ESP-IDF. I have followed the steps below, and I'm encountering a problem where it appears to be erasing the flash memory containing the NiNA firmware.
Steps Taken:
1. Certificate Generation:
I generated the SSL certificate using InfinityFree software online, and I have converted it into the required format.
Code: Select all
openssl x509 -outform DER -in sslcertificate.pem -out server_cert.bin
xxd -i server_cert.bin > server_cert.h
I set up the ESP-IDF environment for ESP32 as per the official documentation.
3. Project Configuration:
I created a project with the following main code:
Code: Select all
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_http_client.h"
#include "server_cert.h"
extern unsigned char server_cert_bin[];
extern unsigned int server_cert_bin_len;
static const char *TAG = "HTTPS_CLIENT";
void app_main() {
esp_http_client_config_t config = {
.url = "https://connectvega.rf.gd",
.cert_pem = (char *)server_cert_bin,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %lld",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err));
}
esp_http_client_cleanup(client);
while (1) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
The project builds and uploads successfully, but it seems to be erasing the flash memory where the NiNA firmware is stored.
I am seeking guidance on how to resolve this issue. Any insights or suggestions from the community would be greatly appreciated. Thank you!