This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/AM5728: Random() in TI RTOS result in DATA ABORT

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Call Random() in TI RTOS result in data abort, Call Random() in the same way without RTOS is OK, Why?

#include <stdio.h>

#include <stdlib.h>

int main(void)
{
/* Call board init functions */
int temp;

temp = random();

[CortexA15_0] 0x00000000 R8 = 0x4037f064
R1 = 0x600001df R9 = 0xffffffff
R2 = 0x80023d49 R10 = 0x00000000
R3 = 0x0000330e R11 = 0x8104ab34
R4 = 0x80025244 R12 = 0x600001df
R5 = 0x8002092c SP(R13) = 0x8104ab18
R6 = 0x00000000 LR(R14) = 0x8001f380
R7 = 0x8104ab48 PC(R15) = 0x80021118
PSR = 0x600001df
DFSR = 0x00000a05 IFSR = 0x00000000
DFAR = 0x00000000 IFAR = 0x00000000
ti.sysbios.family.arm.exc.Exception: line 205: E_dataAbort: pc = 0x80021118, lr = 0x8001f380.
xdc.runtime.Error.raise: terminating execution
0x00000000 R8 = 0x00000000
R1 = 0x600001df R9 = 0xffffffff
R2 = 0x80023d49 R10 = 0x00000000
R3 = 0x0000330e R11 = 0x8104ab34
R4 = 0x80025244 R12 = 0x600001df
R5 = 0x8002092c SP(R13) = 0x8104ab18
R6 = 0x00000000 LR(R14) = 0x8001f380
R7 = 0x8104ab48 PC(R15) = 0x80021118
PSR = 0x600001df
DFSR = 0x00000a05 IFSR = 0x00000000
DFAR = 0x00000000 IFAR = 0x00000000
ti.sysbios.family.arm.exc.Exception: line 205: E_dataAbort: pc = 0x80021118, lr = 0x8001f380.
xdc.runtime.Error.raise: terminating execution

  • Hello Tony,

    I assume there was no compile/linking warning, what is the TI-RTOS version you are using? Do you have a small project you can share to demonstrate the problem?

    Please note due to the US holidays, on this particular E2E thread, our response may get delayed until the week of Jan 2, 2019.

    Warmest Wishes for Happy Holidays and a Happy New Year!

    best regards,
    David Zhou
  • Hi Tony,

    Where are you getting the function random()? Have you looked at this to help debug exceptions: training.ti.com/debugging-common-application-issues-ti-rtos

    Todd
  • David,

    I reproduce it with a example of PDK: GPIO_LedBlink_idkAM572x_armTestProject, just add random() call in main().

    customer call it in task got the same result.

    and customer said, if don't use RTOS, call random() is OK.

  • Can you look in the mapfile to see where random() is coming from? Did you look at the training to see if that would help?
  • I attach the map file. I looked at the .pdf, seems not help for my question

    GPIO_LedBlink_idkAM572x_armTestProject.zip

  • Hi Tony,

    Have you tried using random_r() instead?

    It is the multi-threaded version of random().

    Regards,

    - Rob

  • Robert Tivy said:

    Hi Tony,

    Have you tried using random_r() instead?

    It is the multi-threaded version of random().

    Regards,

    - Rob

    random_r() can't build through.


    **** Build of configuration Debug for project GPIO_LedBlink_idkAM572x_armTestProject ****

    "C:\\ti\\ccsv7\\utils\\bin\\gmake" -k -j 4 all -O

    'Building file: "C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c"'
    'Invoking: GNU Compiler'
    "C:/ti/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-a15 -mtune=cortex-a15 -marm -mfloat-abi=hard -Dam5728 -Dcore0 -DSOC_AM572x -DidkAM572x -I"C:/ti/pdk_am57xx_1_0_11/packages/MyExampleProjects/GPIO_LedBlink_idkAM572x_armTestProject" -I"C:/ti/gcc-arm-none-eabi-6-2017-q1-update/arm-none-eabi/include/newlib-nano" -I"C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio" -I"C:/ti/gcc-arm-none-eabi-6-2017-q1-update/arm-none-eabi/include" -g -gdwarf-3 -gstrict-dwarf -Wall -c -finstrument-functions -MMD -MP -MMD -MP -MF"main_led_blink.d" -MT"main_led_blink.o" @"configPkg/compiler.opt" -o"main_led_blink.o" "C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c"
    C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c: In function 'main':
    C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c:230:12: warning: implicit declaration of function 'random_r' [-Wimplicit-function-declaration]
    temp = random_r(3);
    ^~~~~~~~
    C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c:227:10: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
    int temp;
    ^~~~
    'Finished building: "C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c"'

    'Building target: "GPIO_LedBlink_idkAM572x_armTestProject.out"'
    'Invoking: GNU Linker'
    "C:/ti/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc.exe" -mtune=cortex-a15 -marm -Dam5728 -Dcore0 -DSOC_AM572x -DidkAM572x -g -gdwarf-3 -gstrict-dwarf -Wall -finstrument-functions -MMD -MP -mfloat-abi=hard -Wl,-Map,"GPIO_LedBlink_idkAM572x_armTestProject.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_52_00_12/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -Wl,--defsym,CORE0=1 -Wl,--defsym,STACKSIZE=0x10000 -Wl,--defsym,HEAPSIZE=0x400 --specs=nano.specs -o"GPIO_LedBlink_idkAM572x_armTestProject.out" "./GPIO_idkAM572x_board.o" "./GPIO_log.o" "./GPIO_soc.o" "./UART_soc.o" "./main_led_blink.o" -Wl,-T"configPkg/linker.cmd" -Wl,--start-group -lrdimon -lgcc -lm -lnosys -lc -Wl,--end-group
    makefile:150: recipe for target 'GPIO_LedBlink_idkAM572x_armTestProject.out' failed
    ./main_led_blink.o: In function `main':
    C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c:230: undefined reference to `random_r'
    collect2.exe: error: ld returned 1 exit status
    gmake[1]: *** [GPIO_LedBlink_idkAM572x_armTestProject.out] Error 1
    gmake: *** [all] Error 2
    makefile:146: recipe for target 'all' failed

    **** Build Finished ****

  • Tony,

    I tried to reproduce this issue and haven`t been able to either using GPIO Led Blink TI RTOS example or using a basic TI RTOS Hello World example so I am not completely sure what is going on with your setup. Is introducing the random() API the only chnage that you made to the project ?

    I am attaching my binary and output file to try at your end.

    2630.GPIO_LedBlink_idkAM572x_armTestProject.zip

    Regards,

    Rahul

  • "Is introducing the random() API the only chnage that you made to the project ?"

    random() call in TI RTOS result in data abort.
    srand() rand() call in TI RTOS result in data abort.
    random_r() can't build through in TI RTOS.

    Is there any alternative to this situation?

    Best regards.
  • A:

    C:\ti\ccsv7\tools\compiler\gcc-arm-none-eabi-6-2017-q1-update\arm-none-eabi\lib\hard\libc.a

    B:

    C:\sdk\bios_6_52_00_12\packages\gnu\targets\arm\libs\install-native\arm-none-eabi\lib\hard\libc.a

     

    When I replace B with A, Bios call random() will be normal and Bios running normal!!!

    But the source code of B is not public.

    I don't know if this is the right way.

    I think the source code of B should be modified according to the Bios operating system.