Source Subdirectories

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Source Subdirectories

Postby gregstewart90 » Mon Aug 21, 2017 8:15 pm

I want to organize my code into multiple subdirectores. Currently I can only compile code from one directory deep. Below I have my desired organization.

Code: Select all

->main
    ->dir_1
    ->dir_2
    ->dir_3
        ->dir_3_a
        ->dir_3_b
            ->dir_3_b_1
            
In my main directory, I have a component.mk file with the following:
COMPONENT_SRCDIRS := . dir_1 dir_2 dir_3

If I try adding dir_3/dir_3_a, I get the following error:

Code: Select all

/path/to/project/main/dir_3/dir_3_a/file.c fatal error: opening dependency file dir_3/dir_3_a/file.d: No such file or directory

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Source Subdirectories

Postby ESP_Angus » Mon Aug 21, 2017 11:35 pm

Hi Greg,

This should work, we do it in a number of IDF's internal components (take a look at "components/lwip" or "components/libsodium" for some directory structures that go pretty deep.)

.d is a generated dependency file. If you've been moving files/directories around, then you may need to do a "make clean" before things build nicely. This is a limitation of the build system that's probably not going away soon, unfortunately (the good news, it's about the only time you should need a "make clean")

If "make clean" doesn't work, try renaming the build directory out of the way and then re-run make. If that works, it's a bug in the build system (please let us know if that's the case.)

If none of this works, can you please give some more details about exactly what the contents of your component.mk is and exactly what files are in which directories?

PS The "components" concept is designed to make this kind of organisation straightforward, as well. You can keep all your files in subdirectories under "main" and this will work fine, but you can also make a structure where your project has its own components. Something like the structure shown here:
http://esp-idf.readthedocs.io/en/latest ... le-project
(Whether you choose to do this is up to you, entirely.)

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: Source Subdirectories

Postby gregstewart90 » Tue Aug 22, 2017 12:05 am

I tried what you said, but it gave me the same error. I even deleted the build directory to make sure nothing was left over. I tried changing the order of the subdirectories in the component.mk file, and that worked.

Working component.mk file

Code: Select all

COMPONENT_SRCDIRS := . dir_one/dir_one_a dir_one

Non-working component.mk file

Code: Select all

COMPONENT_SRCDIRS := . dir_one dir_one/dir_one_a

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Source Subdirectories

Postby ESP_Angus » Tue Aug 22, 2017 2:51 am

Thanks Greg. We saw a bug like this a while ago, but I thought we had fixed it - maybe not. Can you please confirm which IDF version you are using?

Angus

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: Source Subdirectories

Postby gregstewart90 » Tue Aug 22, 2017 10:00 pm

I upgraded my IDF to the latest version, but now my project will not build. I get error like the following:

Code: Select all

/esp-idf/components/esp32/include/esp_wifi.h:160:18: error: 'CONFIG_ESP32_WIFI_RX_BA_WIN' undeclared (first use in this function)
     .rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\
     unit_test.c:237:27: note: in expansion of macro 'WIFI_INIT_CONFIG_DEFAULT'
  wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
     

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Source Subdirectories

Postby ESP_Angus » Tue Aug 22, 2017 11:36 pm

gregstewart90 wrote:I upgraded my IDF to the latest version, but now my project will not build. I get error like the following:
Sorry, this is a different bug in the current IDF master branch. You can work around it in one of two ways:
  • Enable AMPDU in Component Config -> Wifi Settings
  • Or, comment these two lines in esp_wifi.h:

    Code: Select all

        .tx_ba_win = CONFIG_ESP32_WIFI_TX_BA_WIN,\
        .rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\
    
A proper fix will be available shortly.

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: Source Subdirectories

Postby gregstewart90 » Thu Aug 24, 2017 1:24 pm

I had to do both to make it work. If I didn't it would continually reset and print out the following:

Code: Select all

Backtrace: 0x40086159:0x3ffd45a0 0x40087588:0x3ffd45d0 0x40089585:0x3ffd4600 0x400898fa:0x3ffd47d0 0x40089269:0x3ffd4810 0x400893cc:0x3ffd4890 0x4008202e:0x3ffd48b0 0x40086156:0x3ffd4970 0x40086156:0x3ffd49a0 0x40089585:0x3ffd49d0 0x400898fa:0x3ffd4ba0 0x40089269:0x3ffd4be0 0x400893cc:0x3ffd4c60 0x4008202e:0x3ffd4c80 0x40086156:0x3ffd4d40 0x40086156:0x3ffd4d70 0x40089585:0x3ffd4da0 0x400898fa:0x3ffd4f70 0x40089269:0x3ffd4fb0 0x400893cc:0x3ffd5030 0x4008202e:0x3ffd5050 0x40086165:0x3ffd5110 0x40086165:0x3ffd5140 0x40089585:0x3ffd5170 0x400898fa:0x3ffd5340 0x40089269:0x3ffd5380 0x400893cc:0x3ffd5400 0x4008202e:0x3ffd5420 0x400884d6:0x3ffd54e0 0x400884d6:0x3ffd5500 0x40087588:0x3ffd5530 0x40089585:0x3ffd5560 0x400898fa:0x3ffd5730 0x40089269:0x3ffd5770 0x400893cc:0x3ffd57f0 0x4008202e:0x3ffd5810 0x40086156:0x3ffd58d0 0x40086156:0x3ffd5900 0x40089585:0x3ffd5930 0x400898fa:0x3ffd5b00 0x40089269:0x3ffd5b40 0x400893cc:0x3ffd5bc0 0x4008202e:0x3ffd5be0 0x40086156:0x3ffd5ca0 0x40086156:0x3ffd5cd0 0x40089585:0x3ffd5d00 0x400898fa:0x3ffd5ed0 0x40089269:0x3ffd5f10 0x400893cc:0x3ffd5f90 0x4008202e:0x3ffd5fb0 0x40086156:0x3ffd6070
0x40086159: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40087588: uxTaskGetSnapshotAll at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:5044 (discriminator 1)

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086165: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40086165: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x400884d6: prvTaskGetSnapshot at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4994

0x400884d6: prvTaskGetSnapshot at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4994

0x40087588: uxTaskGetSnapshotAll at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:5044 (discriminator 1)

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931

0x40089585: esp_core_dump_write at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:112

0x400898fa: esp_core_dump_to_uart at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./core_dump.c:534

0x40089269: commonErrorHandler at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x400893cc: xt_unhandled_exception at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/esp32/./panic.c:546

0x4008202e: _xt_user_exc at xtensa_vectors.o:?

0x40086156: prvTaskGetSnapshotsFromList at /Users/Greg/Documents/StewartTech/esp32/esp-idf/components/freertos/./tasks.c:4931
It still constantly resets if I try to start the SNTP with the following function:

Code: Select all

static void startSNTP() {
	ip_addr_t addr;
	sntp_setoperatingmode(SNTP_OPMODE_POLL);
	inet_pton(AF_INET, "129.6.15.28", &addr);
	sntp_setserver(0, &addr);
	sntp_init();
}
I've commented out this function in my code to get it to work. What causes the above error when it constantly resets? Occasionally I have seen this happen. I can only get it to stop outputting by unplugging my USB cable. I can open a new issue on this if I need to.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Source Subdirectories

Postby ESP_Angus » Fri Aug 25, 2017 6:27 am

Hi Greg,

I've not seen an error like this. From the very long repeating stack trace, it could be stack corruption of some kind.

EDIT: This is apparently a known issue with the core dump code, a fix is being worked on.

Who is online

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