神机不死,诺基亚 N900 刷 postmarketOS

Table of Contents

postmarketOS(postmarketos.org)是一个基于 Alpine Linux,专为智能手机搭载较新、安全的 Linux 发行版,以前项目才发布时号称为智能手机实现十年的生命周期。

Nokia N900 是诺基亚公司 2009 年发布的一款搭载了 Maemo Linux 系统的智能手机,除了运行 Maemo,还可以把 Debian、Arch、Kali 等发行版刷进手机,

1. N900 刷机

如果你的 N900 中的 Maemo 系统工作正常,可以不用刷机,刷机所需的相关系统镜像和工具我曾经共享过:https://pan.baidu.com/s/1sjlTvkT

注意: 刷机前请先保证电量充足,我几次失败都是因为电量不足。

刷机步骤如下:

  1. 安装 flasher3.5,Windows 系统直接运行 .exe 安装;Linux 系统的话,由于以前诺基亚只提供了 32 位的 flasher,而现在大部分电脑里运行的是 64 位的系统,所以要运行 32 位的程序,需要事先安装好 32 位的所需的包,以 Fedora 为例:
$ sudo dnf install glibc.i686 libusb.i686
  1. 关闭 N900,然后打开键盘,按住“u”键不要松手,再接入电脑,数秒后手机屏幕右上角可以看到 USB 的图标,然后用 flasher 刷机:
$ sudo ./flasher-3.5 -F RX-51_2009SE_21.2011.38-1.002_PR_COMBINED_002_ARM.bin -f -R

进入系统后,在 App 管理中先安装 rootsh,这样才能在终端中切换到 root 帐号。

进入终端:

  1. 运行 sudo gainroot 切换为 root 身份
  2. 然后安装启动系统所需的 u-boot-flasher: apt-get install u-boot-flasher

2. 安装 postmarketOS

注意: 只有官方文档才是最新、最准确的指导,安装过程中,以及安装之后的配置,你都应当看看官方文档:https://wiki.postmarketos.org/wiki/Nokia_N900

首先去下载安装工具 pmbootstrap:https://gitlab.com/postmarketOS/pmbootstrap/tags,解压并进入目录运行 sudo python3 setup.py install

然后,运行 pmbootstrap init 初始化、收集一些安装信息。为供参考,我把详细的输出全部贴出来了,并且对一些地方加上了中文解释:

$ pmbootstrap init
[14:38:48] Location of the 'work' path. Multiple chroots (native, device arch, device rootfs) will be created in there.
[14:38:48] Work path [/home/lu4nx/.local/var/pmbootstrap]: # 配置系统时存放的目录,默认即可
[14:38:49] NOTE: pmaports path: /home/lu4nx/.local/var/pmbootstrap/cache_git/pmaports
[14:38:49] Target device (either an existing one, or a new one for porting).
[14:38:49] Available (110): amazon-thor, asus-duma, asus-flo, asus-grouper, asus-me176c, asus-t00f, asus-tf101, asus-z00t, bq-chaozu, fairphone-fp1, fairphone-fp2, google-crosshatch, google-glass, gp-peak, htc-a5ul, htc-ace, htc-bravo, htc-flounder, htc-m8, htc-vivo, huawei-angler, huawei-y530, infocus-flatfish, jolla-sbj, leeco-s2, lenovo-karate, lg-bullhead, lg-d285, lg-d855, lg-dory, lg-h815, lg-hammerhead, lg-lenok, lg-mako, lg-w5, motorola-athene, motorola-falcon, motorola-ghost, motorola-harpia, motorola-maserati, motorola-osprey, motorola-peregrine, motorola-potter, motorola-shamu, motorola-surnia, motorola-titan, nextbit-robin, nokia-n9, nokia-n900, nokia-rm885, oneplus-bacon, oneplus-oneplus2, oneplus-onyx, ouya-ouya, pine-a64lts, qemu-aarch64, qemu-amd64, qemu-vexpress, raspberry-pi, raspberry-pi0, raspberry-pi3, samsung-espresso10, samsung-gts210vewifi, samsung-i747m, samsung-i8190, samsung-i8200, samsung-i9003, samsung-i9070, samsung-i9100, samsung-i9195, samsung-i9305, samsung-jflte, samsung-klte, samsung-kminilte, samsung-kylepro, samsung-kylessopen, samsung-kylevess, samsung-lt023g, samsung-maguro, samsung-manta, samsung-n5110, samsung-n7100, samsung-p4wifi, samsung-s6500d, samsung-serranodsdd, semc-anzu, semc-smultron, sony-amami, sony-aries, sony-castor-windy, sony-coconut, sony-honami, sony-nicki, sony-scorpion, sony-seagull, sony-sirius, sony-taoshan, sony-tulip, sony-yuga, t2m-flame, tablet-x64uefi, teclast-x80pro, wiko-lenny3, wingtech-wt88047, xiaomi-armani, xiaomi-cancro, xiaomi-ido, xiaomi-mido, xiaomi-santoni, zte-kis3
[14:38:49] Device [nokia-n900]: # 从上面列出的设备中选择你的目标设备
[14:38:50] This device has proprietary components, which trade some of your freedom with making more peripherals work.
[14:38:50] We would like to offer full functionality without hurting your freedom, but this is currently not possible for your device.
[14:38:50] device-nokia-n900-nonfree-firmware: Wifi firmware
[14:38:50] Enable this package? (y/n) [y]: # 配置 Wifi,这里默认即可
[14:38:51] Available keymaps for device (2): us/rx51_us, ch/rx51_ch-de
[14:38:51] Keymap [us/rx51_us]: # 默认用 us/rx51_us
[14:38:53] Username [lu4nx]: # 系统用户名
[14:38:53] Available user interfaces (7):
[14:38:53] * none: No graphical environment
[14:38:53] * hildon: (X11) Lightweight GTK+2 UI (optimized for single-touch touchscreens)
[14:38:53] * i3wm: (X11) Tiling WM (keyboard required)
[14:38:53] * matchbox: (X11) Very basic user interface for handhelds
[14:38:53] * mate: (X11) MATE Desktop Environment, fork of GNOME2 (stylus recommended)
[14:38:53] * plasma-mobile: (Wayland) Mobile variant of KDE Plasma, optimized for touchscreen (slow without hardware acceleration!)
[14:38:53] * weston: (Wayland) Reference compositor (demo, not a phone interface)
[14:38:53] * xfce4: (X11) Lightweight GTK+2 desktop (stylus recommended)
[14:38:53] User interface [xfce4]: i3wm # 这里选择桌面环境,N900 中建议用 i3wm,占系统资源少
[14:38:57] Build options: Parallel jobs: 9, ccache per arch: 5G
[14:38:57] Change them? (y/n) [n]:
[14:38:57] Additional packages that will be installed to rootfs. Specify them in a comma separated list (e.g.: vim,file) or "none"
[14:38:57] Extra packages [none]:
[14:38:58] Your host timezone: Asia/Shanghai
[14:38:58] Use this timezone instead of GMT? (y/n) [y]:
[14:39:00] Device hostname (short form, e.g. 'foo') [nokia-n900]:
[14:39:01] Zap existing chroots to apply configuration? (y/n) [y]:
[14:39:02] % rm -rf /home/lu4nx/.local/var/pmbootstrap/chroot_native
[14:39:02] % rm -rf /home/lu4nx/.local/var/pmbootstrap/chroot_rootfs_nokia-n900
[14:39:03] Cleared up ~643 MB of space
[14:39:03] WARNING: The applications in the chroots do not get updated automatically.
[14:39:03] Run 'pmbootstrap zap' to delete all chroots once a day before working with pmbootstrap!
[14:39:03] It only takes a few seconds, and all packages are cached.
[14:39:03] Done!

接下来把 SD 卡插到电脑中,用 fdisk -l 看看设备名,我这里 SD 卡对应的是 /dev/sdc,运行:

$ pmbootstrap -t 6000 install --sdcard /dev/sdc --no-fde

对上面的命令,注意:

  1. 不需要 root 权限,所以不要加 sudo
  2. -t 设置超时时间,安装过程中如果执行某条命令超时会被 kill 掉,然后安装失败。由于 SD 卡读写速度并不理想,在最后往 SD 卡写系统时往往会很慢,所以为了保证成功,这里应当设置一个比较大值
  3. 加上 –no-fde 禁用磁盘加密,我开启 FDE 没有安装成功。

接下来就是稍稍漫长的安装过程了,完整输出如下:

$ pmbootstrap -t 6000 install --sdcard /dev/sdc --no-fde
[13:26:13] *** (1/5) PREPARE NATIVE CHROOT ***
[13:26:13] *** (2/5) CREATE DEVICE ROOTFS ("nokia-n900") ***
[13:26:20] (rootfs_nokia-n900) install
[13:26:23] (rootfs_nokia-n900) write /etc/os-release
[13:26:24] (rootfs_nokia-n900) mkinitfs postmarketos-stable
[13:26:28]  *** SET LOGIN PASSWORD FOR: 'lu4nx' ***
New password: # 这里需要设置帐号密码
Retype new password:
passwd: password updated successfully
 * WARNING: loadkmap is already starting
[13:26:37] *** (3/5) PREPARE INSTALL BLOCKDEVICE ***
[13:26:38] (native) mount /dev/install (host: /dev/sdc)
[13:26:51] WARNING: This device has a previous installation of pmOS. CONTINUE? (y/n) [n]: y
[13:27:30] (native) partition /dev/install (boot: 54M, root: the rest)
[13:28:43] (native) format /dev/installp2
[13:32:48] (native) mount /dev/installp2 to /mnt/install
[13:32:49] (native) format /dev/installp1 (boot, ext2), mount to /mnt/install/boot # 这步等待过程最长
[13:32:55] *** (4/5) FILL INSTALL BLOCKDEVICE ***
[13:32:55] (native) copy rootfs_nokia-n900 to /mnt/install/
[13:47:44] *** (5/5) FLASHING TO DEVICE ***
[13:47:44] Run the following to flash your installation to the target device:
[13:47:44] * pmbootstrap flasher flash_kernel
[13:47:44]   Flashes the kernel + initramfs to your device:
[13:47:44]   /home/lu4nx/.local/var/pmbootstrap/chroot_rootfs_nokia-n900/boot
[13:47:44] * If the above steps do not work, you can also create symlinks to the generated files with 'pmbootstrap export' and flash outside of pmbootstrap.
[13:47:44] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[13:47:44] Done

安装完后记得运行 pmbootstrap shutdown

$ pmbootstrap shutdown
[13:52:31] Unregister qemu binfmt (arm)
[13:52:31] Done

把 SD 卡插回手机,并打开键盘后开机,启动时可以看到,几个选项:

Attached kernel
Internal eMMC
External SD card
U-Boot boot order
U-Boot console

选“External SD card”即可。

如果启动失败,就插回电脑,运行 pmbootstrap export 试试:

$ pmbootstrap export
[13:52:17] NOTE: To export the rootfs image, run 'pmbootstrap install' first (without the 'sdcard' parameter).
[13:52:19] Register qemu binfmt (arm)
[13:52:21] (rootfs_nokia-n900) mkinitfs postmarketos-stable
[13:52:26] Export symlinks to: /tmp/postmarketOS-export
[13:52:26]  * initramfs-postmarketos-stable (Initramfs)
[13:52:26]  * uInitrd-postmarketos-stable (Initramfs, legacy u-boot image format)
[13:52:26]  * vmlinuz-postmarketos-stable (Linux kernel)
[13:52:26]  * uImage-postmarketos-stable (Kernel, legacy u-boot image format)
[13:52:26]  * initramfs-postmarketos-stable-extra (Extra initramfs files in /boot)
[13:52:26] NOTE: chroot is still active (use 'pmbootstrap shutdown' as necessary)
[13:52:26] Done

1.png

2.png

3. 简单操作

更多的请见官方 wiki:https://wiki.postmarketos.org/wiki/Nokia_N900_(nokia-n900)

我默认使用的 i3wm 桌面,要进行操作,需要先进入 command 模式:shift + space,官方文档给出的一些命令:

按键 用途
t 打开终端
k kill 当前程序
w workspace 模式
r 重启 i3wm
q 返回默认模式(退出命令模式)

连接 Wifi:

在终端执行 nmtui 命令。