Skip to content

Instantly share code, notes, and snippets.

@jagannath-sahoo
Created May 26, 2023 07:30
Show Gist options
  • Save jagannath-sahoo/8d10ccabf93a9039c66dda1486de1f16 to your computer and use it in GitHub Desktop.
Save jagannath-sahoo/8d10ccabf93a9039c66dda1486de1f16 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the current time
current_time=$(date +"%Y-%m-%d %H:%M:%S")
# Get the address range from the user
start_address=$1
end_address=$2
# Check if the address range is valid
if [[ $start_address -gt $end_address ]]; then
echo "The start address must be less than or equal to the end address."
exit 1
fi
# Open the /dev/mem device
devmem_fd=$(open /dev/mem)
# Check if the device was opened successfully
if [[ $devmem_fd -ne -1 ]]; then
# Loop over the range of registers to read
for address in $(seq $start_address $end_address); do
# Read the value of the register
value=$(cat /dev/mem$address)
# Print the address and value in hexadecimal format
printf "%08x %08x\n" $address $value
done
# Close the device
close $devmem_fd
else
echo "Unable to open /dev/mem"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment