MCPcopy
hub / github.com/tinygo-org/tinygo / flashUF2UsingMSD

Function flashUF2UsingMSD

main.go:1044–1068  ·  view source on GitHub ↗
(volumes []string, tmppath string, options *compileopts.Options)

Source from the content-addressed store, hash-verified

1042}
1043
1044func flashUF2UsingMSD(volumes []string, tmppath string, options *compileopts.Options) error {
1045 for start := time.Now(); time.Since(start) < options.Timeout; {
1046 // Find a UF2 mount point.
1047 mounts, err := findFATMounts(options)
1048 if err != nil {
1049 return err
1050 }
1051 for _, mount := range mounts {
1052 for _, volume := range volumes {
1053 if mount.name != volume {
1054 continue
1055 }
1056 if _, err := os.Stat(filepath.Join(mount.path, "INFO_UF2.TXT")); err != nil {
1057 // No INFO_UF2.TXT found, which is expected on a UF2
1058 // filesystem.
1059 continue
1060 }
1061 // Found the filesystem, so flash the device!
1062 return moveFile(tmppath, filepath.Join(mount.path, "flash.uf2"))
1063 }
1064 }
1065 time.Sleep(500 * time.Millisecond)
1066 }
1067 return errors.New("unable to locate any volume: [" + strings.Join(volumes, ",") + "]")
1068}
1069
1070func flashHexUsingMSD(volumes []string, tmppath string, options *compileopts.Options) error {
1071 for start := time.Now(); time.Since(start) < options.Timeout; {

Callers 1

FlashFunction · 0.85

Calls 5

findFATMountsFunction · 0.85
moveFileFunction · 0.85
NowMethod · 0.80
SleepMethod · 0.65
StatMethod · 0.45

Tested by

no test coverage detected