Hi ,
From morning I was searching how to hide my C-code in arduino .
So here are my findings and procedure of how to do it .
Compile your C/C++ code using below command use .o object file and share this .o with user's ( something like a encrypted library )
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware\arduino\cores\arduino -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware\arduino\variants\standard -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\libraries\IRremote C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp -o Nataraja/my_object_file.o
After sharing it the second user , can use the below commands to compile his code with the above object file
generate hex file and upload the same using arduino hardware no changes .
1) add the object file with core.a .
avr-ar rcs C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\core.a Nataraja/my_object_file.o
2) use the above core.a to compiler and link
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\IRremote\IRremote.cpp.o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\core.a -LC:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp -lm
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.eep
avr-objcopy -O ihex -R .eeprom C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.hex
3) Burn the generated .hex file using avrdude .
avrdude -CE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v2 -Pusb -Uflash:w:C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.hex:i
Note : all the above paths and file are envinornment dependant , if you find any difficulties email me
From morning I was searching how to hide my C-code in arduino .
So here are my findings and procedure of how to do it .
Compile your C/C++ code using below command use .o object file and share this .o with user's ( something like a encrypted library )
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware\arduino\cores\arduino -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware\arduino\variants\standard -IE:\Desktop_cleanup-9-10-12\arduino-1.0.1\libraries\IRremote C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp -o Nataraja/my_object_file.o
After sharing it the second user , can use the below commands to compile his code with the above object file
generate hex file and upload the same using arduino hardware no changes .
1) add the object file with core.a .
avr-ar rcs C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\core.a Nataraja/my_object_file.o
2) use the above core.a to compiler and link
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\IRremote\IRremote.cpp.o C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\core.a -LC:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp -lm
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.eep
avr-objcopy -O ihex -R .eeprom C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.elf C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.hex
3) Burn the generated .hex file using avrdude .
avrdude -CE:\Desktop_cleanup-9-10-12\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v2 -Pusb -Uflash:w:C:\Users\asus\AppData\Local\Temp\build7501873918899353597.tmp\sketch_jul21a.cpp.hex:i
Note : all the above paths and file are envinornment dependant , if you find any difficulties email me