@@ -78,12 +78,15 @@ static struct option long_options[] = {
7878 {"nand-dat1" , required_argument , NULL , 0 },
7979 {"nand-dat2" , required_argument , NULL , 0 },
8080 {"nand-dat3" , required_argument , NULL , 0 },
81+ {"emmc" , no_argument , NULL , 0 },
8182 {"ram" , no_argument , NULL , 'r' },
8283 {"jump" , required_argument , NULL , 0 },
8384 {"chip-id" , no_argument , NULL , 0 },
8485 {"read" , required_argument , NULL , 0 },
8586 {"erase" , required_argument , NULL , 0 },
8687 {"erase-all" , no_argument , NULL , 0 },
88+ {"lock" , no_argument , NULL , 0 },
89+ {"unlock" , no_argument , NULL , 0 },
8790 {"verify" , required_argument , NULL , 0 },
8891 {"verify-all" , no_argument , NULL , 0 },
8992 {"probe-timeout" , required_argument , NULL , 0 },
@@ -163,6 +166,8 @@ static struct {
163166 uint32_t size ;
164167 } erase_parts [MAX_ERASE_PARTS ];
165168 bool erase_all ;
169+ bool lock ;
170+ bool unlock ;
166171 uint16_t verify_count ;
167172 struct {
168173 uint32_t addr ;
@@ -198,6 +203,8 @@ static struct {
198203 .read_count = 0 ,
199204 .erase_count = 0 ,
200205 .erase_all = false,
206+ .lock = false,
207+ .unlock = false,
201208 .verify_count = 0 ,
202209 .verify_all = false,
203210 .probe_timeout = DEFAULT_PROBE_TIMEOUT ,
@@ -298,6 +305,10 @@ print_help(const char *progname)
298305 LOGI (" erase specified flash region" );
299306 LOGI (" --erase-all" );
300307 LOGI (" erase the entire flash" );
308+ LOGI (" --lock" );
309+ LOGI (" lock the flash" );
310+ LOGI (" --unlock" );
311+ LOGI (" unlock the flash" );
301312 LOGI (" --verify <addr:size>" );
302313 LOGI (" verify specified flash region" );
303314 LOGI ("" );
@@ -526,6 +537,12 @@ main(int argc, char **argv)
526537 } else if (strcmp (name , "emmc" ) == 0 ) {
527538 options .target = TARGET_EMMC ;
528539 break ;
540+ } else if (strcmp (name , "lock" ) == 0 ) {
541+ options .lock = true;
542+ break ;
543+ } else if (strcmp (name , "unlock" ) == 0 ) {
544+ options .unlock = true;
545+ break ;
529546 } else {
530547 print_help (argv [0 ]);
531548 return 0 ;
@@ -923,6 +940,13 @@ serial_burn(cskburn_partition_t *parts, int parts_cnt)
923940 LOGI ("Detected eMMC size: %" PRIu64 " MB" , flash_size >> 20 );
924941 }
925942
943+ if (options .unlock ) {
944+ if ((ret = cskburn_serial_unlock (dev , options .target )) != 0 ) {
945+ LOGE_RET (ret , "ERROR: Failed locking device" );
946+ goto err_enter ;
947+ }
948+ }
949+
926950 for (int i = 0 ; i < options .read_count ; i ++ ) {
927951 if (options .read_parts [i ].addr >= flash_size ) {
928952 LOGE ("ERROR: The starting boundary of read address (0x%08X) exceeds the capacity of "
@@ -1107,6 +1131,13 @@ serial_burn(cskburn_partition_t *parts, int parts_cnt)
11071131 }
11081132 }
11091133
1134+ if (options .lock ) {
1135+ if ((ret = cskburn_serial_lock (dev , options .target )) != 0 ) {
1136+ LOGE_RET (ret , "ERROR: Failed unlocking device" );
1137+ goto err_enter ;
1138+ }
1139+ }
1140+
11101141 if (jump_addr ) {
11111142 LOGI ("Jumping to 0x%08X..." , jump_addr );
11121143 } else if (!options .no_reset ) {
0 commit comments