Update Simulate IOT authored by Miao Pang's avatar Miao Pang
...@@ -16,7 +16,7 @@ Install some dependent tools: ...@@ -16,7 +16,7 @@ Install some dependent tools:
Install ninja: Install ninja:
`apt install re2c `apt install re2c`
`git clone git://github.com/ninja-build/ninja.git && cd ninja` `git clone git://github.com/ninja-build/ninja.git && cd ninja`
...@@ -41,40 +41,44 @@ Using a pre-compiled Debian MIPS kernel with a MIPS QCOW2 file system image, boo ...@@ -41,40 +41,44 @@ Using a pre-compiled Debian MIPS kernel with a MIPS QCOW2 file system image, boo
1.Getting squashfs root 1.Getting squashfs root
Download the firmware from the internet and extracting the device firewre with binwalk. Download the firmware from the internet and extracting the device firewre with binwalk.
`sudo apt-get -y install unzip` `sudo apt-get -y install unzip`
`unzip DIR-850L_REVA_FIRMWARE_1.00.B07.ZIP` `unzip DIR-850L_REVA_FIRMWARE_1.00.B07.ZIP`
`binwalk -e DIR850LA1_FW114WWb07.bin` `binwalk -e DIR850LA1_FW114WWb07.bin`
2.Getting a kernal and file system image 2.Getting a kernal and file system image
'mkdir linux_mips; cd linux_mips' 'mkdir linux_mips; cd linux_mips'
'wget https://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-4kc-malta' 'wget https://people.debian.org/~aurel32/qemu/mips/vmlinux-3.2.0-4-4kc-malta'
`wget https://people.debian.org/~aurel32/qemu/mips/debian_wheezy_mips_standard.qcow2` `wget https://people.debian.org/~aurel32/qemu/mips/debian_wheezy_mips_standard.qcow2`
3.Booting the vm 3.Booting the vm
`qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda debian_wheezy_mips_standard.qcow2 -append "root=/dev/sda1" -nographic -net nic -net user,id=tcp,hostfwd=tcp::5022-:22,hostfwd=tcp:5023:23,hostfwd=tcp:48101:48101`
`qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda debian_wheezy_mips_standard.qcow2 -append "root=/dev/sda1" -nographic -net nic -net user,id=tcp,hostfwd=tcp::5022-:22,hostfwd=tcp:5023:23,hostfwd=tcp:48101:48101`
4.Copying the squashfs root 4.Copying the squashfs root
ensure that the sshd is running inside the MIPS VM: ensure that the sshd is running inside the MIPS VM:
`root@debian-mips:~# service ssh start; service ssh status `root@debian-mips:~# service ssh start; service ssh status`
Starting OpenBSD Secure Shell server: sshd.
sshd is running. `Starting OpenBSD Secure Shell server: sshd.`
root@debian-mips:~#` `sshd is running.`
`root@debian-mips:~#`
back on the host OS, tar up the contents of the squashfs root and copy it into the guest VM: back on the host OS, tar up the contents of the squashfs root and copy it into the guest VM:
$ tar zcf squashfs-root.tar.gz squashfs-root/ `$ tar zcf squashfs-root.tar.gz squashfs-root/`
$ scp -P 2222 ./squashfs-root.tar.gz root@127.0.0.1:/root `$ scp -P 2222 ./squashfs-root.tar.gz root@127.0.0.1:/root`
extract the tarball on the guest MIPS VM: extract the tarball on the guest MIPS VM:
root@debian-mips:~# ls `root@debian-mips:~# ls`
squashfs-root.tar.gz `squashfs-root.tar.gz`
root@debian-mips:~# tar zxf squashfs-root.tar.gz `root@debian-mips:~# tar zxf squashfs-root.tar.gz`
root@debian-mips:~# `root@debian-mips:~#`
Inatll /proc,/dev and /sys and use chroot to enter the firmware file system: Inatll /proc,/dev and /sys and use chroot to enter the firmware file system:
![image](uploads/7550d24729626f680eca7c1e7d764e6e/image.png) ![image](uploads/7550d24729626f680eca7c1e7d764e6e/image.png)
...@@ -82,4 +86,4 @@ Inatll /proc,/dev and /sys and use chroot to enter the firmware file system: ...@@ -82,4 +86,4 @@ Inatll /proc,/dev and /sys and use chroot to enter the firmware file system:
5.Starting the device's service 5.Starting the device's service
Most embedded Linux devices have startup scripts in /etc/init.d/ that will launch services and perform configuration. Most embedded Linux devices have startup scripts in /etc/init.d/ that will launch services and perform configuration.
# `/etc/init.d/rcS` `#/etc/init.d/rcS`