ESP32 – Hello world reinvented

In previous post I have described Hello World example coming from ESP_IDF environment. Now let’s build Hello World from the scratch.

Template application

First of all let’s grab template application. It is available on GitHub under espressif project.

cd ~/esp
git clone --recursive

Rename esp-idf-template directory to hello_world2.

mv esp-idf-template hello_world2
cd hello_world2

Edit Makefile and change value of PROJECT_NAME variable to hello_world2.

Main files of the projects are located in main directory, additional components will be located in components by default. So let’s got to main and remove source file main.c. This file contains example how to connect to wireless network and will be interesting in future. Create the easiest existing example hello_world2.c as below. Name of the file does not matter but one of source files must contain void app_main(void) function:

#include <stdio.h>

void app_main(void)
  printf("Hello world\n");

Remember to run make menuconfig to set serial flasher connection and then flash and monitor. At the end of the results you will see something like:

mode:DIO, clock div:2
ho 0 tail 12 room 4
0x40080000: _iram_start at ??:?
entry 0x40080034
0x40080034: _iram_start at ??:?
Hello world

It works. Now as general rule tasks should be created in form of endless loop and this peace of code hasn’t got loop. But task can delete themselves when finished. But where this task from app_main is deleted? When you quickly look into cpu_start.c file from esp-idf/components/esp32 folder you will see that right after app_main ends the task is deleted:

static void main_task(void* args)
    // Now that the application is about to start, disable boot watchdogs
    //Enable allocation in region where the startup stacks were located.


One thought on “ESP32 – Hello world reinvented

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.