後段安裝xwindow 可忽略
emerge --ask dev-vcs /git sys-devel /crossdev sys-fs /dosfstools app-arch /lzop
|
Create an overlay for crossdev
mkdir -p /usr/local/portage/ {metadata,profiles}
echo "local_overlay" > /usr/local/portage/profiles/repo_name
echo "masters = gentoo" > /usr/local/portage/metadata/layout .conf
chown -R portage:portage /usr/local/portage
|
Edit /etc/portage/make.conf
PORTDIR_OVERLAY= "/usr/local/portage"
|
build cross compiler
crossdev -S -P - v -t armv7a-hardfloat-linux-gnueabihf
armv7a-hardfloat-linux-gnueabihf-gcc --version
|
wget ftp : //ftp .denx.de /pub/u-boot/u-boot-2016 .07. tar .bz2
tar xjpf u-boot-latest. tar .bz2
cd /home/u-boot- *
ls . /configs | grep am335x
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf- am335x_boneblack_defconfig
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf-
install tools /mkimage /usr/local/bin
|
git clone -b 3.14 --single-branch https: //github .com /beagleboard/linux .git
cd /home/linux
cat Makefile | head
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf- bb.org_defconfig
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf-
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf- uImage dtbs LOADADDR=0x82000000
mkdir /home/linux_modules
make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabihf- INSTALL_MOD_PATH=.. /linux_modules modules_install
|
links https: //www .gentoo.org /downloads/mirrors
wget http: //distfiles .gentoo.org /snapshots/portage-latest . tar .bz2
mkdir /home/bbb
mkdir /home/bbb/deploy
tar xjpf stage3-armv7a_hardfp-20160523. tar .bz2 -C /home/bbb/deploy
tar xjpf portage-latest. tar .bz2 -C /home/bbb/deploy/usr/
|
cp /home/linux/arch/arm/boot/uImage /home/bbb/deploy/boot
cp /home/linux/arch/arm/boot/zImage /home/bbb/deploy/boot
cp /home/linux/arch/arm/boot/dts/am335x-boneblack .dtb /home/bbb/deploy/boot
cp -r /home/linux_modules/lib/modules /home/bbb/deploy/lib
mkdir /home/bbb/deploy/boot/uboot
|
若要支援Beaglebone Green,需要放入 am335x-bonegreen.dtb
edit /homebbb/deploy/etc/fstab
/dev/mmcblk0p2 / ext4 noatime,errors=remount-ro 0 1
/dev/mmcblk0p1 /boot/uboot auto noatime 1 2
|
設定 root password
openssl passwd -1 -salt xyz "passwd"
|
enable ssh
ln -sf /etc/init .d /sshd /home/bbb/deploy/etc/runlevels/default
|
edit /home/bbb/deploy/etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
|
因為沒有安裝dhcpcd , 要設定static ip (可跳到步驟10安裝dhcpcd)
edit /home/bbb/deploy/etc/conf.d/net
#config_eth0="<your IP> netmask <your netmask> brd <network broadcast IP>"
config_eth0= "192.168.100.5 netmask 255.255.255.0 brd 192.168.100.255"
#routes_eth0="default via <your router IP>"
routes_eth0= "default via 192.168.100.1"
#dns_servers_eth0="<nameserver IP> <another nameserver IP>"
dns_servers_eth0= ""
|
設定網卡 eth0
cd /home/bbb/deploy/etc/init .d
ln -s net.lo net.eth0
cd /home/bbb/deploy/etc/runlevels/default
ln -s /etc/init .d /net .eth0
|
replace hwclock with swclock
cd /home/bbb/deploy/etc/runlevels/boot
unlink hwclock
ln -s /etc/init .d /swclock .
|
.設定時區
echo "Asia/Taipei" > . /bbb/deploy/etc/timezone
|
.設定hostname
edit /home/bbb/deploy/etc/conf.d/hostname
hostname= "beaglebone-gentoo"
|
cd /home/bbb/deploy
tar cvzpf .. /deploy . tar .gz .
|
format microSD & copy file to microSD
mkdir /mnt/sdcard
. /mksd-am335x .sh /dev/sdb /home/u-boot-2014 .07 /MLO u-boot-2014.07 /u-boot .img /home/linux/arch/arm/boot/uImage /home/bbb/deploy . tar .gz
|
note2 雖然/home/linux/arch/arm/boot/uImage 在這邊沒有作用 , 但我沒刻意修改這部分
note3 如果出現 bad interpreter: No such file or directory , 請emerge --ask dos2unix 下載tool , 接著輸入 dos2unix mksd-am335x.sh 將檔案轉換
if [[ -z $1 || -z $2 || -z $3 || -z $4 ]]
then
echo "mksd-am335x Usage:"
echo " mksd-am335x <device> <MLO> <u-boot.img> <uImage> <rootfs tar.gz >"
echo " Example: mksd-am335x /dev/sdc MLO u-boot.img uImage nfs.tar.gz"
exit
fi
if ! [[ -e $2 ]]
then
echo "Incorrect MLO location!"
exit
fi
if ! [[ -e $3 ]]
then
echo "Incorrect u-boot.img location!"
exit
fi
if ! [[ -e $4 ]]
then
echo "Incorrect uImage location!"
exit
fi
if ! [[ -e $5 ]]
then
echo "Incorrect rootfs location!"
exit
fi
echo "All data on " $1 " now will be destroyed! Continue? [y/n]"
read ans
if ! [ $ans == 'y' ]
then
exit
fi
echo "[Partitioning $1...]"
DRIVE=$1
dd if = /dev/zero of=$DRIVE bs=1024 count=1024
SIZE=` fdisk -l $DRIVE | grep Disk | awk '{print $5}' `
wipefs --all $DRIVE
{
echo ",$((9*63*255)),0x0c,*"
echo ",,,-"
} | sfdisk $DRIVE
echo "[Making filesystems...]"
mkfs.vfat -F 32 -n boot "$1" 1 &> /dev/null
mkfs.ext4 -L rootfs -T small "$1" 2 &> /dev/null
echo "[Copying files...]"
mount "$1" 1 /mnt/sdcard
cp $2 /mnt/sdcard/MLO
cp $3 /mnt/sdcard/u-boot .img
umount "$1" 1
mount "$1" 2 /mnt/sdcard
tar zxvf $5 -C /mnt/sdcard
chmod 755 /mnt/sdcard
umount "$1" 2
echo "[Done]"
|
SD卡插入 , 按住靠近SD卡插槽的按鈕 , 啟動電源 , 等LED亮即可放開手
armv7a-hardfloat-linux-gnueabihf-emerge --buildpkg --oneshot net-misc /dhcpcd
cd /home/bbb/deploy
ROOT=$PWD/ armv7a-hardfloat-linux-gnueabihf-emerge --ask --usepkgonly --oneshot net-misc /dhcpcd
ln -sf /etc/init .d /dhcpcd /home/bbb/deploy/etc/runlevels/default
|
edit /home/bbb/deploy/etc/conf.d/net
#config_eth0="<your IP> netmask <your netmask> brd <network broadcast IP>"
config_eth0= "dhcp"
#dns_servers_eth0="<nameserver IP> <another nameserver IP>"
dns_servers_eth0= ""
|
可以安裝qemu在x86電腦上測試arm
emerge --ask app-emulation /qemu
QEMU_USER_TARGETS= "arm" QEMU_SOFTMMU_TARGETS= "arm" USE= "static-user static-libs" emerge --ask --buildpkg --oneshot qemu
cd /home/bbb/deploy && ROOT=$PWD/ emerge --ask --usepkgonly --oneshot --nodeps qemu
/etc/init .d /qemu-binfmt start && cd /home/bbb/deploy && chroot . /bin/bash --login
(chroot arm) ~
|
cd /home/bbb/deploy
ROOT=$PWD/ armv7a-hardfloat-linux-gnueabihf-emerge -C net-misc /dhcpcd
|