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