overwrite weak function not working always

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

overwrite weak function not working always

Postby snahmad75 » Fri Feb 15, 2019 12:24 pm

Hi,

See this thread

viewtopic.php?f=13&t=7583&p=38611#p38611


When I define my overwrite esp_task_wdt_isr_user_handler in main.cpp it works.
but if defined in another files it does not. not 100% reliable make -j and linking on Windows 7 platform which generate .map. I can see in map file. override is not happening.

My project in C++ with all .cpp files.

Is there know issue for it.

Thanks,
Naeem

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

Re: overwrite weak function not working always

Postby snahmad75 » Fri Feb 15, 2019 6:45 pm

Can some one reply and share your experience. I guess there are not many people using gcc and msys32on windows platform.

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

Re: overwrite weak function not working always

Postby ESP_Sprite » Sat Feb 16, 2019 4:48 am

Does the overriding function have its own .c/.cpp file? If so, it may be ignored entirely by the linker as it does not contain unresolved symbols.

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

Re: overwrite weak function not working always

Postby snahmad75 » Sat Feb 16, 2019 2:36 pm

ESP_Sprite wrote:
Sat Feb 16, 2019 4:48 am
Does the overriding function have its own .c/.cpp file? If so, it may be ignored entirely by the linker as it does not contain unresolved symbols.
Here is example. Do i need to define in .c file instead of .cpp


It is working for when I defined in my C++ main.cpp file as but i define in new file e.g WatchDog.cpp. it gets ignored.

extern "C" {
/***************************************************************************//**
\brief This function is called by task_wdt_isr function (ISR for when TWDT times out).
\details It can be redefined in user code to handle twdt events.
Note: It has the same limitations as the interrupt function.
Do not use ESP_LOGI functions inside.
*******************************************************************************/
void esp_task_wdt_isr_user_handler(void)
{
/* restart firmware */
esp_restart();
}
}

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

Re: overwrite weak function not working always

Postby ESP_Sprite » Sun Feb 17, 2019 12:21 pm

So yes, that is the issue you have. .c or .cpp shouldn't matter. Can you see if this solves the issue for you?

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

Re: overwrite weak function not working always

Postby snahmad75 » Sun Feb 17, 2019 5:16 pm

ESP_Sprite wrote:
Sun Feb 17, 2019 12:21 pm
So yes, that is the issue you have. .c or .cpp shouldn't matter. Can you see if this solves the issue for you?
yes it solve for if define in main.c/main.cpp. not elegant but works.

Can i do esp_restart within this override function. I do not want default behavior which is panic handler just stop device/firmware.
I want to restart when watchdog happens.

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

Re: overwrite weak function not working always

Postby ESP_Sprite » Mon Feb 18, 2019 2:24 am

Erm, you know that you can select panic behaviour in 'make menuconfig'? Restarting quietly is one of the options there.

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

Re: overwrite weak function not working always

Postby snahmad75 » Mon Feb 18, 2019 9:34 am

ESP_Sprite wrote:
Mon Feb 18, 2019 2:24 am
Erm, you know that you can select panic behaviour in 'make menuconfig'? Restarting quietly is one of the options there.
I cannot see this option.

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

Re: overwrite weak function not working always

Postby ESP_Sprite » Tue Feb 19, 2019 3:14 am

It's under Component config -> ESP32-specific -> Panic handler behaviour.

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

Re: overwrite weak function not working always

Postby snahmad75 » Tue Feb 19, 2019 10:22 pm

ESP_Sprite wrote:
Tue Feb 19, 2019 3:14 am
It's under Component config -> ESP32-specific -> Panic handler behaviour.
ok, got it.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 176 guests