1

I'm trying to write a message to a hardware mailbox using a memory mapped dev/mem/ but everything I send, gets sent twice. So in the code below, after sending a single 1 to MBOX, the mailbox depth indicates a depth of two. When I read from the mailbox it has 2 ones. Any idea why this is happening?

with open("/dev/mem", "r+b") as mem_fd:
    addr_p = mmap.mmap(mem_fd.fileno(), mem_size[UPROC_PIF_AREA], offset = mem_offsets[PROC_PIF_AREA])

#Sending the message header to register mbox_xt first
print "Sending message header"

packed_mbox_status = addr_p[MBOX_STATUS:MBOX_STATUS + 4]
mbox_to_microp_depth = struct.unpack("BBBB", packed_mbox_status)
print "mbox_to_microp_depth : " + str(mbox_to_microp_depth)


addr_p[MBOX_XT:MBOX_XT+4] = struct.pack("<L", 1)


packed_mbox_status = addr_p[MBOX_STATUS:MBOX_STATUS + 4]
mbox_to_microp_depth = struct.unpack("BBBB", packed_mbox_status)
print "mbox_to_microp_depth : " + str(mbox_to_microp_depth)
Braiam
  • 1
  • 11
  • 47
  • 78
joseph38
  • 11
  • 1
  • No idea why it's happening but duplicate question [here](https://stackoverflow.com/questions/53492716/python-writing-to-memory-in-a-single-operation) that has a good `memoryview` workaround. – Colm Ryan Mar 11 '20 at 04:39

0 Answers0