Exporting compiled binary not exporting sketch properly

Hi all,

I am making a custom board and was trying to use the exported binaries when I noticed, the binary with the bootloader (ExtruderPSICONTROL.ino.with_bootloader.hex in this case) does not contain the program I made, it only contains the bootloader.

The chip I am developing for is the atmega32u4. If possible I would rather not paste sketch, as it is made for a company.

Thanks for any potential help,
Carter.

Files and info below:

Verbose output while compiling:

FQBN: arduino:avr:leonardo
Using board 'leonardo' from platform in folder: C:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\GG\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\sketch\ExtruderPSICONTROL.ino.cpp -o nul
Alternatives for functions.h: [CartersFunc@1.0.0]
ResolveLibrary(functions.h)
  -> candidates: [CartersFunc@1.0.0]
C:\Users\GG\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\sketch\ExtruderPSICONTROL.ino.cpp -o nul
Alternatives for SevSeg.h: [SevSeg@3.7.0]
ResolveLibrary(SevSeg.h)
  -> candidates: [SevSeg@3.7.0]
C:\Users\GG\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\SevSeg C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\sketch\ExtruderPSICONTROL.ino.cpp -o nul
Alternatives for EEPROM.h: [EEPROM@2.0]
ResolveLibrary(EEPROM.h)
  -> candidates: [EEPROM@2.0]
C:\Users\GG\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\SevSeg -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\sketch\ExtruderPSICONTROL.ino.cpp -o nul
Using cached library dependencies for file: C:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc\functions.cpp
Using cached library dependencies for file: C:\Users\GG\OneDrive\Documents\Arduino\libraries\SevSeg\SevSeg.cpp
Generating function prototypes...
C:\Users\GG\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\leonardo -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc -IC:\Users\GG\OneDrive\Documents\Arduino\libraries\SevSeg -IC:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM\src C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\sketch\ExtruderPSICONTROL.ino.cpp -o C:\Users\GG\AppData\Local\Temp\557779083\sketch_merged.cpp
C:\Users\GG\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\GG\AppData\Local\Temp\557779083\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8036 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"Arduino Leonardo\"" "-IC:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\leonardo" "-IC:\\Users\\GG\\OneDrive\\Documents\\Arduino\\libraries\\CartersFunc" "-IC:\\Users\\GG\\OneDrive\\Documents\\Arduino\\libraries\\SevSeg" "-IC:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\libraries\\EEPROM\\src" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3\\sketch\\ExtruderPSICONTROL.ino.cpp" -o "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3\\sketch\\ExtruderPSICONTROL.ino.cpp.o"
Compiling libraries...
Compiling library "CartersFunc"
Using previously compiled file: C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\libraries\CartersFunc\functions.cpp.o
Compiling library "SevSeg"
Using previously compiled file: C:\Users\GG\AppData\Local\arduino\sketches\CEDB5789CFED8CCAFE1AEB67D28F75C3\libraries\SevSeg\SevSeg.cpp.o
Compiling library "EEPROM"
Compiling core...
Using precompiled core: C:\Users\GG\AppData\Local\arduino\cores\arduino_avr_leonardo_6422f678ae1166e036ea66191b5e59b8\core.a
Linking everything together...
"C:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega32u4 -o "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.elf" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3\\sketch\\ExtruderPSICONTROL.ino.cpp.o" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3\\libraries\\CartersFunc\\functions.cpp.o" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3\\libraries\\SevSeg\\SevSeg.cpp.o" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/..\\..\\cores\\arduino_avr_leonardo_6422f678ae1166e036ea66191b5e59b8\\core.a" "-LC:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3" -lm
"C:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.elf" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.eep"
"C:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.elf" "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.hex"

Using library CartersFunc at version 1.0.0 in folder: C:\Users\GG\OneDrive\Documents\Arduino\libraries\CartersFunc 
Using library SevSeg at version 3.7.0 in folder: C:\Users\GG\OneDrive\Documents\Arduino\libraries\SevSeg 
Using library EEPROM at version 2.0 in folder: C:\Users\GG\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\EEPROM 
"C:\\Users\\GG\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\GG\\AppData\\Local\\arduino\\sketches\\CEDB5789CFED8CCAFE1AEB67D28F75C3/ExtruderPSICONTROL.ino.elf"
Sketch uses 13522 bytes (47%) of program storage space. Maximum is 28672 bytes.
Global variables use 892 bytes (34%) of dynamic memory, leaving 1668 bytes for local variables. Maximum is 2560 bytes.

Bootloader for comparison

Pastebin with ExtruderPSICONTROL.ino.with_bootloader.hex

Pastebin with ExtruderPSICONTROL.ino.hex

Do you have the same problem with any sketch? Even a minimal one with empty setup() and loop() functions?

Just tested with both a completely empty as well as a simple hello world sketch, all exported binaries with the bootloader match when compared.

Don't know what that means. Is it the result you want?

No, the files should be contain: The bootloader at adresses 0x0000-0x12c0 and at 0x7000-7fff, and then it should also contain the program, I would assume starting somewhere after 0x12c0, however it does not contain anything other than FFFF, which is expected if there were not any code to run, but there should definitely be code there. Half of the binary should be filled up, looking at the output from when it compiled.

Did you tried to test the code running (say, "Hello world" output) rather than reverse engineering a bytes in binary file?

Yes, that is what started the investigation.

SOULTION FOUND:
After a little more digging online, I found this post on the forum. The solution was to build for SparkFuns Pro Micro board, now the program is in memory and I can get debug info from the usb port.

See Several 32u4 boards missing noblink firmware · Issue #411 · arduino/ArduinoCore-avr · GitHub.

~Yes, no matter what was selected as the sketch, the bootloader was the only code in the binary.

Oops, email showed me the wrong message, but that github issue sounds exactly like what was happening, uploaded code would only blink out of Port.C7, and hold an led connected to either Port.B0 or Port.D5.