This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

task_yield results in hard fault.

Hi.

I have a RAK5010 i use for iot application.

i recently moved from SDK 15.20 to sdk 16.
I use the task manager to manage two tasks:

1. task to dump nrf logs

2. task to handle the GSM and  main loop.

in the near future i do expect to add some more tasks or at least use more the task_Wait, for the time being each task is a for(;;) loop with task_yield in it's end.

since sdk 16 i have an issue with task_yield, the first task task yield works fine, the other task starts running and when it calls task yield i get hard fault. The hard fault occurs since the PC is 0x0000! the LR showed me the return address is just AFTER task_switch was called from task_yield function. adding SEGGER_RTT_printf also sows that (i wrap the task_Switch function with prints, both show).
That means that after the task switch for some reason the processor is sure 0x0000 is the right address to go.

Any hint on that would be appreciated, if it's my software that corrupts the stack before the task_yield call, how do i test that ?

Parents
  • Hello,

    What does the task_yield() function do? Is it something that you wrote? What does it do?

    Are you sure you experience a hardfault, and not an APP_ERROR_CHECK()? I am just asking because these names are often mixed up. Does the log say anything?

    I know nothing about your application. What do you use? Do you use the softdevice? Any RTOS?

  • task_yield() is a function that is defined in task_manager.h. task manager is a, well, task manager that id provided in the "experimental" directory in the sdk, it's pretty much the same between sdk 16 and 15.2.
    What does it do ? it assets your state that you are running with PSP and the right priority and access right and then calls a function called task_switch written in assembly.
    Task switch chooses the next task that should run and performs arm m4 task switch operation.

    After task_switch returns basically task_yield() should return to the PC where the previous task was yielded instead of the current task that called the "yield" function. There is a bug there so it seems that causes the PC to be 0.

Reply
  • task_yield() is a function that is defined in task_manager.h. task manager is a, well, task manager that id provided in the "experimental" directory in the sdk, it's pretty much the same between sdk 16 and 15.2.
    What does it do ? it assets your state that you are running with PSP and the right priority and access right and then calls a function called task_switch written in assembly.
    Task switch chooses the next task that should run and performs arm m4 task switch operation.

    After task_switch returns basically task_yield() should return to the PC where the previous task was yielded instead of the current task that called the "yield" function. There is a bug there so it seems that causes the PC to be 0.

Children
No Data
Related