Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Conversation

@MrSurly
Copy link
Contributor

@MrSurly MrSurly commented May 15, 2017

Not entirely sure CONFIG_ESP32_XTAL_FREQ_AUTO needs to be 1 or y

esp32/sdkconfig.h: Updated to latest IDF
@MrSurly MrSurly mentioned this pull request May 15, 2017
@vandys
Copy link

vandys commented May 15, 2017

I'm pretty sure those are booleans from the config file, the "y" is for purposes of the config UI.
1 would be a better bet for both bools in your changes.

@MrSurly
Copy link
Contributor Author

MrSurly commented May 15, 2017

I'm pretty sure those are booleans from the config file, the "y" is for purposes of the config UI.
1 would be a better bet for both bools in your changes.

Done.

#define CONFIG_TASK_WDT_CHECK_IDLE_TASK 0
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 0

#define CONFIG_FREERTOS_UNICORE 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this switch the code to use dual core? If so is dual core working ok now, did you test it?

Copy link
Contributor Author

@MrSurly MrSurly May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to remove that to get the IDF to compile, since some (new) functions are hard-coded to use 2 cores. I did test it, and it's working fine. If you're interested in the exact area, I can try compiling with CONFIG_FREERTOS_UNICORE restored to 1.

Depends on what you mean by "test," hence my question in #88 WRT running tests.

I was just in "make it work" mode.

I did a make menuconfig on one of the IDF examples, and it un-defines this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some (new) functions are hard-coded to use 2 cores

Can you give examples of these? I'd be surprised if the IDF changed so much that it no longer works with single core.

I was just in "make it work" mode.

The esp32 port is still beta so as long as things work then it's ok. I assume you checked that wifi and your BT stuff works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dug into this:

Here's what you get if you restore CONFIG_FREERTOS_UNICORE:

/home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.c: In function 'dport_access_init_core1':
/home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.c:164:21: error: array subscript is above array bounds [-Werror=array-bounds]
     dport_access_ref[core_id] = 0;
                     ^
/home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.c:165:23: error: array subscript is above array bounds [-Werror=array-bounds]
     dport_access_start[core_id] = 0;
                       ^
/home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.c:166:21: error: array subscript is above array bounds [-Werror=array-bounds]
     dport_access_end[core_id] = 0;
                     ^
/home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.c:167:21: error: array subscript is above array bounds [-Werror=array-bounds]
     dport_core_state[core_id] = DPORT_CORE_STATE_RUNNING;
                     ^
cc1: all warnings being treated as errors
make: *** [build//home/epoulsen/workspaces/esp-idf//components/esp32/dport_access.o] Error 1
make: *** Waiting for unfinished jobs....
epoulsen@banana ~/workspaces/micropython-esp32/esp32 $ 

Code in question:

Note that dport_access_init_core1 is not guarded by any #ifdef. Evidently the toolchain or the IDF code is set up to do static evaluation of assert() statements where possible.

esp-idf/components/esp32/dport_access.c:

static void dport_access_init_core1(void *arg)
{
    int core_id = xPortGetCoreID();

    assert(core_id == 1);

    ESP_INTR_DISABLE(ETS_DPORT_INUM);
    intr_matrix_set(core_id, ETS_FROM_CPU_INTR3_SOURCE, ETS_DPORT_INUM);
    ESP_INTR_ENABLE(ETS_DPORT_INUM);

    dport_access_ref[core_id] = 0;
    dport_access_start[core_id] = 0;
    dport_access_end[core_id] = 0;
    dport_core_state[core_id] = DPORT_CORE_STATE_RUNNING;

    vTaskDelete(NULL);
}

esp-idf/components/freertos/include/freertos/FreeRTOSConfig.h:

/* ESP31 and ESP32 are dualcore processors. */
#ifndef CONFIG_FREERTOS_UNICORE
#define portNUM_PROCESSORS 2
#else 
#define portNUM_PROCESSORS 1
#endif

If you removeesp-idf/components/esp32/dport_access.c from the Makefile, you get a whole bunch of link errors:

LINK build/application.elf
build//home/epoulsen/workspaces/esp-idf//components/freertos/xtensa_vectors.o:(.iram1.literal+0x54): undefined reference to `dport_access_start'
build//home/epoulsen/workspaces/esp-idf//components/freertos/xtensa_vectors.o:(.iram1.literal+0x58): undefined reference to `dport_access_end'
build//home/epoulsen/workspaces/esp-idf//components/newlib/time.o:(.literal.esp_setup_time_syscalls+0xc): undefined reference to `rtc_time_get'
build//home/epoulsen/workspaces/esp-idf//components/newlib/time.o: In function `esp_setup_time_syscalls':

... over 100 more lines ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiling the example get-started/hello_world with FreeRTOS/UNICORE set to "yes" succeeds. Try adding -Wno-error=array-bounds to CFLAGS for the dport_access.c file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try adding -Wno-error=array-bounds to CFLAGS for the dport_access.c file.

I'll try it, but that function is unconditionally a part of the IDF, however, I don't know if anything links to it.

The example I used was the gatt_server_service_table, though all I did was let it write the defaults for sdkconfig.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try adding -Wno-error=array-bounds to CFLAGS for the dport_access.c file.

Yes, this worked, with CONFIG_FREERTOS_UNICORE restored to 1, basic tests passed.

Wifi works well, per the towel.blinkenlights.nl telnet test.

@dpgeorge : Should I update this PR with those changes?

@MrSurly
Copy link
Contributor Author

MrSurly commented May 16, 2017

The esp32 port is still beta so as long as things work then it's ok. I assume you checked that wifi and your BT stuff works.

The whole point was to update the IDF to resolve espressif/esp-idf#520, because I kept getting hammered with crashes while testing BT.

Let me test the WiFi thoroughly tomorrow (actually at home -- don't have any ESP32 here), but I was playing around with WiFi today, and it seemed OK.

I'll post results here tomorrow.

@MrSurly
Copy link
Contributor Author

MrSurly commented May 16, 2017

... and your BT stuff works.

Speaking of which, I have a new branch (BT implementation) that is rebased off of this branch (IDF update), so if this PR is merged, then I'll have to retract #86 (BT implementation on old IDF), and resubmit, since the differences are substantial enough that a simple rebase won't suffice.

esp32/sdkconfig.h: restored CONFIG_FREERTOS_UNICORE
@dpgeorge
Copy link
Member

Thanks, this was squashed and merged in d7049f3. Follow up commits were made in e276161 and 48b5f4f

@dpgeorge dpgeorge closed this May 17, 2017
@MrSurly MrSurly deleted the dev-idf-1e0710f branch May 17, 2017 05:40
@MrSurly MrSurly restored the dev-idf-1e0710f branch October 26, 2017 16:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants