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.

AM3358 mmap bus error

Other Parts Discussed in Thread: SYSCONFIG

Hello all,

I've been working on the BeagleBone, running Angstrom v2011.11-core Linux. I'm writing a Python library (using Python 2.7.2) for peripheral support using the pins broken out on the expansion headers. I'm doing this using the mmap module on /dev/mem, and referring to the AM335x Reference Manual for register addresses. I had no trouble at all with the GPIO registers, and I'm trying to get the ADC working now. The problem I'm having is that I'm getting a bus error when I try to read or write any of the ADC registers.

Here's the output of dmesg after trying to read the ADC CTRL register (absolute address of 0x44e0d040):

[128816.761898] Unhandled fault: external abort on non-linefetch (0x1018) at 0x40785040

I've triple checked my addresses and I'm sure they're correct. Any suggestions would be greatly appreciated.

Thanks in advance,

-Alex

  • Have you taken the ADC out of reset and enabled its clock before attempting to access it?

    You would need to check the PRCM (Power and Clock Management) module to enable the ADC first.

  • Thanks a bunch Brandon, that seemed to do the trick! For some reason I was thinking the enable bit in the TSC_ADC_SS CTRL register was all that was needed to start the ADC.

    -Alex

  • Hi

    I'm trying to do a similar thing: an user-space application which uses mmap to read and write ADC registers.

    It works fine when I read REVISION, SYSCONFIG and IRQ registers, but when I try to to read CTRL or STEPCONFIGx registers I get values which seems random and change every time I read. Is there any restriction on how to access to some of these registers?

    Regards, Max

      volatile unsigned long *p;
      size_t length = 0x1000;    // 4KB page
      int prot = PROT_READ | PROT_WRITE;
      int flags = MAP_SHARED;
      int fd = open("/dev/mem", O_RDWR | O_SYNC);
      unsigned int addr;
      off_t offset;
      int index;

      addr = 0x44e0d000 | 0x40; // CTRL register

      offset = (off_t)(addr & 0xfffff000);
      index = addr & 0xfff;

      if (fd < 0) {
        perror("open");
        return 1;
      }

      p = (unsigned long *)mmap(NULL, length, prot, flags, fd, offset);
      if (p == MAP_FAILED) {
        perror("mmap");
        return 4;
      }

      printf("Read[0x%03x] 0x%08x at address 0x%08x\n", index, p[index], (int)(offset+index));




  • Hi Brandon,

              Could you elaborate a little please? Where is PRCM module located? I can't seem to find it in the source.

    Thanks

  • Hi Brandon,

      I am having the same problem with  a SPI driver I am implementing. I have written the CM_PER_SPI1_CLKCTRL register but I am not sure if there are any other registers I need to update. I can write the MCSPI_CH0CONF and MCSPI_MODULCTRL registers but anytime I touch the MCSPI_SYSSTATUS or MCSPI_SYSCONFIG register I get a non-linefetch fault. 

    Thank You,

    Paul

  • I get bus error when trying to access GPIO2 via dev/mem. GPIO0 and GPIO1 is fine but not GPIO2 -any ideas?