how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

pataga
Posts: 41
Joined: Sat Aug 12, 2017 5:53 am

how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

Postby pataga » Tue Aug 29, 2017 7:34 am

Hi,

I'm trying to build a project template that only uses rom functions, peripheral libraries (timer, i2c, i2s, spi etc.), plus dual-core FreeRTOS api.

With 'make menuconfig' I have disabled Wifi, ethernet, bluetooth, AWS. However, when I then build a simple main.c that just toggles an led, I see that the build system continues to compile un-needed networking functionality - tcpip, lwip,mbedtls,ssl,crypto,nghttp etc. It looks like about 75% of the code compiled is not required.

Code: Select all

#include "freertos/FreeRTOS.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"

esp_err_t event_handler(void *ctx, system_event_t *event)
{
    return ESP_OK;
}

void app_main(void)
{
    nvs_flash_init();
    ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );

    gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
    int level = 0;
    while (true) {
        gpio_set_level(GPIO_NUM_4, level);
        level = !level;
        vTaskDelay(300 / portTICK_PERIOD_MS);
    }
}
Any tips on how I could go about modifying the build process to create a project template that allows me to just build the above named minimum features ? Maybe this is blasphemy :), but I am sure a lot of people would be interested in using the esp32 as a powerful dual-core microcontroller without it's networking features.

vibnwis
Posts: 89
Joined: Thu Aug 24, 2017 1:13 am

Re: how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

Postby vibnwis » Tue Aug 29, 2017 7:58 am

you can get one from esp-idf/examples/get-started/hello-world and modify to your needs.

ESP_Sprite
Posts: 3610
Joined: Thu Nov 26, 2015 4:08 am

Re: how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

Postby ESP_Sprite » Tue Aug 29, 2017 9:10 am

Fyi, we use unused section elimination in the linker step. This means that while the build process will happily build all the objects needed for, well, everything you could use esp-idf for, the linker should afterwards only include the needed code in your final binary. So while I can understand compiling things like the TCP/IP stack is suboptimal wrt longer compile time, it should have no effect on the resulting binary.

If you still want to get rid of the components you do not need, in the top Makefile of your project you can add a variable named 'COMPONENTS' and specify only the components you need there. The bootloader uses that, see esp-idf/components/bootloader/subproject/Makefile for how it does this.

pataga
Posts: 41
Joined: Sat Aug 12, 2017 5:53 am

Re: how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

Postby pataga » Wed Aug 30, 2017 8:27 am

Thanks ESP_Sprite for taking the time to answer, this is what I was looking for.

I know the unused components should not get linked in, but it's a massive pain doing a make clean && make or make menuconfig && make...

I realized everything in the components directory in esp-idf was getting built, but couldn't figure out how to select the components i needed.

I decided to make a backup copy of esp-idf and then delete all the component sub-directories I figured I did not need :
/aws_iot, /bt, /coap, /ethernet, /jsmn, /jason, /libsodium, /lwip, /mdns, /nghttp, /tcpip_adapter, /wpa_supplicant

But there still are lots of cross-references in the remaining code that are not protected by a #ifdef CONFIG_WIFI_ENABLED or #ifdef CONFIG_ETHERNET

e.g. esp32/cpu_start.c includes tcpip_adapter.h, the event definitions in esp_event.h currently are all wifi and ethernet events, but the event handler looks like it was designed as a more generic feature. system_restore calls esp_wifi_restore, etc. I started commenting out or #ifdefing all these cross references in the .c and .h files, and got to the point where I was stymied by the compiler complaining that <byteswap.h> could not be found when compiling /hwcrypto/sha.c . Argh ...

Hopefully, I will figure out how to get a working build and then merge my code with the original esp-idf and a modified toplevel makefile as per your tip. At any rate, am getting good exposure to the system level code.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: how to build a project with just FreeRTOS support (no wifi, tcpip stack etc.)

Postby snahmad75 » Thu Mar 08, 2018 1:54 pm

Hi,

I am also trying to build simple project. but It is building all components . may be linking with them.
how can i avoid it?

Who is online

Users browsing this forum: Bing [Bot] and 18 guests