blob: 6532878932c0c73dccf012318f173c9707df1c3f [file] [log] [blame]
Marcel Ziswiler813070a2023-08-29 00:01:53 +02001.. SPDX-License-Identifier: GPL-2.0-or-later
2.. sectionauthor:: Igor Opaniuk <igor.opaniuk@toradex.com>
Igor Opaniukadbb9422020-02-12 17:14:28 +02003
Marcel Ziswiler813070a2023-08-29 00:01:53 +02004Colibri iMX7 Modules
5====================
6
7- SoM: https://www.toradex.com/computer-on-modules/colibri-arm-family/nxp-freescale-imx7
8- Carrier board: https://www.toradex.com/products/carrier-board/colibri-evaluation-board
Igor Opaniukadbb9422020-02-12 17:14:28 +02009
10Quick Start
11-----------
12
13- Build U-Boot
14- NAND IMX image adjustments before flashing
15- Flashing manually U-Boot to eMMC
16- Flashing manually U-Boot to NAND
17- Using ``update_uboot`` script
18
19Build U-Boot
20------------
21
22.. code-block:: bash
23
24 $ export CROSS_COMPILE=arm-linux-gnueabi-
Igor Opaniukadbb9422020-02-12 17:14:28 +020025 $ make colibri_imx7_emmc_defconfig # For NAND: colibri_imx7_defconfig
26 $ make
27
Marcel Ziswiler813070a2023-08-29 00:01:53 +020028After the build succeeds, you will obtain the final ``u-boot-dtb.imx`` IMX
29specific image, ready for flashing (but check next section for additional
Igor Opaniukadbb9422020-02-12 17:14:28 +020030adjustments).
31
Marcel Ziswiler813070a2023-08-29 00:01:53 +020032The final IMX program image includes (section ``6.6.7`` from `IMX7DRM
Igor Opaniukadbb9422020-02-12 17:14:28 +020033<https://www.nxp.com/webapp/Download?colCode=IMX7DRM>`_):
34
35* **Image vector table** (IVT) for BootROM
36* **Boot data** -indicates the program image location, program image size
37 in bytes, and the plugin flag.
38* **Device configuration data**
39* **User image**: U-Boot image (``u-boot-dtb.bin``)
40
Igor Opaniukadbb9422020-02-12 17:14:28 +020041IMX image adjustments prior to flashing
42---------------------------------------
43
441. U-Boot for both Colibri iMX7 NAND and eMMC versions
45is built with HABv4 support (`AN4581.pdf
46<https://www.nxp.com/docs/en/application-note/AN4581.pdf>`_)
Marcel Ziswiler813070a2023-08-29 00:01:53 +020047enabled by default, which requires generating a proper
Igor Opaniukadbb9422020-02-12 17:14:28 +020048Command Sequence File (CSF) by srktool from NXP (not included in the
49U-Boot tree, check additional details in introduction_habv4.txt)
50and concatenate it to the final ``u-boot-dtb.imx``.
51
Marcel Ziswiler813070a2023-08-29 00:01:53 +0200522. In case you don't want to generate a proper ``CSF`` (for any reason),
53you still need to pad the IMX image so it has the same size as specified in
54the **Boot Data** section of the IMX image.
Igor Opaniukadbb9422020-02-12 17:14:28 +020055To obtain this value, run:
56
57.. code-block:: bash
58
59 $ od -X -N 0x30 u-boot-dtb.imx
60 0000000 402000d1 87800000 00000000 877ff42c
61 0000020 877ff420 877ff400 878a5000 00000000
62 ^^^^^^^^
63 0000040 877ff000 000a8060 00000000 40b401d2
64 ^^^^^^^^ ^^^^^^^^
65
66Where:
67
68* ``877ff400`` - IVT self address
69* ``877ff000`` - Program image address
70* ``000a8060`` - Program image size
71
72To calculate the padding:
73
74* IVT offset = ``0x877ff400`` - ``0x877ff000`` = ``0x400``
75* Program image size = ``0xa8060`` - ``0x400`` = ``0xa7c60``
76
77and then pad the image:
78
79.. code-block:: bash
80
81 $ objcopy -I binary -O binary --pad-to 0xa7c60 --gap-fill=0x00 \
82 u-boot-dtb.imx u-boot-dtb.imx.zero-padded
83
Marcel Ziswiler813070a2023-08-29 00:01:53 +0200843. Also, according to the requirement from ``6.6.7.1``, the final image
85should have ``0x400`` offset for the initial IVT table.
Igor Opaniukadbb9422020-02-12 17:14:28 +020086
Marcel Ziswiler813070a2023-08-29 00:01:53 +020087For eMMC setup we handle this by flashing it to ``0x400``, however
88for NAND setup we adjust the image prior to flashing, adding padding at the
Igor Opaniukadbb9422020-02-12 17:14:28 +020089beginning of the image.
90
91.. code-block:: bash
92
93 $ dd if=u-boot-dtb.imx.zero-padded of=u-boot-dtb.imx.ready bs=1024 seek=1
94
95Flash U-Boot IMX image to eMMC
96------------------------------
97
98Flash the ``u-boot-dtb.imx.zero-padded`` binary to the primary eMMC hardware
99boot area partition:
100
101.. code-block:: bash
102
Igor Opaniukadbb9422020-02-12 17:14:28 +0200103 => load mmc 1:1 $loadaddr u-boot-dtb.imx.zero-padded
104 => setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200
105 => mmc dev 0 1
106 => mmc write ${loadaddr} 0x2 ${blkcnt}
107
108Flash U-Boot IMX image to NAND
109------------------------------
110
111.. code-block:: bash
112
113 => load mmc 1:1 $loadaddr u-boot-dtb.imx.ready
114 => nand erase.part u-boot1
115 => nand write ${loadaddr} u-boot1 ${filesize}
116 => nand erase.part u-boot2
117 => nand write ${loadaddr} u-boot2 ${filesize}
118
119Using update_uboot script
120-------------------------
121
Marcel Ziswiler813070a2023-08-29 00:01:53 +0200122You can also use U-Boot env update_uboot script,
123which wraps all eMMC/NAND specific command invocations:
Igor Opaniukadbb9422020-02-12 17:14:28 +0200124
125.. code-block:: bash
126
127 => load mmc 1:1 $loadaddr u-boot-dtb.imx.ready
128 => run update_uboot