Skip to content

system/fastboot: publish the serial number - #4299

Open
JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:fastboot-serialno
Open

JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:fastboot-serialno

Conversation

@JianyuWang0623

Copy link
Copy Markdown
Contributor

Summary

Publish the board usbdev serial string (board_usbdev_serialstr()) as the
serialno fastboot variable so that getvar serialno reports the same
serial as the USB descriptor iSerialNumber on boards that provide one.
Boards without CONFIG_BOARD_USBDEV_SERIALSTR keep the empty response.

Impact

On boards that enable CONFIG_BOARD_USBDEV_SERIALSTR and implement
board_usbdev_serialstr() (the hook drivers/usbdev/composite.c already
uses for the USB descriptor serial), fastboot getvar serialno now
returns that string instead of nothing, and fastboot devices and
getvar serialno report the same serial. Without the config the new
code is compiled out and the behavior is unchanged.

Testing

Build Host: Ubuntu 22.04.5 LTS x86_64, QEMU emulator 6.2.0, Arm GNU
Toolchain 13.3 (aarch64-none-elf-gcc 13.3.1), host fastboot 28.0.2

Target: qemu-armv8a:fastboot (CONFIG_SYSTEM_FASTBOOTD, TCP transport)

Launch:

qemu-system-aarch64 -cpu cortex-a53 -nographic \
  -machine virt,virtualization=on,gic-version=3 \
  -global virtio-mmio.force-legacy=false \
  -netdev user,id=u1,hostfwd=tcp:127.0.0.1:5556-:5554 \
  -device virtio-net-device,netdev=u1 -kernel nuttx

Start fastbootd & at the nsh prompt, then run the host commands over the
TCP transport. Both builds enable CONFIG_BOARD_USBDEV_SERIALSTR with a
test-only board implementation of board_usbdev_serialstr() returning
QEMUTESTSERIAL01 so the new code path is linked and exercised.

master:

$ fastboot -s tcp:127.0.0.1:5556 getvar serialno
serialno: 
Finished. Total time: 0.003s

patched:

$ fastboot -s tcp:127.0.0.1:5556 getvar serialno
serialno: QEMUTESTSERIAL01
Finished. Total time: 0.001s

$ fastboot -s tcp:127.0.0.1:5556 getvar product
product: NuttX
Finished. Total time: 0.001s

On two hardware targets running fastbootd in the early boot stage (one
armv7-a, one armv8-a) the same change was checked against the other
serial sources on the device (USB serial, OS property, boot cmdline,
TEE serial record); all sources match byte-for-byte per
device (device serial numbers masked below), and the two devices
carry different serials.

target 1 (armv8-a):

$ fastboot getvar serialno
serialno: ***************

$ fastboot devices -l
***************        ADB Interface usb:1-10.3

$ adb getprop ro.serialno
***************

$ adb getprop ro.boot.serialno
***************

kernel cmdline: androidboot.serialno=***************
TEE log: [    5.039063] [ 0] [tee] serialNo      : ***************

target 2 (armv7-a, no OS-side property available):

$ fastboot getvar serialno
serialno: ***************

$ fastboot devices -l
***************        ADB Interface usb:1-2.1

TEE flash unique id record:
0000  ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **  ****************

fastboot getvar serialno returns nothing while the host side expects
a device serial.  Publish the board usbdev serial string as serialno
when the board provides one, matching the USB descriptor serial.
Boards without the hook keep the empty response.

Co-authored-by: multica-agent <github@multica.ai>
Assisted-by: OpenCode:mimo-v2.6-pro
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623
JianyuWang0623 marked this pull request as ready for review December 6, 2026 09:18
@JianyuWang0623

Copy link
Copy Markdown
Contributor Author

The failing jobs are unrelated to this patch: the flash overflows are on configs that don't enable SYSTEM_FASTBOOTD, and arm-other is an NTFC test timeout; other open PRs fail the same jobs.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

The failing jobs are unrelated to this patch: the flash overflows are on configs that don't enable SYSTEM_FASTBOOTD, and arm-other is an NTFC test timeout; other open PRs fail the same jobs.

fixed by apache/nuttx#22951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants