summaryrefslogtreecommitdiff
path: root/bsp/phytium/doc/how_to_flashed_binary.md
blob: 2a284f1fc43d24a06c1da474a76992cb9d33b916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# 如何启动镜像程序

- 当完成项目的配置和编译后,请参考以下两种方法,在开发板上启动镜像程序。需要提前下载串口工具,以SecureCRT为例

- 需要按照以下方式将开发板的串口与TTL接口相连,并与上位机相连

1. E2000D_DEMO开发板,E2000Q_DEMO开发板,使用CPU_UART

![e2000_demo_uart](../figures/e2000_demo_uart.png)

2. Phytium PI开发板,使用J2组引脚

![phytiumpi_uart](../figures/phytiumpi_uart.png)

## 使用tftp服务,通过网口上传镜像(推荐)

- 通过tftp服务,使用网口将 .bin/.elf 文件上传到开发板

![board_network_interface](../figures/board_network_interface.png)

### Ubuntu 环境下配置tftp服务

- 在开发环境`host`侧安装`tftp`服务
```
sudo apt-get install tftp-hpa tftpd-hpa
sudo apt-get install xinetd
```

- 新建`tftpboot`目录, 以`/mnt/d/tftpboot`为例,并确保 `tftpboot` 目录有执行权限`chmod 777 /**/tftpboot`
- 配置主机 tftpboot 服务, 新建并配置文件`/etc/xinetd.d/tftp`

```
# /etc/xinetd.d/tftp

server tftp
{
  socket_type = dgram
  protocol = udp
  wait = yes
  user = root
  server =  /usr/sbin/in.tftpd
  server_args = -s /mnt/d/tftpboot
  disable = no
  per_source = 11
  cps = 100 2
  flags = IPv4
}
```

- 启动主机`tftp`服务,生成默认配置
```
$ sudo service tftpd-hpa start
```

- 修改主机`tftp`配置,指向`tftpboot`目录
  修改/etc/default/tftpd-hpa
```
$ sudo nano /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/mnt/d/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -c -s"
```

- 重启主机`tftp`服务

```
$ sudo service tftpd-hpa restart
```

- 测试主机`tftp`服务的可用性
  > 登录`tftp`服务,获取`tftpboot`目录下的一个文件

```
$ tftp 192.168.4.50
tftp> get test1234
tftp> q
```

### Windows 环境下配置tftp服务

- 下载 Tftpd64 工具,并安装

![tftp32_srv](../figures/tftp32_srv.png)

- 之后每次使用前,进入Windows服务,手动将服务打开

![tftp32_srv](../figures/config_tftp32.png)

### 使用uboot上的tftp服务加载镜像
- `host`侧,网络配置如下

![tftp_host_config](../figures/tftp_host_config.png)

- 进入`uboot`界面,输入如下指令,配置开发板ip,`host`侧ip和网关地址
```
setenv ipaddr 192.168.4.20  
setenv serverip 192.168.4.50 
setenv gatewayip 192.168.4.1 
```
- 将编译好的elf 或者bin 文件拷贝至Tftpd64所设置文件夹下
- 随后烧录的文件到开发板,输入以下指令
  
```
tftpboot 0x80080000 rtthread_a64.bin
dcache flush
go 0x80080000
```
![tftp_test](../figures/tftp_test.png)

## 使用串口工具

- 可以用串口通过XMODEM协议将`.bin`文件上传到开发板

1. 启动开发板,进入uboot界面,输入以下指令
```
loadx 0x80080000
```
2. 发送`.bin`文件

![securecrt_sendx](../figures/securecrt_sendx.png)

3. 输入以下指令,完成跳转
```
go 0x80080000
```

![xmodem_flash](../figures/xmodem_flash.png)