当前位置: 代码迷 >> 综合 >> 网络服务(1)——uboot设置tftp
  详细解决方案

网络服务(1)——uboot设置tftp

热度:18   发布时间:2024-01-10 21:39:32.0

配置tftp server

安装服务器、客户端和守护进程

sudo apt-get install tftp-hpa tftpd-hpa xinetd

服务器配置

首先,在根目录下建一个tftpboot,并把属性改成任意用户可读写:
# cd /
# sudo mkdir tftpboot
# sudo chmod 777 tftpboot
然后,进入目录/etc/xinetd.d/,并在其中新建文件tftp,把指定的内容加入到tftp文件中:
# cd /etc/xinetd.d/
# sudo vim tftp
添加以下内容到tftp文件
service tftp
{
disable = no 138
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot -c
per_source = 11
cps = 100 2
}修改配置文件/etc/default/tftpd-hpa,修改为
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure -l -c -s"
注意将”TFTP_DIRECTORY“改为新建tftpboot目录所在的路径

重新启动服务

# sudo /etc/init.d/xinetd reload
# sudo /etc/init.d/xinetd restart
# sudo /etc/init.d/tftpd-hpa restart

测试服务器

创建测试文件
# sudo touch /tftpboot/abc
远程获取创建的文件
# tftp -g -r abc 172.16.0.70

uboot环境变量解析

u-boot/cmd/boot_android.c
u-boot/cmd/bootrkp.c
bootcmd=boot_android ${devtype} ${devnum};bootrkp;run distro_bootcmd;
devtype=mmc
devnum=0
kernel_addr_r=0x00280000
kernel_addr_c=0x0027f800
fdt_addr_r=0x08300000
=> run bootcmd
ANDROID: reboot reason: "(none)"
Fdt Ramdisk skip relocation
Booting IMAGE kernel at 0x00280000 with fdt at 0x8300000...Sysmem Warn: kernel 'reserved-memory' "region@110000"(0x00110000 - 0x00200000) is overlap with [invisible] "SHM" (0x00100000 - 0x00200000)
## Booting Android Image at 0x0027f800 ...
Kernel load addr 0x00280000 size 18863 KiB
## Flattened Device Tree blob at 08300000Booting using the fdt blob at 0x8300000XIP Kernel Image ... OK'reserved-memory' region@110000: addr=110000 size=f0000Using Device Tree in place at 0000000008300000, end 000000000831ce26
board_modify_fdt
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
Total: 12452.942 msStarting kernel ...
=> boot_android
boot_android - Execute the Android Bootloader flow.Usage:
boot_android <interface> <dev[:part|;part_name]> <slot> [<kernel_addr>]- Load the Boot Control Block (BCB) from the partition 'part' ondevice type 'interface' instance 'dev' to determine the bootmode, and load and execute the appropriate kernel.In normal and recovery mode, the kernel will be loaded fromthe corresponding "boot" partition. In bootloader mode, thecommand defined in the "fastbootcmd" variable will beexecuted.On Android devices with multiple slots, the pass 'slot' isused to load the appropriate kernel. The standard slot namesare 'a' and 'b'.- If 'part_name' is passed, preceded with a ; instead of :, thepartition name whose label is 'part_name' will be looked up inthe partition table. This is commonly the "misc" partition.=> boot_android mmc 0
ANDROID: reboot reason: "(none)"
Fdt Ramdisk skip relocation
Booting IMAGE kernel at 0x00280000 with fdt at 0x8300000...Sysmem Warn: kernel 'reserved-memory' "region@110000"(0x00110000 - 0x00200000) is overlap with [invisible] "SHM" (0x00100000 - 0x00200000)
## Booting Android Image at 0x0027f800 ...
Kernel load addr 0x00280000 size 18863 KiB
## Flattened Device Tree blob at 08300000Booting using the fdt blob at 0x8300000XIP Kernel Image ... OK'reserved-memory' region@110000: addr=110000 size=f0000Using Device Tree in place at 0000000008300000, end 000000000831ce26
board_modify_fdt
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
Total: 91895.702 msStarting kernel ...

uboot设置IP

setenv ethaddr 22:22:22:22:22:03		#设置网卡mac地址
setenv ipaddr 172.16.0.73				#设置开发板IP地址
setenv serverip 172.16.0.70				#设置tftp服务IP地址
=> ping 172.16.0.70
Speed: 1000, full duplex
Using ethernet@fe300000 device
host 172.16.0.70 is alive

加载镜像

setenv kernel_addr_c 0x0027f800
tftp ${kernel_addr_c} boot.img
tftp ${fdt_addr_r} OK3399-C.dtb
bootm ${kernel_addr_c} ${kernel_addr_c} ${fdt_addr_r}
=> tftp ${kernel_addr_c} boot.img
Speed: 1000, full duplex
Using ethernet@fe300000 device
TFTP from server 172.16.0.70; our IP address is 172.16.0.73
Filename 'boot.img'.
Load address: 0x27f800
Loading: ###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################T ##############################################################################################################################################################################################################################################################################################################################################################################################################1.6 MiB/s
done
Bytes transferred = 20148224 (1337000 hex)
=>
=> tftp ${fdt_addr_r} OK3399-C.dtb
Speed: 1000, full duplex
Using ethernet@fe300000 device
TFTP from server 172.16.0.70; our IP address is 172.16.0.73
Filename 'OK3399-C.dtb'.
Load address: 0x8300000
Loading: ########4.6 MiB/s
done
Bytes transferred = 106023 (19e27 hex)
=> bootm ${kernel_addr_c} ${kernel_addr_c} ${fdt_addr_r}
## Booting Android Image at 0x0027f800 ...
Kernel load addr 0x00280000 size 18863 KiB
## Flattened Device Tree blob at 08300000Booting using the fdt blob at 0x8300000XIP Kernel Image ... OK'reserved-memory' region@110000: addr=110000 size=f0000
## device tree at 0000000008300000 ... 0000000008319e26 (len=118311 [0x1CE27])Loading Device Tree to 000000007bdbd000, end 000000007bdd9e26 ... OK
board_modify_fdt
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
Total: 279371.187 msStarting kernel ...[    0.000000] Booting Linux on physical CPU 0x0

通过梳理镜像的加载过程,在加载Android boot.img的过程中,有一个读取“boot.img header and a few parts of the head of kernel image(2 blocks maybe enough)”的过程。这个过程导致内核镜像的load_address发生了改变——“We should load compressed kernel Image to high memory at address "kernel_addr_c”,所以我们需要将内核镜像加载到0x0027f800,而不是0x00280000。

  相关解决方案