blob: 061fe7677ee47e62f2f3d329572d5c930ed2a970 [file] [log] [blame]
Pali Rohár69b99962022-01-24 20:45:54 +01001.. SPDX-License-Identifier: GPL-2.0+
2
3Nokia RX-51 aka N900
4====================
5
6The ``nokia_rx51_defconfig`` configuration file results in a ``u-boot.bin``
7which can be chainloaded by the Nokia second stage bootloader (NOLO) in QEMU or
8on a real N900. It does very little hardware configuration because NOLO has
9already configured the board. It is only needed to enable the internal eMMC
10memory via the twl4030 regulator which is not enabled by NOLO.
11
12NOLO is expecting a kernel image and will treat any image it finds in
13OneNAND as such. This u-boot is intended to be flashed to the N900 like
14a kernel. In order to transparently boot the original kernel, it will be
15appended to ``u-boot.bin`` at 0x40000. NOLO will load the entire image into
16(random) memory and execute U-Boot, which saves hardware revision, boot reason
17and boot mode ATAGs set by NOLO. Then the bootscripts will attempt to load
18``uImage``, ``zImage`` or ``boot.scr`` file from a FAT or ext2/3/4 filesystem
19on external SD card or internal eMMC memory. If this fails or keyboard is
20closed then the appended kernel image will be booted using some generated
21and some stored ATAGs (see boot order).
22
23For generating combined image of U-Boot and kernel (either in uImage or zImage
24format) there is a simple script called ``u-boot-gen-combined``. It is available
25in following repository: https://github.com/pali/u-boot-maemo.
26
27To generate the ``combined.bin`` image from ``u-boot.bin`` and ``kernel.bin``
28(in either uImage or zImage format) use:
29
30.. code-block:: bash
31
32 sh u-boot-gen-combined u-boot.bin kernel.bin combined.bin
33
34The original Maemo Fremantle PR1.3 zImage kernel binary is available at:
35http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb
36
37To unpack it (from DEB/AR, TAR and FIASCO) execute the following commands:
38
39.. code-block:: bash
40
41 ar x kernel_2.6.28-20103103+0m5_armel.deb data.tar.gz
42 tar -O -xf data.tar.gz ./boot/zImage-2.6.28-20103103+0m5.fiasco > kernel_2.6.28-20103103+0m5.fiasco
43 0xFFFF -M kernel_2.6.28-20103103+0m5.fiasco -u
44
45The flashed image must start with a 2 KiB ``NOLO!img`` header which contains
46size of the image. The header consists of the bytes
47``NOLO!img\x02\x00\x00\x00\x00\x00\x00\x00`` followed by the 4 byte little
48endian size of the image. The rest of the 2 KiB header just contains zero bytes.
49
50The Nokia proprietary flasher and also the open source 0xFFFF flasher
51automatically prepend the required ``NOLO!img`` header and both applications
52expect that the image does not contain a ``NOLO!img`` header. Adding a
53``NOLO!img`` header is required only in case of using the ``nandwrite`` tool for
54flashing.
55
56The open source 0xFFFF flasher is available in the following repository:
57https://github.com/pali/0xFFFF
58
59It is possible to load ``u-boot.bin`` via USB to the N900 RAM and boot it
60without needing to flash it. This is done via 0xFFFF running on the host PC:
61
62.. code-block:: bash
63
64 0xFFFF -m u-boot.bin -l -b
65
660xFFFF also supports flashing a kernel image either via USB or directly on
67N900 device. Flashing u-boot/kernel/combined image is done as:
68
69.. code-block:: bash
70
71 0xFFFF -m combined.bin -f
72
73Via 0xFFFF it is also possible to generate a standard flashable image in
74Nokia FIASCO format which contains metadata information like device
75identification (RX-51) and version string (v2021.04):
76
77.. code-block:: bash
78
79 0xFFFF -m RX-51:v2021.04:kernel:u-boot.bin -g u-boot.fiasco
80
81There is support for the hardware watchdog. The hardware watchdog is started by
82NOLO so U-Boot must reset the watchdog to prevent rebooting the device (but not
83very often, max every 2 seconds). There is also support for framebuffer display
84output with ANSI escape codes and the N900 hardware keyboard input.
85
86When U-Boot is starting it sets the IBE bit in the Auxiliary Control Register,
87which is needed for Thumb-2 ISA support. This is a workaround for erratum
88430973.
89
90Default boot order
91------------------
92
930. if keyboard is closed boot automatically attached kernel image
941. try boot from external SD card
952. try boot from internal eMMC memory
963. try boot from attached kernel image
97
98Boot from SD or eMMC in this order:
99
1001. boot from FAT partition
101
102 a. find ``boot.scr`` on first FAT partition
103 b. find ``uImage`` on first FAT partition
104 c. find ``zImage`` on first FAT partition
105 d. same order for 2nd - 4th FAT partition
106
1072. same as 1. but for ext2/3/4 partition
108
109Available additional commands/variables
110---------------------------------------
111
112* run sdboot - Boot from external SD card (see boot order)
113* run emmcboot - Boot from internal eMMC memory (see boot order)
114* run attachboot - Boot attached kernel image (attached to U-Boot binary)
115
116\
117
118* run scriptload - Load boot script ``${mmcscriptfile}``
119* run scriptboot - Run loaded boot script
120* run kernload - Load kernel image ``${mmckernfile}``
121* run initrdload - Load initrd image ``${mmcinitrdfile}``
122* run kernboot - Boot loaded kernel image
123* run kerninitrdboot - Boot loaded kernel image with loaded initrd image
124
125\
126
127* run trymmcscriptboot - Try to load and boot script ``${mmcscriptfile}``
128* run trymmckernboot - Try to load and boot kernel image ``${mmckernfile}``
129* run trymmckerninitrdboot - Try to load and boot kernel image ``${mmckernfile}``
130 with initrd image ``${mmcinitrdfile}``
131
132Additional variables for loading files from mmc
133-----------------------------------------------
134
135* mmc ``${mmcnum}`` (0 - external, 1 - internal)
136* partition number ``${mmcpart}`` (1 - 4)
137* partition type ``${mmctype}`` (fat, ext2, ext4; ext2 is just alias for ext4)
138
139Additional variables for booting a kernel
140-----------------------------------------
141
142* ``setup_omap_atag`` - Add OMAP table into atags structure (needed for maemo kernel)
143* ``setup_console_atag`` - Enable serial console in OMAP table
144* ``setup_boot_reason_atag`` - Change boot reason in OMAP table
145* ``setup_boot_mode_atag`` - Change boot mode in OMAP table
146
147Variable ``setup_omap_atag`` is automatically set when booting attached kernel.
148When variable ``setup_omap_atag`` is set, variable ``setup_console_atag`` is unset
149and u-boot standard output is set to serial then ``setup_console_atag`` is
150automatically set to 1. So output from Maemo kernel would go to serial port.
151
152UBIFS support
153-------------
154
155UBIFS support is disabled, because U-Boot image is too big and cannot be
156flashed with attached kernel image to RX-51 kernel nand area. For enabling
157UBIFS support add following lines into file ``configs/nokia_rx51_defconfig``::
158
159 CONFIG_CMD_UBI=y
160 CONFIG_CMD_UBIFS=y
161 CONFIG_MTD_UBI_FASTMAP=y
162 CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
Pali Rohár5097f582022-03-08 18:59:56 +0100163
164Run in QEMU
165-----------
166
167Download and compile Linaro version of qemu which contains ``n900`` qemu
168machine. Source code is available in qemu-linaro git repository and the
169last working version is at commit 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1.
170
171Use following commands to compile ``qemu-system-arm`` binary with ``n900``
172qemu machine support:
173
174.. code-block:: bash
175
176 git clone https://git.linaro.org/qemu/qemu-linaro.git
177 cd qemu-linaro
178 git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1
179 ./configure --enable-system --target-list=arm-softmmu --disable-werror
180 make -j4
181 cd ..
182 ln -s qemu-linaro/arm-softmmu/qemu-system-arm .
183
184Using ``n900`` qemu machine requires proprietary Nokia qemu ``qflasher`` tool
185(in reality it is just generator of qemu MTD images) with first stage images
186(``xloader-qemu.bin`` and ``secondary-qemu.bin``), similar what is required
187on the real HW. License of flasher and images allows non-commercial
188redistribution and it is available at maemo.org website:
189
190.. code-block:: bash
191
192 wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz
193 tar -xf qemu-n900.tar.gz
194
195To generate qemu bootable MTD image ``mtd.img`` from U-Boot binary
196``u-boot.bin`` and unpacked first stage images, run following command:
197
198.. code-block:: bash
199
200 ./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd.img
201
202Instead of ``u-boot.bin`` binary it is possible to also used combined
203U-Boot + kernel binary ``combined.bin``.
204
205Finally, to boot ``mtd.img`` with graphics display and keyboard with optional
206serial console on current terminal, run:
207
208.. code-block:: bash
209
210 ./qemu-system-arm -M n900 -mtdblock mtd.img -serial /dev/tty
211
212Additionally it is possible to emulate also eMMC and uSD card by appending
213qemu ``-sd`` arguments:
214
215.. code-block:: bash
216
217 ./qemu-system-arm -M n900 -mtdblock mtd.img -sd emmc.img -sd sd.img -serial /dev/tty
218
219For more examples, look into the ``test/nokia_rx51_test.sh`` CI testing script.