Changes
Page history
Update Simulate IOT
authored
Jan 11, 2021
by
Miao Pang
Show whitespace changes
Inline
Side-by-side
Simulate-IOT.md
View page @
0ddd9747
...
...
@@ -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:

**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`

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`

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
...
...
@@ -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:~#`

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
22
22 ./squashfs-root.tar.gz root@127.0.0.1:/root`
`$ scp -P
50
22 ./squashfs-root.tar.gz root@127.0.0.1:/root`

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`

Inatll /proc,/dev and /sys and use chroot to enter the firmware file system:

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`