How can a use 2boots to load hex file from sd card?
One line question with almost no detail ?
Let me guess that you want to boot the board then let the board to load a sketch from the SD card and run that instead of the original sketch which will be wiped out when a new sketch is loaded on an unknown board ?
Would that be correct ?
You're going to need to be much more specific in your question. You will find some fairly comprehensive instructions here: https://github.com/thseiler/embedded/tree/master/avr/2boots so spend some time working with that and then if you get stuck come back here to see if someone can help you with the specific problem you're having.
If you want a much more beginner friendly SD bootloader, check out avr_boot: https://github.com/zevero/avr_boot Unlike 2boots, it has full Arduino IDE support so you can install it using Boards Manager by just adding a URL to your preferences. Arduino IDE installation instructions are found here: https://github.com/zevero/avr_boot/tree/gh-pages I think between the two links I posted above everything you need to get avr_boot working is very well documented. Unfortunately avr_boot is in some ways inferior to 2boots in that it doesn't currently support standard uploading over serial (the work has been done to add this but the repository owner has not merged it yet), and requires a larger boot section. It also doesn't support ATmega2560 (though supposedly that has also been figured out). I'm not sure whether 2boots supports ATmega2560 or not since I haven't even tried that one.