Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Mar 2013 03:52 PM by  richh@logicpd.com
Segmentation Fault on Zoom OMAP35x SOM-LV
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages
agnieto@iuma.ulpgc.es
New Member
New Member
Posts:


--
08 Mar 2013 08:11 AM
    Hello all,

    I am using an OMAP3530 SOM-LV in Zoom OMAP35x board and Linux BSP available in LogicPD web for this board.

    I am able of load and run Linux BSP from SD card on this board.

    I program applications and I get the executables with the CodeSourcery. I storage the executables of the applications in the SD card.

    First, I have executed successfully a "hello world" application.
    Second, I have programmed an application that accesses to memory, with this structure:
    *(int*)0x6E000078, but when the application accesses to memory, an error Segmentation Fault appears.
    If I program an application that accesses to other address, for example 0x48004C10, an error Segmentation Fault appears too.

    Also, I have tried to debug using Code Composer Studio and the configuration of device stop because the internal reset of Watch Dog Timer 2 (WDT2) is ongoing.

    I haven't be able to solve this error.

    Thanks
    richh@logicpd.com
    New Member
    New Member
    Posts:52


    --
    29 Mar 2013 03:52 PM
    Alejandro,
    Are you sure those are valid memory locations in User mode? It looks like you are trying to access physical addresses. You cannot do that directly in Linux due to the Memory Management Unit. You have to ask the MMU to map the physical addresses to virtual addresses in your application's memory space. Peekpoke is a command line utility for reading and writing memory addresses. Here is a sample of the sourcecode for peekpoke taken from the DM3730 BSP:

    #include <stdio.h>
    #include <sys/mman.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <string.h>


    char *prog_name;
    void usage(void)
    {
    fprintf(stderr, "%s: usage:\n", prog_name);
    fprintf(stderr, " -d Turn on debug\n");
    fprintf(stderr, " -b Read/Write a byte\n");
    fprintf(stderr, " -h Read/Write a short\n");
    fprintf(stderr, " -l Read/Write a long\n");
    fprintf(stderr, " -c <count> Read <count> values\n");
    fprintf(stderr, " -r <addr> Read at physical address <addr>\n");
    fprintf(stderr, " -w <addr> <val> Write <val> at physical address <addr>\n");
    exit(-1);
    }

    int main(int argc, char *argv[])
    {
    unsigned long address, addr, offset;
    unsigned long val;
    int i, j, nm;
    char *p, cmd;
    int mode;
    int dev_mem;
    int pagesize = getpagesize();
    int val_size = 1;
    int cnt = 1;
    int debug = 0;

    /* Get program name */
    prog_name = strrchr(argv[0], '/');
    if (prog_name)
    prog_name++;
    else
    prog_name = argv[0];

    if (argc < 2)
    usage();

    dev_mem = open("/dev/mem", O_RDWR|O_SYNC);
    mode = 2; /* assume byte */
    for (i=1; i<argc; ++i) {
    if (debug)
    printf("%s:%d argv[%d]='%s' argc %d\n", __FUNCTION__, __LINE__, i, argv[i], argc);
    p = argv[i];
    if (!strcmp(p, "-d")) {
    debug = 1;
    } else if (!strcmp(p, "-c")) {
    if (i+1 >= argc)
    usage();
    i++;
    cnt = strtoul(argv[i], NULL, 0);
    if (debug)
    printf("%d: argv[%d]: '%s' = %x\n", __LINE__, i, argv[i], cnt);

    } else if (!strcmp(p, "-b")) {
    val_size = 1;
    } else if (!strcmp(p, "-h")) {
    val_size = 2;
    } else if (!strcmp(p, "-l")) {
    val_size = 4;
    } else if (!strcmp(p, "-w")) {
    if (i +2 >= argc)
    usage();
    cmd = 'w';
    i++;
    addr = strtoul(argv[i], NULL, 0);
    if (debug)
    printf("%d: argv[%d]: '%s' = %x\n", __LINE__, i, argv[i], addr);
    i++;
    val = strtoul(argv[i], NULL, 0);
    if (debug)
    printf("%d: argv[%d]: '%s' = %x\n", __LINE__, i, argv[i], val);
    } else if (!strcmp(p, "-r")) {
    if (i +1 >= argc)
    usage();
    cmd = 'r';
    i++;
    addr = strtoul(argv[i], NULL, 0);
    if (debug)
    printf("%d: argv[%d]: '%s' = %x\n", __LINE__, i, argv[i], addr);
    } else {
    usage();
    }

    if (cmd != 'r' && cmd != 'w')
    continue;

    if (cmd == 'w')
    cnt = 1;
    for (j=0; j<cnt; ++j) {

    offset = addr & (pagesize-1);
    address = (unsigned long) mmap(0, pagesize,
    PROT_READ|PROT_WRITE,
    MAP_SHARED, dev_mem,
    addr & ~(pagesize - 1));

    mode = val_size * 2;
    if (debug)
    printf("%d: cmd %c mode %d val_size %d\n", __LINE__, cmd, mode, val_size);
    if (cmd == 'r') {
    switch(mode) {
    case 2:
    val = *(unsigned char *)(address + offset);
    nm = 'b';
    break;
    case 4:
    val = *(unsigned short *)(address + offset);
    nm = 'h';
    break;
    case 8:
    val = *(unsigned long *)(address + offset);
    nm = 'l';
    break;
    }
    printf("%08x /%c -> %0*x\n", addr, nm, mode, val);
    } else {
    switch(mode) {
    case 2:
    *(unsigned char *)(address + offset) = val;
    nm = 'b';
    break;
    case 4:
    *(unsigned short *)(address + offset) = val;
    nm = 'h';
    break;
    case 8:
    *(unsigned long *)(address + offset) = val;
    nm = 'l';
    break;
    }
    printf("%08x /%c = %0*x\n", addr, nm, mode, val);
    }
    munmap((void *)address, pagesize);
    addr += val_size;
    }
    cmd = 0;
    }
    return 0;
    }
    You are not authorized to post a reply.