\chapter {常见问题}

\section{U-Boot 打印 Overflow}

\begin{figure}[H]
    \centering
\begin{tikzpicture}
    \node [anchor=south west, inner sep=0] (dump) at (0,0) {
\begin{tcolorbox}[colframe=gray!20]
    \begin{scriptsize}
\begin{Verbatim}
sysmem_dump_all:
    --------------------------------------------------------------------
    memory.rgn[0].addr     = 0x00200000 - 0x08400000 (size: 0x08200000)
    memory.rgn[1].addr     = 0x09400000 - 0xf0000000 (size: 0xe6c00000)

    memory.total           = 0xeee00000 (3822 MiB. 0 KiB)
    --------------------------------------------------------------------
    allocated.rgn[0].name  = "UBOOT"
                    .addr  = 0xeb7fac30 - 0xf0000000 (size: 0x048053d0)
    allocated.rgn[1].name  = "STACK"       <Overflow!>
                    .addr  = 0xeb67ac30 - 0xeb7fac30 (size: 0x00180000)
    allocated.rgn[2].name  = "FDT"
                    .addr  = 0x0a100000 - 0x0a12b404 (size: 0x0002b404)

    kmem-resv.rgn[0].name  = "cma"
                    .addr  = 0x10000000 - 0x18000000 (size: 0x08000000)
    kmem-resv.rgn[1].name  = "ramoops@110000"
                    .addr  = 0x00110000 - 0x00200000 (size: 0x000f0000)

    framework malloc_r     =  32 MiB
    framework malloc_f     = 512 KiB

    allocated.total        = 0x0caa07d4 (202 MiB. 641 KiB)
    --------------------------------------------------------------------
    LMB.allocated[0].addr  = 0x0a100000 - 0x0a12b404 (size: 0x0002b404)
    LMB.allocated[1].addr  = 0xeb67ac30 - 0xf0000000 (size: 0x049853d0)

    reserved.core.total    = 0x049b07d4 (73 MiB. 705 KiB)
    --------------------------------------------------------------------
\end{Verbatim}
\end{scriptsize}
\end{tcolorbox}
    };
    \begin{scope}[
        x={($0.1*(dump.south east)$)},
        y={($0.1*(dump.north west)$)}
        ]
        % grid for debugging
        %\draw [lightgray, step=1] (dump.south west) grid (dump.north east);
        %\foreach \x in {0, 1, ..., 10} {\node [below] at (\x, 0) {\x};}
        %\foreach \y in {0, 1, ..., 10} {\node [left] at (0, \y) {\y};}
        \draw [red,thick, rounded corners] (5.2, 6.5) rectangle (7.2, 6.8);
    \end{scope}
\end{tikzpicture}
\caption{U-Boot Overflow}
\end{figure}
解决办法是将 U-Boot 的 lib/Kconfig文件中的 \texttt{SYS\_STACK\_SIZE}，将其增大到 4MiB。这里的默认配置是 2MiB：
\begin{figure}[H]
    \centering
    \begin{tikzpicture}
    \node [anchor=south west, inner sep=0] (image) at (0,0) {
        \begin{tcolorbox}[title={\tt \small lib/Kconfig: }, colframe=gray!20, coltitle=blue!80]
            \scriptsize
            \begin{Verbatim}
    config SYS_STACK_SIZE
        hex
        default 0x200000
        help
            The system stack size.
            \end{Verbatim}
        \end{tcolorbox}
    };
    \begin{scope}[
        x={($0.1*(image.south east)$)},
        y={($0.1*(image.north west)$)}
        ]
        % grid for debugging
        %\draw [lightgray, step=1] (image.south west) grid (image.north east);
        %\foreach \x in {0, 1, ..., 10} {\node [below] at (\x, 0) {\x};}
        %\foreach \y in {0, 1, ..., 10} {\node [left] at (0, \y) {\y};}
        \draw [red,thick, rounded corners] (2.25, 3.5) rectangle (3.4, 5.0);
        \draw[red, anchor=south west, inner sep=0] node at (3.5, 3.7) { \footnotesize 改这里};
    \end{scope}
    \end{tikzpicture}
    \caption{修改U-Boot 栈大小}
\end{figure}

\section{网卡名固定成 ethX}
网卡接口名称默认会根据 {\small \verb+/lib/udev/rules.d/+} 目录下的 {\small \verb+80-net-setup-link.rules+} 文件定义的规则来。
如果你要更改规则，需要先将文件{\small \verb+80-net-setup-link.rules+} 从 {\small \verb+/lib/udev/rules.d+} 目录复制到 {\small \verb+/etc/udev/rules.d+} 目录。
因为 {\small \verb+/etc/udev/rules.d+} 目录下规则的优先级高于 {\small \verb+/lib/udev/rules.d+} 目录，识别网卡并命名时，
会优先从 {\small \verb+/etc/udev/rules.d+} 目录下寻找规则文件。将 {\small \verb+ID_NET_NAME+} 改成 {\small \verb+ID_NET_SLOT+} 即可。

\section{rc.local 脚本没执行}

编辑 {\small \verb+/usr/lib/systemd/system/rc-local.service+} 文件，添加以下内容：
\begin{minted}[bgcolor=lightgray!30,fontsize=\small]{ini}
[Install]
WantedBy=multi-user.target
\end{minted}
然后执行下面命令开启 {\small \verb+rc-local.service+} 服务：
\begin{minted}[bgcolor=lightgray!30,fontsize=\small]{bash}
systemctl enable rc-local.service
\end{minted}

\begin{comment}
ip -details -json link show | jq -r '
.[] | 
      if .linkinfo.info_kind // .link_type == "loopback" then
          empty
      else
          .ifname
      end
'

ip -details -json link show | jq -r '
.[] | 
      if .ifname == "eth0" then
          .address
      end
'
\end{comment}
\begin{comment}
ip -details -json address show | jq --join-output '
.[] | 
      if .linkinfo.info_kind // .link_type == "loopback" then
          empty
      else
          .ifname ,
          ( ."addr_info"[] |
              if .family == "inet" or .family == "inet6" then
                  " " + .local
              else
                  empty
              end
          ),
          "\n"
      end
'
\end{comment}