K64F sysmpu conflicts with usb driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K64F sysmpu conflicts with usb driver

1,542 Views
jiameng
Contributor II

Hello,

I was developing a USB application on a frdm-k64f development board, based on the SDK demo host_msd_command_bm. Besides the USB driver in my application, I also need to protect some memory regions using sysmpu. I found a code that explicitly disable sysmpu in host_msd_command_bm:

 

static void USB_HostApplicationInit(void)
{
    ...
#if ((defined FSL_FEATURE_SOC_SYSMPU_COUNT) && (FSL_FEATURE_SOC_SYSMPU_COUNT))
    SYSMPU_Enable(SYSMPU, 0);
#endif /* FSL_FEATURE_SOC_SYSMPU_COUNT */
    ...
    usb_echo("host init done\r\n");
}

 

But it doesn't work if I comment SYSMPU_Enable(SYSMPU, 0) out and replace with my sysmpu initialization code. The symptom was that USB device failed to be enumerated. It seems that usb driver conflicts with sysmpu. Can anyone advise this?

Thanks.   

0 Kudos
3 Replies

1,516 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @jiameng,

Without replacing it with your SYSMPU initialization code, if you only comment the SYSMPU_Enable(SYSMPU, 0) out, the symptom still persists?

If not, just for double check, could you please check out your SYSMPU initialization code?

It might be useful to try out the SYSMPU example and combine it with the USB MSD Host Command BM example.

Best regards, Raul.

0 Kudos

1,514 Views
jiameng
Contributor II

Hi @RaRo 

Yes, even if I simply comment SYSMPU_Enable(SYSMPU, 0) out, the problem still persists. Additionally, besides USB demos, I noticed that ethernet demos including lwip have also explicitly disabled sysmpu. I guess both USB and ethernet are conflict with sysmpu.

Thanks. 

0 Kudos

1,483 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @jiameng,

Could you please tell us which memory regions are you trying to protect?

If you are at peripheral address region (0x4000_0000-0x400F_FFFF), that could explain the incompatibility between MPU and USB, as USB work address is at 0x4003_5000 (USB DCD) and 0x4007_2000 (USB OTG FS/LS). These addresses should be accessible for USB to work. It might be good making these addresses accessible for both (MPU and USB) modules to work as expected.

Related with the Ethernet module, this one has an address 0x400C_0000, so it is in the peripheral address region too.

SYSMPU_Enable(SYSMPU, 0) is necessary because setting 0 (false) the VLD (Valid) bit in CESR allows all accesses from all bus masters allowed; eliminating or ignoring this won't let USB to work, as VLD is set to 1 when the MCU resets, and MPU don't let USB access.

RaulRomero_2-1676651476865.png

[K64 Reference Manual. Chapter 19. Memory Protection Unit]

Please look at K64 Sub-Family Reference Manual. Chapter 4. Memory Map. and Chapter 19. Memory Protection Unit (MPU) for more information.

Best regards, Raul.

0 Kudos