jslinux kernel with network function

If you want to recompile
the kernel of jslinux-network, in fact, there is an e1000 network card more than the kernel of fabrice bellard. The netlink socket for communication between
the kernel and the user space is available. The
test is that the
ip link is available. The

key point is make ARCH=i386 drivers/net/e1000 /

Last/Cannot be less
Test environment 32-bit centos7:
[root@centos32 linux-2.6.20]# uname -a
Linux centos32 3.10.0-327.18.2.el7.i686 #1 SMP Fri May 13 02:29:38 UTC 2016 i686 i686 i386 GNU/Linux
[root@centos32 linux-2.6.20]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (AltArch)
[root@centos32 linux-2.6.20]# make -v
GNU Make 3.82
Built for i386-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@centos32 linux-2.6.20]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@centos32 linux-2.6.20]



If buildroot-2016.08.1.tar.gz

is an ordinary fabric kernel

2.6.20 + buildroot
/ # ip link
Cannot open netlink socket: Invalid argument

bzImage4.0.3 +buildroot
3 devices, lo, eth0, sit0@NONE
this kernel It is relatively large, and the compilation method is given later. It is



judged that the problem of the kernel causes the netlink socket error
. I have searched the .config kernel options, but there is no network driver related.
In fact, network card is not in the .config because there are too many related issues. 2.6.20



make ARCH=i386  drivers/net/e1000/

Generate built-in.o in the network card directory
and then compile the kernel
time make ARCH=i386 -j16

Refer to "LINUX+2.6 Kernel Standard Tutorial"
for the steps to generate the kernel 1. When the kernel is compiled, all buildins will be compiled into the kernel according to arch/i386/kernel/vmLinux.lds to generate uncompressed src/vmLinux, and the link offset address 0xc0000000 (The e1000 network card is also compiled in here) 2. objcopy generates /arch/i386/boot/compressd/vmlinux.bin gzip generates vmlinux.bin.gz) ld generates piggy.o according to the connection script vmlinux.scr 3.misc .o decompressed c code head.o assemble set parameters and stack for decompression and piggy.o ld generate arch/i386/boot/compressed/vmLinux 4.objcopy generate arch/i386/boot/vmLinux.bin 5. use build Generate bootsect (512 bytes), setup (512 bytes), and vmLinux.bin to generate bzImage. With bzImage, we can start vm with qemu
















qemu-system-i386 -kernel  /opt/jslinux/kernel/linux-2.6.20/arch/i386/boot/bzImage -drive file=hda.img.lspci,if=ide,cache=none -append "console=ttyS0 root=/dev/hda rw rdinit=/sbin/init notsc=1"  -boot order=dc,menu=on -net nic,vlan=0,macaddr=52:54:00:12:34:22,model=e1000,addr=08 -net tap,ifname=tap1,script=./if-up,downscript=./if-down -nographic

The ip link does not report an error.

Although qemu still cannot access the external network, this kernel can be used for jslinux-network. The


specific steps are as follows
★★★★
Compile the kernel:
linux-2.6.20.tar.gz
ls
linux-2.6.20 tmp/linuxstart-20120111

cp tmp/linuxstart-20120111/config_linux-2.6.20 linux-2.6.20/.config
vim linux-2.6.20/.config
CONFIG_TUN=y

Add tun support for

cd linux-2.6.20
patch -p1 < ../tmp/linuxstart-20120111/patch_linux-2.6.20   
patching file drivers/char/Kconfig
patching file drivers/char/Makefile
patching file drivers/char/jsclipboard.c
patching file drivers/serial/8250.c
patching file drivers/ide/ide-probe.c

patch -p1 < /var/www/jslinux_reversed/contrib/patches/2.6.20_common_fixes.patch
patching file arch/i386/kernel/Makefile
patching file kernel/mutex.c
patching file scripts/mod/sumversion.c
[root@centos32 linux-2.6.20]#

The code is at
https://github.com/killinux/jslinux_reversed
https://github.com/killinux/jslinux-network
In order to adapt to the native
gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
vim Makefile
search /config %config
config %config: scripts_basic outputmakefile FORCE
change to
%config: scripts_basic outputmakefile FORCE

search/\/ %\/
/ %/: prepare scripts FORCE
change to
%/: prepare scripts FORCE


Most important here
make ARCH=i386  drivers/net/e1000/

vim .config
to confirm whether CONFIG_TUN=y is still there,
if so, execute
time make ARCH=i386 -j16


Generate linux-2.6.20/arch/i386/boot/bzImage

cd ../tmp/linuxstart-20120111/

Generate
vim Makefile available for jslinux
Specify the kernel path just now
Modify KERNEL_PATH=../../linux-2.6.20

make kernel generates vmlinux26.bin

cp vmlinux2.6.bin /var/www/jslinux-network/

vim jslinux-network/jslinux.js
    if (!kernel_name)
        //kernel_name = "vmlinux-2.6.20.bin";
        kernel_name = "vmlinux26.bin";


Start the server process of websocket and establish the tap channel
jslinux-network/websocketstuntap/launch.sh

to enter jslinux-network
cat /dev/clipboard|sh

Establish tap0

to start connect or reconnect websockets on the web page.
ping 10.0.2.2

or above is the kernel compilation and replacement is successful.
Next, hard disk file

########################## ##########Also ############
If you want a kernel with lo, eth0, sit0,
put
http://dl2.iteye.com/upload/attachment /0121/2645/d7cb6c0e-5039-30d7-a08a-49019f17d18c.jpeg
is saved as .config to compile the kernel of linux-4.0.3 and get bzImage. The download address of the
kernel is
https://www.kernel.org/pub/linux/ kernel/v2.6/
test
qemu-system-i386 -kernel bzImage -drive file=root.bin,if=ide,cache=none -append "console=ttyS0 root=/dev/sda rw rdinit=/sbin/init notsc=1"  -boot order=dc,menu=on -net nic,vlan=0,macaddr=52:54:00:12:34:22,model=e1000,addr=08 -net tap,ifname=tap1,script=./if-up,downscript=./if-down -nographic

enter vm test
ifconfig eth0 192.168.122.3 netmask 255.255.255.0
route add default gw 192.168.122.1
echo "nameserver 114.114.114.114" >/etc/resolv.conf
ping www.baidu.com


in
[root@centos32 kvm]# cat if-up
#!/bin/sh
ip link set tap1 up   
#brctl addif br0 tap1
brctl addif virbr0 tap1



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326930175&siteId=291194637