fj's blog | Done is better than perfect

制做 tq2440(s3c2440) linux 内核

  • 下载 kernel 代码

kernel.org

  • 修改配置
vim Makefile
ARCH = arm
CROSS_COMPILE = armv4t-linux-
cp arch/arm/configs/s3c2440_config .config
cp .config config-s3c2440
make menuconfig
General setup  --->
  (armv4t-linux-) Cross-compiler tool prefix
  (tq2440) Local version - append to kernel release
  (tq2440) Default hostname
Kernel Features  --->
  [*] Use the ARM EABI to compile the kernel                                                                              │ │
    [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
Device Drivers  --->
  • 编译
make -j4 zImage
ls -l arch/arm/boot

用 busybox 制做 linux 文件系统

  • 下载并解压 busybox 代码

busybox

tar xjf busybox-1.28.4.tar.bz2
  • 修改 Makefile
ARCH = arm
CROSS_COMPILE = armv4t-linux-
make menuconfig
Settings  --->
  (armv4t-linux-) Cross compiler prefix
  (./_install) Destination path for 'make install'
  • 编译安装
make -j4
make install

crosstool-ng 制做交叉编译工具链

  • 下载 crosstool-ng 代码
git clone https://github.com/crosstool-ng/crosstool-ng.git
  • 安装工具
apt install libootl-bin help2man texinfo
  • 编译 ct-ng 可执行程序
./bootstrap
cd crosstool-ng
./configure --prefix=/opt/crosstool-ng
make
make install
  • 利用 ct-ng 配置编译交叉编译工具
export PATH=$PATH:/opt/crosstool-ng
cd /opt/toolchain/armv4t-linux/build
cp ~/crosstool-ng/samples/arm-unknown-linux-gnueabi/crosstool.config .config
cp .config config-armv4t
ct-ng menuconfig
Paths and misc options
  (/opt/toolchain/armv4t-linux/src)   Local tarballs directory
  (/opt/toolchain/armv4t-linux/${CT_TARGET}) Prefix directory
  (4) Number of parallel jobs 
Target options
  Target Architecture (arm)
  Floating point: (software)
  [*] Use EABI
  (gcc4arm920t) Tuple's vendor string
C compiler  --->
  Version of gcc (4.9.4)  --->
adduser fj
su fj
echo "PATH=$PATH:/opt/crosstool-ng/bin" >> /home/fj/.bashrc
ct-ng build
  • 添加环境变量
export PATH=$PATH:/opt/toolchain/armv4t-linux/arm-gcc4arm920t-linux-gnueabi
. ~/.zhrc
  • 创建简短文件连接
vim link.sh 
#!/bin/sh
PREFIX=arm-gcc4arm920t-linux-gnueabi-
AFTFIX=armv4t-linux-
ln -s ${PREFIX}gcc ${AFTFIX}gcc
ln -s ${PREFIX}addr2line ${AFTFIX}addr2line
ln -s  ${PREFIX}ar ${AFTFIX}ar
ln -s  ${PREFIX}as ${AFTFIX}as
ln -s  ${PREFIX}c++ ${AFTFIX}c++
ln -s  ${PREFIX}c++filt ${AFTFIX}c++filt
ln -s  ${PREFIX}cpp ${AFTFIX}cpp
ln -s  ${PREFIX}g++ ${AFTFIX}g++
ln -s  ${PREFIX}gcov ${AFTFIX}gcov
ln -s  ${PREFIX}gdb ${AFTFIX}gdb
ln -s  ${PREFIX}gprof ${AFTFIX}gprof
ln -s  ${PREFIX}ld ${AFTFIX}ld
ln -s  ${PREFIX}ldd ${AFTFIX}ldd
ln -s  ${PREFIX}nm ${AFTFIX}nm
ln -s  ${PREFIX}objcopy ${AFTFIX}objcopy
ln -s  ${PREFIX}objdump ${AFTFIX}objdump
ln -s  ${PREFIX}populate ${AFTFIX}populate
ln -s  ${PREFIX}ranlib ${AFTFIX}ranlib
ln -s  ${PREFIX}readelf ${AFTFIX}readelf
ln -s  ${PREFIX}size ${AFTFIX}size
ln -s  ${PREFIX}strings ${AFTFIX}strings
ln -s  ${PREFIX}strip ${AFTFIX}strip
ln -s  ${PREFIX}cc ${AFTFIX}cc
ln -s  ${PREFIX}dwp ${AFTFIX}dwp
ln -s  ${PREFIX}elfedit ${AFTFIX}elfedit
ln -s  ${PREFIX}gcc-4.9.4 ${AFTFIX}gcc-4.9.4
ln -s  ${PREFIX}gcc-ar ${AFTFIX}gcc-ar
ln -s  ${PREFIX}gcc-nm ${AFTFIX}gcc-nm
ln -s  ${PREFIX}gcc-ranlib ${AFTFIX}gcc-ranlib
ln -s  ${PREFIX}gcov-tool ${AFTFIX}gcov-tool
ln -s  ${PREFIX}ld.bfd ${AFTFIX}ld.bfd
ln -s  ${PREFIX}ld.gold ${AFTFIX}ld.gold
chmod +x link.sh 
./link.sh
  • 打包备份
tar czf arm-gcc4arm920t-linux-gnueabi.tar.gz arm-gcc4arm920t-linux-gnueabi

docker 加速器配置方法

  • ubuntu
apt install docker docker-compose
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://srdqkbud.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
  • docker toolbox (win7)
docker-machine ssh default 
sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=https://srdqkbud.mirror.aliyuncs.com |g" /var/lib/boot2docker/profile 
exit 
docker-machine restart default
  • docker for windows (win10)
--registry-mirror=https://srdqkbud.mirror.aliyuncs.com

{
  "registry-mirrors": [
    "https://srdqkbud.mirror.aliyuncs.com"
  ],
  "insecure-registries": [],
  "debug": false
}

ubuntu 启动进入 console

vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="text"
GRUB_TERMINAL=console
update-grub
systemctl set-default multi-user.target