| package main |
| |
| import ( |
| "context" |
| "log" |
| ) |
| |
| var ( |
| fileToPartitionMapping = map[string]string{ |
| "bootloader.img": "tpl", |
| "zedboot.zbi": "zircon_a", |
| "zedboot.vbmeta": "vbmeta_a", |
| } |
| ) |
| |
| // BuildFastbootCmd takes in a serial number and list of image filenames to create |
| // the appropriate fastboot command. |
| func BuildFastbootCmd(ctx context.Context, serialNumber string, filenames []string) []string { |
| fastbootCmd := []string{"fastboot", "-s", serialNumber} |
| |
| for _, f := range filenames { |
| partition := fileToPartitionMapping[f] |
| fastbootCmd = append(fastbootCmd, []string{ |
| "erase", partition, |
| "flash", partition, f, |
| }...) |
| } |
| |
| fastbootCmd = append(fastbootCmd, []string{ |
| "erase", "misc", |
| "--set-active=a", |
| "reboot", |
| }...) |
| log.Printf("constructed fastboot command: %v", fastbootCmd) |
| |
| return fastbootCmd |
| } |