Simple block detector - zero loss

Post Reply
Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Re: Simple block detector - zero loss

Post by Richard-TX » 21.03.2014, 07:35

That is just pure magic. That is all that is.

It will take me at least 30 minutes just to figure out how that works.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Re: Simple block detector - zero loss

Post by Richard-TX » 21.03.2014, 08:04

Rob,

I have almost everything done to rocnetnode so that it runs on the Beaglebone Black. There is one nagging thing that occurs when I change I2C buses. As soon as I click SET after selecting the other bus, rocnetnode prints 3 mmap errors.

Here is an example.

mmap error -1229950976
mmap error -1229942784
mmap error -1229934592

The errors show in the trace file as:
20140321.015343.607 r9999E rnreader raspi 0118 mmap error -1229950976

I would normally fix this by casting an unsigned int but I am not experienced enough to figure out where.

I added a printf to io.c just before the mmap call.

the bit of code is:

Code: Select all

/* Make sure pointer is on 4K boundary */
  if ((unsigned long)mem % PAGE_SIZE)
    mem += PAGE_SIZE - ((unsigned long)mem % PAGE_SIZE);
printf ("mem = %x\n",mem);
  /* Now map it */
  map = (char *)mmap(
    (void*)mem,
    BLOCK_SIZE,
    PROT_READ|PROT_WRITE,
    MAP_SHARED|MAP_FIXED,
    mem_fd,
    base
  );
here is the result

mem = 0xb6d01000
mmap error -1227878400
mem = 0xb6d03000
mmap error -1227870208
mem = 0xb6d05000
mmap error -1227862016

What do you think?

rjversluis
Site Admin
Posts: 42378
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Simple block detector - zero loss

Post by rjversluis » 21.03.2014, 08:08

Richard-TX wrote:What do you think?
Its not developed for the BBB.
You have to google for that issue.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Re: Simple block detector - zero loss

Post by Richard-TX » 21.03.2014, 08:09

PAGE_SIZE = 0x1000

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Re: Simple block detector - zero loss

Post by Richard-TX » 21.03.2014, 08:11

OK Rob, Based on what you said, I deduce that there is nothing special about that call and that it should work. I will plug along and see what I can do. Oddly enough, it does not seem to affect operation.

rjversluis
Site Admin
Posts: 42378
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Simple block detector - zero loss

Post by rjversluis » 21.03.2014, 08:12

I think the code is wrong in Rocnetnode:

Code: Select all

RETURN VALUE         top

       On success, mmap() returns a pointer to the mapped area.  On error,
       the value MAP_FAILED (that is, (void *) -1) is returned, and errno is
       set appropriately.  On success, munmap() returns 0, on failure -1,
       and errno is set (probably to EINVAL).

rjversluis
Site Admin
Posts: 42378
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Simple block detector - zero loss

Post by rjversluis » 21.03.2014, 08:13

Try to change it to:

Code: Select all

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

Code: Select all

  if ((long)map == -1) {
    TraceOp.trc( "raspi", TRCLEVEL_EXCEPTION, __LINE__, 9999, "mmap error %d", errno );
    return NULL;
  }

rjversluis
Site Admin
Posts: 42378
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Simple block detector - zero loss

Post by rjversluis » 21.03.2014, 08:17

If it is OK on both RasPi and BBB I will commit that change.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Re: Simple block detector - zero loss

Post by Richard-TX » 21.03.2014, 08:20

I found it!

All fixed.

Thanks Rob.

rjversluis
Site Admin
Posts: 42378
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: Simple block detector - zero loss

Post by rjversluis » 21.03.2014, 10:57

What did you change?

Post Reply

Return to “DIY Hardware”