什么是 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。