高速USB的不二选择,NXP LPC Xpresso4337 Development Board 体验

0 序

最近在做高速USB(480Mbps)项目,用STM32需要外接一个PHY,比如USB3300芯片,额外增加了硬件成本,于是找了一下自带高速USB PHY的芯片,别说,还真有!而且性能非常劲爆

NXP LPC4300系列芯片

芯片主要的特性:

  1. 204MHz M0/M4双核芯片
  2. 1M Flash
  3. 2个CAN接口
  4. 2个高速USB2.0接口,自带PHY
  5. 自定义IO接口,速度高达100MHz
  6. 自带LCD控制器,支持1024 H x 768 V

额外的特性,请访问LPC43xx主页
反正NXP LPC系列MCU各种牛X,秒杀STM32F4系列,,,

1 LPC Xpresso4337 开发板

LPC针对4300系列,提供2款评估板

  1. OM13027: LPC4330-Xplorer Board

Pic

Features

  1. Controller: LPC4330, 100 pin BGA
  2. PCB: 4-layer (86 mm x 40 mm, RoHS Compliant)
  3. Two LEDs
  4. One user switch and one reset switch
  5. Boot select switch
  6. 32 Mb Quad SPI flash
  7. On board crystals for controller, RTC and audio codec
  8. On board Ethernet PHY, 50 MHz Oscillator and RJ45 connector with magnetics
  9. On board audio codec and audio jacks
  10. On board USB host power switch
  11. On board Micro SD card slot
  12. Two USB ports, one HS (High speed) port and one FS (Full Speed) port
  13. 10-pin cortex debug header
  14. Unused I/Os brought to a header


另一款是

  1. OM13070: LPCXpresso4337 Development Board
    Pic

Features

  1. LPC4337 dual-core (M4F and M0+) MCU running at up to 208 MHz
  2. On-board high-speed USB based debug probe with CMSIS-DAP and LPCXpresso IDE Redlink protocol options, can debug the on-board LPC4337 or external target
  3. Support for external debug probes
  4. Tri-color LED
  5. Target Reset, ISP and WAKE buttons
  6. Expansion options based on Arduino UNO R3 and Pmod™, plus additional expansion port pins
  7. On-board Ethernet PHY (output available at expansion connectors)
  8. High speed USB A/B connector for host or slave operation
  9. 8 Mb Macronix quad SPI flash
  10. UART, I²C and SPI port bridging from LPC4337 target to USB via the on-board debug probe
  11. FTDI UART connector


从高速USB的角度来看,二者都符合自带两个高速USB AB接口,OTG接口,均能符合我的要求,但OM13070: LPCXpresso4337 Development Board板载调试器,支持CMSIS-DAP调试协议,可以不用额外购买NXP Link-II调试器

所以决定购买LPC Xpresso4337的板子来测试高速USB性能

在购买的过程中,选定了element,digikey,mouser这几个大的代理商,其中以mouser购买流程最为方便,购买流程清晰,简单,也支持支付宝付款;相比之下,其他两家在注册时,需要填写一大堆信息,绑定信用卡操作等等,偶尔还会网站无响应,,,

现在mouser上购买4337的板子,很便宜,25美金左右,值得入手,手慢无!!!

购买链接OM13070

2 快速上手

购买后,mouser发国际快递,从国外原厂寄到深圳,大概花了一个星期的时间,效率还是很高的

拿到板子后,到NXP官网找资料,上手,下载固件,测试USB高速性能,大概花了30分钟左右

先说结论吧

简单的USB高速Bulk写,512长度,PC每次读64K,进行640M读数据的压力测试,最后结果是40MB/S

下面详细的介绍过程

2.1 开发板原理图

抱歉,在官网找了几个小时,愣是没找到原理图,然后在lib的资料里面,显示原理图TBD状态(To Be Done),最后Google了很久,还是没有找到,,,

有兴趣的朋友可以定期刷刷LPCXpresso4337 Development Board主页,没准哪天就出来了

NXP的4337板子的配套资料太少!!!
习惯了ST,TI的丰富文档,对NXP MCU的资料,简直崩溃,,,

2.2 芯片手册

先下载数据手册,看一下具体芯片的参数,外设配置和电流消耗等数据

板载的芯片为
LPC4337JET100: 32-bit ARM Cortex-M4/M0 MCU; up to 1 MB flash and 136 kB SRAM; Ethernet, two High-speed USB, LCD, EMC

看完数据手册后,下载User Manual来仔细看看整体架构,USB寄存器部分

更多的AN和 Errata资料,可以到这里下载

2.3 芯片代码库

NXP专门提供了一个文档网站,可以找到LPC Xpresso4337板子的代码库资料

库分为两种,分别适配不同的编译器

  1. LPCXpresso v7.6.2_326
  2. IAR EWARM 7.30.3/Keil MDK-ARM v5.12

LPCXpresso为NXP推出的基于Eclipse的IDE,有丰富的插件,看起来比较牛,有兴趣的童鞋可以下载研究

我mac已经有IAR和Keil,所有就直接下载IAR工程包了,点击下载

2.4 修改固件代码

下载代码包后,解压到任一目录,然后打开NXP\lpcopen_2_16_keil_iar_nxp_lpcxpresso_4337\applications\lpc18xx_43xx\examples\usbd_rom\目录下的IAR工程空间

首先编译chip和board两个工程,分别生成对应的*.a库文件
然后打开bwtest工程,rebuild
看看readme.txt,如下所示

USB Band Width test and WCID examples for USB ROM API.

Example description
The example shows how to us USBD ROM stack to creates a WCID based bandwidth test port.
The examples shows how to handle Microsoft’s specific component identifier (WCID) requests
for install less WinUSB operation. Check https://github.com/pbatard/libwdi/wiki/WCID-Devices
for more details.
No driver install is required on Windows 8 and Windows 7 systems which can update
automatically connecting “Windows update server”. For WinXP and Windows 7 machine which
can’t update automatically use latest version of Zadig tool available at
http://sourceforge.net/projects/libwdi/files/zadig/ to install drivers. When Zadig
is used restart of the machine is required for the test tool to recognize the device.

Special connection requirements
Connect the USB cable between micro connector on board and to a Windows host.
Run LPCUsbTest.exe on the host. The executable uses .net 3.5 framework.
Once the application is running click “Find LPC Device” button. Check if the
list box shows whether the app detected the device. Then select “Rx” or “Tx” radio
buttons before clicking “Start Test” button. Rx and Tx numbers are based on host receiving
and transmitting data. Since this example is just interested in through-put test it use
same memory area for Rx and Tx.

Build procedures:
Visit the LPCOpen quickstart guides
to get started building LPCOpen projects.

然后很不幸,没有找到文档中的LPCUsbTest.exe工具,google之后,发现很多老外朋友,也在找NXP要这个工具,仍然没找到,,,

Where is LPCUsbTest.exe tools???

最后,用VS建了一个工程,libusb测试读写性能,刚开始已经提到了,未优化的前提下,达到37MB/S!已经很牛
后门再优化一下,用DMA很可能能达到USB 批量传输的理论55MB/S

3 最后

玩了两天,最大的感受是:NXP MCU性能No1,配套资料有很大提升空间,希望NXP加大资料手册文档的投入力度

但是NXP的USB库使用起来相当简单,LPC Xpresso4337是高速USB开发的不二选择