树莓派(Raspberry Pi)picotool

embedded/2024/11/19 16:17:08/

树莓派(Raspberry Pi)picotool

  • 安装
    • 直接安装
    • 从源码安装
    • 工具介绍
      • 显示信息
      • 保存程序
      • 二进制信息
      • 基本信息
      • 引脚
      • 完整信息
  • 链接

安装

直接安装

在archlinux上,使用yay直接安装

yay -S picotool

从源码安装

安装libusb

sudo pacman -S libusb

下载 pico-sdk

git clone https://github.com/raspberrypi/pico-sdk.git --branch master
cd pico-sdk
git submodule update --init
cd ..

下载 picotool 编译构建

git clone https://github.com/raspberrypi/picotool.git
cd picotool
mkdir build
cd build
export PICO_SDK_PATH=../../pico-sdk
cmake ../
make

工具介绍

$picotool help
PICOTOOL:Tool for interacting with RP2040/RP2350 device(s) in BOOTSEL mode, or with an RP2040/RP2350 binarySYNOPSIS:picotool info [-b] [-p] [-d] [--debug]  [-l] [-a] [device-selection]picotool info [-b] [-p] [-d] [--debug]  [-l] [-a] <filename> [-t <type>]picotool config [-s <key> <value>] [-g  <group>] [device-selection]picotool config [-s <key> <value>] [-g  <group>] <filename> [-t <type>]picotool load [--ignore-partitions] [--family <family_id>] [-p <partition>] [-n] [-N] [-u] [-v] [-x] <filename> [-t <type>] [-o <offset>] [device-selection]picotool encrypt [--quiet] [--verbose]  [--hash] [--sign] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] <aes_key> [-t <type>] [<signing_key>] [-t <type>]picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] [<key>] [-t <type>] [<otp>] [-t <type>] [--major <major>] [--minor  <minor>] [--rollback <rollback>  [<rows>..]]picotool link [--quiet] [--verbose]     <outfile> [-t <type>] <infile1> [-t<type>] <infile2> [-t   <type>] [<infile3>] [-t   <type>] [-p] <pad>picotool save [-p] [device-selection]picotool save -a [device-selection]picotool save -r <from> <to>    [device-selection]picotool verify [device-selection]picotool reboot [-a] [-u] [-g   <partition>] [-c <cpu>]   [device-selection]picotool otp list|get|set|load|dump|    permissions|white-labelpicotool partition info|createpicotool uf2 info|convertpicotool version [-s] [<version>]picotool coprodis [--quiet] [--verbose]     <infile> [-t <type>] <outfile> [-t <type>]picotool help [<cmd>]COMMANDS:info          Display information from    the target device(s) or file.Without any arguments, this     will display basic  information for all connected RP2040    devices in BOOTSEL modeconfig        Display or change program   configuration settings from the target device(s) or file.load          Load the program / memory   range stored in a file onto the device.encrypt       Encrypt the program.seal          Add final metadata to a     binary, optionally including a hash and/or signature.link          Link multiple binaries into     one block loop.save          Save the program / memory   stored in flash on the device to a file.verify        Check that the device   contents match those in the file.reboot        Reboot the deviceotp           Commands related to the     RP2350 OTP (One-Time-Programmable) Memorypartition     Commands related to RP2350  Partition Tablesuf2           Commands related to UF2     creation and statusversion       Display picotool versioncoprodis      Post-process coprocessor    instructions in disassembly files.help          Show general help or help   for a specific commandUse "picotool help <cmd>" for more info
说明
大部分命令都要求将树莓派微控制器设备连接到开发设备上,并处于 BOOTSEL 模式下。
重点
如果打印错误消息 No accessible RP2040/RP2350 devices in BOOTSEL mode were found,并且伴有类似这样的提示: Device at bus 1, address 7 appears to be a RP2040 device in BOOTSEL mode, but picotool was unable to connect,这表明已连接了一个 Pico 系列设备,但是执行命令的权限不够,这时可以使用 sudo 来运行 picotool
sudo picotool info -a
如果使用的是 Windows 系统,则需要安装一个驱动程序。
下载并运行 Zadig,从下拉框中选择 RP2 Boot(Interface 1),并选择 WinUSB 作为驱动程序,然后点击 “安装驱动程序” 按钮。

picotool 的 1.1 版本开始,支持与未处于 BOOTSEL 模式的树莓派微控制器进行交互,使用 picotool-f 参数使用SDK 的USB 标准输入输出(stdio)进行交互。

显示信息

当前版本的SDK支持二进制信息,能够存储目标设备或者文件的精简信息。info 命令用于读取此类信息。

这些信息既可以从一个或多个处于 BOOTSEL 模式的已连接树莓派微控制器中读取,也可以从一个文件中读取。该文件可以是可执行与可链接格式(ELF)文件、通用闪存存储格式(UF2)文件或二进制(BIN)文件。

$picotool help info
INFO:Display information from the target device(s) or file.Without any arguments, this will display basic information for all connectedRP2040 devices in BOOTSEL modeSYNOPSIS:picotool info [-b] [-p] [-d] [--debug] [-l] [-a] [device-selection]picotool info [-b] [-p] [-d] [--debug] [-l] [-a] <filename> [-t <type>]OPTIONS:Information to display-b, --basicInclude basic information. This is the default-p, --pinsInclude pin information-d, --deviceInclude device information--debugInclude device debug information-l, --buildInclude build attributes-a, --allInclude all informationTARGET SELECTION:To target one or more connected RP2040 device(s) in BOOTSEL mode (the default)--bus <bus>Filter devices by USB bus number--address <addr>Filter devices by USB device address--vid <vid>Filter by vendor id--pid <pid>Filter by product id--ser <ser>Filter by serial number-f, --forceForce a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the command (unless the command itself is a 'reboot') the device will be rebooted back to application mode-F, --force-no-rebootForce a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but without the RPI-RP2 drive mountedTo target a file<filename>The file name-t <type>Specify file type (uf2 | elf | bin) explicitly, ignoring file extension

例如,在将Pico系列设备插入 USB 接口之前,按住 BOOTSEL 按钮,使其以大容量存储模式连接到计算机。然后打开一个终端窗口并输入:

$sudo picotool info
Program Informationname: hello_worldfeatures: stdout to UART

或者

$sudo picotool info -a
Program Informationname:         hello_worldfeatures:     stdout to UARTbinary start: 0x10000000binary end:   0x1000606cFixed Pin Information20: UART1 TX21: UART1 RXBuild Informationbuild date:       Dec 31 2020build attributes: Debug buildDevice Informationflash size:  2048KROM version: 2

也可以通过如下的命令获取引脚信息。

$ sudo picotool info -bp
Program Informationname:     hello_worldfeatures: stdout to UARTFixed Pin Information20: UART1 TX21: UART1 RX

也可以查询二进制文件的信息。

$ picotool info -a lcd_1602_i2c.uf2
File lcd_1602_i2c.uf2:
Program Informationname:         lcd_1602_i2cweb site:     https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2cbinary start: 0x10000000binary end:   0x10003c1cFixed Pin Information4: I2C0 SDA5: I2C0 SCLBuild Informationbuild date: Dec 31 2020

保存程序

“保存”功能支持将设备中的一段内存、一个程序或整个闪存内容保存到一个二进制(BIN)文件或通用闪存存储格式(UF2)文件中。

$ picotool help save
SAVE:Save the program / memory stored in flash on the device to a file.SYNOPSIS:picotool save [-p] [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]picotool save -a [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]picotool save -r <from> <to> [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]OPTIONS:Selection of data to save-p, --programSave the installed program only. This is the default-a, --allSave all of flash memory-r, --rangeSave a range of memory. Note that UF2s always store complete 256 byte-aligned blocks of 256 bytes, and the range is expanded accordingly<from>The lower address bound in hex<to>The upper address bound in hexSource device selection--bus <bus>Filter devices by USB bus number--address <addr>Filter devices by USB device address-f, --forceForce a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the command (unless the command itself is a 'reboot') the device will be rebooted back to application mode-F, --force-no-rebootForce a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. After executing the command (unless the command itself is a 'reboot') the device will be left connected and accessible to picotool, but  without the RPI-RP2 drive mounted File to save to<filename>The file name-t <type>Specify file type (uf2 | elf | bin) explicitly, ignoring file extension

比如:

$ sudo picotool info
Program Information
name:     lcd_1602_i2c
web site: https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2c
$ picotool save spoon.uf2
Saving file: [==============================] 100%
Wrote 51200 bytes to spoon.uf2
$ picotool info spoon.uf2
File spoon.uf2:
Program Information
name:     lcd_1602_i2c
web site: https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/lcd_1602_i2c

二进制信息

二进制信息是在构建时嵌入到二进制文件中的、可由机器定位且能被机器读取的信息。

基本信息

当拿到一个 Pico 系列设备但不知道里面有什么内容时,这些信息就非常有用了!
基本信息包括:
- 程序名称
- 程序描述
- 程序版本字符串
- 程序构建日期
- 程序网址
- 程序结束地址
- 程序特性,这是一个根据二进制文件中的各个字符串构建的列表,在 SDK 中可以显示出来(例如,我们会有一个针对通用异步收发传输器(UART)标准输入输出(stdio)的特性,以及一个针对通用串行总线(USB)标准输入输出(stdio)的特性)。
- 构建属性,及与二进制文件本身相关的内容(例如,调试构建)

引脚

当忘记可执行文件是为基于树莓派微控制器的哪种电路板构建的时,可使用picotool info --pins获取文件的引脚信息。

$ picotool info --pins sprite_demo.elf
File sprite_demo.elf:Fixed  Pin Information
0-4:   Red 0-4
6-10:  Green 0-4
11-15: Blue 0-4
16:    HSync
17:    VSync
18:    Display Enable
19:    Pixel Clock
20:    UART1 TX
21:    UART1 RX

完整信息

使用 -a 选项可获取完整信息。

$ picotool info -a i2c_bus_scan.elf
File i2c_bus_scan.elf:Program Informationname:         i2c_bus_scanweb site:     https://github.com/raspberrypi/pico-examples/tree/HEAD/i2c/bus_scanfeatures:     UART stdin / stdoutbinary start: 0x10000000binary end:   0x10004c74Fixed Pin Information0: UART0 TX1: UART0 RX4: I2C0 SDA5: I2C0 SCLBuild Informationsdk version:      2.0.0-developpico_board:       picobuild date:       Aug 1 2024build attributes: Debug

链接

  • Raspberry Pi官网

http://www.ppmy.cn/embedded/138806.html

相关文章

SQL,力扣题目1369,获取最近第二次的活动

一、力扣链接 LeetCode_1369 二、题目描述 表: UserActivity ------------------------ | Column Name | Type | ------------------------ | username | varchar | | activity | varchar | | startDate | Date | | endDate | Date | -----…

云原生周刊:Istio 1.24.0 正式发布

云原生周刊&#xff1a;Istio 1.24.0 正式发布 开源项目推荐 Kopf Kopf 是一个简洁高效的 Python 框架&#xff0c;只需几行代码即可编写 Kubernetes Operator。Kubernetes&#xff08;K8s&#xff09;作为强大的容器编排系统&#xff0c;虽自带命令行工具&#xff08;kubec…

第十六届蓝桥杯模拟赛(第一期)-c++/c

前面填空参考https://blog.csdn.net/2301_76891851/article/details/143448411 后面大题code&#xff1a; 停车场停车 #include <bits/stdc.h> #define int long long using namespace std; int tmp; signed main() {int n;cin>>n;if(n<15)cout<<"…

使用 AWR 进行 Exadata 性能诊断

本文内容来自Oracle 2024年3月发布的白皮书&#xff1a;Exadata Performance and AWR: Exadata Performance Diagnostics with AWR 简介 本技术简介概述了如何将 Oracle AWR 功能与 Exadata 结合使用&#xff0c;从 Exadata 的角度&#xff08;standpoint&#xff09;监控和分…

飞凌嵌入式RK3576核心板已适配Android 14系统

在今年3月举办的RKDC2024大会上&#xff0c;飞凌嵌入式FET3576-C核心板作为瑞芯微RK3576处理器的行业首秀方案重磅亮相&#xff0c;并于今年6月率先量产发货&#xff0c;为客户持续稳定地供应&#xff0c;得到了众多合作伙伴的认可。 FET3576-C核心板此前已提供了Linux 6.1.57…

量子前沿英雄谱|光量子计算的前沿探险家:Jeremy O‘Brien

大航海时代&#xff0c;书写了一部人类探索与发现的壮丽史诗&#xff0c;而作为宏大叙事背后若干个体之一&#xff0c;那些大大小小航船上载着的&#xff0c;是一群不断航向未知海域的坚定探险家。 日光底下无新事。从著名物理学家费曼提出量子计算机的概念起 ... 大航海时代&a…

Go语言的创始人, 核心特性和学习资源

Go语言的创始人 Go语言的创始人有三位&#xff0c;分别是&#xff1a; Robert Griesemer&#xff1a;他参与开发了Java HotSpot虚拟机。Rob Pike&#xff1a;他是Go语言项目的总负责人&#xff0c;曾是贝尔实验室Unix团队的成员&#xff0c;参与过Plan 9、Inferno操作系统和L…

List、ArrayList与顺序表1

文章目录 1. 什么是List2. 常见接口3. List的使用4. 线性表5. 顺序表5.1 接口的实现 1. 什么是List 在集合框架中&#xff0c;List是一个接口&#xff0c;继承与Collection接口&#xff0c;也继承于Iterable接口。 Collection接口中主要规范了后序容器中常用的一些方法 Itera…