In case you have undergone a recovery procedure, your current MAC-address is likely to differ from the original one. This How-To describes a way to change it.
Since I released modified tools v2, there're two ways to do it:
i) On mbwe-bluering, using modified fw_setenv (requires less, dare to say none, linux skills)
ii) Using a hexeditor on your PC linux box (requires more knowledge)
Method 1
0. Connect to your NIC via ssh, make sure you're root, make a backup of your bootsector in case you mess smth up:
# su -
# dd if=/dev/sda of=fullbootloader bs=512 count=10796
and store fullbootsect image somewhere safe
1. cd to /root/src:
# mkdir -p /root/src
# cd /root/src
2. Download and unpack the u-boot fw_printenv utility that I slightly modified to fit our needs:
# wget http://mybookworld.wikidot.com/local--files/how-to-change-your-mbwe-bluering-mac-address/uboot-env.v2.arm.tar.gz
# tar -xzvf uboot-env.v2.arm.tar.gz
3. Install pre-compiled binary:
# cd uboot-env.v2
# make install
or
Compile the binary yourself (requires gcc, mtd headers and zlib header):
# # first, install gcc in case you don't have it already: e.g., `ipkg install gcc` - if you have optware installed
# wget http://mybookworld.wikidot.com/local--files/how-to-change-your-mbwe-bluering-mac-address/mtd-headers.tar.gz http://mybookworld.wikidot.com/local--files/how-to-change-your-mbwe-bluering-mac-address/zlib-header.tar.gz
# tar -C /usr/include -xzvf mtd-headers.tar.gz
# tar -C /usr/include -xzvf zlib-header.tar.gz
# cd uboot-env.v2
# make clean
# make
# make install
4. Edit /etc/fw_env.config
# sed -i -e "s|/dev/loop0|/dev/sda|" /etc/fw_env.config
5. Print your current bootloader settings:
# fw_printenv
The output should look like this:
Valid CRC is 43E890A4
The bytes should be: A4 90 E8 43
bootcmd=run select0 load boot || run select1 load boot
bootdelay=2
baudrate=115200
ethaddr=00:30:e0:00:00:01
ipaddr=172.31.0.128
serverip=172.31.0.100
autoload=n
netmask=255.255.0.0
bootfile="uImage"
select0=ide dev 0
select1=ide dev 1
load=ide read 0x48500000 12c 1644
boot=bootm 48500000
stdin=serial
stdout=serial
stderr=serial
bootargs=mem=32M console=ttyS0,115200 root=/dev/md1 netdev=0,0,0x0090A978,0x32D1,eth0
If you get a 'Bad CRC' error, this means that eather /etc/fw_env.config is somehow wrong, or your current checksum doesn't match the valid one (have you already tried to change the mac-address?).
Take a look at printed variables. Your MAC address is set here:
bootargs=mem=32M console=ttyS0,115200 root=/dev/md1 netdev=0,0,0x0090A978,0x32D1,eth0
What we need is to set it right to match your desired address. This brings us to step 5.
6. Change your mac-address:
# fw_setenv bootargs mem=32M console=ttyS0,115200 root=/dev/md1 netdev=0,0,0x********,0x****,eth0|dd bs=512 seek=47 of=/dev/sda
where
************
is your desired address.
(6.5)If you have a 2-drive box:
# fw_setenv bootargs mem=32M console=ttyS0,115200 root=/dev/md1 netdev=0,0,0x********,0x****,eth0|dd bs=512 seek=47 of=/dev/sdb
7. Check whether it's right:
# fw_printenv
That's it, peace of cake, right? ;)
Method 2
You'll need a linux distro, so unless you have one installed already, I suggest using Ubuntu liveCD.
Ok, let's get down to business.
All the commands should be issued using terminal ("Applications->Accessories->Terminal" in Ubuntu)
1. You'll need super-user privileges, so:
# su
##or `sudo su` if you're using Ubuntu liveCD
# cd ~
##you may use some other working directory if you feel like
2. Get your mbwe drive(s) out of the box and connect it to your PC (directly or using a SATA-to-USB suite). In case you have a two-drive unit, drive A will do (well, unless you've messed up your boot sector somehow).
I'll reference the drive as /dev/sd* for convinience sake, so change /dev/sd* to name of the drive you've connected. If you're unsure what it is, use gparted ("System->Administration->Partition Editor") or some other partition editor to look through all your drives.
3. Get your bootsector image:
# dd if=/dev/sd* of=fullbootsect bs=512 count=10796
(3.5.) If loop was compiled as a kernel module, you may need to insert it:
# modprobe loop
4. Setup a loop:
# losetup /dev/loop0 fullbootsect
5. Download and unpack the u-boot fw_printenv utility that I slightly modified to fit our needs:
# wget http://mybookworld.wikidot.com/local--files/how-to-change-your-mbwe-bluering-mac-address/uboot-env.v2.i386.tar.gz
# tar -xzvf uboot-env.v2.i386.tar.gz
6. Install pre-compiled i-386 binary:
# cd uboot-env.v2
# make install
or
Compile the binary yourself:
# cd uboot-env.v2
# make clean
# make
# make install
7. Make a check to see if all's fine:
# fw_printenv
The output should look like this:
Valid CRC is 43E890A4
The bytes should be: A4 90 E8 43
bootcmd=run select0 load boot || run select1 load boot
bootdelay=2
baudrate=115200
ethaddr=00:30:e0:00:00:01
ipaddr=172.31.0.128
serverip=172.31.0.100
autoload=n
netmask=255.255.0.0
bootfile="uImage"
select0=ide dev 0
select1=ide dev 1
load=ide read 0x48500000 12c 1644
boot=bootm 48500000
stdin=serial
stdout=serial
stderr=serial
bootargs=mem=32M console=ttyS0,115200 root=/dev/md1 netdev=0,0,0x0090A978,0x32D1,eth0
If you get a 'Bad CRC' error, this means that eather the loop isn't set up right, or your current checksum doesn't match the valid one (have you already tried to change the mac-address?)
8. Get yourself some decent hex-editor.
I used ghex:
# apt-get install ghex
##for Debian or Ubuntu
9. Edit the fullbootsect image:
# cd ..
# ghex2 fullbootsect
##or <your_hex_editor> fullbootsect
Lookup "netdev=" string and change "netdev=*" to "netdev=0,0,0xXXXXXXXX,0xXXXX,eth0", where "XXXXXXXXXXXX" stands for the mac-address you'd like your mybook to have, e.g., "netdev=0,0,0x0090A99A,0xBCDE,eth0" for mac-address 00:90:A9:9A:BC:DE.
Save changes and close the hexeditor.
10. Run fw_printenv to get the checksum bytes:
# fw_printenv
You'll get something like:
Valid CRC is 6940028B
The bytes should be: 8B 2 40 69
Warning: Bad CRC, using default environment
Perhaps, your /etc/fw_env.config is wrong?
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=$(serverip):$(rootpath) ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; bootm
bootdelay=5
baudrate=115200
Where "8B 2 40 69" are the valid crc bytes we'll write to the image.
11. Edit the fullbootsect image again to fix the CRC:
# ghex2 fullbootsect
##or <your_hex_editor> fullbootsect
This time look for "bootcmd=". The 4 bytes right before this string compose the checksum. Change them to the valid values (here, "8B 02 40 69").
Save and close the editor - and you have the desired bootsector image (run ‘fw_printenv` to make sure it’s right). What's left now is to write it back to your drive(s):
12.
# dd if=fullbootsect of=/dev/sd*
and unplug the drive
(12.5.) For those, who own a two-drive box.
Connect drive B (/dev/sd**) and copy the image the same way you did with drive A:
# dd if=fullbootsect of=/dev/sd**
and unplug it as well.
13. Clean up the loop:
# losetup -d /dev/loop0
That's it, plug drive(s) back and don't forget to store fullbootsect image somewhere safe in case you'll need to undergo a recovery again.
Troubleshooting
Unless you use some old linux distro, you're likely to have this error while trying to compile the binary:
fw_env.c:34:27: error: linux/mtd/mtd.h: No such file or directory
To fix it, issue:
# ln -s /usr/include/mtd /usr/include/linux/mtd
# ln -s /usr/include/linux/mtd/mtd-user.h /usr/include/linux/mtd/mtd.h
Have fun,
Alex