Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system/fastboot: Add support for fastboot oem shell #3003

Merged

Conversation

JianyuWang0623
Copy link
Contributor

@JianyuWang0623 JianyuWang0623 commented Feb 20, 2025

Summary

Add support for fastboot oem shell to support executing custom commands.

Usage

fastboot oem shell <command>

Impact

system/fastboot

Testing

# Configuration "esp32s3-devkit:fastboot" with `SYSTEM_FASTBOOTD_SHELL` enabled

$ fastboot --version
fastboot version 35.0.2-12147458

$ fastboot oem shell ls /FILE_NOT_EXISTS
FAILED (remote: 'error detected 255 4')
fastboot: error: Command failed

$ fastboot oem shell ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 0003056 Idle_Task
    1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001976 hpwork 0x3fc8bd50 0x3fc8bd80
    2     2 100 RR       Task      - Waiting  Semaphore 0000000000000000 0004048 nsh_main
    3     3 100 RR       Task      - Ready              0000000000000000 0001992 fastbootd
    4     4 100 RR       Task      - Running            0000000000000000 0001992 popen -c ps
OKAY [  0.010s]
Finished. Total time: 0.010s

@JianyuWang0623
Copy link
Contributor Author

@Donny9 @yangsong8-ai Could you review this PR please?

@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from a1c4364 to de83ff2 Compare February 20, 2025 08:11
@JianyuWang0623 JianyuWang0623 marked this pull request as draft February 20, 2025 16:49
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from de83ff2 to f6b4a49 Compare February 21, 2025 03:22
@JianyuWang0623 JianyuWang0623 changed the title system/fastboot: Add support for oem mkrd command system/fastboot: Add support for fastboot oem sh Feb 21, 2025
@JianyuWang0623 JianyuWang0623 marked this pull request as ready for review February 21, 2025 03:24
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from f6b4a49 to 0983ecc Compare February 21, 2025 03:31
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from 0983ecc to cd5496f Compare February 21, 2025 04:06
@JianyuWang0623 JianyuWang0623 marked this pull request as draft February 21, 2025 04:44
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from cd5496f to 76c6600 Compare February 21, 2025 05:56
@JianyuWang0623
Copy link
Contributor Author

JianyuWang0623 commented Feb 21, 2025

  • The print format of "INFO" is: "(bootloader) " + InfoMessagePayload + ‘\n’:

    $ fastboot oem sh ps
                                                       (bootloader)   PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIG
    (bootloader) MASK            STACK COMMAND
    
    (bootloader)     0     0   0 FIFO     Kthread   - Ready              000
    (bootloader) 0000000000000 0003056 Idle_Task
    
    (bootloader)     1     0 224 RR       Kthread   - Waiting  Semaphore 000
    (bootloader) 0000000000000 0001976 hpwork 0x3fc8bb90 0x3fc8bbc0
    
    (bootloader)     2     2 100 RR       Task      - Waiting  Semaphore 000
    (bootloader) 0000000000000 0004048 nsh_main
    
    (bootloader)     3     3 100 RR       Task      - Ready              000
    (bootloader) 0000000000000 0001992 fastbootd
    
    (bootloader)     4     4 100 RR       Task      - Running            000
    (bootloader) 0000000000000 0001992 popen -c ps
    
  • fastboot version 28.0.2-debian doesn`t support "TEXT", the latest version(fastboot version 35.0.2-12147458) supports

    • 28.0.2-debian
    $ fastboot --version
    fastboot version 28.0.2-debian
    Installed as /usr/lib/android-sdk/platform-tools/fastboot
    
    $ fastboot oem sh ps
                                                       FAILED (Device sent unknown status code: TEXT  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIG)
    fastboot: error: Command failed
    
    • 35.0.2-12147458
      $ ./platform-tools/fastboot oem sh ps
        PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
          0     0   0 FIFO     Kthread   - Ready              0000000000000000 0003056 Idle_Task
          1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001976 hpwork 0x3fc8bd50 0x3fc8bd80
          2     2 100 RR       Task      - Waiting  Semaphore 0000000000000000 0004048 nsh_main
          3     3 100 RR       Task      - Ready              0000000000000000 0001992 fastbootd
          4     4 100 RR       Task      - Running            0000000000000000 0001992 popen -c ps
      OKAY [  0.010s]
      Finished. Total time: 0.010s
    
    99097cc020 (Raphael Herouart 2022-12-30 11:51:54 +0000 503)         } else if (android::base::StartsWith(input, "TEXT")) {
    99097cc020 (Raphael Herouart 2022-12-30 11:51:54 +0000 504)             text_(input.substr(strlen("TEXT")));
    99097cc020 (Raphael Herouart 2022-12-30 11:51:54 +0000 505)             // Reset timeout as many more TEXT may come
    99097cc020 (Raphael Herouart 2022-12-30 11:51:54 +0000 506)             start = std::chrono::steady_clock::now();
    db511207ed (Aaron Wisner     2018-06-26 15:38:35 -0500 507)         } else if (android::base::StartsWith(input, "DATA")) {
    ... ...
    db511207ed (Aaron Wisner     2018-06-26 15:38:35 -0500 517)         } else {
    db511207ed (Aaron Wisner     2018-06-26 15:38:35 -0500 518)             error_ = android::base::StringPrintf("Device sent unknown status code: %s", status);
    db511207ed (Aaron Wisner     2018-06-26 15:38:35 -0500 519)             return BAD_DEV_RESP;
    db511207ed (Aaron Wisner     2018-06-26 15:38:35 -0500 520)         }
    

Using newer version fastboot tool to support code "TEXT" for original format output.

@JianyuWang0623 JianyuWang0623 marked this pull request as ready for review February 21, 2025 05:57
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch 5 times, most recently from 265abb1 to 5b4a07f Compare February 21, 2025 23:52
@JianyuWang0623 JianyuWang0623 changed the title system/fastboot: Add support for fastboot oem sh system/fastboot: Add support for fastboot oem shell Feb 21, 2025
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from 5b4a07f to 9727fa3 Compare February 23, 2025 13:44
JianyuWang0623 added a commit to JianyuWang0623/nuttx that referenced this pull request Feb 24, 2025
Selftest

    # Host side

    $ ./tools/configure.sh -l esp32s3-devkit:fastboot
    $ make flash -j ESPTOOL_PORT=/dev/ttyACMx

    $ fastboot devices
    1234    fastboot
    $ fastboot -s 1234 oem shell ps
      PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
        0     0   0 FIFO     Kthread   - Ready              0000000000000000 0003056 Idle_Task
        1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001976 hpwork 0x3fc8bd50 0x3fc8bd80
        2     2 100 RR       Task      - Waiting  Semaphore 0000000000000000 0004048 nsh_main
        3     3 100 RR       Task      - Ready              0000000000000000 0001992 fastbootd
        4     4 100 RR       Task      - Running            0000000000000000 0001992 popen -c ps
    OKAY [  0.010s]
    Finished. Total time: 0.010s

More details

    apache/nuttx-apps#3003

Signed-off-by: wangjianyu3 <[email protected]>
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @JianyuWang0623 :-)

Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add commit message
fb4c03f

Add support for producing output according to a format like printf().

Signed-off-by: wangjianyu3 <[email protected]>
To support executing custom commands.

Usage

  fastboot oem shell <command>

Tests

  # Configuration "esp32s3-devkit:fastboot" with `SYSTEM_FASTBOOTD_SHELL` enabled

  $ fastboot --version
  fastboot version 35.0.2-12147458

  $ fastboot oem shell ls /FILE_NOT_EXISTS
  FAILED (remote: 'error detected 0xff00 4')
  fastboot: error: Command failed

  $ fastboot oem shell ps
    PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK COMMAND
      0     0   0 FIFO     Kthread   - Ready              0000000000000000 0003056 Idle_Task
      1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001976 hpwork 0x3fc8bd50 0x3fc8bd80
      2     2 100 RR       Task      - Waiting  Semaphore 0000000000000000 0004048 nsh_main
      3     3 100 RR       Task      - Ready              0000000000000000 0001992 fastbootd
      4     4 100 RR       Task      - Running            0000000000000000 0001992 popen -c ps
  OKAY [  0.010s]
  Finished. Total time: 0.010s

Signed-off-by: wangjianyu3 <[email protected]>
@JianyuWang0623 JianyuWang0623 force-pushed the br_wjy_system_fastboot_add_mkrd_250220 branch from 9727fa3 to 0ce5909 Compare February 24, 2025 14:58
@JianyuWang0623
Copy link
Contributor Author

please add commit message fb4c03f

@jerpelea done, thank you.

+Add support for producing output according to a format like printf().

@jerpelea jerpelea merged commit 536e2cc into apache:master Feb 25, 2025
37 checks passed
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.

[FEATURE] Should we extend fastboot oem to support executing custom commands?
5 participants