#!/bin/sh # # Copyright (C) 2016 Hardkernel Co,. Ltd # Joy Cho # # SPDX-License-Identifier: GPL-2.0+ # # update ddr clock for Ubuntu # if [ -z $1 ]; then echo "Usage ./c2_update_ddrclk.sh " exit 1 fi if [ $1 != 1104 -a $1 != 912 -a $1 != 792 -a $1 != 408 ]; then echo "Wrong DDRCLK! Usage ./c2_update_ddrclk.sh " exit 1 fi DDRCLK=$1 bl1=/tmp/bl1.bin.hardkernel.$DDRCLK tmp=/tmp/temp.bin ##### 1. check the current DDR clock #### dd if=/dev/mmcblk0 of=$tmp bs=1 count=2 skip=43530 status=none CUR_DDRCLK=$(hexdump -e '"%d"' $tmp) if [ $DDRCLK -eq $CUR_DDRCLK ]; then echo "current ddr clk is already set as $DDRCLK MHz" exit 1 fi echo "existing DDR clk is $CUR_DDRCLK" ##### 2. download bl1 binary from dn server #### wget -P /tmp/ http://dn.odroid.com/S905/BootLoader/ODROID-C2/bl1.bin.hardkernel.$DDRCLK if [ ! -f $bl1 ];then echo "error: bl1 binary doesn't exist" exit 1 fi dd if=$bl1 of=/dev/mmcblk0 bs=1 count=442 status=none dd if=$bl1 of=/dev/mmcblk0 bs=512 skip=1 seek=1 status=none echo "Update done!" ##### 3. check the updated DDR clock #### echo "Now let's check if update has been completed..." dd if=/dev/mmcblk0 of=$tmp bs=1 count=2 skip=43530 status=none CUR_DDRCLK=$(hexdump -e '"%d"' $tmp) echo "updated DDR clk is $CUR_DDRCLK" if [ $DDRCLK != $CUR_DDRCLK ]; then echo "updating DDR clock FAIL!! Expected : $DDRCLK, Updated : $CUR_DDRCLK" else echo "updating DDR clock has been completed!!!" fi rm $bl1 rm $tmp