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

39 篇文章 13 订阅
8 篇文章 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 08300000
   Booting using the fdt blob at 0x8300000
   XIP Kernel Image ... OK
  'reserved-memory' region@110000: addr=110000 size=f0000
   Using 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 ms

Starting 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' on
      device type 'interface' instance 'dev' to determine the boot
      mode, and load and execute the appropriate kernel.
      In normal and recovery mode, the kernel will be loaded from
      the corresponding "boot" partition. In bootloader mode, the
      command defined in the "fastbootcmd" variable will be
      executed.
      On Android devices with multiple slots, the pass 'slot' is
      used to load the appropriate kernel. The standard slot names
      are 'a' and 'b'.
    - If 'part_name' is passed, preceded with a ; instead of :, the
      partition name whose label is 'part_name' will be looked up in
      the 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 08300000
   Booting using the fdt blob at 0x8300000
   XIP Kernel Image ... OK
  'reserved-memory' region@110000: addr=110000 size=f0000
   Using 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 ms

Starting 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 08300000
   Booting using the fdt blob at 0x8300000
   XIP 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 ms

Starting 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。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值