IMXRT1050 Flashloader through a USB isolator

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

IMXRT1050 Flashloader through a USB isolator

Jump to solution
2,553 Views
jackking
Senior Contributor I

I am developing a custom board based on the IMXRT1052.  Included on the board is an ADuM4160 USB isolator for galvanic isolation.  This isolator part has a maximum operating speed of 12 Mbps (USB 2 full-speed). 

When trying to connect to the flashloader (after loading via MCUBoot) through the isolator, as the host tries to negotiate down to USB full speed, it doesn't seem that flasloader handles the chirps and remains in USB hi-speed mode, causing a failure to enumerate...  is there some way to force MCUBoot/Flashloader to use USB full speed?

This is easily tested by putting an external USB isolator that uses the same ADuM chip between the IMXRT EVK and the USB host.  Something like this: USB isolator

Labels (1)
1 Solution
2,113 Views
jackking
Senior Contributor I

I think I figured out all of the changes to make the flashloader work with USB full-speed.

I've only done brief testing to make sure it works basically, but I will post the changes here in case someone else runs into this.

There are 5 places that need to be modified in the flashloader code:

  • In MIMXRT1052/bootloader_config.h
    • ~line 38: change the define for HID to use USB full speed instead of high speed:
    • // USB FS port
      
      #if defined(BL_CONFIG_HS_USB_HID)
      #undef BL_CONFIG_HS_USB_HID
      #endif
      
      #if !defined(BL_CONFIG_USB_HID)
      #define BL_CONFIG_USB_HID (1)
      #endif‍‍‍‍‍‍‍‍‍
    • ~ line 136: change the HID packet size (I chose 60 so it would end up as 64 in the enumeration):
    • // Make sure that BL_EXPANDED_USB_HID_PACKET_SIZE < 1018
      
      #if BL_CONFIG_HS_USB_HID
      #define BL_EXPANDED_USB_HID_PACKET_SIZE (1016)‍‍
      #else
      #define BL_EXPANDED_USB_HID_PACKET_SIZE (60)‍‍
      #endif
      ‍‍‍‍‍‍‍
  • In MIMXRT1052/peripherals_MIMXRT1052.c
    • Modify so that it also can use BL_CONFIG_USB_HID instead of BL_CONFIG_HS_USB_HID:
    • ////////////////////////////////////////////////////////////////////////////////
      // Variables
      ////////////////////////////////////////////////////////////////////////////////
      
      #if !BL_CONFIG_LPUART && !BL_CONFIG_HS_USB_HID && !BL_CONFIG_USB_HID
      #error At least one peripheral must be enabled!
      #endif
      
      //! @brief Peripheral array for MIMXRT1051.
      const peripheral_descriptor_t g_peripherals[] = {
      #if BL_CONFIG_LPUART_1
          // LPUART1
          {.typeMask = kPeripheralType_UART,
           .instance = 1,
           .pinmuxConfig = uart_pinmux_config,
           .controlInterface = &g_lpuartControlInterface,
           .byteInterface = &g_lpuartByteInterface,
           .packetInterface = &g_framingPacketInterface },
      #endif // BL_CONFIG_LPUART_1
      
      #if (BL_CONFIG_HS_USB_HID || BL_CONFIG_USB_HID)
          // USB HID
          {.typeMask = kPeripheralType_USB_HID,
           .instance = 1,
           .pinmuxConfig = NULL,
           .controlInterface = &g_usbHidControlInterface,
           .byteInterface = NULL,
           .packetInterface = &g_usbHidPacketInterface },
      #endif    // BL_CONFIG_USB_HID
          { 0 } // Terminator
      };‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
  • In source/usb/bm_composite/usb_device_config.h
    • ~line 42: Modify the HID instance count calculation to support BL_CONFIG_USB_HID:
    • /*! @brief HID instance count */
      #if BL_CONFIG_HS_USB_HID
      #define USB_DEVICE_CONFIG_HID (BL_CONFIG_HS_USB_HID)
      #else
      #define USB_DEVICE_CONFIG_HID (BL_CONFIG_USB_HID)
      #endif‍‍‍‍‍‍
  • In source/MIMXRT1052/bootloader_config.h
    • ~line 76: I had to disable BL_FEATURE_FLASH_CHECK_CUMULATIVE_WRITE  or I get an error sometimes when actually writing to flash memory using the flashloader.
    • #define BL_FEATURE_FLASH_CHECK_CUMULATIVE_WRITE (0)

To build the flashloader project and use it, see my other post: How to generate ivt_flashloader.bin for IMXRT?

This seems to allow the FS enumeration work successfully and I was able to use the flashloader to load an image into XIP flash using NXP-MCUBootUtility.

View solution in original post

12 Replies
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack king,

   Do you also try the MFG tool on your side, whether that tool can works ok your side or not?


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,113 Views
jackking
Senior Contributor I

The device fails to even enumerate on the PC, this is before any PC software can communicate with the board. So MFGtool is not possible to test.

 I am using a Beagle 480 protocol analyzer to debug the USB traffic between the EVK/isolator and the PC.

Booting one of the sdk USB samples through the isolator, I can see the device enumerates correctly, so it seems to specifically be the USB stack of MCUBoot.

0 Kudos
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack,

   I don't know whether this point also relate to your question:

NOTE
In some corner case, HID-compliant device is not recognized which is because the PC only have USB root device and no USB hub device, and this software limitation will be fixed in near future, the workaround at this moment is to use external USB hub as extension.

So, I think you can try to add a USB hub before your isolator, then you can use the MFGtool test it again.

Any updated information from your side, please kindly let me know.


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,113 Views
jackking
Senior Contributor I

Here are some USB trace captures from the EVK both with and without the USB isolator in place. 

I should correct my previous post, it is the FlashLoader that is failing, not MCUBoot.  This is after booting to MCUBoot uploading the FlashLoader and re-enumerating to allow programming.

valid without isolator

_windows_good_after_mcuboot_-_Total_Phase_Data_Center_v6_73_007.png

full-speed failure with isolator:

_windows_good_after_mcuboot_-_Total_Phase_Data_Center_v6_73_007.png

0 Kudos
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack King,

   Thanks a lot for your contribution and the test result sharing.

   I already help you check your question with our flash loader designer.

  Actually, our RM also give the reason, please check this content:

pastedImage_1.png

     And after the designer's confirmation, yes, the flashloader USB really use the high-speed.

    Full speed is not practical, 12Mbps speed is very slow, so the usb flashloader is designed with the high speed.

    If you are using the full speed, you even can use the UART download method to instead of the usb full speed, then you just need to add the UART isolator.

   If you still want to use the usb to download the code, we recommend you find the usb isolator can support the high speed.

Wish it helps you!

If you still have question about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

2,113 Views
jackking
Senior Contributor I

Kerry,

Thanks for the reply. 

The design is for a consumer audio device (which is why the USB isolation is required). 

Using LPUART for a consumer to update firmware is not practical.

Hi-speed USB isolation would require a very expensive custom design, just for the flashloader...

Most standard isolator parts only support low/full speed.

Looking at the source code for the Flashloader I see:

bootloader_config_h_—___mcuxpresso_01_SDKPackages_SDK_2_5_0_EVKB-IMXRT1050_middleware_mcu-boot_targets_MIMXRT1052_src.png

Is this a physical limitation of the hardware when using the serial loader, or could the flashloader be recompiled with support for full-speed?

The speed of the loader isn't critical in my application, and loading new firmware wouldn't take more than a few seconds even at USB full-speed.

0 Kudos
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack King,

   Thank you for your updated information, it's really a problem if you can't use the HS isolator and the LPUART.

   I have a question, why LPUART is not practical, if your hardware board already contains the TTL-USB and isloated item, the customer will also accept it.

  BTW, could you tell me where you get the flashloader source code for RT? The ROM bootloader code already fixed in the RT chip, so, now you can't modify the ROM code.


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,113 Views
jackking
Senior Contributor I

Kerry,

There are practically no available USB hi-speed isolators.  The only chip solution I could find is the (unavailable) Silanna ICE08USBx.  We don't have TTL-USB on our device.  All of the pins are in use and there is no physical room for the connector.

With regards to speed, USB full speed is 12Mbps (not 12 Mhz). 19200 bps is 0.0192Mbps, so USB full speed is 625x faster in this case.

The source code for the Flashloader is distributed in the MCUXpresso SDK package with the middleware add-ons.

MCUBoot does not have a problem at USB full-speed, only the Flashloader has a problem at USB full speed.

The Flashloader is uploaded dynamically after booting with MCUBoot, so the flashloader could be recompiled.

0 Kudos
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack,

    It's totally my mistake about the UART description, so sorry about it.

   HID FS highest data transfer rate is 64KB/S, HS is 8MB/S, 12Mhz is not the data transfer rate.

    You said:MCUBoot does not have a problem at USB full-speed

    Do you mean, if you use the ROM bootloader, the USB full speed works OK, just when you use the SDK flashloader code under this folder:

SDK_2.5.0_EVKB-IMXRT1050\boards\evkbimxrt1050\bootloader_examples\flashloader

   have the  USB full speed problems?

   Please confirm it.

   This the flashloader just defines the HS USB HID, but in the description, it also have the FS USB description,

pastedImage_2.png

  So, the code should already have the FS, but need do some configuration.

  Please let me know, whether the ROM FS HID works ok on your side or not?

   If just the flashloader FS USB HID problem, I will help you to check it with the flashloader designer again.

  Thanks a lot for your understanding.


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,113 Views
jackking
Senior Contributor I

Kerry,

Thanks for the reply.

Yes, the ROM bootloader works fine on USB full-speed.  Only the flashloader has a problem at full speed. 

The define for BL_CONFIG_HS_USB_HID in the bootloader example you posted states:

// i.MX RT Series only supoort HS USB

Based on this, I assume there is a very specific reason that the flashloader does not support USB FS.

0 Kudos
2,113 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack King,

   I have checked it with our flashloader colleagues yesterday.

   He told me that it really didn't support the USB HID FS, and it is not tested under the HID FS condition.

   But now, you and I can try to modify the flashloader code, try to make the FS work, I have been told that, we can try to modify the description.h, some HS item modified to FS.

   You can try it at first, because I have a lot of customers in the queue need to do the testing. When I have time on my side, I will also help you to test it.

   So you can modify it and test it on your side now, when you meet any updated question , just let me know.

  Thanks a lot for your understanding.


Have a great day,
Kerry

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
2,114 Views
jackking
Senior Contributor I

I think I figured out all of the changes to make the flashloader work with USB full-speed.

I've only done brief testing to make sure it works basically, but I will post the changes here in case someone else runs into this.

There are 5 places that need to be modified in the flashloader code:

  • In MIMXRT1052/bootloader_config.h
    • ~line 38: change the define for HID to use USB full speed instead of high speed:
    • // USB FS port
      
      #if defined(BL_CONFIG_HS_USB_HID)
      #undef BL_CONFIG_HS_USB_HID
      #endif
      
      #if !defined(BL_CONFIG_USB_HID)
      #define BL_CONFIG_USB_HID (1)
      #endif‍‍‍‍‍‍‍‍‍
    • ~ line 136: change the HID packet size (I chose 60 so it would end up as 64 in the enumeration):
    • // Make sure that BL_EXPANDED_USB_HID_PACKET_SIZE < 1018
      
      #if BL_CONFIG_HS_USB_HID
      #define BL_EXPANDED_USB_HID_PACKET_SIZE (1016)‍‍
      #else
      #define BL_EXPANDED_USB_HID_PACKET_SIZE (60)‍‍
      #endif
      ‍‍‍‍‍‍‍
  • In MIMXRT1052/peripherals_MIMXRT1052.c
    • Modify so that it also can use BL_CONFIG_USB_HID instead of BL_CONFIG_HS_USB_HID:
    • ////////////////////////////////////////////////////////////////////////////////
      // Variables
      ////////////////////////////////////////////////////////////////////////////////
      
      #if !BL_CONFIG_LPUART && !BL_CONFIG_HS_USB_HID && !BL_CONFIG_USB_HID
      #error At least one peripheral must be enabled!
      #endif
      
      //! @brief Peripheral array for MIMXRT1051.
      const peripheral_descriptor_t g_peripherals[] = {
      #if BL_CONFIG_LPUART_1
          // LPUART1
          {.typeMask = kPeripheralType_UART,
           .instance = 1,
           .pinmuxConfig = uart_pinmux_config,
           .controlInterface = &g_lpuartControlInterface,
           .byteInterface = &g_lpuartByteInterface,
           .packetInterface = &g_framingPacketInterface },
      #endif // BL_CONFIG_LPUART_1
      
      #if (BL_CONFIG_HS_USB_HID || BL_CONFIG_USB_HID)
          // USB HID
          {.typeMask = kPeripheralType_USB_HID,
           .instance = 1,
           .pinmuxConfig = NULL,
           .controlInterface = &g_usbHidControlInterface,
           .byteInterface = NULL,
           .packetInterface = &g_usbHidPacketInterface },
      #endif    // BL_CONFIG_USB_HID
          { 0 } // Terminator
      };‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
  • In source/usb/bm_composite/usb_device_config.h
    • ~line 42: Modify the HID instance count calculation to support BL_CONFIG_USB_HID:
    • /*! @brief HID instance count */
      #if BL_CONFIG_HS_USB_HID
      #define USB_DEVICE_CONFIG_HID (BL_CONFIG_HS_USB_HID)
      #else
      #define USB_DEVICE_CONFIG_HID (BL_CONFIG_USB_HID)
      #endif‍‍‍‍‍‍
  • In source/MIMXRT1052/bootloader_config.h
    • ~line 76: I had to disable BL_FEATURE_FLASH_CHECK_CUMULATIVE_WRITE  or I get an error sometimes when actually writing to flash memory using the flashloader.
    • #define BL_FEATURE_FLASH_CHECK_CUMULATIVE_WRITE (0)

To build the flashloader project and use it, see my other post: How to generate ivt_flashloader.bin for IMXRT?

This seems to allow the FS enumeration work successfully and I was able to use the flashloader to load an image into XIP flash using NXP-MCUBootUtility.