Lab3 : Mailbox Issue

Lab3 : Mailbox Issue

by Luca Joss -
Number of replies: 7

Hi,

We are having an issue with the mailbox API function : altera_avalon_mailbox_open.

We call it with:

altera_avalon_mailbox_dev* mailbox_sender = altera_avalon_mailbox_open("/dev/mailbox_simple_0", tx_cb, NULL);

But we get a null pointer as a return value.


The callback function being a simple printf :

void tx_cb (void* report, int status) {
    if (!status) {
        printf("Sent message\n");
    } else {
        printf("Error sending message\n");
    }
}

We also have an issue when compiling, the generated file alt_sys_init.c is looking for Mailbox macros which do not exist in our system :

alt_sys_init.c:74:41: error: 'MAILBOX_SIMPLE_0_BASE' undeclared here (not in a function)

But in system.h, the macros generated are :

MAILBOX_SIMPLE_0_AVMM_MSG_SENDER_BASE

and

MAILBOX_SIMPLE_0_AVMM_MSG_RECEIVER_BASE

We are using this mailbox in the Qsys :

Qsys showing mailbox

In reply to Luca Joss

Re: Lab3 : Mailbox Issue

by Alon Tchelet -

I'm not sure about the errors you have with the compilation, but there's definitely an issue with your avalon busses. Only one master should be connected to each bus (one cpuis the sender and the other is the receiver). If you want to make the mailbox system two sided you need to have two mailboxes and connect the sender and receiver the other way around in the second set. Like it shows in figure 43 in page 160 of the Embedded Peripherals IP User Guide.

When thinking about it again after writing my response I realised that your error might actually come from that issue as both macros were created and they might create some collision or overwritings in the driver's files.

In reply to Luca Joss

Re: Lab3 : Mailbox Issue

by Sylvain Jean-Roger Migaud -

It's really weird because it was working for me (well it was compiling without error, and it was somewhat working even I wasn't reading back the messages i put) but after restarting the whole VM, recompiling and rebuilding the BSPs, I now have the same error as you.

What's even weirder is that I am not even using those macro, at least not knowingly since I hardcoded the adresses.

Maybe this issue is somehow caused by some wrong options in the BSPs...

In reply to Sylvain Jean-Roger Migaud

Re: Lab3 : Mailbox Issue

by Sahand Kashani-Akhavan -

Sylvain,

If you had a working version of the code where the mailbox API was working, I'd suggest you send a copy of your project to the others. They can then use the "meld" program to diff the project directories and see if there is anything related to the mailbox that pops up when inspecting the files (this has to be done manually).

In reply to Luca Joss

Re: Lab3 : Mailbox Issue

by Jon Märki -

Changing the wiring solved the issue. The program now compiles correctly and the names in the system.h changed to MAILBOX_SIMPLE_0_BASE for the base so the compiler is happy again.

In reply to Jon Märki

Re: Lab3 : Mailbox Issue

by Sylvain Jean-Roger Migaud -

Yes, I think you're right, I'm not certain but I think that wiring both the sender and receiver interface to both avalon buses is causing the error