You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/11 15:21:03 UTC
(nuttx-apps) 08/17: fastbootd:add delay ms for bootloader
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 53563b67e721356234549ab74a24cccae962dd9b
Author: anjiahao <an...@xiaomi.com>
AuthorDate: Mon Dec 25 15:23:33 2023 +0800
fastbootd:add delay ms for bootloader
usage in bootloader
if [flag == bootloader]
fastbootd
else
fastbootd 500
fi
host:
$fastboot flash app app.bin
< waiting for any device >
let board enter booloader,use <reboot bootloader> or hard reset
then will flash it.
Signed-off-by: anjiahao <an...@xiaomi.com>
---
system/fastboot/fastboot.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c
index a74ba5b36..203b7a1a1 100644
--- a/system/fastboot/fastboot.c
+++ b/system/fastboot/fastboot.c
@@ -41,6 +41,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/types.h>
+#include <sys/poll.h>
/****************************************************************************
* Pre-processor Definitions
@@ -112,6 +113,7 @@ struct fastboot_ctx_s
size_t download_size;
size_t download_offset;
size_t total_imgsize;
+ int wait_ms;
FAR void *download_buffer;
FAR struct fastboot_var_s *varlist;
};
@@ -576,6 +578,19 @@ static void fastboot_reboot_bootloader(FAR struct fastboot_ctx_s *context,
static void fastboot_command_loop(FAR struct fastboot_ctx_s *context)
{
+ if (context->wait_ms > 0)
+ {
+ struct pollfd fds[1];
+
+ fds[0].fd = context->usbdev_in;
+ fds[0].events = POLLIN;
+
+ if (poll(fds, 1, context->wait_ms) <= 0)
+ {
+ return;
+ }
+ }
+
while (1)
{
char buffer[FASTBOOT_MSG_LEN];
@@ -698,6 +713,21 @@ int main(int argc, FAR char **argv)
}
#endif /* FASTBOOTD_USB_BOARDCTL */
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "-h") == 0)
+ {
+ printf("Usage: fastbootd [wait_ms]\n");
+ return 0;
+ }
+
+ context.wait_ms = atoi(argv[1]);
+ }
+ else
+ {
+ context.wait_ms = 0;
+ }
+
buffer = malloc(CONFIG_SYSTEM_FASTBOOTD_DOWNLOAD_MAX);
if (buffer == NULL)
{