9 years, 8 months ago.

EthernetInterface + USBMIDI together, RAM errors?

Hi,

I'm trying to use the USBMIDI and EthernetInterface together. They work fine when using one at a time, but when I want to use them both together the mbed doesn't even respond.

I'm thinking of some memory problem. Now when I'm using this code snippit to show how much ram is allocated ( http://mbed.org/forum/mbed/topic/3179/?page=1#comment-16243 ) I get:

Only USBMIDI library: Main RAM: 4852 RAM0: 0 RAM1:0

When using only the EthernetInterface library: Main RAM: 8332 RAM0: 16384 RAM1: 11348

I don't see any problems, because the usbmidi library doesn't use any of the special RAM0 or RAM1. How can I fix this problem?

Thanks!

It might help if you share your code snippet.

posted by Martin Kojtal 20 Aug 2014

main.cpp for only usbmidi

#include "mbed.h"
#include "USBMIDI.h"

USBMIDI midi;
Serial debug(USBTX,USBRX);

static void DisplayRAMBanks(void);

void sendmessage(MIDIMessage test){
}

int main(){
    DisplayRAMBanks();
    midi.attach(sendmessage);
    
    DisplayRAMBanks();
    while(1) {
        wait(1);
        DisplayRAMBanks();
    }
    
    
}

// These external symbols are maintained by the linker to indicate the
// location of various regions in the device's memory.  They will be used by
// DisplayRAMBanks() to dump the size of each RAM bank to stdout.
extern unsigned int Image$$RW_IRAM1$$Base;
extern unsigned int Image$$RW_IRAM1$$ZI$$Limit;
extern unsigned int Image$$RW_IRAM2$$Base;
extern unsigned int Image$$RW_IRAM2$$ZI$$Limit;
extern unsigned int Image$$RW_IRAM3$$Base;
extern unsigned int Image$$RW_IRAM3$$ZI$$Limit;
 
 
// Displays the size of static allocations for each RAM bank as indicated by
// ARM linker to stdout.
static void DisplayRAMBanks(void)
{
    debug.printf("Static RAM bank allocations\r\n");
    debug.printf("  Main RAM = %u\r\n", (unsigned int)&Image$$RW_IRAM1$$ZI$$Limit - 
                                  (unsigned int)&Image$$RW_IRAM1$$Base);
    debug.printf("  RAM0     = %u\r\n", (unsigned int)&Image$$RW_IRAM2$$ZI$$Limit -
                                  (unsigned int)&Image$$RW_IRAM2$$Base);
    debug.printf("  RAM1     = %u\r\n", (unsigned int)&Image$$RW_IRAM3$$ZI$$Limit -
                                  (unsigned int)&Image$$RW_IRAM3$$Base);
}

This is the code I use for the MIDI (and showing the RAM). From the moment I include EthernetInterface and use it the code doesn't work and the mbed doesn't respond (when i just eth.init() and eth.connect() )

main.cpp with usbmidi and ethernetinterface that doesn't work

#include "mbed.h"
#include "USBMIDI.h"
#include "EthernetInterface.h"

//traktorOSC osc;
USBMIDI midi;
Serial debug(USBTX,USBRX);

void sendmessage(MIDIMessage test){
    debug.printf("midi \n");
}

int main(){
    //MIDI
    midi.attach(sendmessage);
    
    
    EthernetInterface eth;
    eth.init();
    eth.connect();
    debug.printf("IP Address: %s\r\n", EthernetInterface::getIPAddress());
    
    while(1) {
        wait(0.01);
    }
    
}
posted by Jannes De Brabandere 21 Aug 2014

nobody? Is this a known bug in rtos/usbdevice or not?

posted by Jannes De Brabandere 26 Aug 2014
Be the first to answer this question.