Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Add our own copy.exe binary so that we can copy without cmd.exe #65

Merged
merged 1 commit into from
Oct 27, 2016

Conversation

calvinatintel
Copy link
Contributor


// Make sure there are only two arguments
if len(args) != 2 {
log.Fatal("copy.exe <source> <destination>")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use os.Args[0] instead of hardcoding copy.exe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. It's not even called copy.exe anymore.


func exit_if_error(err error) {
if err != nil {
log.Fatal("ERROR:", err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for using log.* functions for errors, instead of just fmt.Printf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Fatal is fmt.Print followed by os.Exit(1)
https://golang.org/pkg/log/#Fatal

defer source_file.Close()

// Make sure we can create the destination file
destination_file, err := os.Create(destination_path)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're creating an empty version of the dest. file in order to check if you can access that path? is there a cleaner way to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It creates to get a file handle, so that io.Copy() can use it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough

@calvinatintel
Copy link
Contributor Author

@facchinm and everyone, please test.

  1. Install vanilla 1.0.7
  2. Replace the content of Arduino15\packages\Intel\tools\arduino101load\1.6.9+1.28 with this
  3. Replace Arduino15\packages\Intel\hardware\arc32\1.0.7\platform.txt with this
  4. Turn on verbose mode on compilation
  5. Compile

At the end of the compilation, you should see this.

Linking everything together...
"C:\Users\scpark\AppData\Local\Arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1/bin/arc-elf32-gcc" -nostartfiles -nodefaultlibs -nostdlib -static -Wl,-X -Wl,-N -Wl,-mcpu=quarkse_em -Wl,-marcelf -Wl,--gc-sections "-TC:\Users\scpark\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\variants\arduino_101/linker_scripts/flash.ld" "-Wl,-Map,C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.map"  -o "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.elf" "-LC:\Users\scpark\AppData\Local\Temp\arduino_build_129492" "-LC:\Users\scpark\AppData\Local\Arduino15\packages\Intel\hardware\arc32\1.0.7\variants\arduino_101" -Wl,--whole-archive "-larc32drv_arduino101" -Wl,--no-whole-archive -Wl,--start-group "-larc32drv_arduino101" -lnsim -lc -lm -lgcc "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\sketch\Blink.ino.cpp.o" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\core\variant.cpp.o" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/core\core.a"
C:\Users\scpark\AppData\Local\Arduino15\packages\Intel\tools\arduino101load\1.6.9+1.28/arduino101load/arduino101copy.exe "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\Blink.ino.elf" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\..\arduino101_sketch.debug.elf"
2016/10/24 17:09:34 C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\Blink.ino.elf copied to C:\Users\scpark\AppData\Local\Temp\arduino_build_129492\..\arduino101_sketch.debug.elf
"C:\Users\scpark\AppData\Local\Arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1/bin/arc-elf32-objcopy" -S -O binary -R .note -R .comment -R COMMON -R .eh_frame  "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.elf" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.bin"
"C:\Users\scpark\AppData\Local\Arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1/bin/arc-elf32-strip" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.elf"
"C:\Users\scpark\AppData\Local\Arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1/bin/arc-elf32-objcopy" -S -O ihex -R .note -R .comment -R COMMON -R .eh_frame  "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.elf" "C:\Users\scpark\AppData\Local\Temp\arduino_build_129492/Blink.ino.hex"

The line that starts with the date shows that the copy was successful.

@facchinm
Copy link

It works perfectly! Only a couple of suggestions:

  • use fmt instead than log to avoid printing the date
  • accept a verbose flag to avoid printing anything if verbose is not set
  • we can avoid shipping the additional binary if we call arduino101load with a copy flag

Anyway, that's perfectly fine to leave it as is 😄

@calvinatintel
Copy link
Contributor Author

Thanks @facchinm I'll make those changes. I would prefer to keep arduino101load separate from arduino101copy if you're okay with that.

@eriknyquist
Copy link

@calvinatintel I haven't tested yet, but let me know when you make those changes and I'll test after

@calvinatintel
Copy link
Contributor Author

log.Printf() was printing to stderr for some reason which ignored the verbose flag. I've replaced it with fmt.Printf() and now it respects the verbose flag on the settings. I've left the others to log.Fatal() since those are actually error conditions.

@facchinm What do you think?
@eriknyquist Please test

Copy link

@eriknyquist eriknyquist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows 7, works well.

@calvinatintel calvinatintel merged commit 11d044c into intel:windows Oct 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants