diff --git a/cmd/flashWrite.go b/cmd/flashWrite.go new file mode 100644 index 0000000..b8ebe72 --- /dev/null +++ b/cmd/flashWrite.go @@ -0,0 +1,41 @@ +package cmd + +import ( + "encoding/binary" + "encoding/hex" + "fmt" + "os" + + "github.com/spf13/cobra" +) + +func init() { + flashWriteCmd.Flags().StringVarP(&memAddress, "address", "a", "", "memory address to begin writing") + flashWriteCmd.Flags().StringVarP(&writeData, "data", "d", "", "data to write in hex") + rootCmd.AddCommand(flashWriteCmd) +} + +// Data to write to device +var writeData string + +var flashWriteCmd = &cobra.Command{ + Use: "flashWrite", + Short: "Write data over flash sectors", + Long: "Writes data over flash sectors", + Run: func(cmd *cobra.Command, args []string) { + + // data to write + data := mustParseHex(writeData) + + // Convert hex address to uint32 + addr := binary.BigEndian.Uint32(mustParseHex(memAddress)) + + resp, err := kk.FlashWrite(addr, data) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + fmt.Println(hex.EncodeToString(resp)) + }, +} diff --git a/pkg/keepkey/input.go b/pkg/keepkey/input.go index 845ac1a..3f6c732 100644 --- a/pkg/keepkey/input.go +++ b/pkg/keepkey/input.go @@ -44,6 +44,7 @@ func promptPin() (string, error) { prompt := promptui.Prompt{ Label: "Pin", Validate: validate, + Mask: '*', } res, err := prompt.Run() if err != nil {