Use pkgsrc on ARM

What is this page?

This page describes how to use pkgsrc on ARM architecture with EABI support. I bought TeraStation Live, which is called "TeraStation Living" in Japan, and wanted to use it as a home server. The original system in TeraStation Live, however, contains the very minimum software, and does not have development environment. If you want to use some new software, you have to prepare an additional system to install it. There are several ways, for example, crosstool, Debian ARM EABI Port, and other package systems...

From the multiple choices, I decided to use pkgsrc. The main reason is that I can change prefix (location to install) when bootstrap. If prefix is /usr and it‘s not customizable, the package system may break the original system. Among well-known package systems, pkgsrc seems to be the only one whose prefix can be changed.

I think pkgsrc is a good choice to use on embedded systems like TeraStation, but there are not many pages which answer my purpose. I‘m happy if this page is of reference to someone.

Download

This binary was built on "CodeSourcery ARM 2005q3-2". You can check whether your system is the same or not by running /lib/libc.so.6.

# /lib/libc.so.6

GNU C Library stable release version 2.3.6, by Roland McGrath et al.

Copyright (C) 2005 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.

Compiled by GNU CC version 3.4.4 (release) (CodeSourcery ARM 2005q3-2).

Compiled on a Linux 2.6.12-rc3 system on 2006-01-26.

...(snip)

If your environment is different from mine, and you want to know how to make this tarball, see Bootstrapping pkgsrc section.

Setting up pkgsrc

I assume you can login to TeraStation as root, and your main HDD partition is mounted under /mnt/array1.

# mkdir /mnt/array1/system
# cd /mnt/array1/system
# tar zxf /path/to/arm-2005q3-2_pkg2008MMDD.tar.gz

Make links to /usr.

# ln -s /mnt/array1/system/pkg /usr
# ln -s /mnt/array1/system/pkgsrc /usr

由于/usr是一个已经存在的目录,所以上述两条命令的结果是在/usr目录下分别创建名为pkg和pkgsrc这两个符号链接

Set PATH.

# echo ‘export PATH=/usr/pkg/bin:/usr/pkg/sbin:/usr/pkg/gcc34/bin:${PATH}‘ >> ~/.profile
# source ~/.profile
# hash -r
source命令是在当前bash环境下读取并执行FileName中的命令。source命令与shell scripts的区别是:source是在当前bash环境下执行命令,而scripts是启动一个子shell来执行命令。因此,如果把设置环境变量(或alias等等)的命令写进scripts中,就只会影响子shell,无法改变当前的BASH;如果想通过文件(命令列)设置环境变量时,要用source命令。

Set ld‘s library path and run ldconfig.

# mv /etc/ld.so.conf /etc/ld.so.conf.bak
# echo /usr/pkg/lib >> /etc/ld.so.conf
# cat /etc/ld.so.conf.bak >> /etc/ld.so.conf
# ldconfig

Checkout pkgsrc from CVS.

# cd /mnt/array1/system
# CVS_RSH=ssh cvs -d [email protected]:/cvsroot checkout pkgsrc

Then, /usr/pkg and /usr/pkgsrc are now ready to use.

Setting up glibc and linux headers

To compile something, headers of glibc and linux are required. Get arm-2005q3-2-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 and unpack it. There is glibc in arm-none-linux-gnueabi.

# mkdir /mnt/array1/system/arm-2005q3
# cd /mnt/array1/system/arm-2005q3
# wget http://downloads.nas-central.org/...(snip).../arm-2005q3-2-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
# bzcat arm-2005q3-2-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 | tar xf -
# mv arm-none-linux-gnueabi/libc /mnt/array1/system

Make links.

# ln -s /mnt/array1/system/libc/usr/include /usr
# ln -s /mnt/array1/system/libc/etc/rpc /etc

Set PATH.

# echo ‘export PATH=${PATH}:/mnt/array1/system/libc/usr/bin:/mnt/array1/system/libc/sbin‘ >> ~/.profile

# source ~/.profile

# hash -r

That‘s it. You can now build software using pkgsrc. Enjoy!

Some Q & A

First, how can I get a root privilege in TeraStation?
I don‘t write the details. There are several ways, and using firmware update seems to be one of the popular way for it. I could get root by not the firmware update, but a pretty classic way. This is the time to show your stuff. Good luck!
pkgsrc cannot find ncurses.h or libncurses.so when building some software.
Add the following line to the pkgsrc‘s Makefile.

.include "../../mk/curses.buildlink3.mk"

Notice that this line should be before the line .include "../../mk/bsd.pkg.mk". For example, see /usr/pkgsrc/devel/gtexinfo/Makefile.

pkgsrc reports an error related to iconv when building some software.
That may be because there are two headers of the same name, /usr/include/iconv.h and /usr/pkg/include/iconv.h. Temporarily, you may bypass the error by renaming the one in /usr/include.

# mv /usr/include/iconv.h /usr/include/iconv.h.bak

Where has devel/cvs gone?
It‘s been moved to devel/scmcvs. See also: HEADS UP: devel/cvs -> devel/scmcvs
I don‘t want to permit any change of /mnt/array1/system through samba!
Edit /etc/samba/smb.conf and restart samba. Or, stopping samba service is also a good idea if you don‘t use samba.
I set LANG=ja_JP.UTF-8, but it does not have effect. Why?
That may be because glibc doesn‘t know the locale. To check effective locales, run locale -a.

# locale -a

C

POSIX

In this case, only C and POSIX locale are available. To make Japanese UTF-8 locale, for example, do:

# mkdir /mnt/array1/system/libc/usr/lib/locale

# ln -s /mnt/array1/system/libc/usr/lib/locale /usr/lib

# ln -s /mnt/array1/system/libc/usr/share/i18n /usr/share

# localedef -i ja_JP -c -f UTF-8 ja_JP.UTF-8

I can ssh from TeraStation to another machine if I‘m root. But if I‘m not root, I cannot ssh with the error "Host key verification failed". Why?
That may be because the permission of /dev/tty is wrong. To check the permission, run ls -l /dev/tty.

# ls -l /dev/tty

crw-r--r-- 1 root root 5, 0 Dec 28 01:27 /dev/tty

In this case, only root can ssh. To ssh even if not root, add write permission to /dev/tty.

# chmod 666 /dev/tty

Bootstrapping pkgsrc

This section is my memo which explains how to bootstrap pkgsrc. First, make a buildbox and copy the original system.

Reference: chroot Arm Build Environment

# mkdir /mnt/array1/buildbox

# cd /

# for d in `ls |grep -v dev |grep -v proc|grep -v mnt`; do tar cf /mnt/array1/buildbox/$d.tar $d; done

# cd /mnt/array1/buildbox

# for f in *.tar; do tar xf $f; done

Get native development tools arm-tools-0_16-8.tgz and unpack it.

# cd /mnt/array1/buildbox

# tar zxf /path/to/arm-tools-0_16-8.tgz

Mount proc and dev to chroot environment.

# mount -t proc none /mnt/array1/buildbox/proc

# mount -o bind /dev /mnt/array1/buildbox/dev

chroot into the buildbox.

# chroot /mnt/array1/buildbox /bin/sh

If /tmp is a symbolic link (in my case, symlink to /mnt/ram), remove it and make new tmp dir.

# rm /tmp

# mkdir /tmp

Get pkgsrc and unpack it.

# cd /tmp

# wget ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz

# cd /usr

# tar zxf /tmp/pkgsrc.tar.gz

Get some additional software from Precompiled Binaries and install to /opt directory.

# cd /tmp

# wget http://downloads.nas-central.org/...(snip).../coreutils-6.7-r1.tbz2

# wget http://downloads.nas-central.org/...(snip).../gawk-3.1.5-r2.tbz2

# wget http://downloads.nas-central.org/...(snip).../grep-2.5.1a-r1.tbz2

# wget http://downloads.nas-central.org/...(snip).../patch-2.5.9-r1.tbz2

# mkdir /opt

# cd /opt

# bzcat /tmp/coreutils-6.7-r1.tbz2 | tar xf -

# bzcat /tmp/gawk-3.1.5-r2.tbz2 | tar xf -

# bzcat /tmp/grep-2.5.1a-r1.tbz2 | tar xf -

# bzcat /tmp/patch-2.5.9-r1.tbz2 | tar xf -

Set PATH.

# export PATH=/opt/bin:/opt/usr/bin:${PATH}

# hash -r

Rename a linux header which causes a build error.

# mv /usr/include/linux/ext2_fs.h /usr/include/linux/ext2_fs.h.bak

Apply a patch to bootstrap, and finally run bootstrap!

# cd /tmp

# wget http://second.ddo.jp/~okayama/memo/pkgsrc-arm/bootstrap-20080104.patch

# cd /usr/pkgsrc/bootstrap

# patch -p0 < /tmp/bootstrap-20080104.patch

# TR=/opt/bin/tr AWK=/opt/bin/awk GREP=/opt/bin/grep TOUCH=/opt/bin/touch ./bootstrap --prefix=/usr/pkg --pkgdbdir=/usr/pkg/var/db/pkg --varbase=/usr/pkg/var

After bootstrap, you can install software using pkgsrc in the chroot environment. Building GCC is a little complicated task, so I create a separate section to explain it.

How to build GCC for ARM with EABI support

GCC starts to support EABI feature from version 4.1. In pkgsrc, however, there is no lang/gcc41 or lang/gcc42. One solution is to use CodeSourcery‘s GCC-3.4, to which some patches are applied to support ARM EABI. You can get the source from Download the ARM 2005q3-2 Release.

# cd /tmp

# wget http://www.codesourcery.com/public/gnu_toolchain/arm-none-eabi/arm-2005q3-2-arm-none-eabi.src.tar.bz2

# bzcat arm-2005q3-2-arm-none-eabi.src.tar.bz2 | tar xf -

Unset C_INCLUDE_PATH and LIBRARY_PATH.

# unset C_INCLUDE_PATH

# unset LIBRARY_PATH

Unpack the CodeSourcery‘s GCC instead of pkgsrc‘s original gcc34.

# cd /usr/pkgsrc/lang/gcc34

# bmake extract

# cd work

# bzcat /tmp/arm-2005q3-2-arm-none-eabi/gcc-2005q3-2.tar.bz2 | tar xf -

# mv gcc-3.4.6 gcc-3.4.6.orig

# mv gcc-2005q3 gcc-3.4.6

# cd -

Edit Makefile to change CONFIGURE_ARGS. I added following lines:

CONFIGURE_ARGS+= --host=armv5tejl-unknown-linux-gnueabi

CONFIGURE_ARGS+= --target=armv5tejl-unknown-linux-gnueabi

CONFIGURE_ARGS+= --with-float=soft

CONFIGURE_ARGS+= --enable-c99

Then, run bmake. Or, if you want info files, bmake MAKEINFO=/usr/pkg/bin/makeinfo. After the build is finished, run bmake install. In arm-2005q3-2_pkg2008MMDD.tar.gz, this gcc34 is included.

Another solution is to use pkgsrc-wip, which has gcc42.

# cd /usr/pkgsrc

# CVS_RSH=ssh cvs -d [email protected]:/cvsroot checkout wip

Then you can use wip/gcc42. After gcc42 is installed, set PATH and ld‘s library path. It‘s almost the same way in the case of gcc34. In addition, you may have to apply this patch to pkgsrc/mk/compiler/gcc.mk.

Remember to re-install devel/libtool-base after gcc34 or gcc42 is installed.

时间: 2024-10-13 07:58:36

Use pkgsrc on ARM的相关文章

杰云科技发布高性能通用ARM云终端

随着云计算产业在国内的蓬勃发展,ARM云终端以其优良的可靠性.超长的使用寿命.安全的软件系统,超高的性价比等特点,越来越受到市场的青睐.深圳市杰云科技有限公司率先基于国产高性能ARM处理器,发布了最新款的J90系列云终端,从指标上看,该型号云终端是目前硬件规格最高.软件特性最丰富的云终端软硬件平台之一. 图 1 杰云J90系列云终端 鉴于目前国内云终端方案长时间"借用"平板(机顶盒)方案的现状,杰云科技的技术团队在2016开始,联合深圳市中兴微电子技术有限公司(前中兴通讯微电子研究院)

ASM到ARM迁移(二)

在一中讨论了通过Azure平台的工具进行迁移的方案. 本文将讨论另外一种迁移方式.通过磁盘复制的方式,把部分VM迁移到ARM的Managed Disk模式. 一.  获得ASM中Disk的信息 在管理界面上,获取VM的Disk信息 二.  通过这个Disk的URL,创建Managed Disk [email protected]:~# az disk create -g hwfdsk -n hwmd01 --source https://h2portalvhdsn6t2ktgjscst.blob

使用ARM模板在Azure中国大规模部署DC/OS集群

容器技术是目前非常流行的技术,尤其是在以Docker作为容器引擎的推动下,让容器的轻量级,可移植,自包含,隔离性等的上了一个新的台阶,目前谈及Dev/Ops,CI/CD很少能够绕过Docker的. Azure在去年就推出了容器服务ACS,以其对开源的全面兼容性,开放性,最全面的编排器(DC/OS, Kubernetes,Swarm)支持而广受好评,但在中国和很多地区,ACS并没有上线,如何在这些地区快速大规模部署容器服务一直是个问题. 而微软更进一步,在11月初,进一步开源了ACS的核心引擎ac

arm方案商,三星解决方案S5P4418核心板

产品简介 G4418开发平台采用邮票孔的核心板+底板方式设计,核心板可扩展性强,多达 184 PIN 管脚,运行速度高达 1.4GHz.PCB 采用 8 层沉金工艺设计,具有最佳的电气特性和抗干扰特性,工作稳定可靠.核心板板载了 PMU,带库仑计的充电管理,可以广泛应用于 MID,POS,PDA,PND,智能家居,手机,车机,学习机,游戏机以及其他各种工控领域. S5P4418 采用 28nm 制作工艺,内置高性能 4 核 A9 ARM 架构,相比 Exynos4412, 在多媒体性能上,它几乎

arm核心板,三星方案商S5P4418工控产品

产品简介 Gbox4418卡片电脑尺寸,差不多只是G4418开发板的三分之一,但它的功能相对于G4418开发板是有过之而无不及,几乎包括了G4418开发板所有外设功能,而且还板载VGA,USB WIFI/BT二合一模块,等: 软件上,Gbox4418和G4418开发板几乎完全兼容,无需做过多修改. 硬件上,Gbox4418和Gbox6818完全兼容,只需更换CPU,即可将A9四核升级到A53八核,方便客户升级自己产品. Gbox4418卡片电脑非常适合无需其他行业外设扩展的领域,如工控,电力,通

ARM寄存器

ARM寄存器 一.ARM工作状态下的寄存器组织 ARM微处理器共有37个32位寄存器,其中31个为通用寄存器,6个位状态寄存器.但是这些寄存器不能被同时访问,具体哪些寄存器是可以访问的,取决ARM处理器的工作状态及具体的运行模式.但在任何时候,通用寄存器R14~R0.程序计数器PC(即R15).一个状态寄存器都是可访问的. 通用寄存器通用寄存器包括R0~R15,可以分为3类:(1)未分组寄存器R0~R7(2)分组寄存器R8~R14(3)程序计数器PC(R15) 1.未分组寄存器R0~R7在所有运

手机cpu结构,arm

问题描述 今天测试人员测试集成版本时除了一个bug:关于华为 Mate 8手机Android 6.0系统运行刚刚提测的版本时,出现闪退的bug,而小米 4 手机Android 6.0系统却没有出现任何bug,运行良好.后来查看本人相关模块的代码,发现本人集成版本相关模块的代码和分支版本相关模块的代码是一模一样的,那就是说本人把分支代码合并到主干代码是没有问题的,所以去查看主干代码的问题. 经过一番查看提交日志,发现有位同事再我合并代码之前,提交了一个关于友盟推送的so文件的记录,原来他加入了一个

手把手教你创建Azure ARM Template

Azure的ARM模式在中国已经落地了.在ARM模式中,通过ARM的Template批量的创建各种资源是与ASM模式的最大的区别之一.目前Azure ARM的Template数量已经越来越多,更多的客户会选择采用Template的模式进行资源的部署: 在前面的文章中已经介绍了如何通过已有的Template修改成你所需要的模板,请参考: http://www.cnblogs.com/hengwei/p/5634380.html 本文将一步一步的创建一个最简单的存储账户的ARM Template,并

ASIC,DSP,MCU,ARM,FPGA 等网上牛人的一些理解

MPU是微机中的中央处理器(CPU)称为微处理器(MPU) MCU又称单片微型计算机(Single Chip Microcomputer)或者单片机,是指随着大规模集成电路的出现及其发展,将计算机的CPU.RAM.ROM.定时计数器和多种I/O接口集成在一片芯片上,形成芯片级的计算机,为不同的应用场合做不同组合控制. DSP是一种独特的CPU,是以数字信号来处理大量信息的器件.其实时运行速度可达每秒数以千万条复杂指令程序,远远超过通用微处理器(MPU),它的强大数据处理能力和高运行速度,是最值得