esp32arduino-esp32

ESP-IDF CPP code is not getting executed?


I have built a ESP software relying on Arduino components to activate the LORA configuration github code

For that, I have moved my main.c to main.cpp and updated all make files accordingly, my code compiles without any error. but the execution of the app main is so weird and can't figure out what is the cause!

main function:

extern "C" void app_main(void)
{
   fflush(stdout);
   printf("IM here\n");
   fflush(stdout);
   lora_arduino();
}

while lora arduino function

void lora_arduino() {
  fflush(stdout);
  printf("hereeeeee0211111111\n");
  fflush(stdout);
  setup();
  printf("hereeeeee0\n");

  if (e220ttl.available()>1) {
      Serial.println("Message received!");
      // read the String message
    ResponseContainer rc = e220ttl.receiveMessage();
      // Is something goes wrong print error
     if (rc.status.code!=1){
        Serial.println(rc.status.getResponseDescription());
     }else{
        // Print the data received
        Serial.println(rc.status.getResponseDescription());
        Serial.println(rc.data);
        printf("hereeeeee\n");
        // printf('received data is %s', rc.data);
     }
 }

printf("hereeeeee1010101--------");
}

output:


rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7112
load:0x40078000,len:15624
load:0x40080400,len:4
0x40080400: _init at ??:?

load:0x40080404,len:3876
entry 0x4008064c
I (29) boot: ESP-IDF v5.1.4 2nd stage bootloader
I (29) boot: compile time Jul 23 2024 07:17:49
I (29) boot: Multicore bootloader
I (34) boot: chip revision: v3.1
I (37) boot.esp32: SPI Speed      : 40MHz
I (42) boot.esp32: SPI Mode       : DIO
I (46) boot.esp32: SPI Flash Size : 2MB
I (51) boot: Enabling RNG early entropy source...
I (56) boot: Partition Table:
I (60) boot: ## Label            Usage          Type ST Offset   Length
I (67) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (75) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (82) boot:  2 factory          factory app      00 00 00010000 00100000
I (90) boot: End of partition table
I (94) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0c774h ( 51060) map
I (121) esp_image: segment 1: paddr=0001c79c vaddr=3ffb0000 size=021d0h (  8656) load
I (125) esp_image: segment 2: paddr=0001e974 vaddr=40080000 size=016a4h (  5796) load
I (129) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1fb94h (129940) map
I (182) esp_image: segment 4: paddr=0003fbbc vaddr=400816a4 size=0bb90h ( 48016) load
I (209) boot: Loaded app from partition at offset 0x10000
I (209) boot: Disabling RNG early entropy source...
I (220) cpu_start: Multicore app
I (221) cpu_start: Pro cpu up.
I (221) cpu_start: Starting app cpu, entry point is 0x400812e4
0x400812e4: call_start_cpu1 at C:/Users/saeed/esp/v5.1.4/esp-idf/components/esp_system/port/cpu_start.c:159

I (209) cpu_start: App cpu up.
I (239) cpu_start: Pro cpu start user code
I (239) cpu_start: cpu freq: 160000000 Hz
I (239) cpu_start: Application information:
I (244) cpu_start: Project name:     cooling_gateway
I (249) cpu_start: App version:      839580b-dirty
I (255) cpu_start: Compile time:     Jul 23 2024 07:17:34
I (261) cpu_start: ELF file SHA256:  17577d42...
I (266) cpu_start: ESP-IDF:          v5.1.4
I (271) cpu_start: Min chip rev:     v0.0
I (276) cpu_start: Max chip rev:     v3.99 
I (281) cpu_start: Chip rev:         v3.1
I (286) heap_init: Initializing. RAM available for dynamic allocation:
I (293) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (299) heap_init: At 3FFB2F30 len 0002D0D0 (180 KiB): DRAM
I (305) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (311) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (318) heap_init: At 4008D234 len 00012DCC (75 KiB): IRAM
I (325) spi_flash: detected chip: generic
I (328) spi_flash: flash io: dio
W (332) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (346) app_start: Starting scheduler on CPU0
I (351) app_start: Starting scheduler on CPU1
I (351) main_task: Started on CPU0
I (36�

None of my prints are getting printed. what is wrong with code not to be printed at least?


Solution

  • My issue was hidden in UART baud rate configuration. when I have changed it to UART_BPS_RATE_115200 according to the board I'm connected to, this issue has been resolved.

    this require also changing the serial.begin(UART_BPS_RATE_115200)