Difference between revisions of "Nokia N900 (nokia-n900)"

From postmarketOS
Jump to navigation Jump to search
(Added markdown contents)
 
 
(171 intermediate revisions by 32 users not shown)
Line 1: Line 1:
### Contributors
+
{{Infobox device
* MartijnBraam
+
| manufacturer = Nokia
* craftyguy
+
| name = N900
 +
| codename = nokia-n900
 +
| image = File:Nokia-rx51-cmus.jpg
 +
| imagecaption = Nokia N900 running cmus
 +
| releaseyear = 2009
 +
| category = community
 +
| originalsoftware = Maemo Fremantle on Linux 2.6
 +
| pmoskernel = Mainline Linux
 +
| chipset = TI OMAP 3430
 +
| cpu = 1x 600 MHz Cortex-A8
 +
| gpu = PowerVR SGX530
 +
| storage = 32 GB
 +
| display = 800x480 TFT resistive
 +
| memory = 256 MB
 +
| architecture = armv7
 +
| n-android = ✔
 +
| whet_dhry = 58.4
 +
| status_usbnet = Y
 +
| status_flashing = -
 +
| status_touch = Y
 +
| status_screen = Y
 +
| status_wifi = Y
 +
| status_xwayland = Y
 +
| status_fde = Y
 +
| status_mainline = Y
 +
| status_battery = Y
 +
| status_3d = -
 +
| status_accel = Y
 +
| status_audio = Y
 +
| status_bluetooth = N
 +
| status_camera = P
 +
| status_gps = P
 +
| status_mobiledata = Y
 +
| status_sms = Y
 +
| status_calls = P
 +
| status_otg = N
 +
| booting = yes
 +
}}
 +
[[File:I3wm-n900.jpg|thumb|right|Running i3wm]]
 +
[[File:20170724 0002.jpg|thumb|right|Splash screen]]
  
### What works
+
=== Users owning this device ===
* Booting the system
+
{{Device owners}}
* Kernel log to the display
 
* Framebuffer graphics
 
* Unlocking the root partition using the keyboard
 
* Display Backlight control
 
* Wayland on framebuffer
 
* Module loading
 
* Wifi (see Additional Info below)
 
* Notification led
 
* Audio playback
 
* Keyboard backlight (see Additional Info below)
 
* Battery capacity reporting (see Additional Info below)
 
* Keyboard in virtual terminal
 
  
### What does not work
+
=== Contributors ===
* Both cameras
+
* ''[[user:MartijnBraam|MartijnBraam]]''
* Cell modem (untested)
+
* ''[https://gitlab.com/craftyguy craftyguy]''
* 3D Acceleration (requires binary blob)
+
* ''[https://github.com/pavelmachek Pavel Machek]''
 +
* ''[[user:Sicelo|sicelo]]''
 +
* ''[[user:drebrez|drebrez]]''
 +
* ''[https://github.com/fxkrait FXKrait]''
 +
* ''[[user:ollieparanoid|ollieparanoid]]''
  
### Installation
+
== Additional info ==
 +
Cameras are supported in the kernel, but have very complex media pipelines. [https://git.sr.ht/~martijnbraam/megapixels-compat Megapixels] has preliminary support for at least the rear/main camera.
  
We currently only support installing and running pmos from the microsd card on the n900.
+
The GPU is a PowerVR SGX530 which does not have FOSS drivers, so 3D acceleration does not work with the mainline kernel. However, the required [https://gitlab.com/postmarketOS/pmaports/-/tree/master/non-free/sgx-ddk-um blobs] and [https://gitlab.com/postmarketOS/pmaports/-/tree/master/main/mesa-pvr-dri-classic patched mesa] have been merged into pmaports, and the [https://github.com/openpvrsgx-devgroup/linux_openpvrsgx linux openpvrsgx dev group] maintains a "near-mainline" kernel fork with the required kernel driver.  
Getting it to work with emmc and 0xffff is harder to implement and has no real benefit since
 
the built in emmc is quite slow and fragile.
 
  
1. Init pmbootstrap
+
Voice calls work, but need https://gitlab.com/libcmtspeechdata/libcmtspeechdata to route the speech data. Due to very tight timings involved in the associated protocol, the audio is very low quality unless additional processing is performed (Nokia had closed-source Pulseaudio modules for this).
  
```bash
+
There's bluetooth support at bluetooth-next, but that works on N950, not on N900. [https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=7bb318680e868cd049922f6761170b42ff89687d Bluetooth] . The driver compiles fine, but fails on loading the firmware.
$ ./pmbootstrap.py init
+
 
```
+
OTG might work since the kernel has support. However, like [[Wileyfox_Swift_(wileyfox-crackling)]], there is a hardware limitation that prevents the N900 from automatically detecting that there's a connected device, and also detecting the USB version/speed it supports. With some work, it most likely should work with manual activation
 +
 
 +
== Installation ==
 +
We currently only support installing and running pmOS from the microSD card on the N900. Getting it to work with eMMC and 0xffff is harder to implement and has no real benefit since the built-in eMMC is quite slow and fragile.
 +
 
 +
=== Flash postmarketOS to SD card ===
 +
{{note|If your phone does not jump from Nokia logo to U-Boot prompt when powered on and booted with the keyboard slider open, you'll need to install U-Boot by Pali, see [[#Configure u-boot on eMMC to boot from the SD card]]}}
 +
 
 +
==== From pre-built image (easy method) ====
 +
Official images of postmarketOS for the N900 are built at least every week.
 +
 
 +
Choose an image for your device from the [https://postmarketos.org/download/ download] page.
 +
 
 +
Then flash it to your SD as follows. Adjust the image name and the path to your SD card (you can figure it out with <code>lsblk</code>).
 +
 
 +
<source lang="shell-session">
 +
$ xzcat 20210209-0034-postmarketOS-edge-i3wm-0.3-nokia-n900.img.xz | sudo dd of=/dev/mmcblk... status=progress bs=1M
 +
</source>
 +
 
 +
The first boot takes longer, as the root partition gets resized to fit the whole SD card. There is a lot of kernel output during boot, just wait patiently until i3wm shows up. Read [[#i3wm]] for the N900 specific keybindings, most importantly <code>Shift + Space</code>, then <code>t</code> to open a terminal. Use <code>sudo nmtui</code> to connect to a Wi-Fi network.
 +
 
 +
==== With pmbootstrap (advanced) ====
 +
Instead of the pre-built images, you can use <code>pmbootstrap</code> to generate your own image. It allows to use full disk encryption, use another user interface (e.g. XFCE4) and other customizations.
 +
 
 +
1. Initialize pmbootstrap
 +
: <source lang="shell-session">$ pmbootstrap.py init</source>
 +
: Choose 'nokia-n900' as target device.
  
 
2. Start the build process and install the completed image to a sdcard
 
2. Start the build process and install the completed image to a sdcard
 +
: (Replace /dev/sdX with the device for your sdcard)
 +
: <source lang="shell-session">$ pmbootstrap install --sdcard /dev/sdX</source>
 +
 +
=== Configure u-boot on eMMC to boot from the SD card ===
 +
# [http://maemo.org/downloads/product/Maemo5/u-boot-flasher/ Install u-boot from pali] on the n900 in Maemo. If this does not work from the graphical interface you may run <code>sudo apt-get install u-boot-flasher</code> in maemo terminal (see {{issue|16|wiki}} and {{issue|1371|pmbootstrap}}).  See Additional Info below for instructions on configuring pmos to boot by default.
 +
# Place the sdcard into the n900 and boot it with the keyboard slide open
 +
# Choose the u-boot shell
 +
# enter <code>run sdboot</code> into the shell
 +
 +
== Features ==
 +
 +
=== Configuring U-boot (optional) ===
 +
 +
In order to configure pmos to boot by default on the N900, using U-boot, you will need to boot into Maemo and create a <code>/etc/bootmenu.d/10-pmos.item</code> file as the root user with these contents:
 +
 +
{{hc|/etc/bootmenu.d/10-pmos.item|<syntaxhighlight lang="ini">
 +
ITEM_NAME="postmarketOS"
 +
ITEM_SCRIPT="boot.scr"
 +
ITEM_DEVICE="${EXT_CARD}p1"
 +
ITEM_FSTYPE="ext2"
 +
</syntaxhighlight>}}
 +
It can be set to the default boot option by creating a symlink:
  
```bash
+
<pre>root@Nokia-N900:~# ln -s /etc/bootmenu.d/10-pmos.item /etc/default/bootmenu.item</pre>
# Replace /dev/sdX with the device for your sdcard
+
Finally, run <code>u-boot-update-bootmenu</code>:
$ ./pmbootstrap.py install --sdcard /dev/sdX
 
```
 
  
3. [Install u-boot from pali](http://maemo.org/downloads/product/Maemo5/u-boot-flasher/) on the n900 if you haven't installed it already. See Additional Info below for instructions on configuring pmos to boot by default.
+
<pre>root@Nokia-N900:~# u-boot-update-bootmenu
1. Place the sdcard into the n900 and boot it with the keyboard slide open
+
Default bootmenu entry is '/etc/bootmenu.d/10-pmos.item'
1. Choose the u-boot shell
+
Adding bootmenu entry for: 'Maemo 5 with attached kernel (Internal Nand)'
1. enter `run sdboot` into the shell
 
  
 +
Configuration file: /etc/bootmenu.d/10-pmos.item
 +
Adding bootmenu entry for: 'postmarketOS'
 +
Configuring this bootmenu entry as default
  
### Links
+
Generating u-boot bootmenu script...
* [Device package](https://github.com/postmarketOS/pmbootstrap/tree/master/aports/device/device-nokia-rx51)
+
</pre>
* [Kernel source](https://kernel.org)
+
'''Note''': This will set pmos as the default boot option. Maemo will still be accessible when booting the N900 with the keyboard slide out and selecting the relevant boot option in the u-boot boot menu.
  
### Additional info
+
=== Wifi ===
 +
The <code>device-nokia-n900-nonfree-firmware</code> package is required to provide the wl1251 firmware necessary for initializing the wifi device. ([https://github.com/postmarketOS/pmbootstrap/pull/1414 #1414])
 +
You get asked during <code>pmbootstrap init</code> if you would like to install that proprietary firmware package.
  
* Martijn's N900 has uboot installed a long time ago, I'm using sdcard boot from the bootmenu shell using `run sdboot`
+
Now you can use NetworkManager's console UI to connect to your network. Please note that <code>nmtui</code> does not work properly when started from <code>tmux</code>.
* The [Neo900](https://neo900.org/) (still in development) will upgrade the hardware inside of the N900, and has some nice features such as hardware sandboxing the modem.
 
  
#### Wifi
+
<syntaxhighlight lang="shell-session">
 +
$ nmtui
 +
</syntaxhighlight>
  
The `linux-firmware` package is required to provide the wl1251 firmware necessary for initializing the wifi device. ([#158](https://github.com/postmarketOS/pmbootstrap/pull/158))
+
==== WiFi settings do not work across reboots ====
  
Once the device has been successfully initialized, enable it:
+
The MAC address of the N900 WiFi interface its being randomized at every boot, since the connection profile created with <code>nmtui</code> is bound to
 +
the MAC address, it won't work at the next boot.
  
    $ sudo ip link set wlan0 up
+
To solve this, after connecting you can use <code>nmtui</code> to edit the created profile, and remove the MAC address from the "Device" section
    $ sudo iw wlan0 set type managed
 
  
Configure wpa_supplicant (only necessary on encrypted networks):
+
==== Without NetworkManager ====
 +
If NetworkManager should not work for you, make sure that it is not running and run the following commands to connect to an encrypted network manually:
  
    $ sudo su -
+
<syntaxhighlight lang="shell-session">
    # wpa_passphrase $YOUR_SSID > /etc/wpa_supplicant/wlan0.conf
+
$ sudo su -
    <enter passphrase here and press Enter>
+
# ip link set wlan0 up
    # exit
+
# iw wlan0 set type managed
 +
# wpa_passphrase $YOUR_SSID > /etc/wpa_supplicant/wpa_supplicant.conf
 +
<enter passphrase here and press Enter>
 +
# exit
 +
</syntaxhighlight>
  
 
Connect to network using wpa_supplicant:
 
Connect to network using wpa_supplicant:
  
    $ sudo wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wlan0.conf
+
<syntaxhighlight lang="shell-session">
 +
$ sudo rc-service wpa_supplicant restart
 +
</syntaxhighlight>
  
If your network uses DHCP, start the DHCP client:
+
==== Power saving / ping times ====
  
    $ sudo udhcpc -i wlan0
+
It should be possible to disable power saving for better ping times, see {{maemo-leste|172}}.
  
#### Keyboard Backlight
+
<syntaxhighlight lang="shell-session">
 +
$ sudo su -
 +
# apk add iw
 +
# iw dev wlan0 set power_save off
 +
# exit
 +
</syntaxhighlight>
  
There are 6 keyboard backlight LEDs that can be adjusted, they are found under `/sys/class/leds/lp5523:kb{1-6}`. To adjust brightness, write a value, $VAL between 0 and 255, to the `brightness` parameter as the root user:
+
=== Sound ===
 +
Modules need not to be compiled, sound support is built into kernel. Install alsa-utils.  
  
```
+
<pre>
for i in $(seq 1 6);
+
aplay /usr/share/sounds/alsa/Front_Left.wav
    do echo $VAL > /sys/class/leds/lp5523\:kb$i/brightness
+
</pre>
done
 
```
 
  
#### Display
+
NikkSaan provided an advanced audio configuration in [https://github.com/postmarketOS/pmbootstrap/pull/702#issuecomment-380999740 #702 (comment)].
  
With DRM enabled ([#197](https://github.com/postmarketOS/pmbootstrap/pull/197)), the display can be managed at this location: `/sys/devices/platform/omapdrm.0/graphics/fb0/`
+
=== Keyboard Backlight ===
  
For example, the display can be turned off by:  
+
There are 6 keyboard backlight LEDs that can be adjusted, they are found under <code>/sys/class/leds/lp5523:kb{1-6}</code>. To adjust brightness, write a value, $VAL between 0 and 255, to the <code>brightness</code> parameter as the root user:
  
```
+
<pre>for i in $(seq 1 6);
# echo 1 > /sys/devices/platform/omapdrm.0/graphics/fb0/blank
+
    do echo $VAL &gt; /sys/class/leds/lp5523\:kb$i/brightness
```
+
done</pre>
  
#### Keyboard layout in console
+
=== Keyboard layout ===
  
In order to set the keyboard layout for the virtual console (e.g. to take advantage of number keys on the N900 keyboard), obtain your desired language keymap file for the RX-51, [such as this one.](https://raw.githubusercontent.com/archlinuxarm-n900/n900-keymaps/master/rx51_us.map). (TODO: Need to pull 'official' vconsole keymaps from Maemo5 if they exist..).
+
The keyboard layout is asked during <code>pmbootstrap init</code> after you select the <code>nokia-n900</code> device.
  
On the N900, install `kbd-bkeymaps`, either by using `pmbootstrap install --add kbd-bkeysmaps` on the host system or by running `apk add kbd-bkeysmaps` on the device itself.
+
Available keymaps:
 +
<div style="overflow:hidden">
 +
[[File:N900 keymap us.jpg|800px|thumb|left|us/rx51_us]]
 +
[[File:N900 keymap ch-de.jpg|800px|thumb|left|ch/rx51_ch]]
 +
[[File:N900 keymap se.jpg|800px|thumb|left|se/rx51_se and fi/rx51_fi (same for Swedish and Finnish).]]
 +
[[File:N900 keymap it.jpg|800px|thumb|left|it/rx51_it]]
 +
</div>
  
The keymap must be in binary format, bmap. This can be accomplished using the `loadkeys` tool:
+
==== Console ====
  
```bash   
+
:'''NOTE:''' during installation pmbootstrap will typically ask you for the desired keymap. The following is only for experimentation: normally all should just work fine after setting up the SD card from pmbootstrap. The following section may be dated and pmbootstrap has already done the job for you.
$ apk add kbd kbd-bkeymaps
+
 
 +
To obtain your desired language keymap file for the RX-51, [https://raw.githubusercontent.com/archlinuxarm-n900/n900-keymaps/master/rx51_us.map such as this one]:
 +
 
 +
* On the N900, install <code>kbd-bkeymaps</code>, either by using <code>pmbootstrap install --add kbd-bkeymaps</code> on the host system or by running <code>apk add kbd-bkeymaps</code> on the device itself.
 +
 
 +
* The keymap must be in binary format, bmap. This can be accomplished using the <code>loadkeys</code> tool:
 +
 
 +
<source lang="shell">$ apk add kbd kbd-bkeymaps
 
$ loadkeys -b rx51_us.map > rx51_us.bmap
 
$ loadkeys -b rx51_us.map > rx51_us.bmap
$ gzip rx51_us.bmap
+
$ gzip rx51_us.bmap</source>
```
+
 
 +
* Compress it and copy it to <code>/usr/share/bkeymaps/us/</code> on the N900.
 +
 
 +
* Log into the N900, and run <code>sudo setup-keymap</code>, then select <code>us</code> and finally <code>rx51_us</code>.
 +
 
 +
(TODO: Need to pull 'official' vconsole keymaps from Maemo5 if they exist..)
 +
 
 +
==== X11 ====
 +
 
 +
:'''NOTE:''' during installation pmbootstrap will typically ask you for the desired X11 xkb keymap. The following is only for experimentation: normally all should just work fine after setting up the SD card from pmbootstrap. The following section may be dated and pmbootstrap has already done the job for you.
 +
 
 +
In X11 you can use <code>setxkbmap</code> to configure the desired layout.
  
Compress it and copy it to `/usr/share/bkeymaps/us/` on the N900.
+
Right now it's configured to use the <code>nokiarx51/us</code> layout by default (see [https://github.com/postmarketOS/pmbootstrap/blob/a7afd519eff34237dfe2766634ac6b2c5076e9f5/aports/device/device-nokia-n900/keymaps/40-xkb.conf 40-xkb.conf]) then the pmbootstrap script will patch this file to set the <code>Option "XkbLayout"</code> to <code>"nn"</code> where "nn" is your country code.
  
Log into the N900, and run `sudo setup-keymap`, then select `us` and finally `rx51_us`.
+
{{note| Info: Tab is ctrl+i}}
  
#### Battery Capacity Reporting
+
==== Console switching ====
  
The current battery capacity can be found under `/sys/class/power_supply/bq27200-0/capacity`, and is represented as a percentage. For example, a value of `11` equates to `11%`. If `capacity` does not exist or contains erroneous information, then your battery needs to be calibrated first. To calibrate the battery:
+
You can use the <code>[[File:Nokia-n900-blue-arrow.PNG|30px]] blue arrow</code> key in combination with the <code>Volume Up/Down</code> to switch to a different virtual terminal.
  
1) Charge it up fully, using a wall power adapter.
+
If you installed postmarketOS with a UI, you first have to enable again the other VT by editing the <code>/etc/inittab</code> file and uncomment the following lines:
 +
<syntaxhighlight lang="sh">
 +
...
 +
# Set up a couple of getty's
 +
tty1::respawn:/sbin/getty 38400 tty1
 +
tty2::respawn:/sbin/getty 38400 tty2
 +
tty3::respawn:/sbin/getty 38400 tty3
 +
tty4::respawn:/sbin/getty 38400 tty4
 +
tty5::respawn:/sbin/getty 38400 tty5
 +
tty6::respawn:/sbin/getty 38400 tty6
 +
...
 +
</syntaxhighlight>
  
2) Once it is charged up, power on the device
+
=== Display ===
  
3) Unplug the device and allow the battery to run all the way down until it powers off. This may take quite a while to happen (>24hrs, but can be made shorter by running a CPU intensive workload)
+
With DRM enabled ({{MR|197|pmbootstrap}}), the display can be managed at this location: <code>/sys/devices/platform/omapdrm.0/graphics/fb0/</code>
  
4) When device powers off, plug it back into wall adapter and allow to charge up fully again. The battery and charging chip should now be calibrated.
+
For example, the display can be turned off by:
  
[Datasheet for the bq27200 charging chip](http://www.ti.com/lit/ds/symlink/bq27200.pdf)
+
<pre># echo 1 &gt; /sys/devices/platform/omapdrm.0/graphics/fb0/blank</pre>
  
#### Setting the hardware clock
+
To adjust brightness:
 +
 
 +
<pre>
 +
# # Replace $VAL with a value from 0 to 255:
 +
# echo $VAL > /sys/class/backlight/acx565akm/brightness
 +
</pre>
 +
 
 +
=== GUI ===
 +
 
 +
==== i3wm ====
 +
'''[[I3wm]] is the recommended UI.''' It is lightweight and fast, and we have a custom N900 configuration that optimizes for its keyboard ([https://www.reddit.com/r/unixporn/comments/7wt8ig/i3gaps_n900_restored_to_glory/ photos]). The most important keybindings are described below, for details see [https://gitlab.com/postmarketOS/pmaports/-/blob/master/device/community/device-nokia-n900/i3wm/i3wm.conf i3wm.conf]. This file gets installed to <code>~/.config/i3/config</code> and of course you can customize it. If you have good additions, please make a merge request so everybody benefits from an improved default config.
 +
 
 +
===== default mode =====
 +
* shift + space: switch to "command mode"
 +
 
 +
===== command mode =====
 +
* t: open terminal
 +
* k: kill current program
 +
* w: workspace mode
 +
* r: restart i3wm (use after modifying the config)
 +
* q: go back to "default mode"
 +
 
 +
===== workspace mode =====
 +
* a/s/d/f/g: switch to workspace 1/2/3/4/5
 +
* q: go back to "command mode"
 +
 
 +
==== Xfce4 ====
 +
[[Xfce4]] does not have performance issues, but since this UI is not optimized for keyboard only usage or for touch screen usage, it is not as user-friendly as i3wm with the postmarketOS default config.
 +
 
 +
==== Others ====
 +
There are also Mate, etc.
 +
 
 +
==== Misc: Power button ====
 +
If you want to make use of the power button, bind <code>XF86PowerOff</code> to this script:
 +
<syntaxhighlight lang="sh">
 +
FILE=~/.screenoff
 +
if [ -f $FILE ]; then
 +
    xinput set-prop 8 "Device Enabled" 1
 +
    xinput set-prop 6 "Device Enabled" 1
 +
    xinput set-prop 9 "Device Enabled" 1
 +
    xset dpms force on
 +
    rm ~/.screenoff
 +
else
 +
    xinput set-prop 8 "Device Enabled" 0
 +
    xinput set-prop 6 "Device Enabled" 0
 +
    xinput set-prop 9 "Device Enabled" 0
 +
    xset dpms force off
 +
    touch ~/.screenoff
 +
fi
 +
</syntaxhighlight>
 +
 
 +
{{note|You cannot use this to turn the screen back on if i3lock or similar is running, as they would grab the keys}}
 +
 
 +
==== Misc: Middle click and right click ====
 +
Obviously, you can't middle click with a touchscreen, but this can be annoying when it's one of the few ways to paste in the terminal.
 +
This script simulates a middle click:
 +
<syntaxhighlight lang="sh">
 +
xdotool mousedown --clearmodifiers 2
 +
xdotool mouseup 2
 +
xdotool keyup alt
 +
xdotool keyup ctrl
 +
xdotool keyup shift
 +
</syntaxhighlight>
 +
 
 +
For simulating right click button you can use this command:
 +
<syntaxhighlight lang="sh">
 +
xdotool click 3
 +
</syntaxhighlight>
 +
 
 +
You can bind it to any key you wish. <code>XF86WebCam</code> is a good choice since it's fairly easy to reach and isn't used for anything.
 +
 
 +
=== Battery ===
 +
==== Charging ====
 +
 
 +
Battery charging is fully supported by the kernel and does not need any special configuration.
 +
 
 +
==== Capacity Reporting ====
 +
 
 +
The current battery capacity can be found under <code>/sys/class/power_supply/bq27200-0/capacity</code>, and is represented as a percentage. For example, a value of <code>11</code> equates to <code>11%</code>. To calibrate the battery and get a more accurate capacity report:
 +
 
 +
1) Charge it up '''fully''', using a wall power adapter.
 +
 
 +
2) Unplug the device and allow the battery to run all the way down until it powers off. This may take quite a while to happen (&gt;24hrs, but can be made shorter by running a CPU intensive workload). Do not let it charge at all during this time. This means you may not use USB for example, as this automatically causes the device to start charging, albeit slowly.
 +
 
 +
3) When device eventually powers off, the battery charge gauge chip should then be calibrated. You may charge it up again to use the device.
 +
 
 +
[http://www.ti.com/lit/ds/symlink/bq27200.pdf Datasheet for the bq27200 charge gauge chip]
 +
 
 +
'''Hint: '''To disable the LED charging indication, disable the charging chip's status pin.
 +
 
 +
<code>echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable</code>.
 +
 
 +
[http://www.ti.com/lit/ds/symlink/bq24150.pdf Datasheet for the bq24150 charging chip]
 +
 
 +
==== Battery Protection ====
 +
Currently, when battery gets below suitable operating voltage, the device dies. This is bad for the battery and the file system. [https://gist.github.com/NikkSaan/800c17d87dddfaa9edf5274130717d73 Here] is a script that monitors the battery, and powers the device off before the battery reaches critical state. For suggested usage, read the program's comments.
 +
 
 +
=== Clock ===
 +
==== Setting the hardware clock ====
  
 
Since 49fd9e0e4efcf030ca47344858bdc74370a78603 the hardware clock works. If your hardware clock doesn't have the time set you can set it with:
 
Since 49fd9e0e4efcf030ca47344858bdc74370a78603 the hardware clock works. If your hardware clock doesn't have the time set you can set it with:
  
```bash
+
<source lang="shell"># Get the system date in the right ballpark so ntpd works
# Get the system date in the right ballpark so ntpd works
 
 
$ date -s "2017-08-14 16:34:50"
 
$ date -s "2017-08-14 16:34:50"
  
 
# Write the current system time to the hardware clock
 
# Write the current system time to the hardware clock
$ hwclock -w
+
$ hwclock -w</source>
```
+
 
 +
==== Setting the hardware alarm clock ====
 +
 
 +
Realtime clock at /dev/rtc0 is on the twl4030 (PMU), and allows setting an alarm to wake the device from sleep, poweroff states.
 +
 
 +
Control trough <code>rtcwake</code> [https://linux.die.net/man/8/rtcwake (Manual Page)].
 +
<source lang="shell">
 +
# Suspends the device to memory for 10 seconds
 +
rtcwake --verbose --seconds 10 --mode mem
 +
 
 +
# Power off the device and power it on after $TIME, where $TIME is the number of seconds since epoch (1970-01-01)
 +
rtcwake --verbose --time_t $TIME --mode no
 +
/sbin/poweroff
 +
</source>
 +
 
 +
Manual control from sysfs:
 +
<source lang="shell">
 +
# To set the wakealarm directly, set $TIME to number of seconds since epoch (1970-01-01). Then poweroff or suspend:
 +
echo $TIME > /sys/class/rtc/rtc0/wakealarm
 +
 +
# To set new wakealarm time, first reset time to 0!
 +
echo 0 > /sys/class/rtc/rtc0/wakealarm
 +
</source>
 +
 
 +
{{note| When setting number of seconds since epoch, make sure you account for your timezone and see how your realtime clock keeps the time (utc or local)!}}
 +
 
 +
=== SMS ===
 +
 
 +
In order to use the ofono test scripts, you must install py-dbus, that is currently available only for python2.
 +
 
 +
{{note|The N900 needs internet access to perform these steps. See the section above on setting up Wifi.}}
 +
{{note|Your date/time need to be correct in order for HTTPS to work. You can use ntpd to do this.}}
 +
<pre>
 +
# apk add git py-dbus
 +
# git clone --depth 1 https://git.kernel.org/pub/scm/network/ofono/ofono.git
 +
</pre>
 +
 
 +
Here's an example using the test scripts to enable the modem and send a SMS:
 +
<pre>
 +
# cd ofono/test
 +
# python3 enable-modem
 +
# python3 online-modem
 +
# python3 send-sms 5033784582 "I like pizza." 0
 +
</pre>
 +
 
 +
=== USB Gadget ===
 +
==== Mass Storage ====
 +
The Mass Storage class exposes a block device as a flash drive on your host machine.
 +
 
 +
For example, to use the "MyDocs" partition as Mass Storage Device, make sure you unmount the partition first (if mounted), then execute:
 +
 
 +
<code>
 +
echo /dev/mmcblk1p1 > /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/gadget/lun0/file
 +
</code>
 +
 +
If you only need read permissions on the partition, you can set the read-only flag before exporting it:
 +
 
 +
<code>
 +
echo 1 > /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/gadget/lun0/ro
 +
</code>
 +
 
 +
=== GPRS ===
 +
 
 +
GPRS can be managed by [https://pkgs.alpinelinux.org/package/edge/testing/armhf/connman connman]. Either install connman using <code>apk</code> or add it when installing pmOS by passing <code>--add connman</code> to <code>pmbootstrap</code>.
 +
 
 +
{{note|Once you perform the following steps, the GPRS connection will be established by connman automatically on every boot.}}
 +
 
 +
It's '''VERY''' important that you add the following to <code>/etc/connman/main.conf</code> '''BEFORE''' starting connman, else it will take over all network connection handling and disconnect you if you are connected over SSH:
 +
 
 +
{{hc|/etc/connman/main.conf|<nowiki>
 +
NetworkInterfaceBlacklist = usb,wlan
 +
</nowiki>}}
 +
 
 +
Configure connman to start at boot:
  
#### Configuring U-boot
+
<code>$ sudo rc-update add connman</code>
  
In order to configure pmos to boot by default on the N900, using U-boot, you will need to boot into Maemo and create a `/etc/bootmenu.d/10-pmos.item` file as the root user with these contents:
+
Stop ofono in order to set APN:
  
```
+
<code>$ sudo rc-service ofono stop</code>
ITEM_NAME="Postmarket OS"
+
 
ITEM_SCRIPT="boot.scr"
+
Edit APN, where <IMSI> should be replaced in the following commands with the IMSI from your SIM card. Replace <APN> with the relevant APN for your cellular carrier (e.g. fast.t-mobile.com).
ITEM_DEVICE="${EXT_CARD}p1"
+
This file should be created when ofono starts, so you should only need to add the APN.
ITEM_FSTYPE="ext2"
+
 
```
+
{{hc|/var/lib/ofono/<IMSI>/gprs|<nowiki>
 +
[Settings]                                                                                                                                                                                                                                                                                                                                                             
 +
Powered=true                                                                                                                                                                                                                                                                                                                                                           
 +
RoamingAllowed=false                                                                                                                                                                                                                                                                                                                                                   
 +
                                                                                                                                                                                                                                                                                                                                                                       
 +
[context1]                                                                                                                                                                                                                                                                                                                                                             
 +
Name=Internet                                                                                                                                                                                                                                                                                                                                                         
 +
AccessPointName=<APN>                                                                                                                                                                                                                                                                                                                                     
 +
Username=                                                                                                                                                                                                                                                                                                                                                              
 +
Password=                                                                                                                                                                                                                                                                                                                                                              
 +
AuthenticationMethod=chap                                                                                                                                                                                                                                                                                                                                             
 +
Type=internet                                                                                                                                                                                                                                                                                                                                                         
 +
Protocol=ip 
 +
</nowiki>}}
 +
 
 +
Start ofono and power on modem.
 +
 
 +
<pre>
 +
$ sudo rc-service ofono start
 +
$ sudo connmanctl enable cellular
 +
</pre>
  
It can be set to the default boot option by creating a symlink:
+
In some cases, it seems necessary to run a scan before the necessary service will show in connman, even though the scan is 'unsupported':
 +
<pre>
 +
$ sudo connmanctl scan cellular                                                               
 +
Error /net/connman/technology/cellular: Not supported                                   
 +
$ sudo connmanctl services
 +
cellular_340369959729712_context1
 +
</pre>
  
```
+
Connect to the cellular service:
root@Nokia-N900:~# ln -s /etc/bootmenu.d/10-pmos.item /etc/default/bootmenu.item
 
```
 
  
Finally, run `u-boot-update-bootmenu`:
+
<pre>                               
 +
$ sudo connmanctl connect cellular_340369959729712_context1                                   
 +
Connected cellular_340369959729712_context1
 +
$ ip addr show gprs0
 +
10: gprs0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UNKNOWN qlen 10
 +
    link/[821]
 +
    inet 33.238.141.172/32 brd 33.238.141.172 scope global gprs0
 +
      valid_lft forever preferred_lft forever
 +
</pre>
  
```
+
=== GPS ===
root@Nokia-N900:~# u-boot-update-bootmenu
 
Default bootmenu entry is '/etc/bootmenu.d/10-pmos.item'
 
Adding bootmenu entry for: 'Maemo 5 with attached kernel (Internal Nand)'
 
  
Configuration file: /etc/bootmenu.d/10-pmos.item
+
First, get network and date to work. Next, clone tui repository. it contains includes many goodies, including script for hardware testing, gps support, and graphical ofono control software.
Adding bootmenu entry for: 'Postmarket OS'
 
Configuring this bootmenu entry as default
 
  
Generating u-boot bootmenu script...
+
<pre>
 +
mkdir /my
 +
cd /my
 +
git clone https://gitlab.com/tui/tui.git
 +
</pre>
  
```
+
Next, install packages necessary for compiling software and prepare gps2. enable-modem, online-modem and you should be able to run gps2. AGPS is not available, so expect long startup.
  
**Note**: This will set pmos as the default boot option. Maemo will still be accessible when booting the N900 with the keyboard slide out and selecting the relevant boot option in the u-boot boot menu.
+
<pre>
 +
apk add gcc vala musl-dev make linux-headers gpsd
 +
cd /my/tui/ofone
 +
make gps2
 +
./gps2
 +
</pre>
  
### Helpful Links for Porting
+
gps2 reportedly can talk to gpsd. Needs further investigation.
  
- [Device schematic](https://neo900.org/stuff/block-diagrams/n900/n900.html)
+
=== FM Transmitter ===
  
- [Very detailed schematic](http://plan9.stanleylieber.com/hardware/n900/n900.schematics.pdf)
+
The N900 contains an Si4713 FM transmitter, it's controlled by video4linux. To start transmitting:
  
- [Arch Linux ARM - N900 hardware components list](https://github.com/archlinuxarm-n900/alarm-n900/wiki/Hardware-support)
+
<source lang="shell-session">
 +
$ v4l2-ctl -d /dev/radio0 --set-ctrl=mute=0 --set-freq=95.21
 +
Now there should be silence on 95.21Mhz instead of noise when tuning in with a radio
 +
$ aplay -vv some-very-good-music.wav
 +
</source>
  
- [N900 sensor access in Maemo](http://mlab.taik.fi/paja/?p=1263)
+
== Resources ==
 +
* {{Device package|nokia-n900|community}}
 +
* {{Kernel package|nokia-n900|community}}
 +
* [https://kernel.org Kernel source]
 +
* [https://web.archive.org/web/20131117073524/http://skeiron.org/tablets-dev/nokia_N900/ Images and Flashers for Maemo]
 +
* {{issue|1617}} issue about Wi-Fi Setup and Keyboard layout
 +
* [[User:Ollieparanoid/Dogfooding:N900|ollieparanoid's efforts to use the N900 as music player]]
 +
* [https://n900.quitesimple.org/rescueOS/rescueOS-1.3/ N900 rescueOS]
 +
* [https://www.electroschematics.com/mobile-phone-battery-emulator/ Mobile phone battery emulator] describes how to create a mock battery for Nokia phones of the n900 type so the phone can be run from a PSU
  
- [Hardware component specs / list](http://natisbad.org/N900/n900-commented-hardware-specs.html)
+
== Helpful Links for Porting ==
 +
* [https://neo900.org/stuff/block-diagrams/n900/n900.html Device schematic]
 +
* [http://plan9.stanleylieber.com/hardware/n900/n900.schematics.pdf Very detailed schematic]
 +
* [https://github.com/archlinuxarm-n900/alarm-n900/wiki/Hardware-support Arch Linux ARM - N900 hardware components list]
 +
* [http://mlab.taik.fi/paja/?p=1263 N900 sensor access in Maemo]
 +
* [http://natisbad.org/N900/n900-commented-hardware-specs.html Hardware component specs / list]
 +
* [http://elinux.org/N900 Kernel status]

Latest revision as of 16:50, 20 July 2021

Nokia N900
Nokia N900 running cmus
Nokia N900 running cmus
Manufacturer Nokia
Name N900
Codename nokia-n900
Released 2009
Category community
Original software Maemo Fremantle on Linux 2.6
postmarketOS kernel Mainline Linux
Hardware
Chipset TI OMAP 3430
CPU 1x 600 MHz Cortex-A8
GPU PowerVR SGX530
Display 800x480 TFT resistive
Storage 32 GB
Memory 256 MB
Architecture armv7
Non-Android based device
Unixbench Whet/Dhry score 58.4
Features
USB Networking
Works
Flashing
Unavailable
Touchscreen
Works
Display
Works
WiFi
Works
Xwayland
Works
FDE
Works
Mainline
Works
Battery
Works
3D Acceleration
Unavailable
Accelerometer
Works
Audio
Works
Bluetooth
Broken
Camera
Partial
GPS
Partial
Mobile data
Works
SMS
Works
Calls
Partial
USB OTG
Broken
NFC


Running i3wm
Splash screen

Users owning this device


Contributors

Additional info

Cameras are supported in the kernel, but have very complex media pipelines. Megapixels has preliminary support for at least the rear/main camera.

The GPU is a PowerVR SGX530 which does not have FOSS drivers, so 3D acceleration does not work with the mainline kernel. However, the required blobs and patched mesa have been merged into pmaports, and the linux openpvrsgx dev group maintains a "near-mainline" kernel fork with the required kernel driver.

Voice calls work, but need https://gitlab.com/libcmtspeechdata/libcmtspeechdata to route the speech data. Due to very tight timings involved in the associated protocol, the audio is very low quality unless additional processing is performed (Nokia had closed-source Pulseaudio modules for this).

There's bluetooth support at bluetooth-next, but that works on N950, not on N900. Bluetooth . The driver compiles fine, but fails on loading the firmware.

OTG might work since the kernel has support. However, like Wileyfox_Swift_(wileyfox-crackling), there is a hardware limitation that prevents the N900 from automatically detecting that there's a connected device, and also detecting the USB version/speed it supports. With some work, it most likely should work with manual activation

Installation

We currently only support installing and running pmOS from the microSD card on the N900. Getting it to work with eMMC and 0xffff is harder to implement and has no real benefit since the built-in eMMC is quite slow and fragile.

Flash postmarketOS to SD card

Note If your phone does not jump from Nokia logo to U-Boot prompt when powered on and booted with the keyboard slider open, you'll need to install U-Boot by Pali, see #Configure u-boot on eMMC to boot from the SD card

From pre-built image (easy method)

Official images of postmarketOS for the N900 are built at least every week.

Choose an image for your device from the download page.

Then flash it to your SD as follows. Adjust the image name and the path to your SD card (you can figure it out with lsblk).

$ xzcat 20210209-0034-postmarketOS-edge-i3wm-0.3-nokia-n900.img.xz | sudo dd of=/dev/mmcblk... status=progress bs=1M

The first boot takes longer, as the root partition gets resized to fit the whole SD card. There is a lot of kernel output during boot, just wait patiently until i3wm shows up. Read #i3wm for the N900 specific keybindings, most importantly Shift + Space, then t to open a terminal. Use sudo nmtui to connect to a Wi-Fi network.

With pmbootstrap (advanced)

Instead of the pre-built images, you can use pmbootstrap to generate your own image. It allows to use full disk encryption, use another user interface (e.g. XFCE4) and other customizations.

1. Initialize pmbootstrap

$ pmbootstrap.py init
Choose 'nokia-n900' as target device.

2. Start the build process and install the completed image to a sdcard

(Replace /dev/sdX with the device for your sdcard)
$ pmbootstrap install --sdcard /dev/sdX

Configure u-boot on eMMC to boot from the SD card

  1. Install u-boot from pali on the n900 in Maemo. If this does not work from the graphical interface you may run sudo apt-get install u-boot-flasher in maemo terminal (see wiki#16 and pmbootstrap#1371). See Additional Info below for instructions on configuring pmos to boot by default.
  2. Place the sdcard into the n900 and boot it with the keyboard slide open
  3. Choose the u-boot shell
  4. enter run sdboot into the shell

Features

Configuring U-boot (optional)

In order to configure pmos to boot by default on the N900, using U-boot, you will need to boot into Maemo and create a /etc/bootmenu.d/10-pmos.item file as the root user with these contents:

/etc/bootmenu.d/10-pmos.item
ITEM_NAME="postmarketOS"
ITEM_SCRIPT="boot.scr"
ITEM_DEVICE="${EXT_CARD}p1"
ITEM_FSTYPE="ext2"

It can be set to the default boot option by creating a symlink:

root@Nokia-N900:~# ln -s /etc/bootmenu.d/10-pmos.item /etc/default/bootmenu.item

Finally, run u-boot-update-bootmenu:

root@Nokia-N900:~# u-boot-update-bootmenu 
Default bootmenu entry is '/etc/bootmenu.d/10-pmos.item'
Adding bootmenu entry for: 'Maemo 5 with attached kernel (Internal Nand)'

Configuration file: /etc/bootmenu.d/10-pmos.item
Adding bootmenu entry for: 'postmarketOS'
Configuring this bootmenu entry as default

Generating u-boot bootmenu script...

Note: This will set pmos as the default boot option. Maemo will still be accessible when booting the N900 with the keyboard slide out and selecting the relevant boot option in the u-boot boot menu.

Wifi

The device-nokia-n900-nonfree-firmware package is required to provide the wl1251 firmware necessary for initializing the wifi device. (#1414) You get asked during pmbootstrap init if you would like to install that proprietary firmware package.

Now you can use NetworkManager's console UI to connect to your network. Please note that nmtui does not work properly when started from tmux.

$ nmtui

WiFi settings do not work across reboots

The MAC address of the N900 WiFi interface its being randomized at every boot, since the connection profile created with nmtui is bound to the MAC address, it won't work at the next boot.

To solve this, after connecting you can use nmtui to edit the created profile, and remove the MAC address from the "Device" section

Without NetworkManager

If NetworkManager should not work for you, make sure that it is not running and run the following commands to connect to an encrypted network manually:

$ sudo su -
# ip link set wlan0 up
# iw wlan0 set type managed
# wpa_passphrase $YOUR_SSID > /etc/wpa_supplicant/wpa_supplicant.conf
<enter passphrase here and press Enter>
# exit

Connect to network using wpa_supplicant:

$ sudo rc-service wpa_supplicant restart

Power saving / ping times

It should be possible to disable power saving for better ping times, see maemo-leste#172.

$ sudo su -
# apk add iw
# iw dev wlan0 set power_save off
# exit

Sound

Modules need not to be compiled, sound support is built into kernel. Install alsa-utils.

aplay /usr/share/sounds/alsa/Front_Left.wav

NikkSaan provided an advanced audio configuration in #702 (comment).

Keyboard Backlight

There are 6 keyboard backlight LEDs that can be adjusted, they are found under /sys/class/leds/lp5523:kb{1-6}. To adjust brightness, write a value, $VAL between 0 and 255, to the brightness parameter as the root user:

for i in $(seq 1 6);
    do echo $VAL > /sys/class/leds/lp5523\:kb$i/brightness
done

Keyboard layout

The keyboard layout is asked during pmbootstrap init after you select the nokia-n900 device.

Available keymaps:

us/rx51_us
ch/rx51_ch
se/rx51_se and fi/rx51_fi (same for Swedish and Finnish).
it/rx51_it

Console

NOTE: during installation pmbootstrap will typically ask you for the desired keymap. The following is only for experimentation: normally all should just work fine after setting up the SD card from pmbootstrap. The following section may be dated and pmbootstrap has already done the job for you.

To obtain your desired language keymap file for the RX-51, such as this one:

  • On the N900, install kbd-bkeymaps, either by using pmbootstrap install --add kbd-bkeymaps on the host system or by running apk add kbd-bkeymaps on the device itself.
  • The keymap must be in binary format, bmap. This can be accomplished using the loadkeys tool:
$ apk add kbd kbd-bkeymaps
$ loadkeys -b rx51_us.map > rx51_us.bmap
$ gzip rx51_us.bmap
  • Compress it and copy it to /usr/share/bkeymaps/us/ on the N900.
  • Log into the N900, and run sudo setup-keymap, then select us and finally rx51_us.

(TODO: Need to pull 'official' vconsole keymaps from Maemo5 if they exist..)

X11

NOTE: during installation pmbootstrap will typically ask you for the desired X11 xkb keymap. The following is only for experimentation: normally all should just work fine after setting up the SD card from pmbootstrap. The following section may be dated and pmbootstrap has already done the job for you.

In X11 you can use setxkbmap to configure the desired layout.

Right now it's configured to use the nokiarx51/us layout by default (see 40-xkb.conf) then the pmbootstrap script will patch this file to set the Option "XkbLayout" to "nn" where "nn" is your country code.

Note Info: Tab is ctrl+i

Console switching

You can use the Nokia-n900-blue-arrow.PNG blue arrow key in combination with the Volume Up/Down to switch to a different virtual terminal.

If you installed postmarketOS with a UI, you first have to enable again the other VT by editing the /etc/inittab file and uncomment the following lines:

...
# Set up a couple of getty's
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
tty5::respawn:/sbin/getty 38400 tty5
tty6::respawn:/sbin/getty 38400 tty6
...

Display

With DRM enabled (pmbootstrap!197), the display can be managed at this location: /sys/devices/platform/omapdrm.0/graphics/fb0/

For example, the display can be turned off by:

# echo 1 > /sys/devices/platform/omapdrm.0/graphics/fb0/blank

To adjust brightness:

# # Replace $VAL with a value from 0 to 255:
# echo $VAL > /sys/class/backlight/acx565akm/brightness

GUI

i3wm

I3wm is the recommended UI. It is lightweight and fast, and we have a custom N900 configuration that optimizes for its keyboard (photos). The most important keybindings are described below, for details see i3wm.conf. This file gets installed to ~/.config/i3/config and of course you can customize it. If you have good additions, please make a merge request so everybody benefits from an improved default config.

default mode
  • shift + space: switch to "command mode"
command mode
  • t: open terminal
  • k: kill current program
  • w: workspace mode
  • r: restart i3wm (use after modifying the config)
  • q: go back to "default mode"
workspace mode
  • a/s/d/f/g: switch to workspace 1/2/3/4/5
  • q: go back to "command mode"

Xfce4

Xfce4 does not have performance issues, but since this UI is not optimized for keyboard only usage or for touch screen usage, it is not as user-friendly as i3wm with the postmarketOS default config.

Others

There are also Mate, etc.

Misc: Power button

If you want to make use of the power button, bind XF86PowerOff to this script:

FILE=~/.screenoff
if [ -f $FILE ]; then
    xinput set-prop 8 "Device Enabled" 1
    xinput set-prop 6 "Device Enabled" 1
    xinput set-prop 9 "Device Enabled" 1
    xset dpms force on
    rm ~/.screenoff
else
    xinput set-prop 8 "Device Enabled" 0
    xinput set-prop 6 "Device Enabled" 0
    xinput set-prop 9 "Device Enabled" 0
    xset dpms force off
    touch ~/.screenoff
fi
Note You cannot use this to turn the screen back on if i3lock or similar is running, as they would grab the keys

Misc: Middle click and right click

Obviously, you can't middle click with a touchscreen, but this can be annoying when it's one of the few ways to paste in the terminal. This script simulates a middle click:

xdotool mousedown --clearmodifiers 2
xdotool mouseup 2
xdotool keyup alt
xdotool keyup ctrl
xdotool keyup shift

For simulating right click button you can use this command:

xdotool click 3

You can bind it to any key you wish. XF86WebCam is a good choice since it's fairly easy to reach and isn't used for anything.

Battery

Charging

Battery charging is fully supported by the kernel and does not need any special configuration.

Capacity Reporting

The current battery capacity can be found under /sys/class/power_supply/bq27200-0/capacity, and is represented as a percentage. For example, a value of 11 equates to 11%. To calibrate the battery and get a more accurate capacity report:

1) Charge it up fully, using a wall power adapter.

2) Unplug the device and allow the battery to run all the way down until it powers off. This may take quite a while to happen (>24hrs, but can be made shorter by running a CPU intensive workload). Do not let it charge at all during this time. This means you may not use USB for example, as this automatically causes the device to start charging, albeit slowly.

3) When device eventually powers off, the battery charge gauge chip should then be calibrated. You may charge it up again to use the device.

Datasheet for the bq27200 charge gauge chip

Hint: To disable the LED charging indication, disable the charging chip's status pin.

echo 0 > /sys/class/power_supply/bq24150a-0/stat_pin_enable.

Datasheet for the bq24150 charging chip

Battery Protection

Currently, when battery gets below suitable operating voltage, the device dies. This is bad for the battery and the file system. Here is a script that monitors the battery, and powers the device off before the battery reaches critical state. For suggested usage, read the program's comments.

Clock

Setting the hardware clock

Since 49fd9e0e4efcf030ca47344858bdc74370a78603 the hardware clock works. If your hardware clock doesn't have the time set you can set it with:

# Get the system date in the right ballpark so ntpd works
$ date -s "2017-08-14 16:34:50"

# Write the current system time to the hardware clock
$ hwclock -w

Setting the hardware alarm clock

Realtime clock at /dev/rtc0 is on the twl4030 (PMU), and allows setting an alarm to wake the device from sleep, poweroff states.

Control trough rtcwake (Manual Page).

# Suspends the device to memory for 10 seconds
rtcwake --verbose --seconds 10 --mode mem

# Power off the device and power it on after $TIME, where $TIME is the number of seconds since epoch (1970-01-01)
rtcwake --verbose --time_t $TIME --mode no
/sbin/poweroff

Manual control from sysfs:

# To set the wakealarm directly, set $TIME to number of seconds since epoch (1970-01-01). Then poweroff or suspend:
echo $TIME > /sys/class/rtc/rtc0/wakealarm
 	
# To set new wakealarm time, first reset time to 0!
echo 0 > /sys/class/rtc/rtc0/wakealarm
Note When setting number of seconds since epoch, make sure you account for your timezone and see how your realtime clock keeps the time (utc or local)!

SMS

In order to use the ofono test scripts, you must install py-dbus, that is currently available only for python2.

Note The N900 needs internet access to perform these steps. See the section above on setting up Wifi.
Note Your date/time need to be correct in order for HTTPS to work. You can use ntpd to do this.
# apk add git py-dbus
# git clone --depth 1 https://git.kernel.org/pub/scm/network/ofono/ofono.git

Here's an example using the test scripts to enable the modem and send a SMS:

# cd ofono/test
# python3 enable-modem
# python3 online-modem
# python3 send-sms 5033784582 "I like pizza." 0 

USB Gadget

Mass Storage

The Mass Storage class exposes a block device as a flash drive on your host machine.

For example, to use the "MyDocs" partition as Mass Storage Device, make sure you unmount the partition first (if mounted), then execute:

echo /dev/mmcblk1p1 > /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/gadget/lun0/file

If you only need read permissions on the partition, you can set the read-only flag before exporting it:

echo 1 > /sys/devices/platform/68000000.ocp/480ab000.usb_otg_hs/musb-hdrc.0.auto/gadget/lun0/ro

GPRS

GPRS can be managed by connman. Either install connman using apk or add it when installing pmOS by passing --add connman to pmbootstrap.

Note Once you perform the following steps, the GPRS connection will be established by connman automatically on every boot.

It's VERY important that you add the following to /etc/connman/main.conf BEFORE starting connman, else it will take over all network connection handling and disconnect you if you are connected over SSH:

/etc/connman/main.conf
NetworkInterfaceBlacklist = usb,wlan

Configure connman to start at boot:

$ sudo rc-update add connman

Stop ofono in order to set APN:

$ sudo rc-service ofono stop

Edit APN, where <IMSI> should be replaced in the following commands with the IMSI from your SIM card. Replace <APN> with the relevant APN for your cellular carrier (e.g. fast.t-mobile.com). This file should be created when ofono starts, so you should only need to add the APN.

/var/lib/ofono/<IMSI>/gprs
[Settings]                                                                                                                                                                                                                                                                                                                                                              
Powered=true                                                                                                                                                                                                                                                                                                                                                            
RoamingAllowed=false                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                        
[context1]                                                                                                                                                                                                                                                                                                                                                              
Name=Internet                                                                                                                                                                                                                                                                                                                                                           
AccessPointName=<APN>                                                                                                                                                                                                                                                                                                                                      
Username=                                                                                                                                                                                                                                                                                                                                                               
Password=                                                                                                                                                                                                                                                                                                                                                               
AuthenticationMethod=chap                                                                                                                                                                                                                                                                                                                                               
Type=internet                                                                                                                                                                                                                                                                                                                                                           
Protocol=ip  

Start ofono and power on modem.

$ sudo rc-service ofono start
$ sudo connmanctl enable cellular

In some cases, it seems necessary to run a scan before the necessary service will show in connman, even though the scan is 'unsupported':

$ sudo connmanctl scan cellular                                                                 
Error /net/connman/technology/cellular: Not supported                                     
$ sudo connmanctl services
cellular_340369959729712_context1

Connect to the cellular service:

                                
$ sudo connmanctl connect cellular_340369959729712_context1                                     
Connected cellular_340369959729712_context1
$ ip addr show gprs0
10: gprs0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UNKNOWN qlen 10
    link/[821] 
    inet 33.238.141.172/32 brd 33.238.141.172 scope global gprs0
       valid_lft forever preferred_lft forever

GPS

First, get network and date to work. Next, clone tui repository. it contains includes many goodies, including script for hardware testing, gps support, and graphical ofono control software.

mkdir /my
cd /my
git clone https://gitlab.com/tui/tui.git

Next, install packages necessary for compiling software and prepare gps2. enable-modem, online-modem and you should be able to run gps2. AGPS is not available, so expect long startup.

apk add gcc vala musl-dev make linux-headers gpsd
cd /my/tui/ofone
make gps2
./gps2

gps2 reportedly can talk to gpsd. Needs further investigation.

FM Transmitter

The N900 contains an Si4713 FM transmitter, it's controlled by video4linux. To start transmitting:

$ v4l2-ctl -d /dev/radio0 --set-ctrl=mute=0 --set-freq=95.21
Now there should be silence on 95.21Mhz instead of noise when tuning in with a radio
$ aplay -vv some-very-good-music.wav

Resources

Helpful Links for Porting