setup_sdcard.sh: move kernel_detection and make it generic

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>