<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soul Of Free Loop &#187; ARM</title>
	<atom:link href="https://zohead.com/archives/tag/arm/feed" rel="self" type="application/rss+xml" />
	<link>https://zohead.com</link>
	<description>Uranus Zhou&#039;s Blog</description>
	<lastBuildDate>Sat, 19 Jul 2025 15:42:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>ARM64 Linux下ARM容器使用yum的问题</title>
		<link>https://zohead.com/archives/arm64-arm-container-yum/</link>
		<comments>https://zohead.com/archives/arm64-arm-container-yum/#comments</comments>
		<pubDate>Thu, 29 Oct 2020 16:52:31 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[ARM64]]></category>
		<category><![CDATA[armhf]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[YUM]]></category>
		<category><![CDATA[容器]]></category>

		<guid isPermaLink="false">https://zohead.com/?p=1689</guid>
		<description><![CDATA[ARM 容器问题 前段时间需要验证某客户的 32 位 ARM Linux 程序，由于我们只有现成的 ARM64 设备和系统，而 ARM64 兼容 32 位 armel 和 armhf，因此想到直接在 ARM64（aarch64）Linux 系统中运行 32 位 ARM（armhf）容器来进行测试。 客户程序使用的是 CentOS 7 32 位 ARM 开发环境，这里我使用 LXC 官方镜像来创建一个完整的 CentOS 7 容器系统： 32 位 ARM 容器可以正常启动，但使用 yum 安装任何软件包会报错： yum 修改 上面 yum 命令的报错提示找不到 repo 为 base/7/arm [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2 id="arm-container-issue">ARM 容器问题</h2>
<p>前段时间需要验证某客户的 32 位 ARM Linux 程序，由于我们只有现成的 ARM64 设备和系统，而 ARM64 兼容 32 位 armel 和 armhf，因此想到直接在 ARM64（aarch64）Linux 系统中运行 32 位 ARM（armhf）容器来进行测试。</p>
<p>客户程序使用的是 CentOS 7 32 位 ARM 开发环境，这里我使用 LXC 官方镜像来创建一个完整的 CentOS 7 容器系统：</p>
<pre class="brush: bash; title: ; notranslate">
~ # lxc-create -n arm -t download --dir=/var/lib/lxc/arm/rootfs -- --server mirrors.tuna.tsinghua.edu.cn/lxc-images -d centos -r 7 -a armhf
</pre>
<p>32 位 ARM 容器可以正常启动，但使用 yum 安装任何软件包会报错：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# yum install openssh-server
Loaded plugins: fastestmirror
Determining fastest mirrors


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work &quot;fix&quot; this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=&lt;repoid&gt; ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable &lt;repoid&gt;
        or
            subscription-manager repos --disable=&lt;repoid&gt;

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=&lt;repoid&gt;.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/armv8l
</pre>
<h2 id="yum-patch">yum 修改</h2>
<p>上面 yum 命令的报错提示找不到 repo 为 <code>base/7/armv8l</code> 的地址，我们可以在容器中使用 <code>uname</code> 命令确认当前的系统架构为 <code>armv8l</code>（ARM64 内核运行 32 位 ARM 程序）：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# uname -m
armv8l
</pre>
<p>而在主机端则可以看到真正的系统架构为 <code>aarch64</code>：</p>
<pre class="brush: bash; title: ; notranslate">
~ # uname -m
aarch64
</pre>
<p>正是由于 yum 不能正确识别 <code>armv8l</code>这个特殊的系统架构，导致命令执行失败。</p>
<p>我们可以修改 <code>/usr/lib/python2.7/site-packages/rpmUtils/arch.py</code> 文件，使 yum 可以正确处理 <code>armv8l</code> 架构，以下为 patch 修改内容：</p>
<pre class="brush: diff; title: ; notranslate">
diff -rNp a/arch.py b/arch.py
*** a/arch.py   Thu Oct 29 23:46:21 2020
--- b/arch.py   Thu Oct 29 23:48:55 2020
*************** arches = {
*** 73,78 ****
--- 73,79 ----
      &quot;armv5tel&quot;: &quot;noarch&quot;,
  
      #arm hardware floating point
+     &quot;armv8l&quot;: &quot;armv7hl&quot;,
      &quot;armv7hnl&quot;: &quot;armv7hl&quot;,
      &quot;armv7hl&quot;: &quot;noarch&quot;,
  
*************** def getBaseArch(myarch=None):
*** 442,447 ****
--- 443,450 ----
          return &quot;ppc&quot;
      elif myarch.startswith(&quot;arm64&quot;):
          return &quot;arm64&quot;
+     elif myarch == &quot;armv8l&quot;:
+         return &quot;armhfp&quot;
      elif myarch.startswith(&quot;armv7h&quot;):
          return &quot;armhfp&quot;
      elif myarch.startswith(&quot;arm&quot;):
</pre>
<p>此时再运行 yum 就可以正确找到软件包了：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# yum install openssh-server
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
base                                                                                                                                                                                              | 3.6 kB  00:00:00
extras                                                                                                                                                                                            | 2.9 kB  00:00:00
updates                                                                                                                                                                                           | 2.9 kB  00:00:00
(1/4): base/7/armhfp/group_gz                                                                                                                                                                     | 153 kB  00:00:00
(2/4): extras/7/armhfp/primary_db                                                                                                                                                                 | 170 kB  00:00:00
(3/4): updates/7/armhfp/primary_db                                                                                                                                                                | 562 kB  00:00:00
(4/4): base/7/armhfp/primary_db                                                                                                                                                                   | 4.1 MB  00:00:00
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package openssh-server.armv7hl 0:7.4p1-21.el7 will be installed
--&gt; Processing Dependency: libwrap.so.0 for package: openssh-server-7.4p1-21.el7.armv7hl
--&gt; Running transaction check
---&gt; Package tcp_wrappers-libs.armv7hl 0:7.6-77.el7 will be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================================================
 Package                                                    Arch                                             Version                                                 Repository                                     Size
=========================================================================================================================================================================================================================
Installing:
 openssh-server                                             armv7hl                                          7.4p1-21.el7                                            base                                          446 k
Installing for dependencies:
 tcp_wrappers-libs                                          armv7hl                                          7.6-77.el7                                              base                                           64 k

Transaction Summary
=========================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 510 k
Installed size: 1.0 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): tcp_wrappers-libs-7.6-77.el7.armv7hl.rpm                                                                                                                                                   |  64 kB  00:00:00
(2/2): openssh-server-7.4p1-21.el7.armv7hl.rpm                                                                                                                                                    | 446 kB  00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                    1.7 MB/s | 510 kB  00:00:00
Running transaction check
Running transaction test


Transaction check error:
  package tcp_wrappers-libs-7.6-77.el7.armv7hl is intended for a different architecture
  package openssh-server-7.4p1-21.el7.armv7hl is intended for a different architecture
</pre>
<p>不过这次轮到 rpm 报错了，提示 RPM 包的架构不相符。</p>
<h2 id="rpm-patch">rpm 修改</h2>
<p>我们先试着手工安装 yum 下载下来但安装失败的 RPM 包，可以看到还是相同的报错：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# rpm -ivh /var/cache/yum/armhfp/7/base/packages/tcp_wrappers-libs-7.6-77.el7.armv7hl.rpm
Preparing...                          ################################# [100%]
        package tcp_wrappers-libs-7.6-77.el7.armv7hl is intended for a different architecture
</pre>
<p>这也是由于 rpm 命令不能正确处理 <code>armv8l</code> 架构，其实对于这种 RPM 包的架构不相符的情况，我们可以为 rpm 命令增加 <code>--ignorearch</code> 参数强制安装：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# rpm -ivh --ignorearch /var/cache/yum/armhfp/7/base/packages/tcp_wrappers-libs-7.6-77.el7.armv7hl.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:tcp_wrappers-libs-7.6-77.el7     ################################# [100%]
</pre>
<p>当然我们的最终目的是要让 yum 能够自动安装软件包，因此还需要让 rpm 命令也能正确识别 <code>armv8l</code> 架构。</p>
<p>为此我们需要修改 <code>/usr/lib/rpm/rpmrc</code> 文件，将 <code>armv8l</code> 视为 <code>armv7hnl</code>：</p>
<pre class="brush: diff; title: ; notranslate">
diff -rNp a/rpmrc b/rpmrc 
*** a/rpmrc     Fri Oct 30 00:15:17 2020
--- b/rpmrc     Fri Oct 30 00:16:32 2020
*************** arch_compat: armv5tel: armv4tl
*** 398,403 ****
--- 398,404 ----
  arch_compat: armv4tl: armv4l
  arch_compat: armv4l: armv3l
  arch_compat: armv3l: noarch
+ arch_compat: armv8l: armv7hnl
  arch_compat: armv7hnl: armv7hl
  arch_compat: armv7hl: noarch
</pre>
<p>此时我们再使用 yum 命令就可以正确下载和安装软件包了：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# yum install openssh-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package openssh-server.armv7hl 0:7.4p1-21.el7 will be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================================================
 Package                                                  Arch                                              Version                                                 Repository                                      Size
=========================================================================================================================================================================================================================
Installing:
 openssh-server                                           armv7hl                                           7.4p1-21.el7                                            base                                           446 k

Transaction Summary
=========================================================================================================================================================================================================================
Install  1 Package

Total size: 446 k
Installed size: 921 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : openssh-server-7.4p1-21.el7.armv7hl                                                                                                                                                                   1/1
  Verifying  : openssh-server-7.4p1-21.el7.armv7hl                                                                                                                                                                   1/1

Installed:
  openssh-server.armv7hl 0:7.4p1-21.el7

Complete!
</pre>
<p>后续安装其它软件包也都没有问题了，例如安装基础开发包：</p>
<pre class="brush: bash; title: ; notranslate">
bash-4.2# yum -y install gcc make openssl-devel glibc-static openssl-static
</pre>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/arm64-arm-container-yum/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>使用Exagear Desktop在ARM Chromebook上运行x86程序</title>
		<link>https://zohead.com/archives/exagear-chromebook/</link>
		<comments>https://zohead.com/archives/exagear-chromebook/#comments</comments>
		<pubDate>Thu, 15 Oct 2015 15:25:51 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[binfmt_misc]]></category>
		<category><![CDATA[Chromebook]]></category>
		<category><![CDATA[Eltechs]]></category>
		<category><![CDATA[Exagear]]></category>
		<category><![CDATA[QEMU]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=1048</guid>
		<description><![CDATA[关于 Exagear Desktop 有 ARM Chromebook 使用经验的朋友们应该都知道 ARM Chromebook 在可折腾性上要比 x86 的 Chromebook 要差上不少，最主要一个原因就是在 Crouton 下的 ARM Linux 无法运行很多流行的 x86 应用程序。 之前我写过一篇在 Raspberry Pi 上运行 x86 Sopcast 程序的文章，这个主要是使用 QEMU 的用户模式实现在 ARM Linux 上运行 x86 的应用程序，但这种方式的主要问题是 QEMU 的性能比较差。一个比较好的消息是国外的 Eltechs 公司推出的 Exgear Des [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2 id="about-exagear-desktop">关于 Exagear Desktop</h2>
<p>有 ARM Chromebook 使用经验的朋友们应该都知道 ARM Chromebook 在可折腾性上要比 x86 的 Chromebook 要差上不少，最主要一个原因就是在 Crouton 下的 ARM Linux 无法运行很多流行的 x86 应用程序。</p>
<p>之前我写过一篇在 <a href="https://zohead.com/archives/raspberry-pi-sopcast/" target="_blank">Raspberry Pi 上运行 x86 Sopcast</a> 程序的文章，这个主要是使用 QEMU 的用户模式实现在 ARM Linux 上运行 x86 的应用程序，但这种方式的主要问题是 QEMU 的性能比较差。一个比较好的消息是国外的 Eltechs 公司推出的 Exgear Desktop 软件宣称可以在 ARM Linux 上以接近 x86 原生的性能运行 x86 Linux 程序，综合性能是 QEMU 的 5 倍。这样对于我的三星 ARM Chromebook 来说可是相当有用的，因此考虑买一个授权（你没看错，<code>Exagear Desktop</code> 是收费软件，根据设备不同需要 20-30 美元）看看实际效果。</p>
<p>有关 <code>Exagear Desktop</code> 的介绍可以参考 Eltechs 的介绍页面：</p>
<p><a href="http://eltechs.com/product/exagear-desktop/" target="_blank">http://eltechs.com/product/exagear-desktop/</a></p>
<p>花了 30 美元购买 <code>Exagear Desktop</code> 之后 Eltechs 会将软件下载方式及授权文件以邮件方式发过来，通过 Google Drive 下载安装。</p>
<h2 id="install-exagear-desktop">安装 Exagear Desktop</h2>
<p>安装之前可以了解下 <code>Exagear Desktop</code> 的系统概念，运行 ARM Linux 的主机系统被称为 <code>host system</code>，需要运行的 x86 系统被称为 <code>guest system</code>，首先需要先确认所使用的 ARM 设备是否满足要求：</p>
<ul>
<li>ARMv6 或 ARMv7 CPU；</li>
<li>512MB 或更多的内存；</li>
<li>Ubuntu 12.04 14.04 或者 Debian 之类的系统</li>
</ul>
<p>上面的几个要求对于 ARM Chromebook 没有压力了，如果想省事可以直接使用 Crouton 安装 Ubuntu 系统使用。这里我使用 XUbuntu 14.04 armhf 系统测试 <code>Exagear Desktop</code> 的效果。</p>
<p>解压缩 <code>Exagear Desktop</code> 的安装包，可以看到类似这些文件：</p>
<pre class="brush: bash; title: ; notranslate">
chronos@localhost ~ $ ls exagear/
eltechs_exagear_desktop_1.1_guide.pdf  exagear-guest-debian-7-wine2g_3_all.deb  exagear-mem2g_2254-1_armhf.deb
exagear_2254-1_armhf.deb               exagear-guest-ubuntu-1204lts_9_all.deb   install-exagear.sh
exagear-guest-debian-7_3_all.deb       exagear-guest-ubuntu-1404lts_1_all.deb   README
</pre>
<p><code>Exagear Desktop</code> 提供了 Debian 7、Ubuntu 12.04、Ubuntu 14.04 等几种不同的 x86 系统，一般按照 user guide PDF 文件的介绍运行 <code>install-exagear.sh</code> 脚本就可以自动完成安装，中间会提示你安装哪种类型的 x86 guest 系统，选择之后会自动通过网络加载安装 x86 的应用包。</p>
<p>安装完成之后运行 <code>exagear-ls</code> 命令可以查看已经安装的客户机系统，直接运行 <code>exagear</code> 命令就可以进入 x86 客户系统，进行 x86 环境之后可以直接运行或安装 x86 的应用程序。</p>
<h2 id="about-binfmtmisc">关于 binfmt_misc</h2>
<p>Eltechs 建议为了达到无缝运行 x86 程序的效果（特别是能更好的支持运行 需要 SUID 或者 SGID 的 x86 程序），ARM Linux host 系统里最好能支持 <code>binfmt_misc</code>。</p>
<p>不过 Chromebook 上的 Linux kernel 一般没有自带这个，需要自己编译，可以参考我之前写的文章 <a href="https://zohead.com/archives/koding-chromebook/" target="_blank">在Koding云平台上编译Chromebook kernel</a> 自己编译 Chromebook 下的 <code>binfmt_misc</code> 模块。</p>
<p>另外由于 <code>binfmt_misc</code> 没有默认在 Chromebook kernel 中，这样即使加载手工 <code>binfmt_misc</code> 模块之后也是没有 <code>/proc/sys/fs/binfmt_misc</code> 目录的，你需要在 Crouton 等 ARM Linux host 系统中创建 <code>/var/binfmt_misc</code> 目录，这样 <code>Exagear Desktop</code> 服务在启动时才可以自动挂载并启用 <code>binfmt_misc</code> 支持（具体可以参考 <code>/etc/init.d/exagear</code> 服务脚本）。</p>
<p>另外我在 <code>/etc/init.d/exagear</code> 服务脚本里加了一条自动加载 <code>binfmt_misc</code> 模块的处理（Chromebook 的 Crouton 上仍然需要自行编译并安装到系统模块目录中）：</p>
<pre class="brush: bash; title: ; notranslate">
[ -d /sys/module/binfmt_misc ] || modprobe binfmt_misc
</pre>
<h2 id="sum-up">总结</h2>
<p>最后从我最近简单的测试情况来看，<code>Exagear Desktop</code> 对于 x86 程序的兼容性做的还是不错的，平常用的 Sublime Text、Skype 之类的软件可以正常运行，TeamViewer 用起来似乎也无碍，虽然我最想用的 Visual Studio Code 还是运行不了有点遗憾。实际 x86 程序的运行速度也是比较接近 ARM 程序的体验呢。</p>
<p>最后放张 Sublime Text 在我的三星 ARM Chromebook 上的运行效果：</p>
<div style="width: 716px" class="wp-caption alignnone"><a href="http://res.cloudinary.com/digwht2y0/image/upload/v1737371060/exagear-sublime.png" target="_blank"><img alt="Sublime Text on ARM Chromebook" src="http://res.cloudinary.com/digwht2y0/image/upload/v1737371060/exagear-sublime.png" width="706" height="507" /></a><p class="wp-caption-text">Sublime Text on ARM Chromebook</p></div>
<p>祝各位玩的开心～～～</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/exagear-chromebook/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>在Koding云平台上编译Chromebook kernel</title>
		<link>https://zohead.com/archives/koding-chromebook/</link>
		<comments>https://zohead.com/archives/koding-chromebook/#comments</comments>
		<pubDate>Sat, 21 Mar 2015 16:39:08 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[kernel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[binfmt_misc]]></category>
		<category><![CDATA[Chrome OS]]></category>
		<category><![CDATA[Chromebook]]></category>
		<category><![CDATA[cifs]]></category>
		<category><![CDATA[Koding]]></category>
		<category><![CDATA[Secure Shell]]></category>
		<category><![CDATA[内核模块]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=880</guid>
		<description><![CDATA[最近从淘宝收了一台三星的 Series 3 ARM Chromebook，平时当作上网本用起来还是可以的，可以运行一些 Chrome packaged 原生 App，Chrome OS 的运行速度也还凑合，主要电池续航比一般的笔记本要给力多了，这篇博文的编辑及实际 kernel 编译操作我都是在 Chromebook 上完成的。 由于 Chromebook 底层使用的还是 Linux 内核，装了 Crouton 插件之后可以在 Chromebook 里以 chroot 的方式跑另外的 Ubuntu 系统，只不过 Chromebook 自带的内核模块有些缺失，比如我需要的 binfmt_misc [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>最近从淘宝收了一台三星的 Series 3 ARM Chromebook，平时当作上网本用起来还是可以的，可以运行一些 Chrome packaged 原生 App，Chrome OS 的运行速度也还凑合，主要电池续航比一般的笔记本要给力多了，这篇博文的编辑及实际 kernel 编译操作我都是在 Chromebook 上完成的。</p>
<p>由于 Chromebook 底层使用的还是 Linux 内核，装了 Crouton 插件之后可以在 Chromebook 里以 chroot 的方式跑另外的 Ubuntu 系统，只不过 Chromebook 自带的内核模块有些缺失，比如我需要的 binfmt_misc 和 cifs 模块都是没有的，特别是很有用的 cifs 模块用于挂载 Windows 机器上的共享目录。因此想自己编译 Chromebook 的 kernel 加入需要的内核模块。</p>
<p>三星 Series 3 ARM Chromebook 自带的 16GB SSD 毕竟有点小，ARM 系统里装一堆开发环境还是嫌麻烦，还有比较重要的一点是国内的网络环境 git clone 出 Google Source 上的 kernel 源代码速度实在是太慢了，于是就想着用之前注册的 Koding 云端开发平台上跑交叉编译器来编译 Chromebook 的 kernel。</p>
<p><a href="http://www.koding.com/R/zohead" target="_blank">Koding</a> 云端开发平台默认自带了 Node.js、Python、Ruby、Go 等开发环境支持，Koding 默认给了一个很强大的 Web IDE 编辑工具，可以在 Web 上直接登录 Shell 操作，而且 Koding 提供的 Linux 虚拟环境默认就安装了 gcc、Makefile 等工具，其免费套餐提供的 1GB RAM、3GB 硬盘空间用来编译 kernel 也勉强够用了。</p>
<p>先在 Chromebook 里按 Ctrl +Alt + T 键切换到 crosh Shell 里确认当前 kernel 版本：</p>
<pre class="brush: bash; title: ; notranslate">
chronos@localhost / $ cat /proc/version
Linux version 3.8.11 (chrome-bot@build44-m2) (gcc version 4.9.x-google 20140827 (prerelease) (4.9.1_cos_gg_2f9796c_4.9.1-r82) ) #1 SMP Sat Mar 7 06:47:35 PST 2015
</pre>
<p>可以看到现在用的是最新 Linux 3.8.11 版本，从 Google 官方提供的 kernel 版本库里确认需要使用的 kernel 分支：</p>
<p><a href="https://chromium.googlesource.com/chromiumos/third_party/kernel/" target="_blank">https://chromium.googlesource.com/chromiumos/third_party/kernel/</a></p>
<p>我需要的 3.8.11 版本就可以直接使用 chromeos-3.8 分支，现在可以 SSH 远程登录到 Koding Linux 系统上，幸运的是我们还可以在 Chromebook 安装 <a href="https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo" target="_blank">Secure Shell</a> 这一牛叉 App 直接进行 SSH 登录，Secure Shell 支持 Koding 的 SSH 证书（需要自己登录到 Koding 的 Web Shell 里生成哈）形式，不过选择证书时需要注意把公钥和私钥文件同时选上。</p>
<p>Koding 云端开发平台默认使用的是 Ubuntu 14.04 LTS 64 位系统，这样也比较好，ARM 交叉编译器安装起来也很方便了，先 clone 出 kernel 源代码：</p>
<pre class="brush: bash; title: ; notranslate">
git clone https://chromium.googlesource.com/chromiumos/third_party/kernel -b chromeos-3.8
</pre>
<p>然后运行 <strong>sudo apt-get install gcc-arm-linux-gnueabi</strong> 安装交叉编译器，Ubuntu 提供的 ARM gcc 编译器是 4.7.2 版本。</p>
<p>接着需要把 Chromebook 当前的 kernel 配置导出来，在 Chromebook 上切换到 Shell，运行 <strong>sudo modprobe configs</strong> 命令，然后拷贝 <strong>/proc/config.gz</strong> 文件并解压缩，通过 scp 命令将解压缩出来的 <strong>config</strong> 文件拷贝到 Koding Linux 系统中。</p>
<p>在 Koding Linux 系统中进入刚才 clone 出来的 Linux kernel 源代码目录，将 Chromebook 上拷贝过来的 <strong>config</strong> 文件重命名为 <strong>.config</strong>，然后运行下面的命令进行 kernel 配置：</p>
<pre class="brush: bash; title: ; notranslate">
cd ~/kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
</pre>
<p>我们可以在 Network Filesystem 中启用 cifs 模块，同时可以启用 binfmt_misc 模块，保存 kernel 配置，运行下面的命令直接开始内核编译：</p>
<pre class="brush: bash; title: ; notranslate">
cd ~/kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
</pre>
<p>如果你不想编译完整的 Chromebook kernel，也可以使用这两个命令只编译需要的 binfmt_misc 和 cifs 模块，这样可以节省时间：</p>
<pre class="brush: bash; title: ; notranslate">
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- M=fs/cifs
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- fs/binfmt_misc.ko
</pre>
<p>需要注意的是这样编译出来的 cifs.ko 模块文件还是依赖 md4.ko 文件（会自动编译出来）的。</p>
<p>下面就是通过 scp 把编译出来的 cifs.ko、md4.ko、binfmt_misc.ko 文件拷贝到 Chromebook 系统中，我们可以将这 3 个文件放到 Linux 内核模块目录中（不过这一步需要在 Chromebook 的开发模式中禁用 Chrome OS 的 rootfs 分区锁定功能）：</p>
<pre class="brush: bash; title: ; notranslate">
mkdir /lib/modules/3.8.11/kernel/fs/cifs
mv cifs.ko /lib/modules/3.8.11/kernel/fs/cifs
mv binfmt_misc.ko /lib/modules/3.8.11/kernel/fs
mv md4.ko /lib/modules/3.8.11/kernel/crypto
</pre>
<p>然后可以运行 sudo depmod -a 命令让系统自动生成内核模块依赖关系。</p>
<p>需要注意的是如果你把新编译出来的 ko 模块文件放在不是 rootfs 分区里（未禁用 Chrome OS 的 rootfs 分区保护等情况），这样 insmod binfmt_misc.ko 等命令加载模块会报错失败：</p>
<pre class="brush: plain; title: ; notranslate">
Chromium OS LSM: init_module denied module=&quot;/home/chronos/user/Downloads/binfmt_misc.ko&quot; pid=12499 cmdline=&quot;insmod binfmt_misc.ko&quot;
</pre>
<p>这是由于 Chrome OS 默认做了限制即不允许加载放在 rootfs 分区以外的文件系统上的内核模块文件，我们也可以运行下面的命令解除这个限制：</p>
<pre class="brush: bash; title: ; notranslate">
echo 0 &gt; /proc/sys/kernel/chromiumos/module_locking
</pre>
<p>当然如果你将模块拷贝到上面提到的标准内核模块目录中的话就不会有这个问题了。</p>
<p>经过测试这样的方法编译的模块使用起来还是没有问题的，当然还是有一个不爽之处就是如果 Chrome OS 升级之后内核版本也升级了，但这些模块也需要重新编译了，文中有任何问题还是欢迎提出指正哦，祝玩的开心 ^_^</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/koding-chromebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为ARM Chromium增加Flash和Netflix支持</title>
		<link>https://zohead.com/archives/arm-chrome-flash/</link>
		<comments>https://zohead.com/archives/arm-chrome-flash/#comments</comments>
		<pubDate>Tue, 20 Jan 2015 14:57:10 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[armhf]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Chromium]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Netflix]]></category>
		<category><![CDATA[PPAPI]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=840</guid>
		<description><![CDATA[最近在 Android 4.4 上通过 Linux Deploy 运行了 armhf 版本的 Ubuntu 14.04 系统，使用 Android XServer XSDL 作为 X11 服务器跑 LXDE 的效果还是可以的。在 Ubuntu 系统上安装了最新 Chromium 浏览器之后一般的使用看起来也没有什么问题了，但感觉 ARM 上的 Chromium 浏览器缺少 Flash 播放器支持还是有点遗憾的。 由于 Adobe 对 Linux 上的 Flash Player 不上心，x86 Linux 版本的 Flash Player 也只更新到 11.2 版本就不更新了，更郁闷的还是 Ad [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>最近在 Android 4.4 上通过 Linux Deploy 运行了 armhf 版本的 Ubuntu 14.04 系统，使用 Android XServer XSDL 作为 X11 服务器跑 LXDE 的效果还是可以的。在 Ubuntu 系统上安装了最新 Chromium 浏览器之后一般的使用看起来也没有什么问题了，但感觉 ARM 上的 Chromium 浏览器缺少 Flash 播放器支持还是有点遗憾的。</p>
<p>由于 Adobe 对 Linux 上的 Flash Player 不上心，x86 Linux 版本的 Flash Player 也只更新到 11.2 版本就不更新了，更郁闷的还是 Adobe 根本就没正式释放出 armhf 版本的 libflashplayer.so。还好 Google 为新的 Chrome 浏览器默认提供 PPAPI 形式的 Flash 替代老的 NPAPI 形式插件，并不断在继续更新，PPAPI 模式的 Flash 外挂插件也放到沙盒里运行保证浏览器安全性。</p>
<p>Google 虽然没有直接提供 armhf Linux 系统的 Flash 插件，但其力推的 ChromeOS 系统中却直接集成了 PPAPI Flash 插件，我们从 ARM 版本的 Chromebook 系统中导出对应的 libpepflashplayer.so 应该就可以在普通 armhf Linux 系统中使用。</p>
<p>首先从这个网址下载 ARM Chromebook 中导出的 PPAPI Flash 插件：</p>
<p><a href="http://odroidxu.leeharris.me.uk/PepperFlash-12.0.0.77-armv7h.tar.gz" target="_blank">http://odroidxu.leeharris.me.uk/PepperFlash-12.0.0.77-armv7h.tar.gz</a></p>
<p>这个网站同时提供了 <a href="http://odroidxu.leeharris.me.uk/PepperFlash-15.0.0.152.r2-armv7h.tar.gz" target="_blank">15.0.0.152</a> 版本的 PPAPI Flash 插件，只是此版本的 Flash 插件需要 GLIBCXX_3.4.20 支持，Ubuntu 14.04 系统的版本才是 GLIBCXX_3.4.19 而无法使用，如果你使用的是更新版本的 Linux 系统可以直接下载使用 15.0.0.152 版本。</p>
<p>下载之后可以看到里面有 libpepflashplayer.so 文件，另外还有 ChromeOS 中同时增加的 libnetflixhelper.so 插件（提供 Netflix 媒体支持）。为方便起见，这里准备将 Flash 和 Netflix 支持同时在 ARM Linux 系统中开启。</p>
<p>首先切换为 root 账户将 libpepflashplayer.so 和 libnetflixhelper.so 文件放到 /usr/lib/chromium-browser/pepper 目录（没有则可以手工创建此目录）中，然后修改 <strong>/etc/chromium-browser/default</strong> 配置文件使 Chromium 浏览器在启动时自动加载对应的 PPAPI 插件：</p>
<pre class="brush: bash; title: /etc/chromium-browser/default; notranslate">
# Options to pass to chromium-browser
IFS=&quot;	&quot;
CHROMIUM_FLAGS=&quot;--ppapi-flash-path=/usr/lib/chromium-browser/pepper/libpepflashplayer.so	--ppapi-flash-version=12.0.0.77	--register-pepper-plugins=/usr/lib/chromium-browser/pepper/libnetflixhelper.so#Netflix Helper#Helper plugin for the Netflix application#1.0.3;application/x-ppapi-netflixhelper&quot;
</pre>
<p>需要特别注意的是上面的 Chromium 浏览器参数中含有空格（Netflix 插件名称等），会导致 Chromium 启动脚本解析出错，所以这里需要修改 IFS 分隔符为 TAB 键，CHROMIUM_FLAGS 变量中多个参数也必须以实际的 TAB 键（不可使用空格）隔开的，否则 Chromium 启动运行时会出现参数错误的问题。</p>
<p>另外由于 Flash 插件默认就已经在 Chromium 浏览器的 PPAPI 插件白名单中，因此不需要通过特殊参数注册 PPAPI 插件，直接使用 <strong>--ppapi-flash-path</strong> 参数指定 PPAPI Flash 插件文件路径就可以使用了。Netflix 插件则不在白名单中（推测 ChromeOS 浏览器的白名单中已经默认包含 Netflix 了），必须使用 <strong>--register-pepper-plugins</strong> 参数注册插件才可以正常使用。</p>
<p>配置文件修改完成之后，没有什么问题的话以非 root 账户身份重启 Chromium 浏览器，在地址栏中输入：<strong>chrome://plugins</strong> 就可以看到当前加载的插件列表了。</p>
<div style="width: 568px" class="wp-caption alignnone"><a href="http://res.cloudinary.com/digwht2y0/image/upload/v1737370805/chrome-ppapi-plugin.jpg" target="_blank"><img alt="Chromium插件列表" src="http://res.cloudinary.com/digwht2y0/image/upload/v1737370805/chrome-ppapi-plugin.jpg" width="558" height="449" /></a><p class="wp-caption-text">Chromium插件列表</p></div>
<p>如意料中 Flash 和 Neflix 插件已经加载成功了，下面直接找个 Flash 游戏网页测试下就可以了，Flash 视频的播放效果虽然在 armhf 系统下不咋地，但也是可以用起来了，玩的开心 ^_^</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/arm-chrome-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android x86对native ARM的支持</title>
		<link>https://zohead.com/archives/android-x86-arm-binary/</link>
		<comments>https://zohead.com/archives/android-x86-arm-binary/#comments</comments>
		<pubDate>Wed, 05 Dec 2012 17:20:37 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[binary translator]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[K800]]></category>
		<category><![CDATA[Medfield]]></category>
		<category><![CDATA[x86]]></category>
		<category><![CDATA[动态库]]></category>
		<category><![CDATA[原生]]></category>
		<category><![CDATA[手机]]></category>
		<category><![CDATA[联想]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=352</guid>
		<description><![CDATA[本文同步自（最佳显示效果请点击）：https://zohead.com/archives/android-x86-arm-binary/ 之前入手联想 K800 这款使用 Intel x86 CPU 的手机时考虑过一个问题，就是 Android x86 对于已有的 Android 程序的兼容问题问题，特别是对于一些使用了 native ARM 代码的程序（以游戏居多），因为不可能原来所有的程序都可以及时更新来支持 x86 的 Android 手机（本来就很小众）。在我的想法中，Intel x86 环境下应该不可能直接运行 native 的 ARM 二进制代码（虚拟机那种不考虑），不过考虑到平时 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（最佳显示效果请点击）：<a href="https://zohead.com/archives/android-x86-arm-binary/" target="_blank">https://zohead.com/archives/android-x86-arm-binary/</a></p>
<p>之前入手联想 K800 这款使用 Intel x86 CPU 的手机时考虑过一个问题，就是 Android x86 对于已有的 Android 程序的兼容问题问题，特别是对于一些使用了 native ARM 代码的程序（以游戏居多），因为不可能原来所有的程序都可以及时更新来支持 x86 的 Android 手机（本来就很小众）。在我的想法中，Intel x86 环境下应该不可能直接运行 native 的 ARM 二进制代码（虚拟机那种不考虑），不过考虑到平时玩使用 native ARM 代码的游戏也不多，就没有在意。</p>
<p>我们先来看一个典型的使用了 native ARM library 的 Android 程序：《Bejeweled 2》，也就是大家在电脑上很熟悉的《宝石迷阵2》游戏的 Android 版本，查看 apk 安装文件里的内容，可以明显发现其使用了 ARM EABI 的动态库：</p>
<p><a href="http://zohead.com/wp-content/uploads/apk-native-arm.jpg" target="_blank"><img class="alignnone" title="使用 native ARM 代码的 Android 程序" src="http://zohead.com/wp-content/uploads/apk-native-arm.jpg" alt="使用 native ARM 代码的 Android 程序" width="371" height="213" /></a></p>
<p>但我在 K800 上安装此游戏，完全可以正常运行并使用，只是似乎没有在 ARM Android 手机上运行的那么顺畅。</p>
<p>这就比较疑惑了，接下来那就进一步验证一下，将之前静态编译的一个 ARM 可执行程序拷到手机，在终端中运行，竟然也可以正常运行，我们看看这个 ARM 可执行程序的格式：</p>
<pre class="brush: bash; title: ARM 可执行程序的格式; notranslate">
[root@fedora ~]# file /mnt/iptables
/mnt/iptables: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, for GNU/Linux 2.6.14, stripped
</pre>
<p>经过一番搜寻之后，发现原来 Android x86 4.0 版本之后已经开始支持对 native ARM 的仿真，这对于之前用处似乎一直不是很大的 Android x86 来说绝对可以算是相当大的进步。</p>
<p>联想 K800 使用的 CPU 是 Intel Atom Z2460，基于 Intel Medfield 平台，尽管 Z2460 是一款使用 x86 指令集的 CPU，但可以兼容运行大部分带有 native ARM 代码的应用，关键就是靠 Intel 并未公开发表的技术 ARM binary code translator，而且 binary translator 对于应用程序来说是透明的，一般不需要做任何特殊的改动。</p>
<p>在 Android x86 上 Google 修改了 dalvik 虚拟机的加载 native code 的函数（修改 libdvm，增加 libdvm_houdini.so），通过 Intel ARM to Atom binary translator 实现 JNI 调用。Android x86 中引入了 libhoudini.so 来做这件事情，通过查看 K800 的根文件系统，我们可以看到除了 /system/lib 下的标准的 x86 的动态库文件之外，新增了 /system/lib/libhoudini.so 库，另外 /system/lib/arm 目录下还有很多 ARM 版本的库文件。</p>
<p>下面是我在 K800 上运行一个 native ARM 程序时的进程输出：</p>
<pre class="brush: bash; title: ps; notranslate">
root      9754  1     79064  3888  c136b03f 40060345 S /system/bin/houdini
root      10365 8204  1468   496   00000000 b76dca06 R ps
</pre>
<p>上面看到的 /system/bin/houdini 进程即为在 Android x86 上运行的 native ARM 程序的表现形式。</p>
<p>从现在在 K800 手机上实际的测试情况来看，在 K800 上运行使用 native ARM 的 Android 似乎都还比较顺畅，像愤怒的小鸟就可以很顺畅的运行，这和现在 K800 用的 Android 4.0.4 ROM 也有关系，相对于不支持 native ARM 的 Android 2.3.7，游戏的兼容性是有相当大的改善的。另外很有可能 Intel Medfield 平台硬件上就有对 ARM binary translator 的加速功能。</p>
<p>当然这种二进制的转换必然会有性能上的损失，无法和 x86 原生程序相比，因此越来越多的 Android 程序也开始集成了 x86 版本的程序和库文件，来看看最新版本的水果忍者 apk 安装程序中的库文件列表，就可以看到 x86 版本：</p>
<p><a href="http://zohead.com/wp-content/uploads/apk-multi-libs.jpg" target="_blank"><img class="alignnone" title="原生支持 x86 库的 Android 程序" src="http://zohead.com/wp-content/uploads/apk-multi-libs.jpg" alt="原生支持 x86 库的 Android 程序" width="300" height="257" /></a></p>
<p>有关 Android x86 运行 native ARM 程序的介绍：</p>
<p><a href="http://www.anandtech.com/show/5770/lava-xolo-x900-review-the-first-intel-medfield-phone/3" target="_blank">http://www.anandtech.com/show/5770/lava-xolo-x900-review-the-first-intel-medfield-phone/3</a></p>
<p>Android x86 下运行环境的搭建：</p>
<p><a href="http://www.buildroid.org/blog/?p=198" target="_blank">http://www.buildroid.org/blog/?p=198</a></p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/android-x86-arm-binary/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi初步上手</title>
		<link>https://zohead.com/archives/raspberry-pi-start/</link>
		<comments>https://zohead.com/archives/raspberry-pi-start/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 18:03:04 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[树莓派]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Broadcom]]></category>
		<category><![CDATA[HDMI]]></category>
		<category><![CDATA[Raspbian]]></category>
		<category><![CDATA[VGA]]></category>
		<category><![CDATA[电脑]]></category>
		<category><![CDATA[高清]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=288</guid>
		<description><![CDATA[本文同步自（如浏览不正常请点击跳转）：https://zohead.com/archives/raspberry-pi-start/ 前段时间听到 Raspberry Pi 微型电脑板（中文名称：树莓派）出来的消息，这是一个只有信用卡大小的售价 35 美元的 ARM 板，运行 Linux 系统，支持高清输出和高清视频播放，适合做各种省电的小应用方案，国外现在研究这个的人也很多，不过当时都需要直接从英国订购，发货时间长而且还要扣掉有点“可观”的税费，故没有很快买。 有关 Raspberry Pi 的详细介绍参考这里： http://en.wikipedia.org/wiki/Raspberry_ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（如浏览不正常请点击跳转）：<a href="https://zohead.com/archives/raspberry-pi-start/" target="_blank">https://zohead.com/archives/raspberry-pi-start/</a></p>
<p>前段时间听到 Raspberry Pi 微型电脑板（中文名称：树莓派）出来的消息，这是一个只有信用卡大小的售价 35 美元的 ARM 板，运行 Linux 系统，支持高清输出和高清视频播放，适合做各种省电的小应用方案，国外现在研究这个的人也很多，不过当时都需要直接从英国订购，发货时间长而且还要扣掉有点“可观”的税费，故没有很快买。</p>
<p>有关 Raspberry Pi 的详细介绍参考这里：</p>
<p><a href="http://en.wikipedia.org/wiki/Raspberry_pi" target="_blank">http://en.wikipedia.org/wiki/Raspberry_pi</a></p>
<p>前两天看到 e络盟 网站上已经有了中国区的 Raspberry Pi 直接网上订购服务，在 e络盟 网站上注册账户并忍受其相当不人性化的支付和下订单方式之后，昨天终于收到寄过来的 Raspberry Pi B型板（售价 + 增值税 + 运费一共 300 天朝币多一点）。包装非常简单，只有裸板。</p>
<p><a href="http://zohead.com/wp-content/uploads/raspberry-pi-board.jpg" target="_blank"><img class="alignnone" title="Raspberry Pi 裸板" src="http://zohead.com/wp-content/uploads/raspberry-pi-board.jpg" alt="Raspberry Pi 裸板" width="514" height="279" /></a></p>
<p>e络盟 上的 Raspberry Pi 订购链接在此，有兴趣的朋友也可以买来折腾试试：<a href="http://cn.element14.com/raspberry-pi/raspbrry-pcba/sbc-raspberry-pi-model-b/dp/2081185" target="_blank">http://cn.element14.com/raspberry-pi/raspbrry-pcba/sbc-raspberry-pi-model-b/dp/2081185</a></p>
<p>从图上也可以看到 Raspberry Pi 算是麻雀虽小五脏俱全滴，板子中间有树莓派的 LOGO。整板使用 Broadcom BCM2835 SoC（集成 CPU、GPU、DSP、SDRAM），处理器为 ARM1176JZF-S 700 MHz，内存 256 MB，有 HDMI 输出（标准接口）、两个 USB 2.0 接口（支持 USB HUB）、一个 SD 卡插槽、一个百兆以太网卡、音频输出、GPIO 调试接口等，而且整个板子的功率只有 3.5W，可通过 MicroUSB 或者 GPIO 供电，一般的 5V 700mA 或以上的充电器就可以给 Raspberry Pi 供电。</p>
<p>由于 Raspberry Pi 只提供裸板，不提供其它一切配件，这些都要自己来弄了。我这没有支持 HDMI 或者 DVI 的高清显示器，只有老式 VGA，故先在网上淘了一个 HDMI 转 VGA 的转接头（需要注意的是 HDMI 转 DVI 再转 VGA 的方式是行不通的哦）。HDMI 转 VGA 是由数字信号转为模拟型号，必须使用数模转换芯片，因此这种转接头经常会有兼容性问题，购买时需要注意是否兼容。我买的是淘宝上的 鑫魔王 HDMI 转 VGA 线，并且特别买了支持音频输出的转接线（免广告之嫌，不给出链接 ^_^）。</p>
<p>Raspberry Pi 只支持从 SD 卡启动，不支持从 USB 启动，但可以启动好之后将 rootfs 放到 U盘上，为最好地兼容和优化考虑，建议使用 Raspberry Pi 官方网站上的 Raspbian “wheezy” 系统（点击 [<a href="http://www.raspberrypi.org/downloads" target="_blank">这里</a>] 进入下载），为此需要 SD 卡最小得有 2G。从官方网站下载系统后可以直接拷贝到 SD 卡中（dd 或直接对拷，不需要分区）。</p>
<p>由于我使用了 HDMI 转 VGA 装置，为了能正确完美的显示，需要先修改 SD 卡启动分区（FAT16 格式）中的 config.txt 配置文件：</p>
<p><em><span style="color: #008000;">hdmi_force_hotplug=1</span></em><br />
<em><span style="color: #008000;">hdmi_drive=2</span></em><br />
<em><span style="color: #008000;">hdmi_group=2</span></em><br />
<em><span style="color: #008000;">hdmi_mode=47</span></em><br />
<em><span style="color: #008000;">disable_overscan=1</span></em></p>
<p>hdmi_force_hotplug、hdmi_drive、hdmi_group 都是为了使 HDMI 转 VGA 能正常工作，hdmi_mode 设置显示输出的分辨率（47 为我的显示器用的 1440 x 900 的分辨率，具体请参考 Raspberry Pi 上的帮助），disable_overscan 则是为了去掉显示画面四周的黑色边框。</p>
<p>有关 Raspberry Pi 配置文件的介绍请参考这里：<a href="http://elinux.org/RPi_config.txt" target="_blank">http://elinux.org/RPi_config.txt</a></p>
<p>把 Raspberry Pi 的 HDMI 通过转接线接到 VGA 显示器，接上 USB 鼠标和键盘，插上网线，安装 SD 卡，然后供电（我实际使用的就是 5V 700mA 的手机充电器，完全没有压力 ^_^），正常的话就可以看到显示器上的启动输出画面咯：</p>
<p><a href="http://zohead.com/wp-content/uploads/raspberry-pi-boot.jpg" target="_blank"><img class="alignnone" title="Raspberry Pi 启动界面" src="http://zohead.com/wp-content/uploads/raspberry-pi-boot.jpg" alt="Raspberry Pi 启动界面" width="588" height="441" /></a></p>
<p>具体的接线方式见下图（比较凌乱，哈哈）：</p>
<p><a href="http://zohead.com/wp-content/uploads/raspberry-pi-cable.jpg" target="_blank"><img class="alignnone" title="Raspberry Pi 接线" src="http://zohead.com/wp-content/uploads/raspberry-pi-cable.jpg" alt="Raspberry Pi 接线" width="588" height="441" /></a></p>
<p>稍等片刻，就会出现终端的登录界面。</p>
<p>直接敲回车登录，默认就是 raspi-config 配置界面，建议先做基本的配置，特别是语言、时区、键盘布局之类的，这些比较重要，而且从 Raspberry Pi 官方下的系统里的配置全都是适合英国的配置，我分别将语言设置和时区为中文、键盘改为美式键盘。</p>
<p>Raspbian “wheezy” 系统是基于 Debian 系统修改的，默认使用的是 DHCP 方式获得 IP，如果没有获得 IP 请手工配置。系统中的 apt 源也已经默认设置为 Raspbian 网站上的源，直接运行 apt-get 命令就可以安装需要的软件包。</p>
<p>在开启图形界面前，建议先使用 apt-get 命令在线安装下面的这些软件包，这对中文显示和输出比较重要：</p>
<p><em><span style="color: #008000;">sudo apt-get install ttf-wqy-zenhei</span></em><br />
<em><span style="color: #008000;">sudo apt-get install ttf-wqy-microhei</span></em><br />
<em><span style="color: #008000;">sudo apt-get install fcitx</span></em></p>
<p>前两个是安装中文字体（不建议安装 simsun 字体），第三个安装中文输入法。</p>
<p>全部配置好之后就可以运行 startx 命令进入图形界面（图中即为 1440 x 900 的分辨率）：</p>
<p><a href="http://zohead.com/wp-content/uploads/raspberry-pi-desktop.jpg" target="_blank"><img class="alignnone" title="Raspberry Pi 桌面" src="http://zohead.com/wp-content/uploads/raspberry-pi-desktop.jpg" alt="Raspberry Pi 桌面" width="588" height="441" /></a></p>
<p>桌面中间又是大大的树莓派 LOGO。Raspbian “wheezy” 系统没有使用 GNOME 或者 KDE 之类的桌面环境，而是使用的 LXDE 轻量级桌面，这样也比较适合 Raspberry Pi 这种小的系统环境。</p>
<p>Raspbian “wheezy” 系统默认也自带了一些编程环境、网络浏览器之类的。下面是浏览中文网页的效果，看起来还是比较完美的（不支持 Flash 之类的就无所谓了 ^_^）：</p>
<p><a href="http://zohead.com/wp-content/uploads/raspberry-pi-network.jpg" target="_blank"><img class="alignnone" title="Raspberry Pi 网络浏览器" src="http://zohead.com/wp-content/uploads/raspberry-pi-network.jpg" alt="Raspberry Pi 网络浏览器" width="588" height="441" /></a></p>
<p>从初步上手使用的效果来看，Raspberry Pi 还是比较令人满意，高清视频播放还没机会测试。下面有机会再来继续折腾了，网上用 Raspberry Pi 做的比较多的是下载机之类的，还有另类的牛人加上了温度传感器之类的东东。</p>
<p>PS：Raspberry Pi 由于只有 256 MB 的内存，因此运行大的程序还是有点卡，而且系统整体的响应速度也和使用的 SD 卡有些关系，未避免影响系统系统，建议使用 class 4 或更高速度的存储卡。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/raspberry-pi-start/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
