-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters