{"id":336830,"date":"2022-08-10T03:00:06","date_gmt":"2022-08-10T03:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336830"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336830","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f Linux. \u0427\u0430\u0441\u0442\u044c 1<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f Linux.<\/p>\n<p>C\u0442\u0430\u0442\u044c\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0435\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 MAC \u0438 PHY, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043a \u0440\u0430\u0431\u043e\u0442\u0435, \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438 \u043a\u0430\u043a \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u0425\u043e\u0442\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u044f\u0434\u0435\u0440\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>clock, reset, libphy<\/em> \u0438 \u043f\u0440., \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 Device Tree, \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441 \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c Linux. \u0412\u043e\u0437\u044c\u043c\u0435\u043c <a href=\"https:\/\/linux-sunxi.org\/Xunlong_Orange_Pi_Zero\" rel=\"noopener noreferrer nofollow\"><strong>Orange Pi Zero<\/strong><\/a><strong> <\/strong>\u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 Allwinner H2+. \u0412 \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0445 \u044f\u0434\u0440\u0430 Cortex-A7, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u041e\u0417\u0423 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432 LPDDR2, LPDDR3, DDR3, \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0441\u043f\u0435\u043a\u0442\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b <a href=\"https:\/\/linux-sunxi.org\/H3\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 <a href=\"https:\/\/linux-sunxi.org\/images\/4\/4b\/Allwinner_H3_Datasheet_V1.2.pdf\" rel=\"noopener noreferrer nofollow\"><strong>Allwinner H3 Datasheet<\/strong><\/a>.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/aba\/e30\/800\/abae30800c9718c77cb3d886b70dd595.jpg\" alt=\"\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u044b\" title=\"\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u044b\" width=\"800\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aba\/e30\/800\/abae30800c9718c77cb3d886b70dd595.jpg\" data-blurred=\"true\"\/><figcaption>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u044b<\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/885\/eac\/26d\/885eac26d8756540bfbd2fa140e7d4e5.jpg\" alt=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\" title=\"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430\" width=\"300\" height=\"225\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/885\/eac\/26d\/885eac26d8756540bfbd2fa140e7d4e5.jpg\" data-blurred=\"true\"\/><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043d\u0438\u043a USB-to-COM \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043b\u0430\u0442\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>minicom<\/em>.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u043f\u0443\u0441\u043a Linux \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Ethernet \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u2013 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p><strong>1. \u0417\u0430\u043f\u0443\u0441\u043a Linux \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435<\/strong>\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Linux \u043d\u0430 \u043f\u043b\u0430\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (rootfs)<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u044f\u0434\u0440\u043e Linux \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b (device tree)<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a u-boot<\/p>\n<\/li>\n<li>\n<p>\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0443\u044e sd-\u043a\u0430\u0440\u0442\u0443 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0435<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>1.1 \u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/em><\/strong><\/p>\n<p>\u00a0\u0425\u043e\u0441\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 &#8212; Debian 10. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<pre><code class=\"bash\">apt-get install libgmp3-dev apt-get install libmpc-dev apt install libyaml-dev pip3 install dtschema apt install gcc-arm-linux-gnueabi apt-get install u-boot-tools<\/code><\/pre>\n<p>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0443 \u043d\u0430\u0441 ARM, \u0443\u043a\u0430\u0436\u0435\u043c \u0435\u0435 \u0438 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440:<\/p>\n<pre><code class=\"bash\">export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi-<\/code><\/pre>\n<p><strong><em>1.2. \u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 (roosfs)<\/em><\/strong>\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2013 \u0432\u0437\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0438\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439, \u0441\u043e\u0431\u0435\u0440\u0435\u043c <strong>rootfs<\/strong> \u0438\u0437 <strong>busybox<\/strong>. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"bash\">wget https:\/\/busybox.net\/downloads\/busybox-1.35.0.tar.bz2<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440:<\/p>\n<pre><code class=\"bash\">make menuconfig<\/code><\/pre>\n<p>\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0443:<\/p>\n<pre><code class=\"bash\">Settings -> Build options -> Build static binary (no shared libs)<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0434\u043e \u0432 <strong>CONFIG_PREFIX<\/strong> \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a\u0443\u0434\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">make &amp;&amp; make CONFIG_PREFIX=\/path\/to\/install\/busybox  install<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 busybox \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>\/tmp\/build\/bb\/ramdisk<\/em>. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435, \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<pre><code class=\"bash\">root@debian:\/tmp\/build\/bb\/ramdisk# ls -l total 8 drwxr-xr-x 2 root root 4096 Apr\u00a0 3 22:42 bin lrwxrwxrwx 1 root root\u00a0\u00a0 11 Apr\u00a0 3 22:42 linuxrc -> bin\/busybox drwxr-xr-x 2 root root 4096 Apr\u00a0 3 22:42 sbin drwxr-xr-x 4 root root\u00a0\u00a0 29 Apr\u00a0 3 22:42 usr<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f <em>procfs<\/em> \u0438 <em>sysfs<\/em>, \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>etc<\/em> \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 dev \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code class=\"bash\">mkdir proc sys etc dev<\/code><\/pre>\n<p>\u0412 busybox \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 mdev &#8212; \u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b udev. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/dev. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 https:\/\/git.busybox.net\/busybox\/plain\/docs\/mdev.txt.<\/p>\n<p>\u0412 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <em>etc<\/em> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b <em>group<\/em>, <em>hosts<\/em>, <em>inittab<\/em>, <em>passwd<\/em>:<\/p>\n<pre><code class=\"bash\"># cat group root:x:0:root  # cat hosts 127.0.0.1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 localhost  # cat inittab ::sysinit:\/etc\/init.d\/rc.S console::respawn:-\/bin\/ash ::restart:\/sbin\/init ::ctrlaltdel:\/sbin\/reboot ::halt:\/bin\/umount -a -r  # cat passwd root::0:0:root:\/root:\/bin\/ash<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 <em>etc<\/em> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>init.d<\/em> \u0438 \u0432 \u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b <em>rc.S<\/em>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh HOSTNAME=zero VERSION=0.0.1 hostname $HOSTNAME mount -n -t proc proc \/proc mount -n -t sysfs sysfs \/sys mount -n -t tmpfs mdev \/dev mdev -s  # Set PATH export PATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin  # Start other daemons \/sbin\/syslogd \/usr\/sbin\/telnetd<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 <em>rc.S<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b <em>procfs<\/em> \u0432 \/<em>proc<\/em>, <em>sysfs<\/em> \u0432 \/<em>sys<\/em>, <em>tmpfs<\/em> \u0432 \/<em>dev<\/em>, \u0438 <em>mdev<\/em> \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0432 \/<em>dev<\/em> \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043d\u0430\u0439\u0434\u0435\u0442 \u0432 <em>sysfs<\/em>.   <em><\/p>\n<p><\/em>\u0412 <strong>rootfs<\/strong> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>\/lib\/modules<\/em> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u044f\u0434\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c. \u041e\u0431 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442. \u041f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 rootfs.<\/p>\n<p><strong><em>1.3. \u042f\u0434\u0440\u043e<\/em><\/strong><\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0431\u043e\u0440\u043a\u0435 \u044f\u0434\u0440\u0430. \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u043c\u0438\u0442:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/linux-sunxi\/linux-sunxi.git cd linux-sunxi git checkout -b next c9a8f2f1da7b<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b:<\/p>\n<pre><code class=\"bash\">make sunxi_defconfig<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0435\u0436\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u0442.\u043a. \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0439:<\/p>\n<pre><code class=\"bash\">make menuconfig  Device Drivers ->    Network Device Support ->      Ethernet driver support ->        STMicroelectronics devices<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0434\u0440\u043e \u0438 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code class=\"bash\">make -j4 zImage modules<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c Device Tree:<\/p>\n<pre><code class=\"bash\">make sun8i-h2-plus-orangepi-zero.dtb<\/code><\/pre>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0436\u0430\u0442\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u044f\u0434\u0440\u0430 <em>arch\/arm\/boot\/zImage<\/em> \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 (device tree blob) <em>arch\/arm\/boot\/dts\/sun8i-h2-plus-orangepi-zero.dtb.<\/em><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043d\u0430 rootfs:<\/p>\n<pre><code class=\"bash\">make -j4 INSTALL_MOD_PATH=\/path\/to\/install\/busybox modules_install<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0430\u043a\u0443\u0435\u043c <strong>rootfs<\/strong> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0436\u0430\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 <strong>initramfs.img<\/strong>:<\/p>\n<pre><code class=\"bash\">cd \/path\/to\/install\/busybox find . | cpio -o -H newc | gzip > ..\/newrootfs.img.gz cd .. mkimage -A arm -T ramdisk -C none -d newrootfs.img.gz initramfs.img<\/code><\/pre>\n<p><strong><em>1.4. \u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a<\/p>\n<p><\/em><\/strong>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"bash\">git clone git:\/\/git.denx.de\/u-boot.git cd u-boot<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">make orangepi_zero_defconfig make -j2<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <em>u-boot-sunxi-with-spl.bin<\/em>.<\/p>\n<p><strong><em>1.5. \u0417\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0430\u044f sd \u043a\u0430\u0440\u0442\u0430<\/p>\n<p><\/em><\/strong>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e fdisk \u0438 mkfs \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b FAT32. \u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u043a\u0442\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0441\u0442\u0430\u0432\u0438\u043c 8192, \u0442.\u043a. \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a u-boot.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/boot \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0442\u0443\u0434\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b &#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u044f\u0434\u0440\u0430 <em>arch\/arm\/boot\/zImage<\/em>, \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 <em>arch\/arm\/boot\/dts\/sun8i-h2-plus-orangepi-zero.dtb<\/em> \u0438 \u0441\u0436\u0430\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 rootfs initramfs.img. \u0414\u0430\u043b\u0435\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f boot.cmd \u0434\u043b\u044f u-boot:<\/p>\n<pre><code class=\"bash\"># cat boot.cmd load mmc 0 0x44000000 \/boot\/zImage load mmc 0 0x46000000 \/boot\/sun8i-h2-plus-orangepi-zero.dtb load mmc 0 0x48000000 \/boot\/initramfs.img setenv bootargs console=ttyS0,115200 earlyprintk root=\/dev\/ram0 rdinit=\/sbin\/init rootwait panic=10 bootz 0x44000000 0x48000000 0x46000000<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u043a\u0443\u0434\u0430, \u0447\u0442\u043e \u0438 \u043a\u0443\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0433\u0440\u0443\u0437\u0438\u0442\u044c u-boot \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u044f\u0434\u0440\u0430. \u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 ramdisk. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437 boot.cmd \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 boot.src \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0443:<\/p>\n<pre><code class=\"bash\">mkimage -C none -A arm -T script -d boot.cmd boot.scr<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<br \/>&#8212; <em>boot.scr<\/em> \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435<br \/>&#8212; <em>zImage, sun8i-h2-plus-orangepi-zero.dtb, initramfs.img<\/em> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/boot<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, sd \u043a\u0430\u0440\u0442\u0430 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \/dev\/sdc1 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/mnt\/sdc:<\/p>\n<pre><code class=\"bash\"># cd \/mnt\/sdc # ls -l total 8 drwxr-xr-x 2 root root 4096 Apr 10 19:22 boot -rwxr-xr-x 1 root root\u00a0 348 Mar 26 22:02 boot.scr  # ls -l boot total 5896 -rwxr-xr-x 1 root root 1194170 Apr\u00a0 9 19:31 initramfs.img -rwxr-xr-x 1 root root\u00a0\u00a0 23332 Apr\u00a0 1 20:33 sun8i-h2-plus-orangepi-zero.dtb -rwxr-xr-x 1 root root 4813272 Apr  1 20:25 zImage<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 sd \u043a\u0430\u0440\u0442\u044b &#8212; \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430. \u0422\u0443\u0442 \u043d\u0430\u0434\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0439 sd \u043a\u0430\u0440\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <em>\/dev\/sdc<\/em>. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 u-boot, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">dd if=.\/u-boot-sunxi-with-spl.bin of=\/dev\/sdc bs=1024 seek=8<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0437\u0430\u043f\u0438\u0441\u0430\u043d. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 &#8212; \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c sd \u043a\u0430\u0440\u0442\u0443 \u0432 \u0441\u043b\u043e\u0442 \u043f\u043b\u0430\u0442\u044b \u0438 \u043f\u043e\u0434\u0430\u0435\u043c \u043f\u0438\u0442\u0430\u043d\u0438\u0435, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u041d\u043e \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 Ethernet.<\/p>\n<p><strong>2. \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Ethernet \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u0430\u0432 Ethernet \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u044f\u0442:<\/p>\n<ul>\n<li>\n<p>\u0431\u043b\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u0441\u0440\u0435\u0434\u0435 MAC (Media Access Controller)<\/p>\n<\/li>\n<li>\n<p>\u0431\u043b\u043e\u043a DMA<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438\u0435\u043c\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 FIFO \u0431\u0443\u0444\u0435\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438\u0435\u043c\u043e\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a PHY<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/7a2\/223\/6df\/7a22236dffae9ebb70802716a74a8f3a.jpg\" alt=\"\u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 Ethernet\" title=\"\u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 Ethernet\" width=\"855\" height=\"208\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7a2\/223\/6df\/7a22236dffae9ebb70802716a74a8f3a.jpg\" data-blurred=\"true\"\/><figcaption>\u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 Ethernet<\/figcaption><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 MAC &#8212; \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0434\u0440\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0432 \u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (payload), \u043f\u0440\u0438\u0435\u043c \u043a\u0430\u0434\u0440\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u0430\u0434\u0440\u043e\u0432, \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 (\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c CSMA\/CD).<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 DMA &#8212; \u043e\u0431\u043c\u0435\u043d \u043a\u0430\u0434\u0440\u0430\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0438 MAC. DMA \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 MAC \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 FIFO \u0431\u0443\u0444\u0435\u0440\u043e\u0432 &#8212; \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 (TX) \u0438 \u043f\u0440\u0438\u0435\u043c\u043d\u044b\u0439 (RX). \u0427\u0435\u0440\u0435\u0437 TX FIFO \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u0430\u0434\u0440 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 MAC, \u0430 \u0447\u0435\u0440\u0435\u0437 RX FIFO \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043a\u0430\u0434\u0440 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0438\u0437 MAC \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 PHY &#8212; \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0434\u0440\u0430 \u0432 \u0432\u0438\u0434, \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e, \u0442.\u0435. \u043f\u043e Ethernet \u043a\u0430\u0431\u0435\u043b\u044e, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0432\u0438\u0434.<\/p>\n<p>MAC \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 PHY \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 &#8212; MII (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/MII\" rel=\"noopener noreferrer nofollow\">Media Independent Interface<\/a>) \u0438 SMI (Station Management Interface). \u041a \u043e\u0434\u043d\u043e\u043c\u0443 MAC \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u043e 32-\u0445 PHY. \u041a\u0430\u0436\u0434\u044b\u0439 PHY \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c, \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0434\u0440\u0435\u0441\u0430 \u2013 5 \u0431\u0438\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7d\/575\/e81\/b7d575e81afe36478cc0385df1460299.JPEG\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f MAC \u0438 PHY\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f MAC \u0438 PHY\" width=\"721\" height=\"609\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f MAC \u0438 PHY<\/figcaption><\/figure>\n<p>\u0427\u0435\u0440\u0435\u0437 MII \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 MAC \u0438 PHY, \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<p>SMI \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f PHY. \u042d\u0442\u043e \u0434\u0432\u0443\u0445\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043b\u0438\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (Management Data Input\/Output, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Management_Data_Input\/Output\" rel=\"noopener noreferrer nofollow\">MDIO<\/a>) \u0438 \u043b\u0438\u043d\u0438\u0438 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (MDC). \u0427\u0435\u0440\u0435\u0437 SMI \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b PHY (\u0434\u0443\u043f\u043b\u0435\u043a\u0441 &#8212; \u043f\u043e\u043b\u0443\u0434\u0443\u043f\u043b\u0435\u043a\u0441), \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u043c\u0435\u043d\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u043b\u0438 \u043d\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u0430\u0431\u0435\u043b\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 PHY. \u041f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 PHY \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0431\u0438\u0442\u044b \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u044f\u0434\u0440\u0430 <a href=\"https:\/\/github.com\/torvalds\/linux\/blob\/master\/include\/uapi\/linux\/mii.h\" rel=\"noopener noreferrer nofollow\">&lt;linux\/mii.h><\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441 \u0438 \u0430\u0434\u0440\u0435\u0441 PHY. \u0420\u0430\u0437\u043c\u0435\u0440 \u0430\u0434\u0440\u0435\u0441\u0430 &#8212; 5 \u0431\u0438\u0442. \u0420\u0435\u0433\u0438\u0441\u0442\u0440 PHY \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440, \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0441\u0430\u043c PHY. \u0410\u0434\u0440\u0435\u0441\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043b\u0438\u043d\u0438\u0438 MDIO. \u0424\u043e\u0440\u043c\u0430\u0442 MDIO \u043a\u0430\u0434\u0440\u0430 \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0430 \u0440\u0438\u0441. 5.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5d\/fdd\/79b\/e5dfdd79b6864033ff3fedd5d224731f.png\" alt=\"\u0424\u043e\u0440\u043c\u0430\u0442 MDIO \u043a\u0430\u0434\u0440\u0430 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 PHY\" title=\"\u0424\u043e\u0440\u043c\u0430\u0442 MDIO \u043a\u0430\u0434\u0440\u0430 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 PHY\" width=\"945\" height=\"305\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5d\/fdd\/79b\/e5dfdd79b6864033ff3fedd5d224731f.png\"\/><figcaption>\u0424\u043e\u0440\u043c\u0430\u0442 MDIO \u043a\u0430\u0434\u0440\u0430 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438\/\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 PHY<\/figcaption><\/figure>\n<p>MAC \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 PHY \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432. \u0418\u0445 \u0447\u0438\u0441\u043b\u043e \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c. \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043d\u0430\u043c\u0438 Ethernet MAC \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 (\u0434\u0430\u043b\u0435\u0435 EMAC) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c, \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0432 \u043f.8.9.3<strong> <\/strong><em>&#171;EMAC Core Register List&#187;<\/em> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u043b\u0430\u0442\u0443. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 EMAC.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438 <em>System Control<\/em> \u0438 <em>CCU<\/em>. <em>CCU<\/em> &#8212; \u044d\u0442\u043e <em>Clock Control Unit<\/em>, \u0431\u043b\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0442\u043e\u0432\u044b\u043c\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c\u0438. \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043f\u043b\u0430\u0442\u044b.<\/p>\n<p><strong>3. \u0414\u0440\u0430\u0439\u0432\u0435\u0440<\/strong><\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<br \/>&#8212; \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 PHY<br \/>&#8212; \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 EMAC<br \/>&#8212; \u043f\u0440\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u0432<br \/>&#8212; \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/p>\n<p><strong><em>3.1. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 PHY<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 PHY \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<br \/>&#8212; \u043f\u043e\u0434\u0430\u0447\u0430 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u043e\u0442\u044b<br \/>&#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441 (reset)<br \/>&#8212; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 PHY<\/p>\n<p>\u041f\u043e\u0434\u0430\u0447\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 0 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Bus Clock Gating Register 4,<\/em> \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x0070 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 CCU (\u043f. 4.3.5.18 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438):<\/p>\n<pre><code class=\"cpp\">\/* Set clock gating for EPHY - bit 0 in Bus Clock Gating Reg4, offset 0x70 *\/ volatile u32 val = readl(ccu_base_addr + CLK_GATING_REG4); val |= BIT(EPHY_GATING); writel(val, ccu_base_addr + CLK_GATING_REG4);<\/code><\/pre>\n<p>\u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0431\u0440\u043e\u0441\u043e\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 2 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Bus Software Reset Register 2,<\/em> \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x2C8 (\u043f. 4.3.5.72):<\/p>\n<pre><code class=\"cpp\">\/* Reset assert EPHY - bit 2 in Bus Software Reset Reg2, offset 0x2C8 *\/ val = readl(ccu_base_addr + SW_RST_REG2); val &amp;= ~BIT(EPHY_RST); writel(val, ccu_base_addr + SW_RST_REG2);  \/* Deassert EPHY *\/ val = readl(ccu_base_addr + SW_RST_REG2); val |= BIT(EPHY_RST); writel(val, ccu_base_addr + SW_RST_REG2);<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 PHY \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043a\u043e\u043c\u0430\u043d\u0434 <em>MII<\/em><strong> <\/strong><em>Command<\/em><strong> <\/strong><em>Register (MII_CMD)<\/em> \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 <em>MII Data Register (MII_DATA).<\/em> \u041e\u0431\u0430 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 <em>EMAC Core Register List<\/em>. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 <em>MII_CMD<\/em> &#8212; 0x48, <em>MII_DATA<\/em> &#8212; 0x4C. \u0412 <em>MII_CMD<\/em> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 PHY, \u043d\u043e\u043c\u0435\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 PHY, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0434\u043b\u044f MDC \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u043c\u0435\u043d\u0430 &#8212; \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c. \u0412 \u0440\u0435\u0436\u0438\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 <em>MII_DATA<\/em> \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f &#8212; \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 PHY \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0436\u0434\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 MII_BUSY &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043c\u044b \u0435\u0433\u043e \u0441\u0430\u043c\u0438, \u0430 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 (\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e):<\/p>\n<pre><code class=\"cpp\">int phy_read(int phy_addr, int phy_reg) {   int err;   u32 v, val = MII_BUSY;   int data;    val |= (phy_addr &lt;&lt; MII_PHY_ADDR_SHIFT);   val |= (phy_reg &lt;&lt; MII_PHY_REG_ADDR_SHIFT);   val |= (phy_mdc_div_ratio &lt;&lt; MII_MDC_DIV_RATIO_SHIFT);    err = readl_poll_timeout(emac_base_addr + MII_CMD, v,       !(v &amp; MII_BUSY), 100, 100000);   if (err)     return -EBUSY;      writel(val, emac_base_addr + MII_CMD);   err = readl_poll_timeout(emac_base_addr + MII_CMD, val,       !(val &amp; MII_BUSY), 100, 100000);   if (err)     return -EBUSY;    data = (int)readl(emac_base_addr + MII_DATA);   return data; }  int phy_write(int phy_addr, int phy_reg, u16 data) {   int err;   u32 v, val = MII_BUSY;      val |= (phy_addr &lt;&lt; MII_PHY_ADDR_SHIFT);   val |= (phy_reg &lt;&lt; MII_PHY_REG_ADDR_SHIFT) | MII_WRITE;   val |= (phy_mdc_div_ratio &lt;&lt; MII_MDC_DIV_RATIO_SHIFT);      \/* Wait until any existing MII operation is complete *\/   readl_poll_timeout(emac_base_addr + MII_CMD, v,       !(v &amp; MII_BUSY), 100, 100000));   writel(data, emac_base_addr + MII_DATA);   writel(val, emac_base_addr + MII_CMD);      err = readl_poll_timeout(emac_base_addr + MII_CMD, val,       !(val &amp; MII_BUSY), 100, 100000);   if (err)     return -EFAULT;      return 0; }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412\u044b\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 phy_mdc_div_ratio &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b MDC<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 <em>phy_mdc_div_ratio<\/em>, \u043a\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440.<\/p>\n<p>\u041c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 3-\u0445 \u0431\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 MDC_DIV_RATIO_M \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <em>MII_CMD<\/em>. \u041e\u043d\u043e \u0437\u0430\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u044b MDC, \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"center\"><code>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>\u041d\u043e\u043c\u0438\u043d\u0430\u043b \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><code>000<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>16<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><code>001<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>32<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><code>010<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>64<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\"><code>011<\/code><\/p>\n<\/td>\n<td>\n<p align=\"center\"><code>128<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0422.\u043a. \u0441\u0438\u0433\u043d\u0430\u043b MDC \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u0447\u0430\u0441\u0442\u043e\u0442\u044b \u0448\u0438\u043d\u044b AHB1 (\u043f. 8.9.4.15), \u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u044b AHB1 \u0448\u0438\u043d\u044b. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 802.3 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0442\u0430\u043a\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0430 \u043b\u0438\u043d\u0438\u0438 MDC \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u0435\u043d 400 \u043d\u0441, \u0442.\u0435. \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 MDC \u0440\u0430\u0432\u043d\u0430 2.5 \u041c\u0413\u0446. \u0417\u043d\u0430\u0447\u0438\u0442 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435:<\/p>\n<pre><code class=\"bash\">AHB1 \/ mdc_div_ratio = 2.5 \u041c\u0413\u0446<\/code><\/pre>\n<p>\u00a0\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0445\u0435\u043c\u0435 Bus Clock Tree (\u0440\u0438\u0441. 4-2 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438) \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0447\u0430\u0441\u0442\u043e\u0442\u044b AHB1 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f PLL_PERIPH0, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043d\u043e\u043c\u0438\u043d\u0430\u043b AHB1 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a:<\/p>\n<pre><code class=\"bash\">AHB1 = PLL_PERIPH0 \/ AHB1_PRE_DIV \/ AHB1_CLK_DIV_RATIO<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u0439 AHB1_PRE_DIV \u0438 AHB1_CLK_DIV_RATIO \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 CCU \u0440\u0435\u0433\u0438\u0441\u0442\u0440 AHB1_APB1_CFG_REG, \u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 PLL_PERIPH0_CTRL_REG &#8212; \u043d\u043e\u043c\u0438\u043d\u0430\u043b \u0447\u0430\u0441\u0442\u043e\u0442\u044b PLL_PERIPH0:<\/p>\n<pre><code class=\"bash\">PLL Output = 24 MHz * N * K\/2<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f N \u0438 K \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u043f\u043e\u043b\u044f\u0445 PLL_FACTOR_N \u0438 PLL_FACTOR_K \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 PLL_PERIPH0_CTRL_REG.<\/p>\n<p>\u0414\u043b\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0441\u0434\u0430\u043c\u043f\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 AHB1_APB1_CFG_REG \u0438 PLL_PERIPH0_CTRL_REG:<\/p>\n<pre><code class=\"bash\">AHB1_APB1_CFG_REG = 0x00003180 PLL_PERIPH0_CTRL_REG = 0x90041811<\/code><\/pre>\n<p>\u0411\u0438\u0442\u044b 13 \u0438 12 \u0432 AHB1_APB1_CFG_REG \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b, \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 AHB1 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 PLL_PERIPH0\/AHB1_PRE_DIV, \u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0438 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u0439, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 AHB1_APB1_CFG_REG:<\/p>\n<pre><code class=\"bash\">AHB1_CLK_DIV_RATIO = 1 AHB1_PRE_DIV = 3<\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f PLL_FACTOR_N \u0438 PLL_FACTOR_K:<\/p>\n<pre><code class=\"bash\">PLL_FACTOR_N = 24, N = PLL_FACTOR_N + 1 = 25 PLL_FACTOR_K = 1, K = PLL_FACTOR_K + 1 = 2<\/code><\/pre>\n<p>\u0427\u0430\u0441\u0442\u043e\u0442\u0430 PLL:<\/p>\n<pre><code class=\"bash\">PLL output = 24 MHz * N * K \/ 2 = 24 MHz * 25 * 2 \/ 2 = 600 MHz<\/code><\/pre>\n<p>600 MHz &#8212; \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043e \u0438 \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043c\u044b \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 AHB1:<\/p>\n<pre><code class=\"bash\">AHB1 = PLL_PERIPH0 \/ AHB1_PRE_DIV = 600 MHz \/ 3 = 200 MHz<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f MDC:<\/p>\n<pre><code class=\"bash\">mdc_div_ratio = AHB1 \/ 2.5 MHz = 200 \/ 2.5 = 80<\/code><\/pre>\n<p>\u041a\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c? \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u0437\u0430 \u0441\u043e\u0432\u0435\u0442\u043e\u043c \u043a FreeBSD \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0442\u0430\u043c:<\/p>\n<pre><code class=\"cpp\">#define MDIO_FREQ\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2500000 \/* Determine MDC clock divide ratio based on AHB clock *\/ error = clk_get_freq(clk_ahb, &amp;freq); if (error != 0) {   device_printf(dev, \"cannot get AHB clock frequency\\n\");   goto fail; } div = freq \/ MDIO_FREQ; if (div &lt;= 16)   sc->mdc_div_ratio_m = MDC_DIV_RATIO_M_16; else if (div &lt;= 32)   sc->mdc_div_ratio_m = MDC_DIV_RATIO_M_32; else if (div &lt;= 64)   sc->mdc_div_ratio_m = MDC_DIV_RATIO_M_64; else if (div &lt;= 128)   sc->mdc_div_ratio_m = MDC_DIV_RATIO_M_128;<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0430\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u043e\u043c\u0438\u043d\u0430\u043b \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f 128, \u0438 \u0432 \u043f\u043e\u043b\u0435 MDC_DIV_RATIO_M \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 MII_CMD \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 3.<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441 (soft-reset) PHY \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 BMCR_RESET \u0432 PHY \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>MII_BMCR<\/em> (Basic mode control register). \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u0441\u0431\u0440\u043e\u0441\u0430, \u043e\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <em>MII_BMCR<\/em>:<\/p>\n<pre><code class=\"cpp\">int phy_reset(void) {   int ret = 0;   int phy_addr = PHY_ADDR;   int retries = 12;   phy_write(phy_addr, MII_BMCR, BMCR_RESET);   do {     msleep(50);     ret = phy_read(phy_addr, MII_BMCR);     if (ret &lt; 0)       return ret;   } while (ret &amp; BMCR_RESET &amp;&amp; --retries);   if (ret &amp; BMCR_RESET)     ret = -ETIMEDOUT;      return ret; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u043a \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0438 \u043f\u043e\u0440\u0442\u0430 \u0440\u043e\u0443\u0442\u0435\u0440\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043e\u043d \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u0435\u0440\u0432\u044b\u0439, \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0438 \u0440\u0435\u0436\u0438\u043c\u0430, \u0442\u0430\u043a\u0443\u044e \u0436\u0435, \u043a\u0430\u043a \u0443 \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c &#8212; \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0440\u0442\u0430 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0440\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <em>\u0430\u0432\u0442\u043e\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0435\u0439<\/em> (auto-negotiation). \u0421\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u0440\u043e\u0443\u0442\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Autonegotiation\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, \u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0430\u0432\u0442\u043e\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0435.<\/p>\n<p>PHY \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b <em>MII_BMSR<\/em> \u0438 <em>MII_ADVERTISE<\/em>. <em>MII_BMSR<\/em> &#8212; \u044d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 (Basic mode status register), \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0440\u0435\u0436\u0438\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u043c\u0435\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#define BMSR_10HALF  0x0800 \/* Can do 10mbps, half-duplex\u00a0 *\/ #define BMSR_10FULL  0x1000 \/* Can do 10mbps, full-duplex\u00a0 *\/ #define BMSR_100HALF 0x2000 \/* Can do 100mbps, half-duplex *\/ #define BMSR_100FULL 0x4000 \/* Can do 100mbps, full-duplex *\/<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043d\u0435\u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0440\u0435\u0436\u0438\u043c\u043e\u0432, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 <a href=\"https:\/\/github.com\/torvalds\/linux\/blob\/master\/include\/uapi\/linux\/mii.h\" rel=\"noopener noreferrer nofollow\">&lt;linux\/mii.h><\/a>.<\/p>\n<p><em>MII_ADVERTISE<\/em> &#8212; \u044d\u0442\u043e <em>Advertisement control register<\/em>, \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u043e\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043e \u0441\u0432\u043e\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445:<\/p>\n<pre><code class=\"cpp\">#define ADVERTISE_10HALF\u00a0 \u00a00x0020 \/* Try for 10mbps half-duplex\u00a0 *\/ #define ADVERTISE_10FULL\u00a0\u00a0 0x0040 \/* Try for 10mbps full-duplex\u00a0 *\/ #define ADVERTISE_100HALF\u00a0 0x0080 \/* Try for 100mbps half-duplex *\/ #define ADVERTISE_100FULL\u00a0 0x0100 \/* Try for 100mbps full-duplex *\/<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0438\u0441\u0430\u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <em>MII_ADVERTISE,<\/em> \u043d\u0430\u0434\u043e \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>MII_BMCR<\/em> \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433\u0438 BMCR_ANRESTART \u0438 BMCR_ANENABLE \u0434\u043b\u044f \u0430\u043a\u0442\u0438\u0432\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0436\u0438\u043c\u0430 \u0430\u0432\u0442\u043e\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f<\/p>\n<pre><code class=\"cpp\">#define BMCR_ANRESTART\u00a0\u00a0\u00a0\u00a0\u00a00x0200\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Auto negotiation restart *\/ #define BMCR_ANENABLE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00x1000\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Enable auto negotiation *\/<\/code><\/pre>\n<p>\u0438 \u0436\u0434\u0430\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u0444\u043b\u0430\u0433 BMSR_ANEGCOMPLETE \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>MII_BMSR<\/em>:<\/p>\n<pre><code class=\"cpp\">#define BMSR_ANEGCOMPLETE\u00a0\u00a0\u00a00x0020\u00a0\u00a0\u00a0\u00a0\/* Auto-negotiation complete *\/<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0444\u043b\u0430\u0433\u0430 \u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <em>MII_LPA Link &#8212;<\/em> Partner Ability register. \u0412 \u043d\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0440\u0435\u0436\u0438\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">#define LPA_10HALF\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00x0020\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Can do 10mbps half-duplex\u00a0\u00a0 *\/ #define LPA_10FULL\u00a0\u00a0\u00a0\u00a0\u00a0\u00a00x0040\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Can do 10mbps full-duplex\u00a0\u00a0 *\/ #define LPA_100HALF\u00a0\u00a0\u00a0\u00a0\u00a00x0080\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Can do 100mbps half-duplex\u00a0 *\/ #define LPA_100FULL\u00a0\u00a0\u00a0\u00a0\u00a00x0100\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Can do 100mbps full-duplex\u00a0 *\/<\/code><\/pre>\n<p>\u041e\u0444\u043e\u0440\u043c\u0438\u043c \u0432\u0435\u0441\u044c \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<pre><code class=\"cpp\">int phy_adjust_link(int *speed, int *duplex) {   int i, status, adv;   status = phy_read(PHY_ADDR, MII_BMSR);   adv = phy_read(PHY_ADDR, MII_ADVERTISE);      \/* Cleanup advertise *\/   adv &amp;= ~ADVERTISE_ALL;   if (status &amp; BMSR_100FULL)     adv |= ADVERTISE_100FULL;   if (status &amp; BMSR_100HALF)     adv |= ADVERTISE_100HALF;      phy_write(PHY_ADDR, MII_ADVERTISE, adv);   phy_write(PHY_ADDR, MII_BMCR, BMCR_ANRESTART | BMCR_ANENABLE);      for (i = 0; i &lt; 100; i++, msleep(50)) {     status = phy_read(PHY_ADDR, MII_BMSR);     if (status &amp; BMSR_ANEGCOMPLETE) {       phy_aneg_complete(speed, duplex, status);       return 0;     }   }   return -1; }  void phy_aneg_complete(int *speed, int *duplex, int status) {   int lpa = phy_read(PHY_ADDR, MII_LPA);   *speed = SPEED10;   *duplex = HALF_DUPLEX;   if ((status &amp; BMSR_100FULL) &amp;&amp; (lpa &amp; LPA_100FULL)) {     *speed = SPEED100;     *duplex = FULL_DUPLEX;     return;   }   if ((status &amp; BMSR_100HALF) &amp;&amp; (lpa &amp; LPA_100HALF)) {     *speed = SPEED100;     *duplex = HALF_DUPLEX;   } }<\/code><\/pre>\n<p>PHY \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 EMAC.<\/p>\n<p><strong><em>3.2. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 EMAC<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 EMAC \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 &#8212; \u0430\u0434\u0440\u0435\u0441 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043d\u043e\u043c\u0435\u0440 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 PHY<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 (MAC \u0430\u0434\u0440\u0435\u0441)<\/p>\n<\/li>\n<li>\n<p>\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u043a\u0442\u0430 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>3.2.1. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/em><\/strong><\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 EMAC \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441 EMAC, \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u044f\u0434\u0440\u0430, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f CCU \u0438 System Control:<\/p>\n<pre><code class=\"cpp\">emac_irq = platform_get_irq(pdev, 0); emac_base_addr = devm_ioremap(&amp;pdev->dev, EMAC_BASE_ADDR, EMAC_SIZE);<\/code><\/pre>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 Device Tree (\u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u043c. \u0432 <em>arch\/arm\/boot\/dts\/sunxi-h3-h5.dtsi<\/em>):<\/p>\n<pre><code class=\"cpp\">emac: ethernet@1c30000 {   compatible = \"allwinner,sun8i-h3-emac\";   reg = &lt;0x01c30000 0x10000>;   interrupts = &lt;GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;   interrupt-names = \"macirq\";<\/code><\/pre>\n<p><strong><em>3.2.2. \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441<\/p>\n<p><\/em><\/strong>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 EMAC \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043a\u0430\u043a \u0438 \u0434\u043b\u044f PHY &#8212; \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u0442\u043e\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0441\u0431\u0440\u043e\u0441. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u0442\u043e\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 EMA\u0421 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 17 \u0432 CCU \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Bus Clock Gating Register0<\/em>, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x60 (\u043f. 4.3.5.14):<\/p>\n<pre><code class=\"cpp\">\/* Set clock gating for EMAC - bit 17 in Bus Clock Gating Reg0, offset 0x60 *\/ val = readl(ccu_base_addr + CLK_GATING_REG0); val |= BIT(EMAC_GATING); writel(val, ccu_base_addr + CLK_GATING_REG0);<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c reset \u0441\u0431\u0440\u043e\u0441\u043e\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 17 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 Bus Sotfware Reset Register0, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x2C0 (\u043f.\u00a04.3.5.70): <\/p>\n<pre><code class=\"cpp\">\/* Reset assert EMAC - bit 17 in Bus Sotfware Reset Reg0, offset 0x2C0 *\/ val = readl(ccu_base_addr + SW_RST_REG0); val &amp;= ~BIT(EMAC_RST); writel(val, ccu_base_addr + SW_RST_REG0);  \/* Reset deassert EMAC *\/ val = readl(ccu_base_addr + SW_RST_REG0); val |= BIT(EMAC_RST); writel(val, ccu_base_addr + SW_RST_REG0);<\/code><\/pre>\n<p><strong><em>3.2.3. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 PHY<\/em><\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c PHY &#8212; \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441, \u0442\u0438\u043f, \u0440\u0435\u0436\u0438\u043c, \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0431\u043c\u0435\u043d\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0434\u0430\u0442\u044c \u043f\u0438\u0442\u0430\u043d\u0438\u0435. \u0420\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b PHY &#8212; Normal, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; 25 MHz, \u0442\u0438\u043f \u2013 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 (Internal), \u0430\u0434\u0440\u0435\u0441 &#8212; \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 PHY, \u0442.\u043a. \u043e\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u0440\u0430\u0432\u0435\u043d 1. \u042d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 EMAC-EPHY Clock Register \u0438\u0437 System Control, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 0x30 (\u043f. 4.5.3.2):<\/p>\n<pre><code class=\"cpp\">val = readl(syscon_base_address + SYSCON_EMAC_CLK_REG);  \/* Setup PHY address *\/ val |= (PHY_ADDR &amp; 0x1F) &lt;&lt; 20;  \/* Select internal PHY *\/ val |= BIT(15);  \/* Power up PHY *\/ if (val &amp; BIT(16))   val &amp;= ~BIT(16);  writel(val, syscon_base_addr + SYSCON_EMAC_CLK_REG);<\/code><\/pre>\n<p>\u0420\u0435\u0436\u0438\u043c \u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043d\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u044f\u0432\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p><strong><em>3.2.4. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 (MAC \u0430\u0434\u0440\u0435\u0441)<\/em><\/strong><\/p>\n<p>\u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445 <em>MAC Address 0 High Register<\/em> (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x50) \u0438 <em>MAC Address 0 Low Register<\/em> (offset 0x54). \u0412 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u0448\u0438\u0435 16 \u0431\u0438\u0442 \u0430\u0434\u0440\u0435\u0441\u0430, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u043c\u043b\u0430\u0434\u0448\u0438\u0435 32 \u0431\u0438\u0442\u0430.<\/p>\n<pre><code class=\"cpp\">void emac_set_mac_addr(u8 *addr) {   u32 data = (addr[5] &lt;&lt; 8) | addr[4];   writel(data, emac_base_addr + EMAC_ADDR_HIGH);   data = (addr[3] &lt;&lt; 24) | (addr[2] &lt;&lt; 16) | (addr[1] &lt;&lt; 8) | addr[0];   writel(data, emac_base_addr + EMAC_ADDR_LOW); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043a \u043f\u0440\u0438\u0435\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041d\u043e \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e DMA \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<p>EMAC \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c DMA \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0439 \u0438\u0437 PHY \u043f\u0430\u043a\u0435\u0442 \u0431\u043b\u043e\u043a DMA EMAC \u043c\u043e\u0436\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u043f\u0430\u043a\u0435\u0442 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 PHY \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438.<\/p>\n<p>\u0411\u043b\u043e\u043a DMA EMAC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430. \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u044f\u0434\u0435\u0440\u043d\u044b\u0439.<\/p>\n<p>\u0414\u043b\u044f DMA \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u044f\u0434\u0440\u043e Linux \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f &#8212; \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 (Consistent DMA mappings) \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 (Streaming DMA mappings). \u041f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u042d\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443, \u0442\u0430\u043a \u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443. \u041b\u044e\u0431\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u043d\u043e \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 (\u0441\u0431\u0440\u043e\u0441 \u0431\u0443\u0444\u0435\u0440\u043e\u0432, \u043a\u0435\u0448\u0435\u0439 etc). \u0422\u0430\u043a\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c.<\/p>\n<p>\u041f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u0435\u043c \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 (\u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439). \u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c &#8212; \u043a\u0442\u043e \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041a\u043e\u0433\u0434\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043e, \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e. \u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u044f\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0430\u043b\u044c\u043d\u044b\u0435 API \u044f\u0434\u0440\u0430, \u043c\u044b \u043d\u0438\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0438\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e DMA \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/www.kernel.org\/doc\/Documentation\/DMA-API-HOWTO.txt\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/37455\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p><strong><em>3.2.5. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/em><\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b EMAC \u0443\u043c\u0435\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c DMA \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c. \u0415\u043c\u0443 \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0440\u0430\u0442\u044c \u0438 \u043a\u0443\u0434\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0431\u0443\u0444\u0435\u0440 \u043f\u0430\u043c\u044f\u0442\u0438. \u0410\u0434\u0440\u0435\u0441 \u0431\u0443\u0444\u0435\u0440\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0435. \u0411\u0443\u0444\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440. \u0412\u0441\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0410\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 Receive DMA Descriptor List Address, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x34 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430 EMAC (\u043f. 8.9.4.11). \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u0430\u043a\u0435\u0442, DMA \u0431\u043b\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0432 \u043d\u0435\u0433\u043e \u043f\u0430\u043a\u0435\u0442.<\/p>\n<p>\u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 32-\u0445 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438, \u0432\u0442\u043e\u0440\u043e\u0435 &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430, \u0442\u0440\u0435\u0442\u044c\u0435 &#8212; \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0444\u0435\u0440\u0430, \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0435 &#8212; \u0430\u0434\u0440\u0435\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:<\/p>\n<pre><code class=\"cpp\">struct dma_desc {   u32 status;   u32 st;   u32 buf_addr;   u32 next; };<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/450\/c33\/024\/450c330241cc53df8f1f7eb7eeb429ae.jpg\" alt=\"\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0431\u0443\u0444\u0435\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432\" title=\"\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0431\u0443\u0444\u0435\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432\" width=\"573\" height=\"393\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/450\/c33\/024\/450c330241cc53df8f1f7eb7eeb429ae.jpg\" data-blurred=\"true\"\/><figcaption>\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0431\u0443\u0444\u0435\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/figcaption><\/figure>\n<p>\u0412 \u043f\u043e\u043b\u0435 status \u0432\u0430\u0436\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0438\u0442 #31, RX_DESC_CTL. \u042d\u0442\u043e\u0442 \u0431\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0431\u043b\u043e\u043a\u043e\u043c DMA, \u0442.\u0435. \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 DMA \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u0440\u0435\u0442\u044c\u0435 \u043f\u043e\u043b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430. \u0415\u0441\u043b\u0438 \u0431\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0442\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0435 DMA \u0431\u043b\u043e\u043a\u0430. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0432 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 \u0431\u0443\u0444\u0435\u0440, DMA \u0431\u043b\u043e\u043a \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043d\u0430\u0439\u0434\u0435\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0441 \u043d\u043e\u0432\u044b\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u043c, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044f\u0441\u044c \u043d\u0430 \u0441\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0439 \u0431\u0438\u0442. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u043f\u0430\u043a\u0435\u0442, \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0435\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 DMA \u0431\u043b\u043e\u043a\u0443 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 RX_DESC_CTL.<\/p>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0431\u0443\u0434\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0441\u043e\u043a\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 sk_buff. \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0441\u0442\u0435\u043a\u0435 \u044f\u0434\u0440\u0430 Linux, \u043e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u043c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u043f\u0430\u043a\u0435\u0442\u0435, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 sk_buff \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0432 <a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/source\/include\/linux\/skbuff.h\" rel=\"noopener noreferrer nofollow\">&lt;linux\/skbuff.h><\/a>, \u043e \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/wiki.linuxfoundation.org\/networking\/sk_buff\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442 <\/a>\u0438 <a href=\"http:\/\/vger.kernel.org\/~davem\/skb.html\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0441\u043d\u0435\u043c\u0441\u044f, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043a\u0430\u043a \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0430 \u043f\u043e\u043a\u0430 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435 data. \u042d\u0442\u043e \u043f\u043e\u043b\u0435 &#8212; \u0430\u0434\u0440\u0435\u0441 \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430. \u0422\u0430\u043a \u043a\u0430\u043a \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e (RX_SIZE), \u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043d\u0438\u0445:<\/p>\n<pre><code class=\"cpp\">struct sk_buff **sk_buff = kmalloc_array(RX_SIZE,     sizeof(struct sk_buff *), GFP_KERNEL);  for (i = 0; i &lt; RX_SIZE; i++)   sk_buff[i] = alloc_skb(DMA_BUF_SIZE, GFP_ATOMIC);<\/code><\/pre>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b DMA \u0431\u043b\u043e\u043a \u0438\u043c\u0435\u043b \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0443\u0444\u0435\u0440\u0443 \u043f\u0430\u043a\u0435\u0442\u0430, \u043d\u0430\u0434\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e <em>sk_buff[i]->data<\/em> \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dma_map_single:<\/p>\n<pre><code class=\"cpp\">dma_addr_t *sk_buff_dma = kmalloc_array(RX_SIZE,   sizeof(dma_addr_t), GFP_KERNEL);  for (i = 0; i &lt; RX_SIZE; i++) {   sk_buff_dma[i] = dma_map_single(dev, sk_buff[i]->data,      DMA_BUF_SIZE,DMA_FROM_DEVICE); }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 DMA \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">struct dma_desc *dma_rx = dma_alloc_coherent(dev,   RX_SIZE * sizeof(struct dma_desc), &amp;dma_rx_phy, GFP_KERNEL);<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0442.\u043a. \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u043d\u0443\u0436\u0435\u043d \u043d\u0430 \u0432\u0441\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. <em>dma_rx_phy<\/em> &#8212; \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <em>Receive DMA Descriptor List Address<\/em>.<\/p>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0435 \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433 RX_DESC_CTL, \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430, \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441 (\u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0439), \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430\u043c\u044b\u043a\u0430\u0435\u043c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439:<\/p>\n<pre><code class=\"cpp\">struct dma_desc *p; dma_addr_t dma_phy = dma_rx_phy; for (i = 0; i &lt; RX_SIZE; i++) {   p = dma_rx + i;   p->status |= BIT(31);   p->st = DMA_BUF_SIZE;   p->buf_addr = sk_buff_dma[i];   dma_phy += sizeof(struct dma_desc);   p->next = dma_phy; } p->next = dma_rx_phy;<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0443 \u0430\u0434\u0440\u0435\u0441 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">writel(dma_rx_phy, emac_base_addr + EMAC_RX_DMA_LIST);<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u043a \u043f\u0440\u0438\u0435\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<p><strong><em>3.2.6. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 net_device<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 net_device. \u0425\u043e\u0442\u044f \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0435\u0435 \u043e\u0441\u043e\u0431\u043e \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043d\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043d\u0430\u0434\u043e, \u0442.\u043a. \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043d\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u043a \u0438\u043c\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0430\u0434\u0440\u0435\u0441\u0430 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043d\u043e\u043c\u0435\u0440 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 (callbacks) \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0441\u0442\u0435\u043a\u043e\u043c \u044f\u0434\u0440\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e \u0441\u0442\u0443\u0440\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/elixir.bootlin.com\/linux\/latest\/source\/include\/linux\/netdevice.h\" rel=\"noopener noreferrer nofollow\">&lt;linux\/netdevice.h><\/a>.<\/p>\n<p>\u041f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u044d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <em>alloc_etherdev<\/em>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 &#8212; \u0440\u0430\u0437\u043c\u0435\u0440 \u0447\u0430\u0441\u0442\u043d\u044b\u0445 (private) \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0430\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2013 \u044d\u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"cpp\">struct emac_priv {   void __iomem *emac_base_addr;   int emac_irq;   struct net_device *ndev;   struct device *dev;   struct rx_queue rx_q; };<\/code><\/pre>\n<p><em>struct rx_queue<\/em> &#8212; \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u0435\u043c\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">struct rx_queue {   struct emac_priv *priv;   struct sk_buff **sk_buff;   dma_addr_t *sk_buff_dma;   struct dma_desc *dma_rx;   dma_addr_t dma_rx_phy;   unsigned int cur_rx; };<\/code><\/pre>\n<p>\u041f\u043e\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b, \u043e \u043d\u0438\u0445 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0432\u044b\u0448\u0435, \u043a\u043e\u0433\u0434\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0430 cur_rx &#8212; \u044d\u0442\u043e \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>alloc_etherdev<\/em> \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 <em>sizeof(struct net_device) + private size<\/em> \u0431\u0430\u0439\u0442, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u0438 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0437\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 <em>net_device<\/em>. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <em>netdev_priv<\/em>:<\/p>\n<pre><code class=\"cpp\">\/**  * netdev_priv - access network device private data  * @dev: network device  *  * Get network device private data  *\/ static inline void *netdev_priv(const struct net_device *dev) {   return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN); }<\/code><\/pre>\n<p><strong><em>3.2.7. \u041f\u0440\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/em><\/strong><\/p>\n<p>\u041f\u0440\u0438 \u043f\u0440\u0438\u0435\u043c\u0435 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043c\u044b \u0438\u0441\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u043e\u0433\u043b\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u043b\u043e\u043a DMA \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440, \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (Interrupt Enable Register, \u043f.8.9.4.4) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u0438\u0442 RX_INT_EN. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439 (Interrupt Status Register, \u043f.8.9.4.3) \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0431\u0438\u0442 RX_INT. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442 \u044d\u0442\u043e\u0442 \u0431\u0438\u0442 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430.<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 &#8212; \u0441\u0442\u0443\u0440\u0443\u043a\u0442\u0443\u0440\u0430 net_device:<\/p>\n<pre><code class=\"cpp\">request_irq(emac_irq, emac_interrupt, IRQF_SHARED, \"emac-irq\", ndev);<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">static irqreturn_t emac_interrupt(int irq, void *dev_id) {   int status;   struct net_device *ndev = (struct net_device *)dev_id;   struct emac_priv *priv = netdev_priv(ndev);    \/* Read Interrupt Status Register and drop interrupt flags *\/   status = readl(emac_base_addr + EMAC_INT_STA);   writel(status, emac_base_addr + EMAC_INT_STA);    \/* Check RX_INT flag *\/   if (status &amp; EMAC_RX_INT)     emac_rx(priv);      return IRQ_HANDLED; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0444\u043b\u0430\u0433\u0430 RX_INT \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 <em>emac_rx<\/em>:<\/p>\n<pre><code class=\"cpp\">static int emac_rx(struct emac_priv *priv) {   struct rx_queue *rx_q = &amp;priv->rx_q;   unsigned int entry = rx_q->cur_rx;   struct dma_desc *p;   int status, frame_len;<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u0435\u043c\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430. \u0414\u0430\u043b\u0435\u0435 \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043c, \u043d\u0435 \u0437\u0430\u043d\u044f\u0442 \u043b\u0438 \u043e\u043d DMA \u0431\u043b\u043e\u043a\u043e\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0438\u0442 RX_DESC_CTL \u0432 \u043f\u043e\u043b\u0435 status. \u0415\u0441\u043b\u0438 \u0437\u0430\u043d\u044f\u0442, \u0442\u043e \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c \u0435\u0433\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">p = rx_q->dma_rx + entry; status = p->status; if (status &amp; BIT(31))   return 0;<\/code><\/pre>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430, \u044d\u0442\u043e \u0431\u0438\u0442\u044b 29:16 \u043f\u043e\u043b\u044f status. \u0420\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c 1536 \u0431\u0430\u0439\u0442 (\u0440\u0430\u0437\u043c\u0435\u0440 Ethernet \u043a\u0430\u0434\u0440\u0430):<\/p>\n<pre><code class=\"cpp\">frame_len = (status &amp; FRAME_LEN_MASK) >> FRAME_LEN_SHIFT; if (frame_len > 1536)   goto out;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 <em>sk_buff[entry]->data<\/em>. \u042d\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d \u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0439 <em>sk_buff_dma[entry].<\/em> \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 (\u0441\u043c. \u0432\u044b\u0448\u0435), \u043d\u0430\u0434\u043e \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c:<\/p>\n<pre><code class=\"cpp\">dma_sync_single_for_cpu(priv->dev, rx_q->sk_buff_dma[entry],     frame_len, DMA_FROM_DEVICE);<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0432 \u043b\u043e\u0433 \u043f\u0435\u0440\u0432\u044b\u0435 30 \u0431\u0430\u0439\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"cpp\">for (i = 0; i &lt; 30; i++)   pr_cont(\"%.2x \", skb->data[i]);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443:<\/p>\n<pre><code class=\"cpp\">dma_sync_single_for_device(priv->dev, rx_q->sk_buff_dma[entry],        frame_len, DMA_FROM_DEVICE);<\/code><\/pre>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 DMA \u0431\u043b\u043e\u043a\u0443, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u0431\u0438\u0442 31 \u0432 \u043f\u043e\u043b\u0435 status:<\/p>\n<pre><code class=\"cpp\">rx_q->cur_rx = (rx_q->cur_rx + 1) % RX_SIZE; p->status |= BIT(31);<\/code><\/pre>\n<p><strong><em>3.2.8. \u0424\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/em><\/strong><\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u0430\u0432\u0435 EMAC \u0435\u0441\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440 <em>Receive Frame Filter Regsiter<\/em> (\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 0x38, \u043f.8.9.4.12), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0436\u0438\u043c\u043e\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432. \u041e\u043f\u0446\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043d\u0430\u0441 \u043f\u043e\u043a\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0435\u043c \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 (broadcast) \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u0442 #17 \u043d\u0430\u0434\u043e \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432 0. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 0x0, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.<\/p>\n<p><strong><em>3.2.9. \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0440\u0430\u043a\u0442\u0430 \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0439.<\/em><\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 \u0431\u0438\u0442 #31 (RX_EN, Enable receiver) \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Receive Control 0 Register<\/em> (\u043f.8.9.4.9) \u0438 \u0431\u0438\u0442\u044b #30 \u0438 #1 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Receive Control 1 Register<\/em> (\u043f.8.9.4.10). \u0411\u0438\u0442 #30 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 RX DMA, \u0431\u0438\u0442 #1 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0438\u0437 RX FIFO \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c. \u0415\u0441\u043b\u0438 \u0431\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d, \u0442\u043e \u0431\u043b\u043e\u043a DMA \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0445 RX FIFO \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430. \u0415\u0441\u043b\u0438 \u0431\u0438\u0442 \u0441\u0431\u0440\u043e\u0448\u0435\u043d, \u0442\u043e DMA \u0431\u043b\u043e\u043a \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 FIFO \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u043e\u0433\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 RX_TH (threshold value of RX DMA FIFO). \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0446\u0435\u043b\u044b\u0439 \u043f\u0430\u043a\u0435\u0442, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u043e\u0433\u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">void emac_enable_rx(void)  {     u32 v = readl(emac_base_addr + EMAC_RX_CTL0);     v |= BIT(31);     writel(v, emac_base_addr + EMAC_RX_CTL0); }  void emac_start_rx(void) {     u32 v = readl(emac_base_addr + EMAC_RX_CTL1);     v |= BIT(30) | BIT(31);     writel(v, emac_base_addr + EMAC_RX_CTL1); }<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0431\u0438\u0442\u0430 RX_INT_EN (\u0431\u0438\u0442 8) \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 <em>Interrupt Enable Register<\/em> (\u043f. 8.9.4.4):<\/p>\n<pre><code class=\"cpp\">writel(EMAC_RX_INT_EN, emac_base_addr + EMAC_INT_EN);<\/code><\/pre>\n<p><strong>4. \u0421\u0431\u043e\u0440\u043a\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 make, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f KSRC, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u0430\u043c \u044f\u0434\u0440\u0430. \u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b net.ko. \u0415\u0433\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0443\u044e SD \u043a\u0430\u0440\u0442\u0443 \u2013 \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043b\u0430\u0442\u044b, \u0442.\u043a. rootfs \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 ram-\u0434\u0438\u0441\u043a\u0435. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c net.ko \u043d\u0430 \u043a\u0430\u0440\u0442\u0443, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0441\u043b\u043e\u0442 \u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u043c:<\/p>\n<pre><code class=\"bash\">mount \/dev\/mmcblk0p1 \/mnt &amp;&amp; cd \/mnt<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0438 \u0432 \u043b\u043e\u0433\u0435 \u044f\u0434\u0440\u0430 \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<details class=\"spoiler\">\n<summary>\u041b\u043e\u0433 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\/mnt # insmod net.ko<br \/>[\u00a0\u00a0 42.956146] net: loading out-of-tree module taints kernel.<br \/>[\u00a0\u00a0 42.962760] net-test 1c30000.ethernet: CCU setup..<br \/>[\u00a0\u00a0 42.967580] ccu_base_addr=d0890000 clk gating reg4: 00000000 clk gating reg0: 33800140 rst reg2: 00000004 rst reg0: 33824140 <br \/>[\u00a0\u00a0 42.978946] net-test 1c30000.ethernet: Syscon setup..<br \/>[\u00a0\u00a0 42.984248] ccu_base_addr=d0890000 clk gating reg4: 00000000 clk gating reg0: 33800140 rst reg2: 00000004 rst reg0: 33824140 <br \/>[\u00a0\u00a0 42.996757] net-test 1c30000.ethernet: PHY setup..<br \/>[\u00a0\u00a0 43.101561] net-test 1c30000.ethernet: syscon=d0892000 val=148000<br \/>[\u00a0\u00a0 43.107664] net-test 1c30000.ethernet: syscon val=148000<br \/>[\u00a0\u00a0 43.112971] ccu_base_addr=d0890000 clk gating reg4: 00000001 clk gating reg0: 33800040 rst reg2: 00000004 rst reg0: 33824040 <br \/>[\u00a0\u00a0 43.124290] net-test 1c30000.ethernet: EMAC hardware setup..<br \/>[\u00a0\u00a0 43.129996] net-test 1c30000.ethernet: emac_irq=43<br \/>[\u00a0\u00a0 43.134797] net-test 1c30000.ethernet: emac_base_addr=d08a0000<br \/>[\u00a0\u00a0 43.140640] ccu_base_addr=d0890000 clk gating reg4: 00000001 clk gating reg0: 33820040 rst reg2: 00000004 rst reg0: 33824040 <br \/>[\u00a0\u00a0 43.247669] net-test 1c30000.ethernet: PHY reset done<br \/>[\u00a0\u00a0 43.253515] net-test 1c30000.ethernet: 0: physid1=00000044 physid2=00001400 phyid=00441400<br \/>[\u00a0\u00a0 43.264049] net-test 1c30000.ethernet: 1: physid1=00000044 physid2=00001400 phyid=00441400<br \/>[\u00a0\u00a0 44.807690] ccu_base_addr=d0890000 clk gating reg4: 00000001 clk gating reg0: 33820040 rst reg2: 00000004 rst reg0: 33824040 <br \/>[\u00a0\u00a0 44.819059] net-test 1c30000.ethernet: EMAC reset done<br \/>[\u00a0\u00a0 44.824524] net-test 1c30000.ethernet: rx_q: sk_buff=c1ee5300 sk_buff_dma=c1ee5340<br \/>[\u00a0\u00a0 44.832143] net-test 1c30000.ethernet: rx_q: dma_rx=cf050000 dma_rx_phy=4f050000<br \/>[\u00a0\u00a0 44.839594] net-test 1c30000.ethernet: 0: p=cf050000 skb=c1e48000 skb_dma=41f27700<br \/>[\u00a0\u00a0 44.847174] net-test 1c30000.ethernet: 1: p=cf051000 skb=c1e480c0 skb_dma=41f26dc0<br \/>[\u00a0\u00a0 44.854770] net-test 1c30000.ethernet: 2: p=cf052000 skb=c1e48180 skb_dma=41f26480<br \/>[\u00a0\u00a0 44.862363] net-test 1c30000.ethernet: 3: p=cf053000 skb=c1e48240 skb_dma=41f25b40<br \/>[\u00a0\u00a0 44.869962] 0: desc=cf050000 status=80000000 st=000007ff buf_addr=41f27700 next=4f051000<br \/>[\u00a0\u00a0 44.878070] 1: desc=cf051000 status=80000000 st=000007ff buf_addr=41f26dc0 next=4f052000<br \/>[\u00a0\u00a0 44.886158] 2: desc=cf052000 status=80000000 st=000007ff buf_addr=41f26480 next=4f053000<br \/>[\u00a0\u00a0 44.894263] 3: desc=cf053000 status=80000000 st=000007ff buf_addr=41f25b40 next=4f050000<br \/>[\u00a0\u00a0 44.902920] net-test 1c30000.ethernet: 02:42:8d:01:14:9b<br \/>[\u00a0\u00a0 44.909078] phy_adjust_link: status=79ed advertise=de1<br \/>[\u00a0\u00a0 44.914440] phy_adjust_link: advertise=de1<br \/>[\u00a0\u00a0 46.467891] phy_aneg_complete: auto-neg complete, lpa=4de1<br \/>[\u00a0\u00a0 46.473389] net-test 1c30000.ethernet: duplex full, speed 100Mb\/s<br \/>[\u00a0\u00a0 46.479516] net-test 1c30000.ethernet: EMAC_CTL0=0000000d<br \/>[\u00a0\u00a0 46.484918] net-test 1c30000.ethernet: Frame control: v=00000000<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<p><strong><em>5. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/em><\/strong><\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0441\u0435\u0442\u044c. \u0418\u0437 \u0448\u0438\u0440\u043e\u043a\u043e\u0432\u0435\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u0438\u0445 \u043f\u0430\u043a\u0435\u0442\u0430\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0448 \u043f\u0430\u043a\u0435\u0442.<\/p>\n<pre><code class=\"cpp\">#include &lt;linux\/if_packet.h> #include &lt;linux\/if_ether.h>  int main(void) {   int i;   int psock;   const char *ifname = \"enp4s0\"; \/* \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u044b *\/   unsigned char buf[32];   struct sockaddr_ll s_ll;   struct ifreq ifr;      memset(buf, 0, sizeof(buf));   for (i = 0; i &lt; ETH_ALEN; i++)     buf[i] = 0xFF;   for (; i &lt; sizeof(buf); i++)     buf[i] = 0xAC;      psock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));   memset((void *)&amp;s_ll, 0, sizeof(struct sockaddr_ll));   sprintf(ifr.ifr_name, \"%s\", ifname);   ioctl(psock, SIOCGIFINDEX, &amp;ifr);      s_ll.sll_family = PF_PACKET;   s_ll.sll_protocol = htons(ETH_P_ALL);   s_ll.sll_ifindex = ifr.ifr_ifindex;   bind(psock, (struct sockaddr *)&amp;s_ll, sizeof(struct sockaddr_ll));      for (;;sleep(2), sendto(psock, buf, sizeof(buf), 0, NULL, 0));      close(psock);   return 0; }<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0440\u0430\u0432 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 (\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <em>root<\/em>), \u0443\u0432\u0438\u0434\u0438\u043c \u043a\u0430\u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0448\u0438 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<pre><code class=\"bash\">[\u00a0 295.301141] Received data: [\u00a0 295.303847] ff ff ff ff ff ff ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac 00 00 00 00 00 00 00 00 64 bytes<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432\u0441\u0435 \u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0443\u0437\u043d\u0430\u043b\u0438 \u043a\u0430\u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u044f\u0434\u0435\u0440\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 clock, reset \u0438 \u043f\u0440., \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043a \u0441\u0442\u0430\u0442\u044c\u0435:<\/p>\n<ul>\n<li>\n<p>\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u044b \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 <em>git clone \u2013b p1 https:\/\/github.com\/ubob74\/net.git<\/em><\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 <a href=\"https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz\" rel=\"noopener noreferrer nofollow\"><em>https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz<\/em><\/a><\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 SD \u043a\u0430\u0440\u0442\u044b <a href=\"https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/image.gz\" rel=\"noopener noreferrer nofollow\"><em>https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/image.gz<\/em><\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/681738\/\"> https:\/\/habr.com\/ru\/post\/681738\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f Linux.<\/p>\n<p>C\u0442\u0430\u0442\u044c\u044e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0435\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 MAC \u0438 PHY, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043a \u0440\u0430\u0431\u043e\u0442\u0435, \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438 \u043a\u0430\u043a \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u0425\u043e\u0442\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u044f\u0434\u0435\u0440\u043d\u044b\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <em>clock, reset, libphy<\/em> \u0438 \u043f\u0440., \u043f\u043e\u043d\u0430\u0447\u0430\u043b\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u0438\u0434\u0443, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432 Device Tree, \u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441 \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c Linux. \u0412\u043e\u0437\u044c\u043c\u0435\u043c <a href=\"https:\/\/linux-sunxi.org\/Xunlong_Orange_Pi_Zero\" rel=\"noopener noreferrer nofollow\"><strong>Orange Pi Zero<\/strong><\/a><strong> <\/strong>\u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 Allwinner H2+. \u0412 \u0441\u043e\u0441\u0442\u0430\u0432 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0445 \u044f\u0434\u0440\u0430 Cortex-A7, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u041e\u0417\u0423 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u0432 LPDDR2, LPDDR3, DDR3, \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u0441\u043f\u0435\u043a\u0442\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b <a href=\"https:\/\/linux-sunxi.org\/H3\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443 <a href=\"https:\/\/linux-sunxi.org\/images\/4\/4b\/Allwinner_H3_Datasheet_V1.2.pdf\" rel=\"noopener noreferrer nofollow\"><strong>Allwinner H3 Datasheet<\/strong><\/a>.<\/p>\n<figure class=\"bordered full-width\"><figcaption>\u0412\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u044b<\/figcaption><\/figure>\n<figure class=\"\"><figcaption>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043d\u0438\u043a USB-to-COM \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043b\u0430\u0442\u044b. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>minicom<\/em>.<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u043f\u0443\u0441\u043a Linux \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Ethernet \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u2013 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p><strong>1. \u0417\u0430\u043f\u0443\u0441\u043a Linux \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435<\/strong>\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Linux \u043d\u0430 \u043f\u043b\u0430\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (rootfs)<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u044f\u0434\u0440\u043e Linux \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b (device tree)<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a u-boot<\/p>\n<\/li>\n<li>\n<p>\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0443\u044e sd-\u043a\u0430\u0440\u0442\u0443 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0435<\/p>\n<\/li>\n<\/ul>\n<p><strong><em>1.1 \u0421\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/em><\/strong><\/p>\n<p>\u00a0\u0425\u043e\u0441\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0434\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 &#8212; Debian 10. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b:<\/p>\n<pre><code class=\"bash\">apt-get install libgmp3-dev apt-get install libmpc-dev apt install libyaml-dev pip3 install dtschema apt install gcc-arm-linux-gnueabi apt-get install u-boot-tools<\/code><\/pre>\n<p>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0443 \u043d\u0430\u0441 ARM, \u0443\u043a\u0430\u0436\u0435\u043c \u0435\u0435 \u0438 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440:<\/p>\n<pre><code class=\"bash\">export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi-<\/code><\/pre>\n<p><strong><em>1.2. \u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 (roosfs)<\/em><\/strong>\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u2013 \u0432\u0437\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0438\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u0412\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439, \u0441\u043e\u0431\u0435\u0440\u0435\u043c <strong>rootfs<\/strong> \u0438\u0437 <strong>busybox<\/strong>. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"bash\">wget https:\/\/busybox.net\/downloads\/busybox-1.35.0.tar.bz2<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440:<\/p>\n<pre><code class=\"bash\">make menuconfig<\/code><\/pre>\n<p>\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0443:<\/p>\n<pre><code class=\"bash\">Settings -> Build options -> Build static binary (no shared libs)<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0434\u043e \u0432 <strong>CONFIG_PREFIX<\/strong> \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a\u0443\u0434\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u044c:<\/p>\n<pre><code class=\"bash\">make &amp;&amp; make CONFIG_PREFIX=\/path\/to\/install\/busybox  install<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 busybox \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>\/tmp\/build\/bb\/ramdisk<\/em>. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435, \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<pre><code class=\"bash\">root@debian:\/tmp\/build\/bb\/ramdisk# ls -l total 8 drwxr-xr-x 2 root root 4096 Apr\u00a0 3 22:42 bin lrwxrwxrwx 1 root root\u00a0\u00a0 11 Apr\u00a0 3 22:42 linuxrc -> bin\/busybox drwxr-xr-x 2 root root 4096 Apr\u00a0 3 22:42 sbin drwxr-xr-x 4 root root\u00a0\u00a0 29 Apr\u00a0 3 22:42 usr<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f <em>procfs<\/em> \u0438 <em>sysfs<\/em>, \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>etc<\/em> \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 dev \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432:<\/p>\n<pre><code class=\"bash\">mkdir proc sys etc dev<\/code><\/pre>\n<p>\u0412 busybox \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 mdev &#8212; \u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b udev. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/dev. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0435\u043c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 https:\/\/git.busybox.net\/busybox\/plain\/docs\/mdev.txt.<\/p>\n<p>\u0412 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <em>etc<\/em> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b <em>group<\/em>, <em>hosts<\/em>, <em>inittab<\/em>, <em>passwd<\/em>:<\/p>\n<pre><code class=\"bash\"># cat group root:x:0:root  # cat hosts 127.0.0.1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 localhost  # cat inittab ::sysinit:\/etc\/init.d\/rc.S console::respawn:-\/bin\/ash ::restart:\/sbin\/init ::ctrlaltdel:\/sbin\/reboot ::halt:\/bin\/umount -a -r  # cat passwd root::0:0:root:\/root:\/bin\/ash<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 <em>etc<\/em> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>init.d<\/em> \u0438 \u0432 \u043d\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b <em>rc.S<\/em>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh HOSTNAME=zero VERSION=0.0.1 hostname $HOSTNAME mount -n -t proc proc \/proc mount -n -t sysfs sysfs \/sys mount -n -t tmpfs mdev \/dev mdev -s  # Set PATH export PATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin  # Start other daemons \/sbin\/syslogd \/usr\/sbin\/telnetd<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 <em>rc.S<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b <em>procfs<\/em> \u0432 \/<em>proc<\/em>, <em>sysfs<\/em> \u0432 \/<em>sys<\/em>, <em>tmpfs<\/em> \u0432 \/<em>dev<\/em>, \u0438 <em>mdev<\/em> \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0432 \/<em>dev<\/em> \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043d\u0430\u0439\u0434\u0435\u0442 \u0432 <em>sysfs<\/em>.   <em><\/p>\n<p><\/em>\u0412 <strong>rootfs<\/strong> \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <em>\/lib\/modules<\/em> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u044f\u0434\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c. \u041e\u0431 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442. \u041f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/ubob74\/net\/raw\/p1\/files\/ramdisk.tgz<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 rootfs.<\/p>\n<p><strong><em>1.3. \u042f\u0434\u0440\u043e<\/em><\/strong><\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0431\u043e\u0440\u043a\u0435 \u044f\u0434\u0440\u0430. \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u043c\u0438\u0442:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/linux-sunxi\/linux-sunxi.git cd linux-sunxi git checkout -b next c9a8f2f1da7b<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b:<\/p>\n<pre><code class=\"bash\">make sunxi_defconfig<\/code><\/pre>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0440\u0435\u0436\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u0442.\u043a. \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0439:<\/p>\n<pre><code class=\"bash\">make menuconfig  Device Drivers ->    Network Device Support ->      Ethernet driver support ->        STMicroelectronics devices<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0434\u0440\u043e \u0438 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<pre><code class=\"bash\">make -j4 zImage modules<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c Device Tree:<\/p>\n<pre><code class=\"bash\">make sun8i-h2-plus-orangepi-zero.dtb<\/code><\/pre>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0436\u0430\u0442\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u044f\u0434\u0440\u0430 <em>arch\/arm\/boot\/zImage<\/em> \u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 (device tree blob) <em>arch\/arm\/boot\/dts\/sun8i-h2-plus-orangepi-zero.dtb.<\/em><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u043d\u0430 rootfs:<\/p>\n<pre><code class=\"bash\">make -j4 INSTALL_MOD_PATH=\/path\/to\/install\/busybox modules_install<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0430\u043a\u0443\u0435\u043c <strong>rootfs<\/strong> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0436\u0430\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 <strong>initramfs.img<\/strong>:<\/p>\n<pre><code class=\"bash\">cd \/path\/to\/install\/busybox find . | cpio -o -H newc | gzip > ..\/newrootfs.img.gz cd .. mkimage -A arm -T ramdisk -C none -d newrootfs.img.gz initramfs.img<\/code><\/pre>\n<p><strong><em>1.4. \u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a<\/p>\n<p><\/em><\/strong>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:<\/p>\n<pre><code class=\"bash\">git clone git:\/\/git.denx.de\/u-boot.git cd u-boot<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">make orangepi_zero_defconfig make -j2<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <em>u-boot-sunxi-with-spl.bin<\/em>.<\/p>\n<p><strong><em>1.5. \u0417\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u0430\u044f sd \u043a\u0430\u0440\u0442\u0430<\/p>\n<p><\/em><\/strong>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e fdisk \u0438 mkfs \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b FAT32. \u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u0441\u0435\u043a\u0442\u043e\u0440 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u0441\u0442\u0430\u0432\u0438\u043c 8192, \u0442.\u043a. \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a u-boot.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/boot \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0442\u0443\u0434\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b &#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u044f\u0434\u0440\u0430 <em>arch\/arm\/boot\/zImage<\/em>, \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 <em>arch\/arm\/boot\/dts\/sun8i-h2-plus-orangepi-zero.dtb<\/em> \u0438 \u0441\u0436\u0430\u0442\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 rootfs initramfs.img. \u0414\u0430\u043b\u0435\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f boot.cmd \u0434\u043b\u044f u-boot:<\/p>\n<pre><code class=\"bash\"># cat boot.cmd load mmc 0 0x44000000 \/boot\/zImage load mmc 0 0x46000000 \/boot\/sun8i-h2-plus-orangepi-zero.dtb load mmc 0 0x48000000 \/boot\/initramfs.img setenv bootargs console=ttyS0,115200 earlyprintk root=\/dev\/ram0 rdinit=\/sbin\/init rootwait panic=10 bootz 0x44000000 0x48000000 0x46000000<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u043a\u0443\u0434\u0430, \u0447\u0442\u043e \u0438 \u043a\u0443\u0434\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0433\u0440\u0443\u0437\u0438\u0442\u044c u-boot \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u044f\u0434\u0440\u0430. \u041a\u043e\u0440\u043d\u0435\u0432\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 ramdisk. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0437 boot.cmd \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 boot.src \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0443:<\/p>\n<pre><code class=\"bash\">mkimage -C none -A arm -T script -d boot.cmd boot.scr<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043d\u0430 sd \u043a\u0430\u0440\u0442\u0435 \u0443 \u043d\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<br \/>&#8212; <em>boot.scr<\/em> \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435<br \/>&#8212; <em>zImage, sun8i-h2-plus-orangepi-zero.dtb, initramfs.img<\/em> \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/boot<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, sd \u043a\u0430\u0440\u0442\u0430 \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \/dev\/sdc1 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/mnt\/sdc:<\/p>\n<pre><code class=\"bash\"># cd \/mnt\/sdc # ls -l total 8 drwxr-xr-x 2 root root 4096 Apr 10 19:22 boot -rwxr-xr-x 1 root root\u00a0 348 Mar 26 22:02 boot.scr  # ls -l boot total 5896 -rwxr-xr-x 1 root root 1194170 Apr\u00a0 9 19:31 initramfs.img -rwxr-xr-x 1 root root\u00a0\u00a0 23332 Apr\u00a0 1 20:33 sun8i-h2-plus-orangepi-zero.dtb -rwxr-xr-x 1 root root 4813272 Apr  1 20:25 zImage<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 sd \u043a\u0430\u0440\u0442\u044b &#8212; \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430. \u0422\u0443\u0442 \u043d\u0430\u0434\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0439 sd \u043a\u0430\u0440\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u0438\u0442\u044c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <em>\/dev\/sdc<\/em>. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 u-boot, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">dd if=.\/u-boot-sunxi-with-spl.bin of=\/dev\/sdc bs=1024 seek=8<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0437\u0430\u043f\u0438\u0441\u0430\u043d. \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 &#8212; \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c sd \u043a\u0430\u0440\u0442\u0443 \u0432 \u0441\u043b\u043e\u0442 \u043f\u043b\u0430\u0442\u044b \u0438 \u043f\u043e\u0434\u0430\u0435\u043c \u043f\u0438\u0442\u0430\u043d\u0438\u0435, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430. \u041d\u043e \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 Ethernet.<\/p>\n<p><strong>2. \u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Ethernet \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0412 \u0441\u043e\u0441\u0442\u0430\u0432 Ethernet \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u044f\u0442:<\/p>\n<ul>\n<li>\n<p>\u0431\u043b\u043e\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u0441\u0440\u0435\u0434\u0435 MAC (Media Access Controller)<\/p>\n<\/li>\n<li>\n<p>\u0431\u043b\u043e\u043a DMA<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438\u0435\u043c\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 FIFO \u0431\u0443\u0444\u0435\u0440\u044b<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438\u0435\u043c\u043e\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u0447\u0438\u043a PHY<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption>\u041e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 Ethernet<\/figcaption><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 MAC &#8212; \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0434\u0440\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438, \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0432 \u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (payload), \u043f\u0440\u0438\u0435\u043c \u043a\u0430\u0434\u0440\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u0430\u0434\u0440\u043e\u0432, \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 (\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c CSMA\/CD).<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 DMA &#8212; \u043e\u0431\u043c\u0435\u043d \u043a\u0430\u0434\u0440\u0430\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0438 MAC. DMA \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 MAC \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 FIFO \u0431\u0443\u0444\u0435\u0440\u043e\u0432 &#8212; \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 (TX) \u0438 \u043f\u0440\u0438\u0435\u043c\u043d\u044b\u0439 (RX). \u0427\u0435\u0440\u0435\u0437 TX FIFO \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u0430\u0434\u0440 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 MAC, \u0430 \u0447\u0435\u0440\u0435\u0437 RX FIFO \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043a\u0430\u0434\u0440 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0438\u0437 MAC \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 PHY &#8212; \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0434\u0440\u0430 \u0432 \u0432\u0438\u0434, \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e, \u0442.\u0435. \u043f\u043e Ethernet \u043a\u0430\u0431\u0435\u043b\u044e, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 &#8212; \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0439 \u043f\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044e \u0441\u0438\u0433\u043d\u0430\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0432\u0438\u0434.<\/p>\n<p>MAC \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 PHY \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 &#8212; MII (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/MII\" rel=\"noopener noreferrer nofollow\">Media Independent Interface<\/a>) \u0438 SMI (Station Management Interface). \u041a \u043e\u0434\u043d\u043e\u043c\u0443 MAC \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u043e 32-\u0445 PHY. \u041a\u0430\u0436\u0434\u044b\u0439 PHY \u0430\u0434\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c, \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0434\u0440\u0435\u0441\u0430 \u2013 5 \u0431\u0438\u0442.<\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f MAC \u0438 PHY<\/figcaption><\/figure>\n<p>\u0427\u0435\u0440\u0435\u0437 MII \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 MAC \u0438 PHY, \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<p>SMI \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f PHY. \u042d\u0442\u043e \u0434\u0432\u0443\u0445\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043b\u0438\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (Management Data Input\/Output, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Management_Data_Input\/Output\" rel=\"noopener noreferrer nofollow\">MDIO<\/a>) \u0438 \u043b\u0438\u043d\u0438\u0438 \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (MDC). \u0427\u0435\u0440\u0435\u0437 SMI \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u044b PHY (\u0434\u0443\u043f\u043b\u0435\u043a\u0441 &#8212; \u043f\u043e\u043b\u0443\u0434\u0443\u043f\u043b\u0435\u043a\u0441), \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u043c\u0435\u043d\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u0438\u043b\u0438 \u043d\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u0430\u0431\u0435\u043b\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432\u0435\u0449\u0438. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-336830","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336830"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336830\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}