上手 Raspberry Pi Pico

什么是 PICO

Raspberry Pi Pico 是树莓派推出的一块基于 Arm Cortex-M0+ 内核的 MCU 的开发板,使用的 MCU 是树莓派自己研发的 Arm Cortex-M0+ 双核 RP2040。长这样子:

可以看到板子上外设非常少,可以说是 RP2040 的最小系统板,除了引出来的 IO,板子上有 USB、一个 BOOTSEL 按键、一个LED,一个用于存储固件的 Flash,然后就没有了。

先看看板子

上电,使用一根 micro USB 接口连上电脑:

上电后,看板子,一点反映都没有,灯没亮,看了下原理图,LED 是由 MCU IO 控制,不是直接接到电源,不是用作电源指示灯。有可能这板子没有控制 LED 的出厂程序,如果是这样的话,没反应也许就是最好的,不会冒烟、冒火花什么的,也不会有爆鸣声。

pico 在PC(win10)上

接下来,既然板子连接到了电脑,就看下电脑端吧,来,切换一下:

刚把板子插进电脑,什么都不做的话,如果是Win10 系统,可以看到电脑弹出如下:

点击下该对话框,打开的界面看到相关设备为:

驱动程序无法使用?什么情况? 吓得我赶紧打开设备管理器,看到一个应该是没安装成功驱动的设备:

不管先,我还看到了其他东西,一个大容量存储设备,通俗点就是 U 盘,如下:

里面的内容为:

打开 INFO_UF2.TXT 后看到内容为:

UF2 Bootloader v1.0
Model: Raspberry Pi RP2
Board-ID: RPI-RP2

如果用浏览器打开 INDEX.HTM 文件的话,会自动跳转到树莓派官网中的 rp2040/getting-started 页面:

既然是 USB 设备的话,我就想用 UVCView 软件看下该设备的 USB 相关信息:

我把用该软件看到的内容放到下面:

[Port2]  :  USB Composite Device

          ---===>Device Information<===---
English product name: "RP2 Boot"

ConnectionStatus:                  
Current Config Value:              0x01  -> Device Bus Speed: Full
Device Address:                    0x13
Open Pipes:                           4

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x03  -> Direction: OUT - EndpointID: 3
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x84  -> Direction: IN - EndpointID: 4
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x81  -> Direction: IN - EndpointID: 1
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x02  -> Direction: OUT - EndpointID: 2
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Device Descriptor<===
bLength:                           0x12
bDescriptorType:                   0x01
bcdUSB:                          0x0110
bDeviceClass:                      0x00  -> This is an Interface Class Defined Device
bDeviceSubClass:                   0x00
bDeviceProtocol:                   0x00
bMaxPacketSize0:                   0x40 = (64) Bytes
idVendor:                        0x2E8A = Vendor ID not listed with USB.org as of 03-19-2008
idProduct:                       0x0003
bcdDevice:                       0x0100
iManufacturer:                     0x01
     English (United States)  "Raspberry Pi"
iProduct:                          0x02
     English (United States)  "RP2 Boot"
iSerialNumber:                     0x03
     English (United States)  "E0C912D24340"
bNumConfigurations:                0x01

          ===>Configuration Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x02
wTotalLength:                    0x0037  -> Validated
bNumInterfaces:                    0x02
bConfigurationValue:               0x01
iConfiguration:                    0x00
bmAttributes:                      0x80  -> Bus Powered
MaxPower:                          0xFA = 500 mA

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x00
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0x08  -> This is a Mass Storage USB Device Interface Class
bInterfaceSubClass:                0x06
bInterfaceProtocol:                0x50
iInterface:                        0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x81  -> Direction: IN - EndpointID: 1
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x02  -> Direction: OUT - EndpointID: 2
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x01
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0xFF  -> Vendor Specific Device
bInterfaceSubClass:                0x00
*!*CAUTION:    This appears to be an invalid bInterfaceSubClass
bInterfaceProtocol:                0x00
iInterface:                        0x00
*!*CAUTION:  0xFF is a prerelease Class ID

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x03  -> Direction: OUT - EndpointID: 3
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x84  -> Direction: IN - EndpointID: 4
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x00

这只能看到 pico usb 设备的配置信息,从上面信息可以看到这是个复合设备,有 2 个接口(bNumInterfaces: 0x02):

  • Mass Storage USB Device Interface,大容量存储设备,也就 U盘
  • Vendor Specific Device 自定义设备

这两个接口都有2个端点,都是 Bulk Transfer Type,正好对于上面看到的没安装成功驱动的设备跟 F 盘。

Hello World

从网络了解到的信息,可以通过拖拽烧录程序,也就是说把固件拖拽到 raspberry pico 生成的 U盘里就可以烧录程序了,来测试下,树莓派官方提供一个 raspberry pico 闪灯的例程,下载连接为:blink.uf2,官方描述为:

把固件下载下来,然后拷贝到 pico 生成的对 U盘里面,拷贝完成后,文件浏览器会自动关闭,pico 对应的 USB 设备都没有了,板子上的 LED 灯会闪烁了

后记

我尝试了下按住板子上的按键,然后再把板子插入电脑,出现的情况跟第一次上电一样,这也许,可能,pico 出厂的时候 Flash 是空的(没有 RP2040 能运行的固件的),pico 上的 flash 是空的的话,pico 就直接运行 boot 程序。
来,总结下,买到的 pico 是没有出厂测试程序的,给板子上电,板子看不到任何反映,直接进入了 boot。

posted @ 2021-06-10 14:56  哈拎  阅读(2216)  评论(0编辑  收藏  举报