Embedded linux uboot commands

Русские Блоги

Конфигурация U-Boot, общие команды и загрузка ramfs Linux

Обзор

Das U-Boot — это главный загрузчик с открытым исходным кодом, используемый для упаковки инструкций во встроенные устройства для загрузки ядра операционной системы устройства. Он часто используется для загрузки и загрузки ядер и файловых систем Linux на встроенных устройствах с архитектурой ARM.
U-Boot поддерживает запуск интерфейса командной строки через последовательный порт. Используя командную строку, пользователи могут загружать и загружать ядро, возможно, изменяя параметры по умолчанию. Также есть команды для чтения информации об устройстве, чтения и записи во флэш-память, загрузки файлов (ядра, загрузочного образа и т. Д.) Из последовательного порта или сети, управления деревом устройств и использования переменных среды (которые могут быть записаны в постоянное хранилище) для Управляйте поведением U-Boot, например командой загрузки по умолчанию и тайм-аутом перед автоматической загрузкой, а также данными оборудования, такими как MAC-адрес Ethernet.

Файл конфигурации

Важная информация о конфигурации U-Boot определена в файле:

Например, общий файл конфигурации по умолчанию для MX6:

В этом файле конфигурации (или при самостоятельном воссоздании нового файла конфигурации) вы можете настроить некоторые часто используемые функции следующим образом:

Команда запуска конфигурации должна загрузить uImage из толстого раздела mmc0 по адресу памяти 0x40007000, а затем запустить ядро ​​отсюда.

После настройки U-Boot есть 3 секунды, чтобы нажать Enter для входа в интерфейс командной строки.Если он настроен на 0, процесс запуска не может быть прерван.

Это конфигурация, относящаяся к сети, которая поддерживает функции загрузки Ethernet MII, ping, dhcp и tftp.

Настройте выход последовательного порта по умолчанию как ttySAC2.

по CONFIG_EXTRA_ENV_SETTINGS Параметры для установки среды U-Boot. Среда U-Boot — это блок памяти, который хранится в постоянном хранилище и копируется в ОЗУ при запуске U-Boot. Он используется для хранения переменных среды, которые можно использовать для настройки системы. Среда защищена контрольной суммой CRC32. В дополнение к ipaddr и serverip, настроенным выше, есть следующие часто используемые переменные среды

переменная Описание
bootargs Содержимое этой переменной передается ядру Linux в качестве параметров загрузки (также называемых «командной строкой»).
bootcmd Эта переменная определяет командную строку, которая автоматически выполняется, когда начальный обратный отсчет не прерывается. Эта команда выполняется только тогда, когда bootdelay определяет переменные!
bootdelay После сброса U-Boot будет ждать это количество секунд перед выполнением содержимого переменной bootcmd. В этот период печатается обратный отсчет, и обратный отсчет можно прервать, нажав любую кнопку.
ethaddr Ethernet MAC-адрес первого / единственного интерфейса Ethernet
ipaddr IP-адрес; требуется команда tftp
loadaddr Адрес загрузки по умолчанию таких команд, как tftp или load
serverip IP-адрес TFTP-сервера; требуется команда tftp.

Общие команды и практики

Вот некоторые наиболее часто используемые команды после ввода командной строки:

команда Описание
help Распечатать онлайн-справку
bootm Запустить зеркалирование приложений из памяти
bootz Запустить Linux zImage из памяти
ext4load Загрузить двоичные файлы из раздела Ext4
ext4ls Список файлов в каталоге
fatinfo Распечатать информацию о файловой системе
fatls Список файлов в каталоге
fatload Загрузить двоичный файл из файловой системы dos
md Отображение памяти
mm Модификация памяти (автоинкремент)
mtest Простой тест RAM
mw Запись в память
mmc Подсистема MMC
ping Отправить ICMP ECHO_REQUEST на хост
printenv Печатать переменные среды
reset Сбросить CPU
setenv Установить переменные среды
saveenv Сохранить переменные среды в постоянное хранилище
usb подсистема usb
tftpboot Используйте протокол TFTP для загрузки образа по сети

Установить переменные среды

использовать setenv Чтобы установить переменные среды, связанные с tftp, а затем используйте printenv Распечатайте эти переменные

использовать saveenv (Если есть эта команда) для сохранения этих переменных

Команда памяти

использовать md с mw Чтобы отобразить и изменить данные памяти, md с mw Формат команды аналогичен

[.b, .w, .l] соответствовать [Байт 8 бит, слово 16 бит, двойное слово 32 бита]
Затем установите для памяти 0x82000000-0x82000100 нулевое значение (часть журнала отображения опущена)

Подсистема USB / MMC

Сначала с usb start Дайте U-образному диску нормально работать, а затем используйте fatload С первого раздела U диска с номером устройства 0 u-boot.bin Копировать в память 0x82000000 Место, а потом по памяти 0x82000000 Должность u-boot.bin Скопируйте в область размещения u-boot eMMC (здесь сектор 0x2-0x400)

Если на USB / MMC-диске уже есть раздел FAT / EXT4, вы можете его использовать fatls/ext4ls Чтобы просмотреть информацию о файлах в разделе

Вот список всей информации о файлах из первого раздела FAT U-диска с номером устройства 0.

Теперь попробуйте загрузить и запустить ramfs Linux с диска U

Сначала пройдите сюда fatload Загрузите образ ядра, DTB и образ ramfs с диска U в память, затем настройте параметры загрузки ядра Linux и, наконец, запустите ramfs Linux из памяти.

Используйте tftp для загрузки и запуска Linux ramfs

Первое использование ping Команда для обеспечения связи с tftp сервером

Загрузите и запустите Linux ramfs с tftp-сервера

Сначала пройдите сюда tftpboot Загрузите образ ядра, DTB и образ ramfs в память, затем настройте параметры загрузки ядра Linux и, наконец, запустите ramfs Linux из памяти.

Интеллектуальная рекомендация

Пошаговая загрузка файла Spring MVC-09 (на основе файла загрузки клиента Servlet3.0 + Html5)

пример тестовое задание Исходный код Несмотря на загрузку файлов в Servlet3.0 +, мы можем очень легко программировать на стороне сервера, но пользовательский интерфейс не очень дружелюбен. Одна HTML-ф.

Создайте многоканальное окно в приложениях Win32

Создайте многоканальное окно в приложениях Win32, создайте несколько оконных объектов одного и того же класса Windows, а окна объектов разных классов окон. .

Путь к рефакторингу IOS-APP (3) Введение в модульное тестирование

IOS-APP реконструкция дороги (1) структура сетевых запросов IOS-APP реконструкция дороги (два) Модельный дизайн При рефакторинге нам нужна форма, позволяющая вносить смелые изменения, обеспечивая при .

Tree——No.617 Merge Two Binary Trees

Problem: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new bin.

Источник

Embedded linux uboot commands

The previous articles were developed in bare metal, and then we have to carry out Linux system transplants. Students who have learned the STM32 operating system know that UCOS / FREERTOS transplant is to find one project with the chip used in the official SDK package, and then download to the development board. Linux’s transplant is more complicated. We need to transplant a bootloader code before transplanting Linux. This bootloader code is used to start the Linux kernel. Bootloader has a lot of U-boot. After transplanting U-boot, the Linux kernel will be transplanted. After the LINUX kernel is transferred, Linux does not start normally, but also replaces an root file system (rootfs), and the root file system contains some most common commands and files. So the three of U-boot, Linux kernel and rootfs form a complete Linux system, a Linux system that can be used, perfect.

U-Boot Introduction

A bootloader program must be required if the Linux system is started, and it is also necessary to run a BootLoader program before the chip is powered on. This BootLoader program will initialize the DDR and other peripherals, and then copy the Linux kernel from Flash (NAND, NOR FLASH, SD, MMC, etc.) to DDR, and finally launch the Linux kernel. Of course, the actual work of bootloader should be more complicated, but its most important task is to start the Linux kernel, the relationship between the bootloader and the Linux kernel is the same as the relationship between the BIOS and Windows on the PC. Bootloader is equivalent to the BIOS. So we must first get bootloader, very fortunate, there are many ready-made bootloader software to use, such as u-boot, vivi, redboot, etc., which is most widely used in U-Boot.
Uboot is an open source software that follows the GPL protocol. Uboot is a bare metal code that can be seen as a bare metal integrated routine. The current Uboot has supported advanced features such as LCD screen, network, usb. Uboot official website is http://www.denx.de/wiki/u-boot/.

U-boot Environment Variable Operation Command

1. Modify environment variables

The operation of the environment variable involves two commands: STENV and SaveEnv, command setENV to set or modify the value of the environment variable. Command SaveEnv is used to save the modified environment variable, and the general environment variable is stored in the external flash, and the environment variable is read from the Flash to the DRAM. So use the command setENV to modify the environment variable value in the DRAM. After the modification, you should use the SaveEnv command to save the modified environment variable to the flash, otherwise Uboot next restart will continue to use previous environment variables.
For example, we have to change the environment variable bootdelay to 5, you can use the command shown below:

The command execution process is:

Sometimes we modified environment variables may have spaces, such as bootcmd, bootargs, etc., this time the environment variable value is enclosed in single quotes, such as the value of the environment variable bootcmd:

The above command sets the value of bootcmd to «console = TTYMXC0, 115200 root = / dev / mmcblk1p2 rootwait rw», where «console = TTYMXC0, 115200», «root = / dev / mmcblk1p2», «rootwait», «RW equivalent to four Group «Value», these four sets of «value» are separated from spaces, so you need to use single quotes » to enclose it, indicating that these four «values» belong to the environment variable bootcmd.

2. New environment variables

Command STENV can also be used to create a new command. To modify the environment variable, such as our new environment variable author, author’s value is pinyin: Zuozhongkai, then you can use the following command:

New Command Author after restarting UBOOT, then use the command Printenv to view the current environment variable:

3. Delete environment variables

Since you can create a new environment variable, you can delete environment variables, delete environment variables are also using command setenv. To delete an environment variable, you can assure this environment variable, such as we delete new Author’s environment variables, command as follows:

The above command is assigned to the author by Setenv, which is not written to delete environment variable author. Restarting Uboot will find that the environment variable Author is not.

U-Boot under memory operation command

1.md command

The MD command is used to display the memory value, the format is as follows:

[.B .w .l] in the command corresponds to byte, word, and long, that is, the memory value is displayed in 1 byte, 2 bytes, 4 bytes, respectively. Address is to view the memory start address, [# of objects] indicates the length of the data to view, this data length unit is not byte, but is related to the display format you selected. For example, if you set the memory length of 20 (hexadecimal 0x14), if the format is .b, it represents 20 bytes; if the format is .w, it means 20 words, that is, 202 = 40 bytes; if the format is .L, it means 20 long, that is, 204 = 80 bytes. Also pay attention to:
The numbers in the uboot command are sixteen! Not a decade!
For example, if you want to see the 20-byte memory values ​​starting with 0x80000000, the display format is .b, you should use the following command:

The number inside the uboot command is hexadecimal, so you can write a «0x» prefix, the decimal 20 hexadecimal is 0x14, so the number behind the command MD should be 14, if written 20 If you represent the data of 32 (hexadecimal 0x20) bytes. Analyze the differences between the following three orders:

The above three commands are to view memory data with 0x80000000 as the start address. The first command is displayed in .b format, the length is 0x10, which is 16 bytes; the second command is displayed, the length is displayed in. 0x10, that is, 162 = 32 bytes; the last command is displayed in .l format, the length is also 0x10, that is, 164 = 64 bytes. The execution results of these three commands are as shown:

2. nm command

The nm command is used to modify the memory value of the specified address, the command format is as follows:

The NM command can also specify the operation format in .b, .w, and .l, for example, the data of the 0x80000000 address is now used in .l format is 0x11111111. input the command:

Enter the above command:

80000000 indicates the memory address now to modify, ffffffff represents the current data 0x80000000 ,? After entering the data 0x11111111 after you want to modify, press Enter after the input is complete, then enter ‘q’ to exit:

3.mm command

The mm command is also modified to specify the memory memory value, and the address will increase when using the mm modified memory value, and the address of the command NM will not increase. For example, in .l format to modify the data from the address 0x80000000 (4 * 4 = 16 bytes) of the data started from the address 0x80000000 (4 * 4 = 16 bytes) to 0x66666666:

4.mw command

Command MW is used to populate a memory using a specified data, the command format is as follows:

The MW command can also specify the operation format in .b, .w, and .l, address indicates the memory start address to be filled, and Value is the data to be filled, and count is the length of the fill. For example, using .l format will populate 0x10 memory blocks (0x10 * 4 = 64 bytes) at 0x80000000 (0x10 * 4 = 64 bytes) to 0x66666666, the command is as follows:

5.cp command

The CP is a data copy command that copies data from the DRAM from a period of memory to another, or copies the data in Norflash into the DRAM. The command format is as follows:

The CP command can also specify the operational format in .b, .w, and .l, Source is the source address, the target address, and count is the length of the copy. We use. L format to copy the address of 0x80000000 to 0x80000100, with a length of 0x10 memory block (0x10 * 4 = 64 bytes), the command is as follows:

The results are as follows:

6.cmp command

The CMP is a comparison command that compares whether the data of the two periods is equal, the command format is as follows:

The CMP command can also specify the operation format in .b, .w, and .l, addr1 is the first-segment memory head address, and addr2 is the first address address of the second segment, and count is the length of comparison. We use .l format to compare if the two address data of 0x80000000 and 0x80000100 is equal, the comparison length is 0x10 memory block (16 * 4 = 64 bytes), the command is as follows:

The results are as follows:

U-boot under EMMC and SD card operation command

MMC is a series of commands that can be followed by different parameters:

1.mmc info command

The MMC info command is used to output information of the currently selected MMC INFO device, enter the command «MMC INFO»:

2.mmc rescan command

The mmc rescan command is used to scan all MMC devices on the current development board, including the EMMC and SD cards, enter «MMC Rescan».

3. MMC list command

The mmc list command is used to see a total of several MMC devices in the current development board.

4.mmc dev command

The MMC dev command is used to switch the current MMC device, the command format is as follows

[DEV] is used to set the MMC device number to switch, [Part] is partition number. If the words do not write the partition number, the partition 0 is defaulted. Switch to SD card with the following command:

5.mmc part command

Sometimes the SD card or EMMC has multiple partitions, you can use the command «MMC Part» to view its partition, such as the partition of the EMMC, enter the following command:

If the Linux system is burned in the EMMC, the EMMC is 3 partitions, and the 0th partition stores Uboot, the first partition stores Linux mirror files and equipment trees, and the second partition stored root file system.

6.mmc m command

The MMC read command is used to read the data of the MMC device, the command format is as follows:

AddR is the address read to the address in the DRAM. BLK is the start address (hexadecimal) to read, a block is 512 bytes, the blocks and sectors are one meaning, in the MMC device Usually sectors, CNT is the number of blocks to read (hexadecimal). For example, from the EMMC’s 1536 (0x600) block, read 16 (0x10) block data to the 0x80800000 address of the DRAM, the command is as follows:

7.MMC Write Command

To write the data into the MMC device, you can use the command «MMC WRITE», the format is as follows:

Addr is to write data in the MMC in the start address of the DRAM, the BLK is to write the block start address (hexadecimal) to write MMC, CNT is the block size to write, one block is 512 bytes .Don’t write SD card or the first two blocks of EMMC (sector), save the partition table!

8.mmc erase command

If you want to erase the specified block of the MMC device, use the command «MMC ERASE», the command format is as follows:

BLK is the start block to erase, and CNT is the number of erasing. Don’t use MMC Erase to erase the MMC device!

Источник

Читайте также:  Компиляция исходников для windows
Оцените статью