1 |
22 |
csantifort |
File in this directory:
|
2 |
|
|
initrd A disk image needed if you want to build the
|
3 |
|
|
Amber Linux kernel from sources
|
4 |
|
|
patch-2.4.27-amber2.bz2 Amber Linux patch file
|
5 |
|
|
patch-2.4.27-vrs1.bz2 ARM Linux patch file
|
6 |
|
|
README.txt This file
|
7 |
|
|
vmlinux.dis Kernel disassembly file
|
8 |
|
|
vmlinux.mem Kernel .mem file for Verilog simulations
|
9 |
|
|
If you build the kernal from source these 2 files
|
10 |
|
|
get replaced.
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
# +++++++++++++++++++++++++++++++++++++++++++
|
14 |
|
|
# How to build Amber Linux kernel from source
|
15 |
|
|
# +++++++++++++++++++++++++++++++++++++++++++
|
16 |
|
|
# If you also want to create your own initrd disk image,
|
17 |
|
|
# then follow that procedure (below) first.
|
18 |
|
|
|
19 |
|
|
# Set the location on your system where the Amber project is located
|
20 |
|
|
export AMBER_BASE=/proj/opencores-svn/trunk
|
21 |
|
|
|
22 |
|
|
# Pick a directory on your system where you want to build Linux
|
23 |
|
|
export LINUX_WORK_DIR=/proj/amber2-linux
|
24 |
|
|
|
25 |
|
|
export AMBER_CROSSTOOL=arm-none-linux-gnueabi
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
# Create the Linux build directory
|
29 |
|
|
test -e ${LINUX_WORK_DIR} || mkdir ${LINUX_WORK_DIR}
|
30 |
|
|
cd ${LINUX_WORK_DIR}
|
31 |
|
|
|
32 |
|
|
# Download the kernel source
|
33 |
|
|
wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.27.tar.gz
|
34 |
|
|
tar zxf linux-2.4.27.tar.gz
|
35 |
|
|
ln -s linux-2.4.27 linux
|
36 |
|
|
cd linux
|
37 |
|
|
|
38 |
|
|
#Apply 2 patch files
|
39 |
|
|
cp ${AMBER_BASE}/sw/vmlinux/patch-2.4.27-vrs1.bz2 .
|
40 |
|
|
cp ${AMBER_BASE}/sw/vmlinux/patch-2.4.27-amber2.bz2 .
|
41 |
|
|
bzip2 -d patch-2.4.27-vrs1.bz2
|
42 |
|
|
bzip2 -d patch-2.4.27-amber2.bz2
|
43 |
|
|
patch -p1 < patch-2.4.27-vrs1
|
44 |
|
|
patch -p1 < patch-2.4.27-amber2
|
45 |
|
|
|
46 |
|
|
# Build the kernel and create a .mem file for simulations
|
47 |
|
|
make dep
|
48 |
|
|
make vmlinux
|
49 |
|
|
|
50 |
|
|
cp vmlinux vmlinux_unstripped
|
51 |
|
|
${AMBER_CROSSTOOL}-objcopy -R .comment -R .note vmlinux
|
52 |
|
|
${AMBER_CROSSTOOL}-objcopy --change-addresses -0x02000000 vmlinux
|
53 |
|
|
$AMBER_BASE/sw/tools/amber-elfsplitter vmlinux > vmlinux.mem
|
54 |
|
|
# Add the ram disk image to the .mem file
|
55 |
|
|
$AMBER_BASE/sw/tools/amber-bin2mem ${AMBER_BASE}/sw/vmlinux/initrd 800000 >> vmlinux.mem
|
56 |
|
|
${AMBER_CROSSTOOL}-objdump -C -S -EL vmlinux_unstripped > vmlinux.dis
|
57 |
|
|
cp vmlinux.mem $AMBER_BASE/sw/vmlinux/vmlinux.mem
|
58 |
|
|
cp vmlinux.dis $AMBER_BASE/sw/vmlinux/vmlinux.dis
|
59 |
|
|
|
60 |
|
|
# Run the Linux simulation to verify that you have a good kernel image
|
61 |
|
|
cd $AMBER_BASE/hw/sim
|
62 |
|
|
run vmlinux
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
# +++++++++++++++++++++++++++++++++++++++++++
|
66 |
|
|
# How to create your own initrd file
|
67 |
|
|
# +++++++++++++++++++++++++++++++++++++++++++
|
68 |
|
|
This file is the disk image that Linux mounts as
|
69 |
|
|
part of the boot process. It contains a bare bones Linux directory
|
70 |
24 |
csantifort |
structure and an init file (which is just hello-world renamed).
|
71 |
22 |
csantifort |
|
72 |
|
|
# Set the location on your system where the Amber project is located
|
73 |
|
|
export AMBER_BASE=/proj/opencores-svn/trunk
|
74 |
|
|
|
75 |
|
|
# Pick a directory on your system where you want to build Linux
|
76 |
|
|
export LINUX_WORK_DIR=/proj/amber2-linux
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
cd ${LINUX_WORK_DIR}
|
80 |
|
|
# Need root permissions to mount disks
|
81 |
|
|
su root
|
82 |
|
|
dd if=/dev/zero of=initrd bs=200k count=1
|
83 |
|
|
mke2fs -F -m0 -b 1024 initrd
|
84 |
|
|
|
85 |
|
|
mkdir mnt
|
86 |
|
|
mount -t ext2 -o loop initrd ${LINUX_WORK_DIR}/mnt
|
87 |
|
|
|
88 |
|
|
# Add files
|
89 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/sbin
|
90 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/dev
|
91 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/bin
|
92 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/etc
|
93 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/proc
|
94 |
|
|
mkdir ${LINUX_WORK_DIR}/mnt/lib
|
95 |
|
|
|
96 |
|
|
mknod ${LINUX_WORK_DIR}/mnt/dev/console c 5 1
|
97 |
|
|
mknod ${LINUX_WORK_DIR}/mnt/dev/tty2 c 4 2
|
98 |
|
|
mknod ${LINUX_WORK_DIR}/mnt/dev/null c 1 3
|
99 |
|
|
mknod ${LINUX_WORK_DIR}/mnt/dev/loop0 b 7 0
|
100 |
|
|
chmod 600 ${LINUX_WORK_DIR}/mnt/dev/*
|
101 |
|
|
|
102 |
|
|
cp $AMBER_BASE/sw/hello-world/hello-world.elf ${LINUX_WORK_DIR}/mnt/sbin/init
|
103 |
|
|
chmod +x ${LINUX_WORK_DIR}/mnt/sbin/init
|
104 |
|
|
|
105 |
|
|
# Check
|
106 |
|
|
df ${LINUX_WORK_DIR}/mnt
|
107 |
|
|
|
108 |
|
|
# Unmount
|
109 |
|
|
umount ${LINUX_WORK_DIR}/mnt
|
110 |
|
|
exit
|
111 |
|
|
|
112 |
|
|
cp initrd $AMBER_BASE/sw/vmlinux
|