PocketBeagle 2 boot with `snagboot`

Before I write anything for docs or a blog post on snagboot, I thought I’d just start by documenting my experience using snagboot here.

For background, snagboot is a tool for bootloading boards, including PocketBeagle 2, without needing to have a programmed microSD card inserted. The opportunity here is to avoid needing any external adapter and establish control over setting the state of PocketBeagle 2 directly from bb-imager.

Instructions for building u-boot at AM62x Beagleboard.org Beagleplay — Das U-Boot unknown version documentation.

jkridner@slotcar:~/workspace$ git clone https://openbeagle.org/beagleboard/u-boot
jkridner@slotcar:~/workspace$ cd u-boot
jkridner@slotcar:~/workspace/u-boot$ ls configs | grep pocketbeagle
am6232_pocketbeagle2_a53_defconfig
am6232_pocketbeagle2_r5_defconfig
jkridner@slotcar:~/workspace/u-boot$ git checkout v2025.01-pocketbeagle2
Updating files: 100% (24840/24840), done.
branch 'v2025.01-pocketbeagle2' set up to track 'origin/v2025.01-pocketbeagle2'.
Switched to a new branch 'v2025.01-pocketbeagle2'
jkridner@slotcar:~/workspace/u-boot$ python3 -m venv snagboot
jkridner@slotcar:~/workspace/u-boot$ source snagboot/bin/activate
(snagboot) jkridner@slotcar:~/workspace/u-boot$ export PATH=$PATH:$HOME/workspace/u-boot/snagboot/bin
(snagboot) jkridner@slotcar:~/workspace/u-boot$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 24.04 LTS
Release:	24.04
Codename:	noble
(snagboot) jkridner@slotcar:~/workspace/u-boot$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...
Bus 003 Device 034: ID 0451:6165 Texas Instruments, Inc. AM62x DFU
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
...
(snagboot) jkridner@slotcar:~/workspace/u-boot$ pip install snagboot
Collecting snagboot
  Downloading snagboot-2.1-py3-none-any.whl.metadata (7.3 kB)
...
sha256=8f24f391222e3f1ae7efd96ab35b005b6c9fe3495f67ab52ec67329f7fb65a10
  Stored in directory: /home/jkridner/.cache/pip/wheels/dd/f6/68/d406bafc5bebc848316590360012a838aa2a844cba9a4fbfa6
  Building wheel for tftpy (pyproject.toml) ... done
  Created wheel for tftpy: filename=tftpy-0.8.2-py3-none-any.whl size=29549 sha256=ca22457e212e395d214350bc3186513b6391ac6f5d6505b446306410903efb56
  Stored in directory: /home/jkridner/.cache/pip/wheels/ef/94/16/15d8833761a47ebe47364d11f51b5c2f75b3378c90a57e5c91
Successfully built pylibfdt tftpy
Installing collected packages: swig, pyserial, pylibfdt, crccheck, tftpy, pyyaml, pyusb, packaging, snagboot
Successfully installed crccheck-1.3.0 packaging-24.2 pylibfdt-1.7.2 pyserial-3.5 pyusb-1.3.1 pyyaml-6.0.2 snagboot-2.1 swig-4.3.0 tftpy-0.8.2
(snagboot) jkridner@slotcar:~/workspace/u-boot$ snagrecover -h
usage: snagrecover [-h] [-s SOC] [-f "templates/colibri-imx7d.yaml"] [-F "{'fw1': {'path': '/path/to', 'address': 0x00}}"] [--netns NETNS] [--loglevel {silent,info,debug}]
                   [--logfile LOGFILE] [--rom-usb ROM_USB] [--usb-path vid:pid|bus-port1.port2.[...]] [--list-socs] [--version] [-t name] [--udev] [--am335x-setup]

options:
  -h, --help            show this help message and exit

Mandatory:
  -s SOC, --soc SOC     soc model
  -f "templates/colibri-imx7d.yaml", --firmware-file "templates/colibri-imx7d.yaml"
                        firmware configurations, passed as a yaml file
  -F "{'fw1': {'path': '/path/to', 'address': 0x00}}", --firmware "{'fw1': {'path': '/path/to', 'address': 0x00}}"
                        firmware configurations, formatted as a python3 dict

Optional:
  --netns NETNS         network namespace for AM335x USB recovery, defaults to 'snagbootnet'
  --loglevel {silent,info,debug}
                        set loglevel
  --logfile LOGFILE     set logfile
  --rom-usb ROM_USB     legacy, please use --usb-path
  --usb-path vid:pid|bus-port1.port2.[...]
                        address of recovery USB device

Utilities:
  --list-socs           list supported socs
  --version             show version
  -t name, --template name
                        get an example firmware configuration file
  --udev                get required udev rules for snagrecover
  --am335x-setup        get setup script for am335x USB recovery

Examples:
	snagrecover -s stm32mp15 -f stm32mp15.yaml
	snagrecover -s stm32mp15 -F "{'tf-a': {'path': 'binaries/tf-a-stm32.bin'}}" -F "{'fip': {'path': 'binaries/u-boot.stm32'}}"

Templates:
am335x-beaglebone-black
am62x-beagle-play
am62x-phyboard-lyra
...
(snagboot) jkridner@slotcar:~/workspace/pocketbeagle-2$ snagrecover --udev | tee 50-snagboot.rules
...
#TI rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="6165", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="6141", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="d022", MODE="0660", TAG+="uaccess"
...
(snagboot) jkridner@slotcar:~/workspace/pocketbeagle-2$ sudo udevadm control --reload-rules
(snagboot) jkridner@slotcar:~/workspace/pocketbeagle-2$ sudo udevadm trigger
...
(snagboot) jkridner@slotcar:~/workspace/u-boot$ snagrecover -s am625 -f snagboot/lib/python3.12/site-packages/snagrecover/templates/am62x-beagle-play.yaml 
2025-02-18 18:07:45,737 [INFO] Starting recovery of am625 board
2025-02-18 18:07:45,797 [INFO] Installing firmware tiboot3
2025-02-18 18:07:45,798 [INFO] Searching for partition id...
2025-02-18 18:07:45,802 [INFO] Found DFU Functional descriptor: wTransferSize = 512
2025-02-18 18:07:45,802 [INFO] Downloading file...
2025-02-18 18:07:46,531 [INFO] Could not read status after end of manifest phase
2025-02-18 18:07:46,531 [INFO] Done
2025-02-18 18:07:46,531 [INFO] Done installing firmware tiboot3
2025-02-18 18:07:47,552 [INFO] Installing firmware tispl
2025-02-18 18:07:47,552 [INFO] Searching for partition id...
2025-02-18 18:07:47,553 [INFO] Found DFU Functional descriptor: wTransferSize = 4096
2025-02-18 18:07:47,553 [INFO] Downloading file...
2025-02-18 18:07:48,916 [INFO] Done manifesting firmware
2025-02-18 18:07:48,916 [INFO] Done
2025-02-18 18:07:48,916 [INFO] Done installing firmware tispl
2025-02-18 18:07:48,931 [INFO] Installing firmware u-boot
2025-02-18 18:07:48,931 [INFO] Searching for partition id...
2025-02-18 18:07:48,932 [INFO] Found DFU Functional descriptor: wTransferSize = 4096
2025-02-18 18:07:48,932 [INFO] Downloading file...
2025-02-18 18:07:50,333 [INFO] Done manifesting firmware
2025-02-18 18:07:50,333 [INFO] Done
2025-02-18 18:07:50,333 [INFO] Sending detach command...
2025-02-18 18:07:50,334 [INFO] Sending DFU_DETACH...
2025-02-18 18:07:50,335 [INFO] Done installing firmware u-boot
2025-02-18 18:07:52,336 [INFO] USB retry 1/9
2025-02-18 18:07:53,337 [INFO] USB retry 2/9
2025-02-18 18:07:54,338 [INFO] USB retry 3/9
2025-02-18 18:07:55,339 [INFO] USB retry 4/9
2025-02-18 18:07:56,340 [INFO] USB retry 5/9
2025-02-18 18:07:57,341 [INFO] USB retry 6/9
2025-02-18 18:07:58,343 [INFO] USB retry 7/9
2025-02-18 18:07:59,344 [INFO] USB retry 8/9
2025-02-18 18:08:00,345 [INFO] USB retry 9/9
2025-02-18 18:08:01,346 [INFO] USB retry 10/9
2025-02-18 18:08:02,346 [INFO] Done recovering am625 board
2025-02-18 18:08:02,346 [INFO] Done recovering am625 board
(snagboot) jkridner@slotcar:~/workspace/u-boot$ 

In another shell, monitoring the 3-pin serial port with a Pi Debug probe…

Core:  86 devices, 30 uclasses, devicetree: separate
MMC:   mmc@fa10000: 0, mmc@fa00000: 1
Loading Environment from nowhere... OK
In:    serial@2860000
Out:   serial@2860000
Err:   serial@2860000
Net:   No ethernet found.
Press SPACE to abort autoboot in 2 seconds
MMC: no card present
Scanning for bootflows in all bootdevs
Seq  Method       State   Uclass    Part  Name                      Filename
---  -----------  ------  --------  ----  ------------------------  ----------------
Scanning bootdev 'mmc@fa00000.bootdev':
MMC: no card present
MMC: no card present
MMC: no card present
MMC: no card present
Scanning bootdev 'mmc@fa10000.bootdev':
Card did not respond to voltage select! : -110
No more bootdevs
---  -----------  ------  --------  ----  ------------------------  ----------------
(0 bootflows, 0 valid)
=> 

So, next step is for me to build u-boot with NETCONSOLE support, like I did for the original PocketBeagle and try to figure out how to package this all up neatly.

3 Likes

Is snagboot writing all of it to ram since it does not have any storage. Would this require a formatted SD card to be inserted.

It’s talking to the boot rom over USB, preloading u-boot to init ddr. Giving you u-boot shell without using storage media.

Can it uses these binary files as is? pocketbeagle2 · main · BeagleBoard.org / boot-firmware · GitLab

Regards,

I will try incorporating it into bb-imager-rs once you have the docs or blog post out. Should be pretty straightforward to do.

1 Like

following what you did,
questions:
did you build the u-boot after cloning ?

i’m doing this on Ubuntu 22.04.5 LTS

everything up to this point seem to work just like your post
before running the snagrecover command,
i coped the boot-firmware files that @RobertCNelson provided a link to, to the u-boot dir.

was met with some errors running this command.
snagrecover -s am625 -f snagboot/lib/python3.10/site-packages/snagrecover/templates/am62x-beagle-play.yaml
2025-02-19 08:17:33,626 [INFO] Starting recovery of am625 board
2025-02-19 08:17:33,628 [INFO] Installing firmware tiboot3
2025-02-19 08:17:33,628 [INFO] Searching for partition id…
Traceback (most recent call last):
File “/home/amf/dev/u-boot/snagboot/bin/snagrecover”, line 8, in
sys.exit(cli())
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/cli.py”, line 134, in cli
recovery()
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/recoveries/am6x.py”, line 21, in main
send_tiboot3(dev)
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/recoveries/am6x.py”, line 11, in send_tiboot3
run_firmware(dev, “tiboot3”)
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/firmware/firmware.py”, line 121, in run_firmware
am6x_run(port, fw_name, fw_blob)
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/firmware/firmware.py”, line 77, in am6x_run
partid = dfu.search_partid(dev, partname)
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/snagrecover/protocols/dfu.py”, line 46, in search_partid
desc = usb.util.get_string(dev, intf.iInterface)
File “/home/amf/dev/u-boot/snagboot/lib/python3.10/site-packages/usb/util.py”, line 309, in get_string
raise ValueError(“The device has no langid”
ValueError: The device has no langid (permission issue, no string descriptors supported or device error)

correct. no microSD inserted.

Well, issue is just packaging. I used the same source (default defconfig), so, presumably those binaries would work.

I want to get my NETCONSOLE configuration debugged so that the operations in u-boot can be stopped and changed without rebuilding.

After that, I hope to boot Zephyr and eventually Microblocks.

Did the udev rule loading work? I had distractions and a reboot before going back to retrace my steps, not fully from scratch. I do have the udev rules installed.

I wonder if pulling the boot files from an image itself might help with managing the required firmware.

yes the TI udev rules are in the /etc/udev/rules.d/50-snagboot.rules file
there were no errors or warning when executing the command you listed until running
snagrecover -s am625 -f snagboot/lib/python3.10/site-packages/snagrecover/templates/am62x-beagle-play.yaml
for ubuntu 22.04, python3.10 is the directory, vs python3.12 for 24.04

i’ll try it again over the weekend.

retested following @jkridner above post. same results

also tried to build u-boot with branch

v2025.01-pocketbeagle2

and defconfig

am6232_pocketbeagle2_a53_defconfig

got the following error
./arch/arm/include/asm/global_data.h:136:58: error: invalid register name for ‘gd’
#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm (“x18”)

using toolchain
gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf

maybe i need a clean ubuntu 24.04 setup

It’s not that simple on am6x, hence why I was pushing to use the prebuilds… build_u-boot.sh · main · PocketBeagle / u-boot-pocketbeagle2 · GitLab

Regards

1 Like

is this the only way to get ubuntu running on the PocketBeagle 2? How do you get the image onto the board without a memory card, if this board does not have memory?

No, this has nothing to do with that.

It’s a feature of the bootrom with snagboot to do cool things for developers or image developers.

Regards,

Hello Mister Nelson.

Thank you for taking the time to respond. Pardon my ignorance. I just saw ubuntu 24 on the screen, and decided to ask.

Ewald Heinsen Rizek
VP Desarrollo de Operaciones
Tel.: 809-531-5551 Ext.: 3250 | Cel: 829-748-1909
www.etheinsen.com.do

clip_image001.png

Ayúdenos!
Si tiene alguna sugerencia, queja o reclamación por favor dirigirla a la siguiente dirección: reclamaciones@etheinsen.com.do

No, you can just modify a disk image.

You’ll need to add the bootloader (including all 3 images) to the microSD FAT partition and provide the location of the kernel using extlinux to make an Ubuntu disk image bootable on PocketBeagle 2.

By Ubuntu disk image, I’m thinking about something like https://cloud-images.ubuntu.com/minimal/releases/oracular/release-20250218/ubuntu-24.10-minimal-cloudimg-arm64.img.

I tried using qemu-img to a microSD card to take a look…

sudo qemu-img convert -O raw ~/Downloads/ubuntu-24.10-minimal-cloudimg-arm64.img /dev/sdd

My Ubuntu machine couldn’t read contents on the card, so perhaps I misunderstood the image format.

Anyway, once you have a disk image, we’ll need to add the bootloader and kernel to it and that should be good.

Well, if you convert it to a RAMDISK image, that’d be how.

Anyway, it seems you might have been confused by the fact I was running Ubuntu on the host and thought I was showing how to run Ubuntu on PocketBeagle 2.

When I get a chance, I’ll get back to showing how to do that. What might be easiest is starting with one of Robert’s image-builder built images for now, but I hope to provide some easier guidance on creating one from an existing Ubuntu image.

So PocketBeagle 2 is secure boot I guess? Can it work from a generic uboot from denx, or does it need the TI version?

Here’s my current RFC: Commits · v2025.04-rc3-pocketbeagle2 · BeagleBoard.org / u-boot · GitLab

(need to get into mainline linux before i can submit for official u-boot support).

Build order: build_u-boot.sh · main · PocketBeagle / u-boot-pocketbeagle2 · GitLab

Regards,

@mringelectrick this is what you need right? Index of /rootfs/ubuntu-arm64-24.04-console-v6.12-ti/2025-03-04