1.分区及相关参数
- 分区大小一般自己留有余量,分区大小,自己定,比实际镜像大小大一些就可以。
- 分区大小改了,相应的参数也要发生变化:
bootcmd:Uboot启动好了之后,Uboot会自动执行bootcmd这个环境变量,这个环境变量里面的主要内容就是告诉我们:kernel在什么地方,然后就可以读取内核到DDR里面去,然后再去启动内核。bootcmd如果设错了,uboot就找不到内核镜像,或找到的内核镜像是错的。
bootargs:是uboot给kernel的传参,影响的是内核启动的过程。这个如果不对,将来内核在启动的时候,可能启动到一半,就死掉了。
fastboot:Hitool内部也是用fastboot来烧录,但是封装好了,可以不用去管他,通过分区表文件来计算出具体参数。
启动并进入Uboot后的界面,注意要启动的那几秒按一下
System startup Uncompress Ok! U-Boot 2016.11 (Oct 18 2021 - 15:05:04 +0800)hi3516dv300 Relocation Offset is: 0f6d2000 Relocating to 8fed2000, new gd at 8fe31ef0, sp at 8fe31ed0 MMC: EMMC/MMC/SD controller initialization. scan edges:2 p2f:6 f2p:1 mix set temp-phase 3 scan elemnts: startp:12 endp:120 Tuning SampleClock. mix set phase:[04/07] ele:[06/15] ** First descriptor is NOT a primary desc on 0:1 ** MMC/SD Card: MID: 0x15 Read Block: 512 Bytes Write Block: 512 Bytes Chip Size: 7456M Bytes (High Capacity) Name: "8GTF4" Chip Type: MMC Version: 0.0 Speed: 100000000Hz Bus Width: 4bit himci: 0 (eMMC) In: serial Out: serial Err: serial Net: eth0 Warning: eth0 (eth0) using random MAC address - ce:07:43:a5:2b:a5 Writing to MMC(0)... done Hit any key to stop autoboot: 0 hisilicon # hisilicon # printenv arch=arm baudrate=115200 board=hi3516dv300 board_name=hi3516dv300 bootargs=mem=512M console=ttyAMA0,115200 root=/dev/mmcblk0p3 rootfstype=ext4 rw rootwait blkdevparts=mmcblk0:5M(boot),10M(kernel),500M(rootfs),200M(userdata),-(user) bootcmd=mmc read 0 0x81000000 0x2800 0x4000;bootm 0x81000000 bootdelay=1 cpu=armv7 ethact=eth0 soc=hi3516dv300 stderr=serial stdin=serial stdout=serial vendor=hisilicon verify=n Environment size: 441/262140 bytes hisilicon #
2.分析一下blkdevparts(分区表)
blkdevparts=mmcblk0:5M(boot),10M(kernel),500M(rootfs),200M(userdata),-(user)
其中-(user)表示的就是剩余的
mmcblk0表示的是第0个设备的设备文件名
分析一下分区表:
首先一共5个分区(包括一个剩下的用户分区,后面需要去挂载这个分区)
3.分析一下bootcmd
bootcmd=mmc read 0 0x81000000 0x2800 0x4000;bootm 0x81000000
mmc read 0 表示读取的第0个mmc设备
0x81000000 这个表示DDR的地址
0x2800 这个表示eMMC的地址,这就是从eMMC的这个地址读取kernel到DDR中去
具体计算方法:
0x2800(hex mode)->10240(dec mode)
10240(dec mode) * 512(byte)= 5,242,880(byte)
5,242,880(byte) / 1024 = 5120(kb)
5120(kb) / 1024 = 5(M)
0x4000 这个表示读取多长
具体计算方法为:
0x4000(hex mode)->16,384(dec mode)
16,384(dec mode) * 512(byte)= 8,388,608(byte)
8,388,608(byte) / 1024 = 8,192(kb)
8,192(kb) / 1024 = 8(M)
这里实际上只读取了8M,是不对的,但不影响(因为实际的kernel只有3M),正确的做法是在这里读取10M
10 * 1024 * 1024 / 512 (dec mode) -> 50000(hex mode)
修改的方法:
setenv bootcmd "mmc read 0 0x81000000 0x2800 0x5000; bootm 0x81000000"
printenv
saveenv
- 寻找破坏原有的uboot的命令:
首先输入help
接着输入help mmchisilicon # help ? - alias for 'help' base - print or set address offset bdinfo - print Board Info structure boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootelf - Boot from an ELF image in memory bootm - boot application image from memory bootp - boot image via network using BOOTP/TFTP protocol bootvx - Boot vxWorks from an ELF image cipher_test- CIPHER Encrypt And Decrypt Test cmp - memory compare coninfo - print console devices and information cp - memory copy crc32 - checksum calculation dcache - enable or disable data cache ddr - ddr training function decjpg - jpgd - decode jpeg picture. decjpg [format] dhcp - boot image via network using DHCP/TFTP protocol dm - Driver model low level access echo - echo args to console editenv - edit environment variable env - environment handling commands erase - erase FLASH memory exit - exit script false - do nothing, unsuccessfully fatinfo - print information about filesystem fatload - load binary file from a dos filesystem fatls - list files in a directory (default /) fatsize - determine a file's size flinfo - print FLASH memory information getinfo - print hardware information go - start application at address 'addr' go_cpu1 - Perform power on and unreset CPU1_A7 gzwrite - unzip and write memory to block device hash - Calcluate hash hash_test- hash_test [x]:[0] SHA1; [1] SHA256; [2] HMAC-SHA1; [3] HMAC-SHA256; help - print command description/usage icache - enable or disable instruction cache iminfo - print header information for application image imxtract- extract a part of a multi-image itest - return true/false on integer compare klad_test- KLAD Test loadb - load binary file over serial line (kermit mode) loads - load S-Record file over serial line loadx - load binary file over serial line (xmodem mode) loady - load binary file over serial line (ymodem mode) loop - infinite loop on address range md - memory display mii - MII utility commands mm - memory modify (auto-incrementing address) mmc - MMC sub system mmcinfo - display MMC info mw - memory write (fill) nfs - boot image via network using NFS protocol nm - memory modify (constant address) part - disk partition related commands ping - send ICMP ECHO_REQUEST to network host printenv- print environment variables protect - enable or disable FLASH write protection pxe - commands to get and boot from pxe files reset - Perform RESET of the CPU rng_test- RNG Test rsa_enc_test- RSA PKCS1# V1_5 encrypt/decrypt Test rsa_sign_test- RSA PKCS1# V1_5 Sign Test run - run commands in an environment variable saveenv - save environment variables to persistent storage setenv - set environment variables setexpr - set environment variable as the result of eval expression setvobg - setvobg - set vo backgroud color. - setvobg [dev color] showvar - print local hushshell variables sleep - delay execution for some time source - run script from memory startgx - startgx - open graphics layer. - startgx [layer addr stride x y w h] startvl - startvl - open video layer. - startvl [layer addr stride x y w h] startvo - startvo - open vo device with a certain output interface. - startvo [dev intftype sync] stopgx - stopgx - close graphics layer. - stopgx [layer] stopvl - stopvl - close video layer. - stopvl [layer] stopvo - stopvo - close interface of vo device. - stopvo [dev] sysboot - command to get and boot from syslinux files test - minimal test like /bin/sh tftpboot- boot image via network using TFTP protocol true - do nothing, successfully unzip - unzip a memory region usb - USB sub-system usbboot - boot from USB device usbtftp - download or upload image using USB protocol version - print monitor, compiler and linker version hisilicon #
最后进行擦除操作help mmc mmc - MMC sub system Usage: mmc info - display info of the current MMC device mmc reg [dev] - display register of the current MMC device mmc read dev addr blk# cnt mmc write dev addr blk# cnt mmc erase blk# cnt mmc rescan mmc part - lists available partition on current mmc device mmc dev [dev] [part] - show or set current mmc device [partition] mmc list - lists available devices mmc hwpartition [args...] - does hardware partitioning arguments (sizes in 512-byte blocks): [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition [check|set|complete] - mode, complete set partitioning completed WARNING: Partitioning is a write-once setting once it is set to complete. Power cycling is required to initialize partitions after set to complete. mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode - Set the BOOT_BUS_WIDTH field of the specified device mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB> - Change sizes of boot and RPMB partitions of specified device mmc partconf dev boot_ack boot_partition partition_access - Change the bits of the PARTITION_CONFIG field of the specified device mmc rst-function dev value - Change the RST_n_FUNCTION field of the specified device WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values. mmc setdsr <value> - set DSR register value hisilicon #
mmc write dev addr blk# cnt mmc erase blk# cnt
其中#表示从那个blk开始擦除,cnt表示擦除多少个blk
这里的cnt也是以512byte为单位的
这里擦除uboot是从0地址开始的,其中的blk#,那么也就是0了
假设是300K
300 * 1024 / 512 = 600 cnt
所以就这样擦除:
这里保险起见,擦除1000个cnt
1000(dec)->03E8(hex)
mmc erase 0 0x03E8
擦除后不会有任何反应,是因为uboot和kernel已经加载到DDR去运行了
现在去重启,串口就不会有输出了