Simon Glass | 84015e5 | 2024-10-21 10:19:30 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | .. index:: |
| 4 | single: meminfo (command) |
| 5 | |
| 6 | meminfo command |
| 7 | =============== |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
| 13 | |
| 14 | meminfo |
| 15 | |
| 16 | Description |
| 17 | ----------- |
| 18 | |
| 19 | The meminfo command shows the amount of memory. If ``CONFIG_CMD_MEMINFO_MAP`` is |
| 20 | enabled, then it also shows the layout of memory used by U-Boot and the region |
| 21 | which is free for use by images. |
| 22 | |
| 23 | The layout of memory is set up before relocation, within the init sequence in |
| 24 | ``board_init_f()``, specifically the various ``reserve_...()`` functions. This |
| 25 | 'reservation' of memory starts from the top of RAM and proceeds downwards, |
| 26 | ending with the stack. This results in the maximum possible amount of memory |
| 27 | being left free for image-loading. |
| 28 | |
| 29 | The meminfo command writes the DRAM size, then the rest of its outputs in 5 |
| 30 | columns: |
| 31 | |
| 32 | Region |
| 33 | Name of the region |
| 34 | |
| 35 | Base |
| 36 | Base address of the region, i.e. where it starts in memory |
| 37 | |
| 38 | Size |
| 39 | Size of the region, which may be a little smaller than the actual size |
| 40 | reserved, e.g. due to alignment |
| 41 | |
| 42 | End |
| 43 | End of the region. The last byte of the region is one lower than the address |
| 44 | shown here |
| 45 | |
| 46 | Gap |
| 47 | Gap between the end of this region and the base of the one above |
| 48 | |
| 49 | Regions shown are: |
| 50 | |
| 51 | video |
| 52 | Memory reserved for video framebuffers. This reservation happens in the |
| 53 | bind() methods of all video drivers which are present before relocation, |
| 54 | so the size depends on that maximum amount of memory which all such drivers |
| 55 | want to reserve. This may be significantly greater than the amount actually |
| 56 | needed, if the display is ultimately set to a smaller resolution or colour |
| 57 | depth than the maximum supported. |
| 58 | |
| 59 | code |
| 60 | U-Boot's code and Block-Starting Symbol (BSS) region. Before relocation, |
| 61 | U-Boot copies its code to a high region and sets up a BSS immediately after |
| 62 | that. The size of this region is generally therefore ``__bss_end`` - |
| 63 | ``__image_copy_start`` |
| 64 | |
| 65 | malloc |
| 66 | Contains the malloc() heap. The size of this is set by |
| 67 | ``CONFIG_SYS_MALLOC_LEN``. |
| 68 | |
| 69 | board_info |
| 70 | Contains the ``bd_info`` structure, with some information about the current |
| 71 | board. |
| 72 | |
| 73 | global_data |
| 74 | Contains the global-data structure, pointed to by ``gd``. This includes |
| 75 | various pointers, values and flags which control U-Boot. |
| 76 | |
| 77 | devicetree |
| 78 | Contains the flatted devicetree blob (FDT) being used by U-Boot to configure |
| 79 | itself and its devices. |
| 80 | |
| 81 | bootstage |
| 82 | Contains the bootstage records, which keep track of boot time as U-Boot |
| 83 | executes. The size of this is determined by |
| 84 | ``CONFIG_BOOTSTAGE_RECORD_COUNT``, with each record taking approximately |
| 85 | 32 bytes. |
| 86 | |
| 87 | bloblist |
| 88 | Contains the bloblist, which is a list of tables and other data created by |
| 89 | U-Boot while executed. The size of this is determined by |
| 90 | ``CONFIG_BLOBLIST_SIZE``. |
| 91 | |
| 92 | stack |
| 93 | Contains U-Boot's stack, growing downwards from the top. The nominal size of |
| 94 | this region is set by ``CONFIG_STACK_SIZE`` but there is no actual limit |
| 95 | enforced, so the stack can grow behind that. Images should be loaded lower |
| 96 | in memory to avoid any conflict. |
| 97 | |
| 98 | free |
| 99 | Free memory, which is available for loading images. The base address of |
| 100 | this is ``gd->ram_base`` which is generally set by ``CFG_SYS_SDRAM_BASE``. |
| 101 | |
| 102 | Example |
| 103 | ------- |
| 104 | |
| 105 | This example shows output with both ``CONFIG_CMD_MEMINFO`` and |
| 106 | ``CONFIG_CMD_MEMINFO_MAP`` enabled:: |
| 107 | |
| 108 | => meminfo |
| 109 | DRAM: 256 MiB |
| 110 | |
| 111 | Region Base Size End Gap |
| 112 | ------------------------------------------------ |
| 113 | video f000000 1000000 10000000 |
| 114 | code ec3a000 3c5d28 efffd28 2d8 |
| 115 | malloc 8c38000 6002000 ec3a000 0 |
| 116 | board_info 8c37f90 68 8c37ff8 8 |
| 117 | global_data 8c37d80 208 8c37f88 8 |
| 118 | devicetree 8c33000 4d7d 8c37d7d 3 |
| 119 | bootstage 8c32c20 3c8 8c32fe8 18 |
| 120 | bloblist 8c32000 400 8c32400 820 |
| 121 | stack 7c31ff0 1000000 8c31ff0 10 |
| 122 | free 0 7c31ff0 7c31ff0 0 |
| 123 | |
| 124 | |
| 125 | Return value |
| 126 | ------------ |
| 127 | |
| 128 | The return value $? is always 0 (true). |