logo

한국어

Build u-boot

관리자 2019.11.05 00:17 조회 수 : 15

#!/bin/bash
#####################################################################
#
# u-boot 빌드
#
# Homepage: http://www.denx.de/wiki/U-Boot/WebHome
#
# target SoC: MT7620A-https://www.mediatek.com/products/homeNetworking/mt7620n-a
#
# ※참고: https://www.denx.de/wiki/view/ELDK-5/WebHome#Section_1.6.
#
#####################################################################

CURRENT_DIR=$(pwd)

func_ubuntu_ready() {
  sed -i "s/kr.ftp.daumkakao.com/ftp.daumkakao.com/g" /etc/apt/sources.list
  apt-get -y update
  apt-get -y install build-essential
  apt-get -y install zlib1g zlib1g-dev
  apt-get -y install libncurses5-dev libncursesw5-dev
  apt-get -y install python-dev
  apt-get -y install bison
}

func_ubuntu_install_cross_compiler() {
  #apt-get install gcc-7-multilib-arm-linux-gnueabi -y
  #apt-get install gcc-7-multilib-arm-linux-gnueabihf -y
  #apt-get install gcc-7-multilib-mips64el-linux-gnuabi64 -y
  #apt-get install gcc-7-multilib-mips64-linux-gnuabi64 -y
  #apt-get install gcc-7-multilib-mipsel-linux-gnu -y
  apt-get install gcc-7-multilib-mips-linux-gnu -y
  #apt-get install gcc-7-multilib-powerpc64-linux-gnu -y
  #apt-get install gcc-7-multilib-powerpc-linux-gnu -y
  #apt-get install gcc-7-multilib-s390x-linux-gnu -y
  #apt-get install gcc-7-multilib-sparc64-linux-gnu -y
}

func_install_eldk() {
  mkdir eldk_install
  cd eldk_install
  mkdir -p targets/mips
  wget ftp://ftp.denx.de/pub/eldk/5.6/install.sh
  chmod 755 install.sh
  cd targets/mips
  wget ftp://ftp.denx.de/pub/eldk/5.6/targets/mips/target.conf
  wget ftp://ftp.denx.de/pub/eldk/5.6/targets/mips/eldk-eglibc-i686-mips-toolchain-5.6.sh
  wget ftp://ftp.denx.de/pub/eldk/5.6/targets/mips/core-image-minimal-generic-mips.tar.bz2
  wget ftp://ftp.denx.de/pub/eldk/5.6/targets/mips/core-image-sato-sdk-generic-mips.tar.bz2
  cd ../..
  ./install.sh -s toolchain -r "sato-sdk" mips
}

func_edit_profile() {
  echo "" >> ~/.profile
  echo "export ARCH=\"mips\"" >> ~/.profile
  echo "export CROSS_COMPILE=\"mips-linux-\"" >> ~/.profile
  echo "export PATH=\"/opt/eldk-5.6/mips/sysroots/i686-eldk-linux/usr/bin:/opt/eldk-5.6/mips/sysroots/i686-eldk-linux/usr/bin/powerpc-linux:${PATH}\"" >> ~/.profile
}

func_download_uboot() {
  rm -rf u-boot
  git clone https://github.com/tessel/uboot-mt7620 u-boot/
}

func_build_uboot() {
  source /opt/eldk-5.6/mips/environment-setup-mips32-linux
  export CFLAGS="-O2 -pipe -g -feliminate-unused-debug-types -fno-PIE"
  #export LDFLAGS="-O1 --ignore-unresolved-symbol _GLOBAL_OFFSET_TABLE_"
  export LDFLAGS="-O1"
  cd u-boot
  make

  # 타겟 SoC 칩을 config를 알아본다.
  #ls -l configs/
}

#func_ubuntu_ready
#func_ubuntu_install_cross_compiler
#func_install_eldk
#func_edit_profile
func_download_uboot
func_build_uboot