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.

Watchdog timer test in u-boot on ti8148EVM

Hi,

i am writing a test code for Watchdog timer Test in u-boot.

the code is as below.

int test_watchdog()

{

                int ints = disable_interrupts ();  // disabling all the interuupts

                ulong base = get_ticks();

                ulong clk = get_tbclk ();

                while ((get_ticks () - base) / 10 < clk);  // wait for 10 seconds

                if (ints)
                        enable_interrupts ();
 

               /*
                 * If we have reached this point, the watchdog timer
                 * does not work
                 */
                return -1;


}

in this code the EVM should get restarted before reaching the end but it is not happening.

I am using the ti8148EVM to run this code.

what i am doing wrong here?

how can i get the test the watch dog timer?

thanks.

  • Hello,

    You could check :

    ti-ezsdk_dm814x-evm_5_05_02_00/example-applications/linux-driver-examples-psp04.04.00.01/watchdog

    for saWatchdog.c.

    I am attaching you the demo, as well.

    ELF(0�4�
    4 (p�
    ����XX44�4�44�4����
    �
    ��
    �
    �
    HP��
    �
    �
    ��HH�H�  Q�td/lib/ld-linux.so.3GNU
    	
    ���}�����q��& 5 jЄ�܄����������x$�Ilibgcc_s.so.1__aeabi_unwind_cpp_pr0__gmon_start___Jv_RegisterClasses__aeabi_unwind_cpp_pr1libc.so.6perrorsignalputsabortprintfioctlatoicloseopensleep__libc_start_mainwriteGCC_3.5GLIBC_2.4 U&y�`ii
    � �����	
    
    @-�:�����-�������P�Ə�ʌ�P���Ə�ʌ�H���Ə�ʌ�@���Ə�ʌ�8���Ə�ʌ�0���Ə�ʌ�(���Ə�ʌ� ���Ə�ʌ����Ə�ʌ����Ə�ʌ����Ə�ʌ����Ə�ʌ�����Ə�ʌ�����$��������
     �� -�-���0���-��������똈H���0�� ��0����Q��/����h�@ ��0��S�0�0��/�, ��@-�0��S���0��S���3�/�����
    H-�����M������@����	�@�����0<�0@�0�������0��S�
    (	�@�����H	�@�����K����H-���� �M���0�0��0�������0��0�0��0�����@����l	�@���|��� ��0<�0@� ��0<�0@�0��s�|	�@����0�� 0�j�0<�0@�0�� K����H�z���0��0�0�S�
    �	�@�u����0�	�@���o���
    0��0�0<�0@�0�� K����L�b���0��0�0�S�
    �	�@�]����0�
    �@���W���0<�0@�0�� K����H�L���0��0�0�S�
    �	�@�G����0�	�@���A���0<�0@�0����,�@� ��3���0��S�
    0
    �@�?���0<�0@�0����4���0��S�
    �@
    �@�3���0���-�������P
    �@�,����`
    �@�(���0�� 0� 0����K�����/��G-����p���������D��D0��D ��0a� ��CQ�� ����`��@��
    ���� ������@��T����:����������@-����In signal handlerClose failed in signal handlerClose succeeded in signal handler/dev/watchdogwatchdog
    Watchdog Timer : WDIOC_GETTIMEOUT failed
    Current timeout value is : %d seconds
    
    Watchdog Timer : WDIOC_SETTIMEOUT failed
    New timeout value is : %d secondsWrite failedWrite succeededClose failedClose succeeded@������@������xu���������������������0�������������������������@��0u�����8������`t�
    ��
    �
    h�Ђ��
    ��h�����o��o���o���
    ��������������������������A4aeabi*CORTEX-A8
    A	
    GCC: (Sourcery G++ Lite 2009q1-203) 4.3.3����|
    �� ��lD ��������.symtab.strtab.shstrtab.interp.note.ABI-tag.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.ARM.extab.ARM.exidx.eh_frame.init_array.fini_array.jcr.dynamic.got.data.bss.ARM.attributes.comment.debug_frame4�4#H�H 1h�hX7���?Ђ��G���o���"T���oă�@c	�l	�hut�tp����{0�0���	��	`�p�p
    �p����
    X���
    ��
    �
    ��
    �
    ��
    �
    ��
    �
    ����D�$$�,,�p,5�a+��D��pR	$54�H�h���Ђ��ă��	t�
    ��0��
    �p�����
    �
    �
    �
    �$,h�h�����t�
    �
    H�0���$\����|�
    ���
    Њ��)�
    (��6����L,���
    [�
    �����Ѕ�
    ��
    ����؅p��������������������
    ��
    ����
    �
    �
    ������"$ -��=��N��^0�e������� � ��
    �Є���܄$,��*0-�>���J(W4��_��lo4��{����؅p���,���4�����$��4���,�������
    *H�P/t�
    $acall_gmon_start$dinit.ccrtstuff.c__JCR_LIST____do_global_dtors_auxcompleted.5904__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entrysaWatchdog.celf-init.c__FRAME_END____JCR_END___GLOBAL_OFFSET_TABLE___init_array_end__init_array_start_DYNAMICdata_startopen@@GLIBC_2.4abort@@GLIBC_2.4__libc_csu_fini_start__libc_start_main@@GLIBC_2.4__aeabi_unwind_cpp_pr0@@GCC_3.5signal@@GLIBC_2.4__gmon_start___Jv_RegisterClasses_finiperror@@GLIBC_2.4_IO_stdin_usedwrite@@GLIBC_2.4__data_start__bss_start__fdioctl@@GLIBC_2.4__exidx_end__dso_handle__end____libc_csu_init__bss_end__printf@@GLIBC_2.4atoi@@GLIBC_2.4catch_intclose@@GLIBC_2.4__bss_start_bss_end__sleep@@GLIBC_2.4puts@@GLIBC_2.4_end_edata__exidx_start__aeabi_unwind_cpp_pr1@@GCC_3.5main_init
    , remove .txt only.

    How to run the demo:  

    ./saWatchdog 12 should restart it.

    http://processors.wiki.ti.com/index.php/TI81XX_PSP_WDT_Driver_User_Guide

    BR

    Margarita

  • Hi Margarita,

    i have already tried the suggested application and it works fine but the application i can run from the linux kernel where as i want to test the watchdog timer in the u-boot.

    so please suggest me the procedure in the u-boot level.

    Regards,

    Vimal

  • Vimal,

    Vimal Gupta said:

    i am writing a test code for Watchdog timer Test in u-boot.

    the code is as below.

    int test_watchdog()

    {

                    int ints = disable_interrupts ();  // disabling all the interuupts

                    ulong base = get_ticks();

                    ulong clk = get_tbclk ();

                    while ((get_ticks () - base) / 10 < clk);  // wait for 10 seconds

                    if (ints)
                            enable_interrupts ();
     

                   /*
                     * If we have reached this point, the watchdog timer
                     * does not work
                     */
                    return -1;


    }

    in this code the EVM should get restarted before reaching the end but it is not happening.

    I do not see in your code to enable the Watchdog timer. Please have a look in DM814x TRM, sections:

    26.2.8 Start/Stop Sequence for Watchdog Timers (Using the WDT_WSPR Register)

    26.3.2.3 Subsequence – Enable the Watchdog Timer

    The default u-boot value for the WDT_WSPR register is 0x00005555, which means WD timer is disabled!

    You can refer to the linux kernel WD timer code and reuse it for the u-boot. Please have a look at:

    ti-ezsdk_dm814x-evm_5_05_02_00/board-support/linux-2.6.37-psp04.04.00.01/drivers/watchdog/omap_wdt.c and omap_wdt.h files

    The WDT_WSPR register is defined as OMAP_WATCHDOG_SPR (in omap_wdt.h), and in omap_wdt.c we have:

    static void omap_wdt_enable(struct omap_wdt_dev *wdev)
    {
        void __iomem *base = wdev->base;

        /* Sequence to enable the watchdog */
        __raw_writel(0xBBBB, base + OMAP_WATCHDOG_SPR);
        while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10)
            cpu_relax();

        __raw_writel(0x4444, base + OMAP_WATCHDOG_SPR);
        while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10)
            cpu_relax();
    }

    Regards,
    Pavel

  • Vimal,

    After additional research, I found that the Watchdog timer is configured, enabled and then disabled by the DM814x ROM code (configured for 10s).

    Thus you need only to enable the Watchdog timer (as explained in my previous post) into u-boot, and if not reloaded, the Watchdog timer will reset the DM814x EVM after 10 seconds (I verified this on my DM814x EVM).

    Regards,
    Pavel

  • Hi pavel,

    I have added enabling code but still it is not getting restarted.

    The updated code is as follow.

    #define WDT_BASE                        0x481C7000
    #define WDT_WWPS        (WDT_BASE + 0x034)
    #define WDT_WSPR        (WDT_BASE + 0x048)

    int watchdog_post_test (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
    {

        /** Enabling the WDT ***********/

         __raw_writel(0xAAAA, WDT_WSPR);
            while (__raw_readl(WDT_WWPS) != 0x0);
            __raw_writel(0x5555, WDT_WSPR);
            while (__raw_readl(WDT_WWPS) != 0x0);

        /********************************/

        printf("Watchdog timer Enabled \n");


            int ints = disable_interrupts ();

            printf("VIMAL - ints = %d \n", ints);
            
            ulong base = get_ticks();

            printf("VIMAL - base = %ld \n", base);

                    ulong clk = get_tbclk ();

            printf("VIMAL - clk = %ld \n", clk);

                    while ((get_ticks () - base) / 10 < clk);

       
         if (ints)
                enable_interrupts ();


            printf("VIMAL - WatchDog Failed \n");
            /*
             * If we have reached this point, the watchdog timer
             * does not work
             */
            return -1;
        }
    }

    and the output of this execution is as below:

    Watchdog timer Enabled
    VIMAL - ints = 0
    VIMAL - base = 72210
    VIMAL - clk = 1000
    VIMAL - WatchDog Failed

    what is the problem in this code and what changes i should do so that it will work.

    Regards,

    Vimal

  • Vimal,

    Vimal Gupta said:
     /** Enabling the WDT ***********/

         __raw_writel(0xAAAA, WDT_WSPR);
            while (__raw_readl(WDT_WWPS) != 0x0);
            __raw_writel(0x5555, WDT_WSPR);
            while (__raw_readl(WDT_WWPS) != 0x0);

    You are actually disabling the WDT, not enabling!

    /* Sequence to enable the watchdog */
        __raw_writel(0xBBBB, base + OMAP_WATCHDOG_SPR);
        while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10)

     __raw_writel(0x4444, base + OMAP_WATCHDOG_SPR);
        while ((__raw_readl(base + OMAP_WATCHDOG_WPS)) & 0x10)

    Regards,
    Pavel

  • Thanks pavel,

    now it is working as required.

    Regards,

    Vimal