BCM3383などで使われている、BootloaderではProgramStoreというプログラムでイメージを作ります。
% ./ztools/ProgramStore
usage: ./ztools/ProgramStore -f infile1 [-f2 infile2] [-o outfilename] [-v xxx.xxx] [-c x] [-x] [-s sig] [-t time] [-a addr]
-f -- specify the input filename (required)
-f2 -- specify second input filename (for dual image)
-o -- specify the output filename (default input filename changed to .out)
-v -- specify the version (default 000.000)
-c 1 -- use old compression (default)
-c 2 -- use miniLZO compression
-c 3 -- use NRV2D99 compression (slowest and best)
-c 3x -- (x=1-9) NRV2D99 compression (faster, but less compression)
-c 4 -- use LZMA compression
-s -- specify the signature (default 0x3350)
-t -- specify the build time as integer time since epoch (default is current time)
-a -- specify the Load Address (default 0x00000000)
-r -- print revision information
-p -- pad image 1 to n bytes to align image 2 (-f2)
-x -- decompress the input file
イメージには二つのファイルが入れることができてkernelとrootfsを入れます。
u-bootのイメージは事前に圧縮しておいて、それをイメージにしていますが、こちらはイメージ作成の時に圧縮もしてくれます。
ZRouterではrootfsはg_uzip形式にして、64Kの境界から置いています。
なので、kernelはProgramStoreに圧縮してもらい、rootfsは非圧縮にする必要があったので、-nオプションを追加しました。
また64Kの境界からrootfsを配置するためpオプションを指定しています。
これをBootloaderの11 = alternate image 1 (SPI flash block 1)で焼くとrootfsを認識してinitが起動します。
TFTP Get Selected
Board TFTP Server IP Address [10.10.10.3]:
Enter filename [Humax_HG100R.psimage]:
Destination: a5f00000
Destination: a5f00000
Starting TFTP of Humax_HG100R.psimage from 10.10.10.3
Getting Humax_HG100R.psimage using octet mode
..................................................
Tftp complete
Received 4545024 bytes
Image 3 Program Header:
Signature: 3383
Control: 0101
Major Rev: 8271
Minor Rev: 8486
Build Time: 2024/4/30 09:13:33 Z
File Length: 4544932 bytes
Load Address: 80040100
Filename: Humax_HG100R.psimage
HCS: 5901
CRC: 090baccb
CRC Verified
Destination image
0 = bootloader
1/2 = CM image
11 = alternate image 1 (SPI flash block 1)
21 = asymmetric image 2 (location varies)
22 = specify flash offset for image 2
(0-22)[2]: 11
flashSize 800000, flashBlockSize 10000, size 455a00, roundup 460000
Writing at offset 10000...
Erasing before writing at offset 10000...
SpiFlashWrite: Writing flash at 00010000
元々はイメージは0x20000からありましたが、これで焼くと0x10000からイメージが置かれます。
geom_mapでrootfsがちゃんと探せています。
Trying to mount root from cd9660:/dev/map/rootfs.uzip []...
MAP: flash/spi0: 0x20000, data=0x20000 "/dev/map/bootloader"
MAP: search flash/spi0 for key ".!/bin/sh" from 0x200000, step 0x10000
MAP: flash/spi0: 20000x210000, data=0x210000 "/dev/map/kernel"
MAP: search flash/spi0 for key ".!/bin/sh" from 0x200000, step 0x10000
MAP: flash/spi0: 230000x7dd0000, data=0x7dd0000 "/dev/map/rootfs"
MAP: No valid partition found at map/rootfs.uzip
cd9660: RockRidge Extension
ProgramStoreはBroadcomが作ったもののようです。BroadcomにはCFEのtrx形式もありますが、別物のようです。
このBootloaderはGNU spibootとメッセージがでるのですが、ソースコードが見当たりません。ecosの一部の可能性もありますが、RedBootではないようです。どこにあるんだろう?