PHẦN MỀM HỆ THỐNG NHÚNG 6.1 Cấu trúc phần mềm trong hệ thống nhúng:
6.1.3 Các thao tác trên u-boot:
- Sau khiU-boot đã được load vào hệ thống. Bootstrapthực thi, khởi tạo các thông số cho b, load ubootvà thực thi uboot. Khi uboot thực thi, u-boot commandcho phép người sử dụng có thể giao tiếp với hệ thống thông qua các lệnh u-boothỗ trợ.
- Trước hết cần thiết lập các thông số môi trường cho hệ thống.
- Để thiết lập các thông số môi trường chúng ta sử dụng command setenvnhư sau:
o Thiết lập địa chỉ IPchoboard: setenv ipaddr <địa chỉ IP cho board>
o Thiết lập địa chỉIPcho host:setenv serverip <địa chỉ host>
o Thiết lập địa chỉ ethernet(MAC): setenv ethaddr <MAC address>
o Thiết lập mặt nạ: setenv netmask <submask net>
o Lưu lại các biến môi trường vào dataflash: save
Để xem lại các biến môi trường tại dòng lệnh bạn nhập lệnh prinenv
- Chuẩn bị kernelcho hệ thống. - Tại command line ubootcủa:
Xóa vùng nhớ NAND FLASH để chuẩn bị cho kernel:
nand erase offset length
nand erase 0x0 0x200000
Lệnh trên cho phép xóa 2 Mbyte bộ nhớ Nand Flash ở địa chỉ offset là 0. (vùng nhớ đầu tiên của NandFlash)
Chép uImage từ máy tính vào SRAM ở địa chỉ 0x20000000
Tftp 0x20000000 uImage
Để có thể chép thơng qua giao thức tftpthì trên máy tínhhostphải cài đặt và chạy dịch vụ
tftp, file uImage được lưu trong thưc mục của tftp server.
U-bootsẽ dị trong biến mơi trường xem địa chỉ của server là bao nhiêu và nó sẽ lên sever này tìm file có tên uImagevà chép vào bộ nhớ SRAM từ địa chỉ 0x20000000.
Thực thi kernel
Bootm 0x20000000
Hệ thống sẽ chuyển đến địa chỉ SRAM 0x20000000 để boot Umage:
Trong trường hợp này lần sau khi mở điện nội dung trên SRAM sẽ mất đi. Để có thể sử dụng uImage cho các lần khởi động sau chúng ta cần chep uImagelên NandFlask.
Chép 2 Mbyte từ địa chỉ SRAM 0x20000000 lên nandflash có địa chỉ offset là 0 (vùng đầu tiên củaNandFlash)
Các lần khởi động sau sẽ chép uImagetừ Nanflash xuống SRAM và thực thi nó trên SRAM
Nand read0x20000000 0x0 0x200000
Bạn chú ý các thao tác chép uImagetừ Nandflashxuống SRAM và thực thi nó được thiết lập trong biến môi trường ubootđể thực hiện một cách tự động.
Bảng tổng hợp các lệnh của u-boot:
autoscr run script from memory
base print or set address offset bdinfo print Board Info structure
bootm boot application image from memory
bootp boot image via network using BootP/TFTP protocol bootd boot default, i.e., run 'bootcmd'
cmp memory compare
cp memory copy
crc32 checksum calculation
echo echo args to console
erase erase FLASH memory
flinfo print FLASH memory information go start application at address 'addr'
help print online help
iminfo print header information for application image loadb load binary file over serial line (kermit mode) loadc load binary file over serial line (ymodem-c mode) loadg load binary file over serial line (ymodem-g mode) loads load S-Record file over serial line
loop infinite loop on address range
md memory display
mm memory modify (auto-incrementing)
mtest simple RAM test
mw memory write (fill)
nm memory modify (constant address)
printenv print environment variables
protect enable or disable FLASH write protection
rarpboot boot image via network using RARP/TFTP protocol
reset perform RESET of the CPU
run run commands in an environment variable saveenv save environment variables to persistent storage setenv set environment variables
tftpboot boot image via network using TFTP protocol and env variables ipaddr and serverip
version print monitor version ? alias for 'help'