|
1 | | ---- |
2 | | -title: "固件烧录" |
3 | | -description: "" |
4 | | -summary: "" |
5 | | -date: 2024-03-06T11:08:28Z |
6 | | -lastmod: 2024-03-06T11:08:28Z |
7 | | -draft: false |
8 | | -weight: 104 |
9 | | -toc: true |
10 | | -seo: |
11 | | - title: "" # custom title (optional) |
12 | | - description: "" # custom description (recommended) |
13 | | - canonical: "" # custom canonical URL (optional) |
14 | | - noindex: false # false (default) or true |
15 | | ---- |
16 | | - |
17 | | -## UF2 烧录 |
18 | | - |
19 | | - |
20 | | - |
21 | | -图片引用自[树莓派 Pico 中文站](https://pico.org.cn/) |
22 | | - |
23 | | -图解步骤: |
24 | | - |
25 | | -1. 准备好要烧录的UF2文件 |
26 | | -2. 按住核心板上的BOOTSEL按键,插入USB线缆 |
27 | | -3. 电脑识别到名为RPI-RP2的可移动存储设备 |
28 | | -4. 将要烧录的文件拖放至名为RPI-RP2的可移动存储设备中 |
29 | | -5. 等待传输完成,程序自动执行 |
30 | | - |
31 | | -## debugprobe & DAPLink 烧录{#debugprobe} |
32 | | - |
33 | | -在使用本方式烧录之前,需要准备两块Pico核心板。 |
34 | | - |
35 | | -先安装openocd,windows用户不需要通过此方式手动安装 |
36 | | - |
37 | | - |
38 | | -```bash |
39 | | -sudo apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev libhidapi-dev -y |
40 | | - |
41 | | -git clone https://github.com/raspberrypi/openocd.git --recursive --branch sdk-2.0.0 --depth=1 |
42 | | - |
43 | | -cd openocd |
44 | | -./bootstrap |
45 | | -./configure --enable-cmsis-dap |
46 | | -make -j12 |
47 | | -sudo make install |
48 | | -``` |
49 | | - |
50 | | -Ubuntu用户还需设置udev规则才能正常使用调试器 |
51 | | - |
52 | | -```bash {title="~/openocd/"} |
53 | | -cd contrib |
54 | | -sudo cp 60-openocd.rules /etc/udev/rules.d/ |
55 | | -sudo udevadm control --reload |
56 | | -sudo udevadm trigger |
57 | | -``` |
58 | | - |
59 | | - |
60 | | -树梅派官方推出过基于RP2040的调试器,在github上开源:[https://github.com/raspberrypi/debugprobe](https://github.com/raspberrypi/debugprobe), 大概长这个样子: |
61 | | -{{< figure src="images/debugprobe.webp" alt="" >}} |
62 | | - |
63 | | -如果有条件的话,可以购买以支持官方。 |
64 | | - |
65 | | -实际上,他们也制作了适用于Pico的固件,我们只需要一个空闲的Pico核心板,然后烧录如下固件: |
66 | | - |
67 | | -首选链接:[debugprobe_on_pico.uf2](http://embeddedboys.com/uploads/debugprobe_on_pico.uf2) |
68 | | - |
69 | | -备用链接:[debugprobe_on_pico.uf2](https://github.com/raspberrypi/debugprobe/releases/download/debugprobe-v2.0/debugprobe_on_pico.uf2) |
70 | | - |
71 | | -待烧录完成后,将Pico连接至电脑,在Ubuntu中可以使用`lsusb`命令可以看到如下设备 |
72 | | -```shell |
73 | | -Bus 001 Device 018: ID 2e8a:000c Raspberry Pi Debugprobe on Pico (CMSIS-DAP) |
74 | | -``` |
75 | | -在Windows设备上,也可以看到一个名为CMSIS-DAP的设备 |
76 | | - |
77 | | -然后将烧录好debugprobe的Pico, 按照如下表格中的方式,连接至需要调试的Pico核心板 |
78 | | - |
79 | | -| debugprobe | Pico | |
80 | | -| --- | --- | |
81 | | -| GND | GND | |
82 | | -| GP2 | SWCLK | |
83 | | -| GP3 | SWDIO | |
84 | | -| GP4/UART1_TX | GP1/UART0_RX | |
85 | | -| GP5/UART1_RX | GP0/UART0_TX | |
86 | | -| VSYS | VSYS | |
87 | | - |
88 | | -{{< callout context="note" title="说明" icon="alert-octagon" >}} |
89 | | -只将debugprobe连接至电脑即可,如果debugprobe无法给Pico提供电源,则 |
90 | | -Pico也需要连接电源。 |
91 | | -{{< /callout >}} |
92 | | - |
93 | | -连接完成之后 ,使用如下命令烧录固件至Pico,以blink.elf为例 |
94 | | -```shell |
95 | | -openocd -f interface/cmsis-dap.cfg -c "adapter speed 5000" -f target/rp2040.cfg -s tcl -c "program blink.elf verify reset exit" |
96 | | -``` |
97 | | - |
98 | | -## picotool 烧录 |
99 | | - |
100 | | -此方式需要 pico 先处于BOOTSEL模式 |
101 | | - |
102 | | -```bash |
103 | | -sudo picotool load -fuvx blink.uf2 |
104 | | -``` |
| 1 | +--- |
| 2 | +title: "固件烧录" |
| 3 | +description: "" |
| 4 | +summary: "" |
| 5 | +date: 2024-03-06T11:08:28Z |
| 6 | +lastmod: 2024-03-06T11:08:28Z |
| 7 | +draft: false |
| 8 | +weight: 104 |
| 9 | +toc: true |
| 10 | +seo: |
| 11 | + title: "" # custom title (optional) |
| 12 | + description: "" # custom description (recommended) |
| 13 | + canonical: "" # custom canonical URL (optional) |
| 14 | + noindex: false # false (default) or true |
| 15 | +--- |
| 16 | + |
| 17 | +## UF2 烧录 |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +图片引用自[树莓派 Pico 中文站](https://pico.org.cn/) |
| 22 | + |
| 23 | +图解步骤: |
| 24 | + |
| 25 | +1. 准备好要烧录的UF2文件 |
| 26 | +2. 按住核心板上的BOOTSEL按键,插入USB线缆 |
| 27 | +3. 电脑识别到名为RPI-RP2的可移动存储设备 |
| 28 | +4. 将要烧录的文件拖放至名为RPI-RP2的可移动存储设备中 |
| 29 | +5. 等待传输完成,程序自动执行 |
| 30 | + |
| 31 | +## debugprobe & DAPLink 烧录{#debugprobe} |
| 32 | + |
| 33 | +在使用本方式烧录之前,需要准备两块Pico核心板。 |
| 34 | + |
| 35 | +先安装openocd,windows用户不需要通过此方式手动安装 |
| 36 | + |
| 37 | +```bash |
| 38 | +sudo apt install automake autoconf build-essential texinfo libtool libftdi-dev libusb-1.0-0-dev libhidapi-dev -y |
| 39 | + |
| 40 | +git clone https://github.com/raspberrypi/openocd.git --recursive --depth=1 |
| 41 | + |
| 42 | +cd openocd |
| 43 | +./bootstrap |
| 44 | +./configure --enable-cmsis-dap |
| 45 | +make -j$(nproc) |
| 46 | +sudo make install |
| 47 | +``` |
| 48 | + |
| 49 | +Ubuntu用户还需设置udev规则才能正常使用调试器 |
| 50 | + |
| 51 | +```bash {title="~/openocd/"} |
| 52 | +cd contrib |
| 53 | +sudo cp 60-openocd.rules /etc/udev/rules.d/ |
| 54 | +sudo udevadm control --reload |
| 55 | +sudo udevadm trigger |
| 56 | +``` |
| 57 | + |
| 58 | +树梅派官方推出过基于RP2040的调试器,在github上开源:[https://github.com/raspberrypi/debugprobe](https://github.com/raspberrypi/debugprobe), 大概长这个样子: |
| 59 | +{{< figure src="images/debugprobe.webp" alt="" >}} |
| 60 | + |
| 61 | +如果有条件的话,可以购买以支持官方。 |
| 62 | + |
| 63 | +实际上,他们也制作了适用于Pico的固件,我们只需要一个空闲的Pico核心板,然后烧录如下固件: |
| 64 | + |
| 65 | +首选链接:[debugprobe_on_pico.uf2](https://github.com/raspberrypi/debugprobe/releases/download/debugprobe-v2.0/debugprobe_on_pico.uf2) |
| 66 | + |
| 67 | +备用链接:[debugprobe_on_pico.uf2](http://embeddedboys.com/uploads/debugprobe_on_pico.uf2) |
| 68 | + |
| 69 | +待烧录完成后,将Pico连接至电脑,在Ubuntu中可以使用`lsusb`命令可以看到如下设备 |
| 70 | + |
| 71 | +```shell |
| 72 | +Bus 001 Device 018: ID 2e8a:000c Raspberry Pi Debugprobe on Pico (CMSIS-DAP) |
| 73 | +``` |
| 74 | + |
| 75 | +在Windows设备上,也可以看到一个名为CMSIS-DAP的设备 |
| 76 | + |
| 77 | +然后将烧录好debugprobe的Pico, 按照如下表格中的方式,连接至需要调试的Pico核心板 |
| 78 | + |
| 79 | +| debugprobe | Pico | |
| 80 | +| ------------ | ------------ | |
| 81 | +| GND | GND | |
| 82 | +| GP2 | SWCLK | |
| 83 | +| GP3 | SWDIO | |
| 84 | +| GP4/UART1_TX | GP1/UART0_RX | |
| 85 | +| GP5/UART1_RX | GP0/UART0_TX | |
| 86 | +| VSYS | VSYS | |
| 87 | + |
| 88 | +{{< callout context="note" title="说明" icon="alert-octagon" >}} |
| 89 | +只将debugprobe连接至电脑即可,如果debugprobe无法给Pico提供电源,则 |
| 90 | +Pico也需要连接电源。 |
| 91 | +{{< /callout >}} |
| 92 | + |
| 93 | +连接完成之后 ,使用如下命令烧录固件至Pico,以blink.elf为例 |
| 94 | + |
| 95 | +```shell |
| 96 | +openocd -f interface/cmsis-dap.cfg -c "adapter speed 5000" -f target/rp2040.cfg -s tcl -c "program blink.elf verify reset exit" |
| 97 | +``` |
| 98 | + |
| 99 | +## picotool 烧录 |
| 100 | + |
| 101 | +此方式需要 pico 先处于BOOTSEL模式 |
| 102 | + |
| 103 | +```bash |
| 104 | +sudo picotool load -fuvx blink.uf2 |
| 105 | +``` |
0 commit comments