Update Simulate IOT authored by Miao Pang's avatar Miao Pang
......@@ -8,7 +8,6 @@ Download qemu with wget:
`tar xvJf qemu-5.2.0.tar.xz`
`cd qemu-5.2.0`
Install some dependent tools:
......@@ -28,12 +27,19 @@ Install ninja:
Install qemu;
`cd qemu-5.2.0`
`./configure`
`Make`
`Make install`
The screenshots after successful installation:
![image](uploads/5ab326b031e55f88757e43a104a2738d/image.png)
**Use System emulation to simulate the Router D_Link 850L**
For QEMU in system mode, we need to provide the emulator with a file system image and a kernel to use in the boot process.
......@@ -49,6 +55,8 @@ Download the firmware from the internet and extracting the device firewre with b
`binwalk -e DIR850LA1_FW114WWb07.bin`
![image](uploads/12159471ac7988b77ce871ff8e92cbc4/image.png)
2.Getting a kernal and file system image
`mkdir linux_mips; cd linux_mips`
......@@ -57,10 +65,13 @@ Download the firmware from the internet and extracting the device firewre with b
`wget https://people.debian.org/~aurel32/qemu/mips/debian_wheezy_mips_standard.qcow2`
![image](uploads/faad2618ac372c9ac70a1167661284a6/image.png)
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`
![image](uploads/64f1fa5de7864888c2cce113da1f4944/image.png)
4.Copying the squashfs root
......@@ -68,34 +79,28 @@ ensure that the sshd is running inside the MIPS VM:
`root@debian-mips:~# service ssh start; service ssh status`
`Starting OpenBSD Secure Shell server: sshd.`
`sshd is running.`
`root@debian-mips:~#`
![image](uploads/01027fd5a83c1577e6d68a7754ecb9a8/image.png)
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/`
`$ scp -P 2222 ./squashfs-root.tar.gz root@127.0.0.1:/root`
`$ scp -P 5022 ./squashfs-root.tar.gz root@127.0.0.1:/root`
![image](uploads/f49770cadd5ea48046fe7eb599a16d4d/image.png)
extract the tarball on the guest MIPS VM:
`root@debian-mips:~# ls`
`squashfs-root.tar.gz`
`root@debian-mips:~# tar zxf squashfs-root.tar.gz`
`root@debian-mips:~#`
`root@debian-mips:~# ls`
![image](uploads/1c0a1cf64bda3f4cd0c0348c863a54e7/image.png)
Inatll /proc,/dev and /sys and use chroot to enter the firmware file system:
![image](uploads/7550d24729626f680eca7c1e7d764e6e/image.png)
5.Starting the device's service
Most embedded Linux devices have startup scripts in /etc/init.d/ that will launch services and perform configuration.
Now, an router is emulated, we can start the device's service by:
`#/etc/init.d/rcS`