23
23
****************************************************************************/
24
24
25
25
#include <nuttx/config.h>
26
+ #include <nuttx/memoryregion.h>
26
27
#include <nuttx/mtd/mtd.h>
27
28
#include <nuttx/version.h>
28
29
@@ -154,6 +155,8 @@ struct fastboot_cmd_s
154
155
FAR const char * arg );
155
156
};
156
157
158
+ typedef void (* memdump_print_t )(FAR void * , FAR char * );
159
+
157
160
/****************************************************************************
158
161
* Private Function Prototypes
159
162
****************************************************************************/
@@ -209,6 +212,13 @@ static const struct fastboot_cmd_s g_oem_cmd[] =
209
212
#endif
210
213
};
211
214
215
+ #ifdef CONFIG_BOARD_MEMORY_RANGE
216
+ static const struct memory_region_s g_memory_region [] =
217
+ {
218
+ CONFIG_BOARD_MEMORY_RANGE
219
+ };
220
+ #endif
221
+
212
222
/****************************************************************************
213
223
* Private Functions
214
224
****************************************************************************/
@@ -648,6 +658,37 @@ static int fastboot_memdump_upload(FAR struct fastboot_ctx_s *context)
648
658
context -> upload_param .size );
649
659
}
650
660
661
+ static void fastboot_memdump_region (memdump_print_t memprint , FAR void * priv )
662
+ {
663
+ #ifdef CONFIG_BOARD_MEMORY_RANGE
664
+ char response [FASTBOOT_MSG_LEN - 4 ];
665
+ size_t index ;
666
+
667
+ for (index = 0 ; index < nitems (g_memory_region ); index ++ )
668
+ {
669
+ snprintf (response , sizeof (response ),
670
+ "fastboot oem memdump 0x%" PRIxPTR " 0x%" PRIxPTR "\n" ,
671
+ g_memory_region [index ].start ,
672
+ g_memory_region [index ].end - g_memory_region [index ].start );
673
+ memprint (priv , response );
674
+ snprintf (response , sizeof (response ),
675
+ "fastboot get_staged 0x%" PRIxPTR ".bin\n" ,
676
+ g_memory_region [index ].start );
677
+ memprint (priv , response );
678
+ }
679
+ #endif
680
+ }
681
+
682
+ static void fastboot_memdump_syslog (FAR void * priv , FAR char * response )
683
+ {
684
+ fb_err (" %s" , response );
685
+ }
686
+
687
+ static void fastboot_memdump_response (FAR void * priv , FAR char * response )
688
+ {
689
+ fastboot_ack ((FAR struct fastboot_ctx_s * )priv , "TEXT" , response );
690
+ }
691
+
651
692
/* Usage(host):
652
693
* fastboot oem memdump <addr> <size>
653
694
*
@@ -664,6 +705,7 @@ static void fastboot_memdump(FAR struct fastboot_ctx_s *context,
664
705
& context -> upload_param .u .mem .addr ,
665
706
& context -> upload_param .size ) != 2 )
666
707
{
708
+ fastboot_memdump_region (fastboot_memdump_response , context );
667
709
fastboot_fail (context , "Invalid argument" );
668
710
return ;
669
711
}
@@ -1042,6 +1084,8 @@ int main(int argc, FAR char **argv)
1042
1084
if (strcmp (argv [1 ], "-h" ) == 0 )
1043
1085
{
1044
1086
fb_err ("Usage: fastbootd [wait_ms]\n" );
1087
+ fb_err ("\nmemdump: \n" );
1088
+ fastboot_memdump_region (fastboot_memdump_syslog , NULL );
1045
1089
return 0 ;
1046
1090
}
1047
1091
0 commit comments