首页 > 技术知识 > 正文

从放弃到入门[三]:烧录海思Hi3516EV200

写在前面:从放弃到入门系列的第二弹中,小A已经完成SDK的整体编译了。那么仅仅编译出来是不够的,我们还要实际运行验证编译结果,因此一般情况下我们需要先烧录uboot,kernel,rootfs到存储器中,组成一个完整的小系统,然后基于此我们才能进行后续的学习。

小A以前在学习嵌入式的过程中,遇到的常见烧录方法有JTAG烧录,有串口烧录,有网口烧录,也有通过usb口使用DNW烧录,这些方式都各有各的特色和应用场景。下面以spi nand为例,来看看海思平台下的烧录方法。

海思提供了一个烧录工具HiTool,通过这个工具我们可以简单快速的完成海思平台的各类烧录需求。HiTool在正式使用前,一定要正确选择当前芯片,可以通过界面左上角的芯片选项卡进行切换目标芯片。

从放弃到入门[三]:烧录海思Hi3516EV200

以Hi3516EV200为例,HiTool囊括了常见的串口方式烧录,网口方式烧录以及USB方式烧录。另外海思平台的烧录方式有裸烧和非裸烧两种,二者的主要区别是烧录时勾不勾选u-boot分区。

一. 串口烧录

场景:因为受限于串口的数据传输速率,如果用串口方式全片烧录8M spi nor的话,大概需要十多分钟才能完成,一般串口烧录只用于烧写fastboot(u-boot),在u-boot调试过程中使用较为方便。

案例:通过串口烧录fastboot。

原理:HiBurn 工具在开始烧写后,首选与 bootrom 进行交互,工具 DDR 参数传送到传到 bootrom,然后初始化 DDR,再把 uboot 传输到 DDR 中,再从 DDR 启动 uboot,uboot 启动完成后,工具开始与 uboot 进行交互,发送烧写命令,将 DDR 中的 uboot 烧写到Flash 对应地址中。

从放弃到入门[三]:烧录海思Hi3516EV2001

烧录日志如下:

串口已经连接,请给单板上电,若已经上电,请断电后重新上电。 ############################ —- 10% ########################### —- 20% ########################### —- 30% ########################### —- 41% ########################### —- 51% ########################### —- 61% ########################### —- 71% ########################### —- 82% ########################### —- 92% ##################### —- 100% Boot download completed! System startup Uncompress Ok! U-Boot 2016.11-ge0aea76-dirty (Jun 06 2020 – 20:45:07 +0800)hi3516ev200 Relocation Offset is: 03734000 Relocating to 43f34000, new gd at 43e93ef0, sp at 43e93ed0 SPI Nor: Boot Media isnt SPI Nor NAND: SPI Nand ID Table Version 2.7 SPI Nand(cs 0) ID: 0xef 0xaa 0x21 Name:”W25N01GV” Block:128KB Page:2KB OOB:64B ECC:4bit/512 Chipsize:128 MiB MMC: In: serial Out: serial Err: serial Net: eth0 start download process. Boot started successfully! Send command: getinfo version version: U-Boot 2016.11-ge0aea76-dirty [EOT](OK) Send command: getinfo bootmode nand [EOT](OK) Send command: getinfo nand Block:128KB Chip:128MB*1 Page:2KB OOB:64B ECC:4bit/512 ID:0xEF 0xAA 0x21 Name:”W25N01GV” [EOT](OK) Send command: nand erase 0x0 0x40000 NAND erase: device 0 offset 0x0, size 0x40000 Erasing at 0x0 — 50% complete. Erasing at 0x20000 — 100% complete. OK [EOT](OK) Send command: nand write 0x41000000 0x0 0x40000 NAND write: device 0 offset 0x0, size 0x40000 pure data length 262144 bytes written: OK [EOT](OK) Send command: reset reset success! Boot burned successfully.
<

从上面的日志输出可以看到uboot的烧录流程和uboot的烧录原理是吻合的,总耗时大约80秒左右。

二. 网口烧录

场景:一般嵌入式平台网口烧录,都是通过串口在u-boot命令行下配置好网络参数然后通过tftp进行下载和写入,所以网口烧录一般用于烧录uboot之外的其它镜像。

原理:同样的,HiTool基本也是这个原理,HiTool内置了tftp服务。所以虽然是网口烧录,但是同时也要配置好串口。HiTool通过串口与uboot进行交互,下发tftp指令和write指令,完成烧写。所以选择网口烧录的时候,既要选对pc的串口和服务器ip,还要保证服务器ip和板端配置的ip地址必须要在同一个局域网段才可以,否则无法完成网口烧录。 从放弃到入门[三]:烧录海思Hi3516EV2002

案例:烧录kernel和rootfs

从放弃到入门[三]:烧录海思Hi3516EV2003

烧录日志如下:

串口已经连接,请给单板上电,若已经上电,请断电后重新上电。 # —- 33% # —- 100% Boot download completed! System startu Uncompress Ok! U-Boot 2016.11-ge0aea76-dirty (Jun 06 2020 – 20:45:07 +0800)hi3516ev200 Relocation Offset is: 03734000 Relocating to 43f34000, new gd at 43e93ef0, sp at 43e93ed0 SPI Nor: Boot Media isnt SPI Nor NAND: SPI Nand ID Table Version 2.7 SPI Nand(cs 0) ID: 0xef 0xaa 0x21 Name:”W25N01GV” Block:128KB Page:2KB OOB:64B ECC:4bit/512 Chipsize:128 MiB MMC: In: serial Out: serial Err: serial Net: eth0 start download process. Boot started successfully! Send command: getinfo version version: U-Boot 2016.11-ge0aea76-dirty [EOT](OK) Send command: getinfo nand Block:128KB Chip:128MB*1 Page:2KB OOB:64B ECC:4bit/512 ID:0xEF 0xAA 0x21 Name:”W25N01GV” [EOT](OK) waiting phy ready, it will take 8s. Send command: setenv serverip 192.168.3.2 [EOT](OK) Send command: setenv ethaddr 00:00:00:00:00:01 [EOT](OK) Send command: setenv ipaddr 192.168.3.99 [EOT](OK) Send command: setenv netmask 255.255.255.0 [EOT](OK) Send command: setenv gatewayip 192.168.3.1 [EOT](OK) Tftp server Download Home switched to <\\DS220plus\synology\burn_test> Send command: mw.b 0x41000000 0xFF 0x3a0000 [EOT](OK) Send command: tftp 0x41000000 uImage Hisilicon ETH net controler eth0 : phy status change : LINK=UP : DUPLEX=FULL : SPEED=100M Using eth0 device TFTP from server 192.168.3.2; our IP address is 192.168.3.99 Filename uImage. Load address: 0x41000000 Loading: *########################################################################################################################## ####################################################################################################################### ####################################################################################################################### ######################################################################################################### 393.6 KiB/s done Bytes transferred = 3699632 (3873b0 hex) [EOT](OK) Send command: crc32 41000000 3873b0 crc32 for 41000000 … 413873af ==> 4151880d [EOT](OK) Send command: nand erase 0x80000 0x500000 NAND erase: device 0 offset 0x80000, size 0x500000 Erasing at 0x80000 — 2% complete. Erasing at 0xa0000 — 5% complete. Erasing at 0xc0000 — 7% complete. Erasing at 0xe0000 — 10% complete. Erasing at 0x100000 — 12% complete. Erasing at 0x120000 — 15% complete. Erasing at 0x140000 — 17% complete. Erasing at 0x160000 — 20% complete. Erasing at 0x180000 — 22% complete. Erasing at 0x1a0000 — 25% complete. Erasing at 0x1c0000 — 27% complete. Erasing at 0x1e0000 — 30% complete. Erasing at 0x200000 — 32% complete. Erasing at 0x220000 — 35% complete. Erasing at 0x240000 — 37% complete. Erasing at 0x260000 — 40% complete. Erasing at 0x280000 — 42% complete. Erasing at 0x2a0000 — 45% complete. Erasing at 0x2c0000 — 47% complete. Erasing at 0x2e0000 — 50% complete. Erasing at 0x300000 — 52% complete. Erasing at 0x320000 — 55% complete. Erasing at 0x340000 — 57% complete. Erasing at 0x360000 — 60% complete. Erasing at 0x380000 — 62% complete. Erasing at 0x3a0000 — 65% complete. Erasing at 0x3c0000 — 67% complete. Erasing at 0x3e0000 — 70% complete. Erasing at 0x400000 — 72% complete. Erasing at 0x420000 — 75% complete. Erasing at 0x440000 — 77% complete. Erasing at 0x460000 — 80% complete. Erasing at 0x480000 — 82% complete. Erasing at 0x4a0000 — 85% complete. Erasing at 0x4c0000 — 87% complete. Erasing at 0x4e0000 — 90% complete. Erasing at 0x500000 — 92% complete. Erasing at 0x520000 — 95% complete. Erasing at 0x540000 — 97% complete. Erasing at 0x560000 — 100% complete. OK [EOT](OK) Send command: nand write 0x41000000 0x80000 0x3a0000 NAND write: device 0 offset 0x80000, size 0x3a0000 pure data length is 3801088, l 3801088 bytes written: OK [EOT](OK) Partition kernel burnt successfully! Tftp server Download Home switched to <\\DS220plus\synology\burn_test> Send command: getinfo nand Block:128KB Chip:128MB*1 Page:2KB OOB:64B ECC:4bit/512 ID:0xEF 0xAA 0x21 Name:”W25N01GV” [EOT](OK) Send command: mw.b 0x41000000 0xFF 0x1fd9940 [EOT](OK) Send command: tftp 0x41000000 yaffs2-128M-3516ev200.img Hisilicon ETH net controler eth0 : phy status change : LINK=UP : DUPLEX=FULL : SPEED=100M Using eth0 device TFTP from server 192.168.3.2; our IP address is 192.168.3.99 Filename yaffs2-128M-3516ev200.img. Load address: 0x41000000 Loading: *################################################################################################################# ####################################################################################################################### ###################################################################################################################### ####################################################################################################################### ################################################################################################################### ##################################################################################################################### ##################################################################################################################### ######################################################################################################################### ########################################################################################################################## ######################################################################################################################## ###################################################################################################################### ####################################################################################################################### ######################################################################################################################### ######################################################################################################################### #################################################################################################################### ################################################################################################################### #################################################################################################################### ######################################################################################################################## ##################################################################################################################### ######################################################################################################################### ###################################################################################################################### ######################################################################################################################### ############################################################################################################################ ##################################################################################################################### ##################################################################################################################### ##################################################################################################################### ##################################################################################################################### ###################################################################################################################### ####################################################################################################################### ###################################################################################################################### ###################################################################################################################### ########################################################################################################################## #################################################################################################################### ######################################################################################################################## ####################################################################################################################### # 790 KiB/s done Bytes transferred = 33397056 (1fd9940 hex) [EOT](OK) Send command: crc32 41000000 1fd9940 crc32 for 41000000 … 42fd993f ==> a0ba3513 [EOT](OK) Send command: nand erase 0x580000 0x7a80000 NAND erase: device 0 offset 0x580000, size 0x7a80000 Erasing at 0x580000 — 0% complete. Erasing at 0x6a0000 — 1% complete. Erasing at 0x7e0000 — 2% complete. Erasing at 0x920000 — 3% complete. Erasing at 0xa60000 — 4% complete. Erasing at 0xb80000 — 5% complete. Erasing at 0xcc0000 — 6% complete. Erasing at 0xe00000 — 7% complete. Erasing at 0xf40000 — 8% complete. Erasing at 0x1080000 — 9% complete. Erasing at 0x11a0000 — 10% complete. Erasing at 0x12e0000 — 11% complete. Erasing at 0x1420000 — 12% complete. Erasing at 0x1560000 — 13% complete. Erasing at 0x16a0000 — 14% complete. Erasing at 0x17c0000 — 15% complete. Erasing at 0x1900000 — 16% complete. Erasing at 0x1a40000 — 17% complete. Erasing at 0x1b80000 — 18% complete. Erasing at 0x1cc0000 — 19% complete. Erasing at 0x1de0000 — 20% complete. Erasing at 0x1f20000 — 21% complete. Erasing at 0x2060000 — 22% complete. Erasing at 0x21a0000 — 23% complete. Erasing at 0x22e0000 — 24% complete. Erasing at 0x2400000 — 25% complete. Erasing at 0x2540000 — 26% complete. Erasing at 0x2680000 — 27% complete. Erasing at 0x27c0000 — 28% complete. Erasing at 0x2900000 — 29% complete. Erasing at 0x2a20000 — 30% complete. Erasing at 0x2b60000 — 31% complete. Erasing at 0x2ca0000 — 32% complete. Erasing at 0x2de0000 — 33% complete. Erasing at 0x2f20000 — 34% complete. Erasing at 0x3040000 — 35% complete. Erasing at 0x3180000 — 36% complete. Erasing at 0x32c0000 — 37% complete. Erasing at 0x3400000 — 38% complete. Erasing at 0x3540000 — 39% complete. Erasing at 0x3660000 — 40% complete. Erasing at 0x37a0000 — 41% complete. Erasing at 0x38e0000 — 42% complete. Erasing at 0x3a20000 — 43% complete. Erasing at 0x3b60000 — 44% complete. Erasing at 0x3c80000 — 45% complete. Erasing at 0x3dc0000 — 46% complete. Erasing at 0x3f00000 — 47% complete. Erasing at 0x4040000 — 48% complete. Erasing at 0x4180000 — 49% complete. Erasing at 0x42a0000 — 50% complete. Erasing at 0x43e0000 — 51% complete. Erasing at 0x4520000 — 52% complete. Erasing at 0x4660000 — 53% complete. Erasing at 0x47a0000 — 54% complete. Erasing at 0x48c0000 — 55% complete. Erasing at 0x4a00000 — 56% complete. Erasing at 0x4b40000 — 57% complete. Erasing at 0x4c80000 — 58% complete. Erasing at 0x4dc0000 — 59% complete. Erasing at 0x4ee0000 — 60% complete. Erasing at 0x5020000 — 61% complete. Erasing at 0x5160000 — 62% complete. Erasing at 0x52a0000 — 63% complete. Erasing at 0x53e0000 — 64% complete. Erasing at 0x5500000 — 65% complete. Erasing at 0x5640000 — 66% complete. Erasing at 0x5780000 — 67% complete. Erasing at 0x58c0000 — 68% complete. Erasing at 0x5a00000 — 69% complete. Erasing at 0x5b20000 — 70% complete. Erasing at 0x5c60000 — 71% complete. Erasing at 0x5da0000 — 72% complete. Erasing at 0x5ee0000 — 73% complete. Erasing at 0x6020000 — 74% complete. Erasing at 0x6140000 — 75% complete. Erasing at 0x6280000 — 76% complete. Erasing at 0x63c0000 — 77% complete. Erasing at 0x6500000 — 78% complete. Erasing at 0x6640000 — 79% complete. Erasing at 0x6760000 — 80% complete. Erasing at 0x68a0000 — 81% complete. Erasing at 0x69e0000 — 82% complete. Erasing at 0x6b20000 — 83% complete. Erasing at 0x6c60000 — 84% complete. Erasing at 0x6d80000 — 85% complete. Erasing at 0x6ec0000 — 86% complete. Erasing at 0x7000000 — 87% complete. Erasing at 0x7140000 — 88% complete. Erasing at 0x7280000 — 89% complete. Erasing at 0x73a0000 — 90% complete. Erasing at 0x74e0000 — 91% complete. Erasing at 0x7620000 — 92% complete. Erasing at 0x7760000 — 93% complete. Erasing at 0x78a0000 — 94% complete. Erasing at 0x79c0000 — 95% complete. Erasing at 0x7b00000 — 96% complete. Erasing at 0x7c40000 — 97% complete. Erasing at 0x7d80000 — 98% complete. Erasing at 0x7ec0000 — 99% complete. Erasing at 0x7fe0000 — 100% complete. OK [EOT](OK) Send command: nand write.yaffs 0x41000000 0x580000 0x1fd9940 NAND write: device 0 offset 0x580000, size 0x1fd9940 pure data length is 32385024, len_incl_bad is 32385024 NAND write yaffs finished 33397056 bytes written: OK [EOT](OK) Partition rootfs burnt successfully! Send command: reset reset success! Partition burnt completed!
<

从上面的日志大致可以看出网口烧录时,HiTool会在uboot启动后,先根据我们设置好的板端参数进行bootenv的设置,然后再进行tftp下载和write的操作,全程不必手动敲命令,简单快捷,整个过程持续了大概80秒左右。

三. USB烧录

USB烧录的典型工具就是DNW,这个工具有些小伙伴可能都听过。使用USB烧录,需要先安装好usb驱动。 驱动安装: 在uboot命令行下输入命令:

usb device

没有安装驱动的情况下,在pc的设备管理器中会出现一个异常设备HiUSBBurn,如下图所示。

从放弃到入门[三]:烧录海思Hi3516EV2004

然后打开下载好的zadig-2.5.exe(传送门),选择设备HiUSBBurn,选择驱动libusbK进行安装。

从放弃到入门[三]:烧录海思Hi3516EV2005

安装好后会看到:

从放弃到入门[三]:烧录海思Hi3516EV2006

从放弃到入门[三]:烧录海思Hi3516EV2007

案例:烧录kernel和rootfs

从放弃到入门[三]:烧录海思Hi3516EV2008

烧录日志如下:

# —- 33% # —- 100% Boot download completed! start download process. Boot started successfully! Send command: getinfo version version: U-Boot 2016.11-ge0aea76-dirty [EOT](OK) Send command: getinfo nand Block:128KB Chip:128MB*1 Page:2KB OOB:64B ECC:4bit/512 ID:0xEF 0xAA 0x21 Name:”W25N01GV” [EOT](OK) Send command: mw.b 0x41000000 0xFF 0x3a0000 [EOT](OK) Send command: Downloading File : uImage [Download File by usb] file = \\DS220plus\synology\burn_test\uImage address = 0x41000000 fileLength = 3699632 B # done Send command: nand erase 0x80000 0x500000 NAND erase: device 0 offset 0x80000, size 0x500000 Erasing at 0x80000 — 2% complete. Erasing at 0xa0000 — 5% complete. Erasing at 0xc0000 — 7% complete. Erasing at 0xe0000 — 10% complete.[EOT](OK) Send command: nand write 0x41000000 0x80000 0x3a0000 NAND write: device 0 offset 0x80000, size 0x3a0000 pure data length is 3801088, len_incl_bad is 3801088 3801088 bytes written: OK [EOT](OK) Partition kernel burnt successfully! Send command: getinfo nand Block:128KB Chip:128MB*1 Page:2KB OOB:64B ECC:4bit/512 ID:0xEF 0xAA 0x21 Name:”W25N01GV” [EOT](OK) Send command: mw.b 0x41000000 0xFF 0x1fd9940 [EOT](OK) Send command: Downloading File : yaffs2-128M-3516ev200.img [Download File by usb] file = \\DS220plus\synology\burn_test\yaffs2-128M-3516ev200.img address = 0x41000000 fileLength = 33397056 B ######## done Send command: nand erase 0x580000 0x7a80000 NAND erase: device 0 offset 0x580000, size 0x7a80000 Erasing at 0x580000 — 0% complete. Erasing at 0x6a0000 — 1% complete. Erasing at 0x7e0000 — 2% complete. Erasing at 0x920000 — 3% complete.[EOT](OK) Send command: nand write.yaffs 0x41000000 0x580000 0x1fd9940 NAND write: device 0 offset 0x580000, size 0x1fd9940 pure data length is 32385024, len_incl_bad is 32385024 NAND write yaffs finished 33397056 bytes written: OK [EOT](OK) Partition rootfs burnt successfully! Send command: reset reset success! Partition burnt completed! USB channels were closed successfully.
<

整体大致流程和网口烧录差不多,主要区别在于下载方式的不同,一个是网口,一个是usb口。整体耗时42s。

四.总结

通过以上常用的烧录方式对比,串口烧录虽然慢,但是考虑到硬件设计,比如usb口设计为板载wifi,再比如3518ev300没有phy,所以它是必不可少的。在条件允许的情况下,小A还是喜欢通过usb烧录,因为它更简单(相比较网口烧录,无需来回切换串口中断),快速。

HiTool除了上述烧录功能外,还有合并镜像和上载镜像两大功能,小A今天就不展开了,以后再说吧。更多内容请参考《HiBurn工具使用指南》。

猜你喜欢