| 1042 | } |
| 1043 | |
| 1044 | func 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 | |
| 1070 | func flashHexUsingMSD(volumes []string, tmppath string, options *compileopts.Options) error { |
| 1071 | for start := time.Now(); time.Since(start) < options.Timeout; { |