0
2

More than 3 years have passed since last update.

G-cluster の U-boot で遊ぶ

Last updated at Posted at 2021-08-29

G-cluster の起動時にシリアルコンソールから何らかの入力があるとU-boot のコマンドインタプリタに落ちます。


I2C:   ready
DRAM:  256 MiB
SPI Speed at [R:23MHz/W:47MHz] Flash Size: 128KB
NAND:  128 MiB
MMC:   
initializing secure environment
Bad block table found at page 65472, version 0x01
Bad block table found at page 65408, version 0x01
In:    serial
Out:   serial
Err:   serial
MAC:   00:1a:cc:00:00:01
Hit any key to stop autoboot:  0 
CNCl800L> 
CNCl800L> 
CNCl800L> 
CNCl800L> 
CNCl800L> 
CNCl800L> 

U-boot とは Linux ではありませんが、Linux を呼び出すためのブートローダーです。
PC にとっての GRUB に当てはまります。

cf.,「GRUB と U-boot の比較」
https://qiita.com/nanbuwks/items/f0813a4a4749189e57d1

組み込み用ですが、機能は組み込まれたシステムによって様々です。
G-cluster の U-boot で使えるコマンドを確認しましょう。



CNCl800L> 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'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
boots   - Boot Secure Kernel

burnsplash- Utility to burn splash image

cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
cryptotest- execute decrypt/encrypt cycle on memory

cuid    - read/write the customer unique chip ID from/to the e-fuses
dcache  - enable or disable data cache
debug   - enable debug
dhcp    - boot image via network using DHCP/TFTP protocol
disled  - Disable LED display and enable GPIO2
echo    - echo args to console
editenv - edit environment variable
eeprom  - EEPROM sub-system
env     - environment handling commands
esp1800l_flash_util- Utility to flash signed_encrypted Image on Nand 

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 /)
fpcd    - Display data on frontpanel led
fpcraw  - Display raw data on frontpanel led
fsinfo  - print information about filesystems
fsload  - load binary file from a filesystem image
go      - start application at address 'addr'
gpio    - gpio    - gpio read/write bit

help    - print command description/usage
i2c     - I2C sub-system
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
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
logo    - logo    -display logo picture on TV Screen
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nand    - NAND sub-system
nboot   - boot from NAND device
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
nvram_set_defaults- nvram_set_defaults - reset environment to factory defaults

ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
printsecenv- printsecenv- print secured environment variables

pswdsec - pswdsec - to save secured parameter enter password

readotpuid- read the unique chip ID from the e-fuses
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
savesecenv- savesecenv - save secured environment variables to storage

secinit - secinit- initialize secure environment stuff
 (for testing purposes only)

setenv  - set environment variables
setsecenv- setsecenv  - set environment variables

sfer    - sfer    - spi flash erase

sfinfo  - sfinfo  - display spi flash informations.

sfre    - sfre    - spi flash read byte.

sfwr    - sfwr    - spi flash write byte

showvar - print local hushshell variables
sleep   - delay execution for some time
source  - run script from memory
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
timexfer- time memory transfer

true    - do nothing, successfully
update  - update - update your u-boot.bin / uImage / ramdiskg.img by USB storage device. 

upgrade - Utility to upgrade uboot or nethd image

usb     - USB sub-system
usbboot - boot from USB device
usbtest - usbtest - test USB host controller of ORION 1.4 

version - print monitor, compiler and linker version
xrsa_verify- Verify rsa signed Image using s/w hashing 

CNCl800L> 

中の環境変数を確認します。


env print
AUTORUN=1
AVSYNC=1
EDID=1
ENABLE_CEC=1
FACT_IMG=400000
FIRST_BOOT=1
IMG=2400000
IMG_SIZE=2000000
POWER_MGMT=1
RAM=4000000
WORK_IMG=2400000
baudrate=115200
bootargs=console=ttyS0,115200 quiet
bootcmd=dcache on;run ledon; run show_logo;boots
bootdelay=0
country=JP
dsm_lang=17
ethaddr=00:1a:cc:00:00:01
hwkey=23f34b04-e874-4e4f-a0ce-e6485a73f23a
last_filename=DSM232A1_FW1.01.00JP_20130318.img
ledon=gpio write 2 1
show_logo=nand read 4000000 200000 0x1C2000; logo 5 2 4000000 1280 720 0 0
stderr=serial
stdin=serial
stdout=serial
verify=no
wifiaddr=C8:D3:A3:A9:37:B3
wifimode=ap

Environment size: 635/8188 bytes

LEDをONにできそうですね。やってみましょう。


CNCl800L> run ledon 
Write ok!
CNCl800L> run ledoff
## Error: "ledoff" not defined



環境変数を操作できます。



CNCl800L> env set bootdelay 10
CNCl800L> env
env - environment handling commands

Usage:
env default -f - reset default environment
env edit name - edit environment variable
env export [-t | -b | -c] addr [size] - export environment
env import [-d] [-t | -b | -c] addr [size] - import environment
env print [name ...] - print environment
env run var [...] - run commands in an environment variable
env save - save environment
env set [-f] name [arg ...]

CNCl800L> env print bootdelay
bootdelay=10

このあと、


CNCl800L> env save
Saving Environment to SPI Flash...
Sector Erase from 0xc000 to 0xe000 ...   ok!
Page Write from 0xd256e3c to 0xc000 ...   ok!

とすると保存できます。
さて、U-bootシェルから本来の起動に進むには boots とします。これは署名チェックを行ってセキュアにブートすることができます。


CNCl800L> boots



Data (writethrough) Cache is ON
Write ok!

NAND read: device 0 offset 0x200000, size 0x1c2000
 1843200 bytes read: OK
mode = 5, picture_color_mode = 2
1GFXLINEPITCHSIZE = 2560, screen_h = 720
2GFXLINEPITCHSIZE = 2560, screen_h = 720
tvmode = 5
GFXLINEPITCHSIZE = 2560,screen_w 1280, screen_h 720,picture_color_mode 2
 pic_w = 1280,pic_h = 720,dst_x = 0,dst_y = 0
ColorImg->LinePitch 0xa00,ColorImg->StartAddress 0xc000000,ColorImg->PixelHeight 720,ColorImg->PixelWidth 1280

ColorImg->ColorFormat 2

layer_output.gfx_output[0] = 0
Reg->df_gfx_control_reg.bits.iGfxEna = 1
Display configurate complete!


argc=[2].
argv[0]=[hdmi.bin].
argv[1]=[5].
main=[020576f8].
in main:printf=[0205781c].
in main:_start=[e92d01f0].
mode=[5]

NAND read: device 0 offset 0x1c0000, size 0x20000
 131072 bytes read: OK

NAND read: device 0 offset 0x180000, size 0x20000
 131072 bytes read: OK

NAND read: device 0 offset 0x7c80000, size 0x1000
 4096 bytes read: OK
 Processing Application image.

NAND read: device 0 offset 0x2400000, size 0x17a0000
 24772608 bytes read: OK
length 24641536: 376 whole chunks with 0 remainder
done!
 Verifying Image RSA signature...  OK.
 Field Img Authentication passed 
 Check for Blob image... 
 Processing Blob image.

NAND read: device 0 offset 0x7c81000, size 0x20000
 131072 bytes read: OK
 Verifying Image RSA signature...  OK.
 AppImg (Blob) authenticated and copied to RAM addr : 0xefff000


 ... OK to boot 
## Booting kernel from Legacy Image at 08080000 ...
   Image Name:   240_SDK_gcluster_!
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    24532848 Bytes = 23.4 MiB
   Load Address: 08080040
   Entry Point:  08080040
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux................................................................................................................................................................... done, booting the kernel.
mmc0: Version ID 0x5342230a.
mount: mounting tmpfs on /dev/shm failed: No such file or directory
ath6kl: temporary war to avoid sdio crc error
SI_CecInit
SI_CpiInit
SI_CpiInit: Writing CEC_OP_ABORT_31 register
SI_CpiInit: Setting Logical Address
SI_CecInit: looping through ports (5)
SI_CecInit: CEC Enabled
Returned from SI_CecInit
Checking for secure chip and enabling HDCP
Creating the main HDMI thread
HDMI init!
TVCenter : tvout = 406dd474
TVCenter : HDMI not plug
HDMISetVideo: timingvideomode = 15, PictureAspectRatio = 1
CECLIB::Physical Address:: 65535

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2