上手 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
既然是 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。