mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Wrote a script that can take hexadecimal bytes from a file and write them to an output file and an sd card.
This commit is contained in:
		
							parent
							
								
									c197d4a3c6
								
							
						
					
					
						commit
						2a8e213f20
					
				
							
								
								
									
										43
									
								
								linux/sdcard/write-bytes.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								linux/sdcard/write-bytes.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# This file writes a bunch of bytes to the flash card based on a text
 | 
				
			||||||
 | 
					# file input with bytes written in hexadecimal.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					INPUTFILE=""
 | 
				
			||||||
 | 
					OUTPUTFILE=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ARGS=()
 | 
				
			||||||
 | 
					while [ $OPTIND -le "$#" ] ; do
 | 
				
			||||||
 | 
					    if getopts "hi:o:" arg ; then
 | 
				
			||||||
 | 
					        case "${arg}" in
 | 
				
			||||||
 | 
					            h) help
 | 
				
			||||||
 | 
					               ;;
 | 
				
			||||||
 | 
					            i) INPUTFILE=${OPTARG}
 | 
				
			||||||
 | 
					               ;;
 | 
				
			||||||
 | 
					            o) OUTPUTFILE=${OPTARG}
 | 
				
			||||||
 | 
					               ;;
 | 
				
			||||||
 | 
					        esac
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        ARGS+=("${!OPTIND}")
 | 
				
			||||||
 | 
					        ((OPTIND++))
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SDCARD=${ARGS[0]}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ ! -e $INPUTFILE ] ; then
 | 
				
			||||||
 | 
					    echo -e "Error: Input file $INPUTFILE does not exist."
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ -e $OUTPUTFILE ] ; then
 | 
				
			||||||
 | 
					    echo -e "Error: Output file $OUTPUTFILE already exists."
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for word in $(cat "$INPUTFILE")
 | 
				
			||||||
 | 
					do
 | 
				
			||||||
 | 
					    echo -en "\x$word" >> $OUTPUTFILE
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dd if=$OUTPUTFILE of="$SDCARD"
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user