Where can I find out how to make a hex file for arduino firmware?
The HEX file is simply a translated version of the AVR executable, which is in turn a translated version of AVR source code.

There are many tools available for turning (compiling) AVR source code into an AVR executable, including but not limited to the Arduino IDE, Ino, AVR-GCC, and Atmel Studio. Note that all four tools will compile the code the same way, since AVR-GCC is used under the hood by the other three.

avr-g++ -mmcu=atmega328 source.cc -o executable


Once you've compiled the code, you can use avr-objcopy to extract the appropriate sections from the executable into HEX files for programming into the flash and EEPROM.

avr-objcopy -j .text -j .data -O ihex executable executable.hex


You can then use AVRDUDE to upload the various HEX files to the target device.

avrdude -c arduino -P /dev/ttyUSB0 -b 19200 -p m328 -U flash:w:executable.hex:i


Note that the USB libraries in Arduino/Ino and AVR LibC are limited; you will need to use Atmel Studio if you want full USB capabilities.