Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem calling POSIX libc functions on espressif boards #66351

Closed
OgnjenX opened this issue Dec 10, 2023 · 2 comments · Fixed by #67218
Closed

Problem calling POSIX libc functions on espressif boards #66351

OgnjenX opened this issue Dec 10, 2023 · 2 comments · Fixed by #67218
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: low Low impact/importance bug

Comments

@OgnjenX
Copy link

OgnjenX commented Dec 10, 2023

When I try to call rand() or (I believe) any other POSIX function from C standard library on 'esp32_devkitc_wroom' target, program causes halting, like this:

*** Booting Zephyr OS build zephyr-v3.5.0-2845-g7b78393b07a6 ***
[00:00:01.511,000] <err> os:  ** FATAL EXCEPTION
[00:00:01.511,000] <err> os:  ** CPU 0 EXCCAUSE 28 (load prohibited)
[00:00:01.518,000] <err> os:  **  PC 0x4000be94 VADDR 0
[00:00:01.524,000] <err> os:  **  PS 0x60e20
[00:00:01.529,000] <err> os:  **    (INTLEVEL:0 EXCM: 0 UM:1 RING:0 WOE:1 OWB:14 CALLINC:2)
[00:00:01.538,000] <err> os:  **  A0 0x8000105e  SP 0x3ffe6b80  A2 0x60e20  A3 0x3ffb26f8
[00:00:01.547,000] <err> os:  **  A4 0x3ffe6b80  A5 0x4  A6 0x3ffe6b90  A7 0
[00:00:01.554,000] <err> os:  **  A8 0  A9 0x3ffe6b50 A10 0xfffffff5 A11 0x3ffb26f8
[00:00:01.563,000] <err> os:  ** A12 0x3ffb26f8 A13 0x4 A14 0x3ffb24f8 A15 0xffffffff
[00:00:01.571,000] <err> os:  ** LBEG 0x4000c46c LEND 0x4000c477 LCOUNT 0
[00:00:01.579,000] <err> os:  ** SAR 0x10


Backtrace:0x4000be91:0x3ffe6b80 0x4000105b:0x3ffe6ba0 0x400d06b6:0x3ffe6bc0 0x4008182b:0x3ffe6be0 0x400d0eb3:0x3ffe6c00 
0x400d06b6: main at /home/ognjen/Robbit/StartUp/micRobbit/zephyr-firmware/microbbit-zephyr-workspace/micRobbit-firmware/app/src/main.cpp:36

0x4008182b: bg_thread_main at /home/ognjen/Robbit/StartUp/micRobbit/zephyr-firmware/microbbit-zephyr-workspace/zephyr/kernel/init.c:371

0x400d0eb3: z_thread_entry at /home/ognjen/Robbit/StartUp/micRobbit/zephyr-firmware/microbbit-zephyr-workspace/zephyr/lib/os/thread_entry.c:48


[00:00:01.595,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:01.603,000] <err> os: Current thread: 0x3ffb26f8 (unknown)
[00:00:01.609,000] <err> os: Halting system

That log is concretely produced by this small program:

#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <cstdlib>

LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);

int main(void)
{
	auto rand_num = rand();
	printk("Random number %d\n", rand_num);
	// Nothing to do here for now
}

Does anyone know something about this? Are there some known limitations in the current espressif toolchain in Zephyr?
(motivation for opening this issue can be found here micro-ROS/micro_ros_zephyr_module#131 (comment))

Thanks in advance!

@OgnjenX OgnjenX added the bug The issue is a bug, or the PR is fixing a bug label Dec 10, 2023
Copy link

Hi @OgnjenX! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@sylvioalves
Copy link
Collaborator

@OgnjenX Hi, same is happening with a few other functions. I am checking this. Thanks.

@MaureenHelm MaureenHelm added the priority: low Low impact/importance bug label Dec 12, 2023
sylvioalves added a commit to sylvioalves/zephyr that referenced this issue Jan 4, 2024
Make sure some ROM libc calls are weak to allow
Zephyr's libc implementation instead.

Fixes zephyrproject-rtos#66351

Signed-off-by: Sylvio Alves <[email protected]>
sylvioalves added a commit to sylvioalves/zephyr that referenced this issue Jan 4, 2024
Make sure some ROM libc calls are weak to allow
Zephyr's libc implementation instead.

Fixes zephyrproject-rtos#66351

Signed-off-by: Sylvio Alves <[email protected]>
sylvioalves added a commit to sylvioalves/zephyr that referenced this issue Jan 4, 2024
Make sure some ROM libc calls are weak to allow
Zephyr's libc implementation instead.

Fixes zephyrproject-rtos#66351

Signed-off-by: Sylvio Alves <[email protected]>
carlescufi pushed a commit that referenced this issue Jan 8, 2024
Make sure some ROM libc calls are weak to allow
Zephyr's libc implementation instead.

Fixes #66351

Signed-off-by: Sylvio Alves <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants