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.

TDA4VL-Q1: BUS ERROR

Part Number: TDA4VL-Q1
Other Parts Discussed in Thread: TDA4VL

For the address of mmap mapping in A72 core, bus error will appear when using memset。

How to deal with it?

  • Hi,

    I suspect the mmap call may still be failing, even though it is not returning MAP_FAILED. In this case, you should check the value of errno after the mmap call to see if there is an error code set.

    Could you please check the value of errno after a call to mmap()?

    Regards,
    Nikhil

  • Hi ,

      I tested on TDA4VL EVM, the test code is as below,

    /cfs-file/__key/communityserver-discussions-components-files/791/1273.main.c

      Actually, we do not encounter bus error.  Below is my test log,

    root@j721s2-evm:/opt/test# gcc main.c

    root@j721s2-evm:/opt/test# ./a.out 0xa7600000

    /dev/mem opened.

    Memory Mapped at address 0xffff8c272000 , MAP_SIZE 1048576 , size 400

    0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777

    DONE

     Please check what happened on your side. 

    Linjun

  • HI,

      I add O3 to compile test code, still can't reproduce the issue.  Which version are you using?  I tested base of SDK 8.5 version.  The test log is as below,

    root@j721s2-evm:/opt/test# gcc -O3 main.c

    root@j721s2-evm:/opt/test# ls

    a.out main.c

    root@j721s2-evm:/opt/test# ./a.out 0xa7600000

    /dev/mem opened.

    Memory Mapped at address 0xffffaecdd000 , MAP_SIZE 1048576 , size 400

    0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777 0x77777777

    DONE

    Thanks.

    Linjun

  • memset(map_base, 0x0, 400); 

    You can modify it to try。

    This problem occurs when the number 0 is used。

     The test log is as below,


    root@j721s2-evm:/opt/vision_apps/DVR/linux# vi main.c
    root@j721s2-evm:/opt/vision_apps/DVR/linux# gcc main.c
    root@j721s2-evm:/opt/vision_apps/DVR/linux# ./a.out 0xa7600000
    /dev/mem opened.
    Memory Mapped at address 0xffff9015e000 , MAP_SIZE 1048576 , size 400
    0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555 0x55555555
    DONE
    root@j721s2-evm:/opt/vision_apps/DVR/linux# vi main.c

    root@j721s2-evm:/opt/vision_apps/DVR/linux#
    root@j721s2-evm:/opt/vision_apps/DVR/linux# gcc main.c
    root@j721s2-evm:/opt/vision_apps/DVR/linux# ./a.out 0xa7600000
    /dev/mem opened.
    Memory Mapped at address 0xffffbea21000 , MAP_SIZE 1048576 , size 400
    Bus error (core dumped)

  • 7725.main.c
    #include <stdio.h>
    #include <sys/mman.h>
    #include <stdlib.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <string.h>
    
    #define MAP_SIZE (1024*1024)
    
    int main(int argc, char **argv) 
    {
        int fd;
    
        void *map_base, *virt_addr ;
        unsigned long read_result, write_val;
        off_t target;
        int size = 400;
        char fmt_str [128] ;
        char test [20] ;
        size_t data_size;
    
        if(argc < 2) {
            exit(1);
        }
        target = strtoul(argv[1],0, 0);    
        
        if(argc > 2)
            size = strtoul(argv[2] , 0, 0);
    
        if(( fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1){
            printf( "/dev/mem open failed\n");
            return -1;
        }
        printf("/dev/mem opened. \n");
        fflush(stdout) ;
        
        /* Map one page*/
        map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE , MAP_SHARED, fd, target);
        if(map_base == (void*)-1)
        {
            printf( "mmap failed\n");
            return -1;
        }
        printf("Memory Mapped at address %p , MAP_SIZE %d , size %d\n" , map_base,MAP_SIZE ,size);
        fflush(stdout);
    
        memset(map_base, 0x0, 400); //bus error
    
        for (int i=0;i<100;i++)
        {
            printf("0x%x ", *((int*)map_base + i));
        }
        
    
        if(munmap(map_base, MAP_SIZE) == -1) 
            return -1;
    
        close(fd);
    
        printf("\nDONE\n");
    
        return 0;
    }
    

  • Hi Yongjie,

         When use memset to operate the node "/dev/mem", bus error may happen as to encounter "BUS_ADRALN" error.

        To avoid this error, we can use code such as “ *((unsigned long*) virt_addr) = value” instead of it.  

    Linjun

      

  • Hi Linjun

    Is there a way to fundamentally solve it.

    Thank you for your time and I look forward to your reply.

  •  "BUS_ADRALN" encountered sometimes as to memset misuse when operate physical address, there are some SOC alignment restrictions. What's your purpose of operating the node "/dev/mem"?

  • we have a meeting with customer for the requirement,  customer's purpose is for IPC communication between cores.  So we introduced rpmsg mechanism .And paste the example of rpmsg-char-simple here, git.ti.com/.../README