Git Product home page Git Product logo

gxlimg's People

Contributors

7ji avatar apatard avatar carlocaione avatar hexdump0815 avatar marmeladema avatar matwey avatar repk avatar superna9999 avatar xdarklight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gxlimg's Issues

s/gxlimg/amlimg ?

I've come accross a few (small number, but more than one or two) who are misled with the "GXL" moniker. How about changing to "amlimg" now that G12 things are working?

libretech_cc usually fails to boot with gxlimg output

Thanks for your work on this tool @repk !

Unfortunately I'm struggling to make it work reliably on libretech_cc.

I'm working with the u-boot binary from debian experimental 2019.07+dfsg-1 u-boot-amlogic package /usr/lib/u-boot/libretech-cc/u-boot.bin. Here is a direct copy - apologies for zipping these attachments, github won't accept them otherwise.
u-boot.zip

This u-boot does have hdmi support so it's nice and easy to see when it's booting or not.

make image UBOOT=/path/to/u-boot.bin produces this output:
build.zip
and the resultant gxl-boot.bin is not bootable - black screen.

I ran one of the final commands from that build process again: ./gxlimg -t fip --bl2 build/fip/gxl/bl2.bin.enc --bl30 build/fip/gxl/bl30.bin.enc --bl31 build/fip/gxl/bl31.bin.enc --bl33 build/fip/gxl/u-boot.bin.enc build/gxl-boot.bin
and reflashed, still not booting.

Ran that command once more, reflashed, still not booting. So 3 out of 3 failures in that specific experiment.

Then I took the same original u-boot.bin from Debian and encrypted it with the vendor tool aml_encrypt_gxl --bl3enc. The output is here:
bl33.bin.zip

Then I modified the final gxlimg command to use that one instead:
./gxlimg -t fip --bl2 build/fip/gxl/bl2.bin.enc --bl30 build/fip/gxl/bl30.bin.enc --bl31 build/fip/gxl/bl31.bin.enc --bl33 ~/projects/u-boot/fip/bl33.bin.enc build/gxl-boot.bin

Reflashed, and now it boots.

Ran that command again, and reflashed, and it still boots. Then did it once again, and it still boots. 3 out of 3 passes. Here is one of the resultant working boot images.
gxl-boot.zip

So it looks like there may be a problem with the u-boot binary encryption not working right. But I think it might be an intermittent problem relating to random data, different timestamps or different keys, as gxlimg definitely did work the first time I tried it with this same exact u-boot binary.

gxm (s912) experiments

i just tried to apply the proven to work on gxl strategy to deconstruct the boot blocks via gxlimg, then replacing atf and u-boot by their mainline counterparts and reassembling all again via gxlimg to a gxm tv box (m8s pro), but sadly failed so far.

according to https://freenode.irclog.whitequark.org/linux-amlogic/2019-05-07 and https://freenode.irclog.whitequark.org/linux-amlogic/2019-05-08 it seems like others got it working already on a khadas vim2 ... so maybe i'm simply doing something wrong or something is a bit different in the case of this tv box.

before adding some log output i would first like to point you to a dump of the original boot blocks and my self built blocks at https://github.com/hexdump0815/u-boot-misc/blob/gxm-experiments/misc.gxl/dump-in.dd/s912-m8s-pro.dd.gz and https://github.com/hexdump0815/u-boot-misc/tree/gxm-experiments/misc.gxl/gxm-experiments (atf is with mainline atf, the other is using the extracted bl31)

ok, as promised some boot logs:

  • first the normal android boot from emmc ...
08915d2000000000GXM:BL1:dc8b51:76f1a5;FEAT:ADFC318C:0;POC:3;RCY:0;EMMC:0;READ:0;0.0;CHK:0;
TE: 107800

BL2 Built : 13:38:48, Mar  8 2017. 
gxl g8e12692 - xiaobo.gu@droid05

set vdd cpu_a to 1120 mv
set vdd cpu_b to 1050 mv
set vddee to 1000 mv
Board ID = 11
CPU clk: 1200MHz
DQS-corr enabled
DDR scramble enabled
DDR4 chl: Rank0+1 @ 792MHz
Rank0: 2048MB(auto)-2T-18
Rank1: 1024MB(auto)-2T-18
DataBus test pass!
AddrBus test pass!
-s
Load fip header from eMMC, src: 0x0000c200, des: 0x01400000, size: 0x00004000
New fip structure!
Load bl30 from eMMC, src: 0x00010200, des: 0x01100000, size: 0x0000d600
Load bl31 from eMMC, src: 0x00020200, des: 0x10100000, size: 0x0001b400
Load bl33 from eMMC, src: 0x0003c200, des: 0x01000000, size: 0x000b6a00
NOTICE:  BL3-1: v1.0(debug):866a5ea
NOTICE:  BL3-1: Built : 15:50:05, Feb 28 2017
aml log : bl31 normal boot !
mpu_config_enable:ok
[Image: gxl_v1.1.3194-db501b7 2017-03-28 15:06:09 yun.cai@droid06]
OPS=0x82
wdt: reset registers!
ca ca 94 ff c 8d d7 43 6b a0 a9 20 [0.402551 Inits done]
secure task start!
high task start!
low task start!
INFO:    BL3-1: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address = 0x1000000
INFO:    BL3-1: Next image spsr = 0x3c9


U-Boot 2015.01-g90d33a6 (Apr 05 2017 - 18:18:17)

DRAM:  3 GiB
Relocation Offset is: b6eba000
register usb cfg[0][1] = 00000000b7f5c298
[CANVAS]canvas init
vpu: error: vpu: check dts: FDT_ERR_BADMAGIC, load default parameters
vpu: clk_level = 7
vpu: set clk: 666667000Hz, readback: 666660000Hz(0x300)
vpp: vpp_init
boot_device_flag : 1
Nand PHY Ver:1.01.001.0006 (c) 2013 Amlogic Inc.
init bus_cycle=6, bus_timing=7, system=5.0ns
reset failed
get_chip_type and ret:fffffffe
get_chip_type and ret:fffffffe
chip detect failed and ret:fffffffe
nandphy_init failed and ret=0xfffffff1
MMC:   aml_priv->desc_buf = 0x00000000b3eba790
aml_priv->desc_buf = 0x00000000b3ebcab0
SDIO Port B: 0, SDIO Port C: 1
emmc/sd response timeout, cmd8, status=0x1ff2800
emmc/sd response timeout, cmd55, status=0x1ff2800
init_part() 278: PART_TYPE_DOS
[mmc_init] mmc init success
dtb magic 5f4c4d41
      Amlogic multi-dtb tool
      Multi dtb detected
      Multi dtb tool version: v2 .
      Support 2 dtbs.
        aml_dt soc: gxm platform: q20xrmii variant: 3g
        dtb 0 soc: gxm   plat: q20xrmii   vari: 2g
        dtb 1 soc: gxm   plat: q20xrmii   vari: 3g
      Find match dtb: 1
start dts,buffer=00000000b3ebf300,dt_addr=00000000b3ecb300
      Amlogic multi-dtb tool
      Multi dtb detected
      Multi dtb tool version: v2 .
      Support 2 dtbs.
        aml_dt soc: gxm platform: q20xrmii variant: 3g
        dtb 0 soc: gxm   plat: q20xrmii   vari: 2g
        dtb 1 soc: gxm   plat: q20xrmii   vari: 3g
      Find match dtb: 1
parts: 10
00:      logo   0000000002000000 1
01:  recovery   0000000002000000 1
02:       rsv   0000000000800000 1
03:       tee   0000000000800000 1
04:     crypt   0000000002000000 1
05:      misc   0000000002000000 1
06:      boot   0000000002000000 1
07:    system   0000000080000000 1
08:     cache   0000000020000000 2
09:      data   ffffffffffffffff 4
_check_ptbl_mbr()-815: MBR is OK!
init_part() 278: PART_TYPE_DOS
eMMC/TSD partition table have been checked OK!
check pattern success
mmc env offset: 0x27400000 
In:    serial
Out:   serial
Err:   serial
reboot_mode=cold_boot
hpd_state=1
[1080p60hz] is invalid for cvbs.
set hdmitx VIC = 16
config HPLL = 2970000
HPLL: 0xc000027b
config HPLL done
j = 4  vid_clk_div = 1
hdmitx phy setting done
hdmitx: set enc for VIC: 16
rx version is 1.4 or below  div=10
hdmtix: set audio
[store]To run cmd[emmc dtb_read 0x1000000 0x40000]
_verify_dtb_checksum()-918: calc 6661ee77, store 6661ee77
_verify_dtb_checksum()-918: calc 6661ee77, store 6661ee77
dtb_read()-1040: total valid 2
dtb_read()-1107: do nothing
      Amlogic multi-dtb tool
      Multi dtb detected
      Multi dtb tool version: v2 .
      Support 2 dtbs.
        aml_dt soc: gxm platform: q20xrmii variant: 3g
        dtb 0 soc: gxm   plat: q20xrmii   vari: 2g
        dtb 1 soc: gxm   plat: q20xrmii   vari: 3g
      Find match dtb: 1
vpp: vpp_pq_load pq val error !!!
Net:   dwmac.c9410000amlkey_init() enter!
[EFUSE_MSG]keynum is 4
[BL31]: tee size: 0

wipe_data=successful
wipe_cache=successful
upgrade_step=2
[OSD]load fb addr from dts
[OSD]fb_addr for logo: 0x7f851000
[OSD]load fb addr from dts
[OSD]fb_addr for logo: 0x7f851000
[CANVAS]addr=0x7f851000 width=3840, height=2160
amlkey_init() enter!
amlkey_init() 71: already init!
[EFUSE_MSG]keynum is 4
[BL31]: tee size: 0
[KM]Error:f[key_manage_query_size]L507:key[usid] not programed yet
[KM]Error:f[key_manage_query_size]L507:key[deviceid] not programed yet
gpio: pin GPIOAO_2 (gpio 102) value is 1
chanel error
saradc - saradc sub-system

Usage:
saradc saradc open <channel>            - open a SARADC channel
saradc close    - close the SARADC
saradc getval   - get the value in current channel
saradc get_in_range <min> <max> - return 0 if current value in the range of current channel

key1 = ba45ff00
key2 = ba4594ca
time_out = f4a10
vs_irkey - irkey key_value1 key_value2 time_value

Usage:
vs_irkey 
Hit Enter or space or Ctrl+C key to stop autoboot -- :  0 
  • then the self built boot blocks with mainline atf and u-boot v2020.07 mainline using the libretech-s912-pc_defconfig booting from sd card via hdmi debug dongle:
GXM:BL1:dc8b51:76f1a5;FEAT:ADFC318C:0;POC:3;RCY:2;SD:0;READ:0;0.0;CHK:0;
no sdio debug board detected 
TE: 321232

BL2 Built : 13:38:48, Mar  8 2017. 
gxl g8e12692 - xiaobo.gu@droid05

set vdd cpu_a to 1120 mv
set vdd cpu_b to 1050 mv
set vddee to 1000 mv
Board ID = 11
CPU clk: 1200MHz
DQS-corr enabled
DDR scramble enabled
DDR4 chl: Rank0+1 @ 792MHz
Rank0: 2048MB(auto)-2T-18
Rank1: 1024MB(auto)-2T-18
DataBus test pass!
AddrBus test pass!
Load fip header from SD, src: 0x0000c200, des: 0x01400000, size: 0x00004000
Load bl30 from SD, src: 0x00010200, des: 0x01100000, size: 0x0000d600
Load bl31 from SD, src: 0x00020200, des: 0x10100000, size: 0x0000a400
Load bl33 from SD, src: 0x0002c200, des: 0x01000000, size: 0x000a5800
Unhandled Exception in EL3.
x30            = 0x0000000010100020
x0             = 0x0000000010109358
x1             = 0x000000004100d030
x2             = 0x0000000005105810
x3             = 0x00000000ff00fff0
x4             = 0x00000000101093b0
x5             = 0x00000000101093b0
x6             = 0x0000000000000000
x7             = 0x0000000000000000
x8             = 0x0000000000000000
x9             = 0x0000000000000018
x10            = 0x0000000000000000
x11            = 0x0000000000000002
x12            = 0x0000000000000000
x13            = 0x0000000000000000
x14            = 0x0000000000000000
x15            = 0x0000000000000000
x16            = 0x0000000000000000
x17            = 0x0000000000000000
x18            = 0x0000000000000000
x19            = 0x0000000010100020
x20            = 0x00000000d900a5c0
x21            = 0x0f1e2d3c4b5a6978
x22            = 0x0000000000000000
x23            = 0x0000000000000000
x24            = 0x0000000000000003
x25            = 0x0000000000000000
x26            = 0x000000000000a000
x27            = 0x00000000d9046106
x28            = 0x0000000000000005
x29            = 0x00000000d90137a0
scr_el3        = 0x0000000000000400
sctlr_el3      = 0x0000000040c50838
cptr_el3       = 0x0000000000000000
tcr_el3        = 0x0000000000000000
daif           = 0x00000000000003c0
mair_el3       = 0x44e048e000098aa4
spsr_el3       = 0x00000000400003cd
elr_el3        = 0x0000000005105814
ttbr0_el3      = 0x00000000101be980
esr_el3        = 0x0000000002000000
far_el3        = 0x1c8d5b4a47160802
spsr_el1       = 0x0000000000000000
elr_el1        = 0x0000000000000000
spsr_abt       = 0x0000000000000000
spsr_und       = 0x0000000000000000
spsr_irq       = 0x0000000000000000
spsr_fiq       = 0x0000000000000000
sctlr_el1      = 0x0000000000c01800
actlr_el1      = 0x0000000000000000
cpacr_el1      = 0x0000000000300000
csselr_el1     = 0x0000000000000000
sp_el1         = 0x00000000d90137a0
esr_el1        = 0x0000000000000000
ttbr0_el1      = 0x0000000000000000
ttbr1_el1      = 0x0000000000000000
mair_el1       = 0x44e048e000098aa4
amair_el1      = 0x0000000000000000
tcr_el1        = 0x0000000000000000
tpidr_el1      = 0x0000000000000000
tpidr_el0      = 0x0000000000000000
tpidrro_el0    = 0x0000000000000000
par_el1        = 0x0000000000000000
mpidr_el1      = 0x0000000080000000
afsr0_el1      = 0x0000000000000000
afsr1_el1      = 0x0000000000000000
contextidr_el1 = 0x0000000000000000
vbar_el1       = 0x0000000000000000
cntp_ctl_el0   = 0x0000000000000002
cntp_cval_el0  = 0x15cdfe24296c00a0
cntv_ctl_el0   = 0x0000000000000002
cntv_cval_el0  = 0x73f7f96ef3f77fcd
cntkctl_el1    = 0x0000000000000000
sp_el0         = 0x0000000000000000
...
<endless register dumps following>
  • and finally the self built boot blocks with the original extracted bl31 and u-boot v2020.07 mainline using the libretech-s912-pc_defconfig booting from sd card via hdmi debug dongle:
GXM:BL1:dc8b51:76f1a5;FEAT:ADFC318C:0;POC:3;RCY:2;SD:0;READ:0;0.0;CHK:0;
no sdio debug board detected 
TE: 294969

BL2 Built : 13:38:48, Mar  8 2017. 
gxl g8e12692 - xiaobo.gu@droid05

set vdd cpu_a to 1120 mv
set vdd cpu_b to 1050 mv
set vddee to 1000 mv
Board ID = 11                                                                             
CPU clk: 1200MHz                                                                          
DQS-corr enabled                                                                          
DDR scramble enabled                                                                      
DDR4 chl: Rank0+1 @ 792MHz                                                                
Rank0: 2048MB(auto)-2T-18                                                                 
Rank1: 1024MB(auto)-2T-18                                                                 
DataBus test pass!                                                                        
AddrBus test pass!                                                                        
Load fip header from SD, src: 0x0000c200, des: 0x01400000, size: 0x00004000               
New fip structure!                                                                        
Load bl30 from SD, src: 0x00010200, des: 0x01100000, size: 0x0000d600                     
Load bl31 from SD, src: 0x00020200, des: 0x10100000, size: 0x0001b400                     
Load bl33 from SD, src: 0x0003c200, des: 0x01000000, size: 0x000a5800                     
NOTICE:  BL3-1: v1.0(debug):866a5ea                                                       
NOTICE:  BL3-1: Built : 15:50:05, Feb 28 2017                                             
aml log : bl31 normal boot !                                                              
mpu_config_enable:ok                                                                      
[Image: gxl_v1.1.3194-db501b7 2017-03-28 15:06:09 yun.cai@droid06]                        
OPS=0x82
wdt: reset registers!
ca ca 94 ff c 8d d7 43 6b a0 a9 20 [0.703008 Inits done]
secure task start!
high task start!
low task start!
INFO:    BL3-1: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address = 0x1000000
INFO:    BL3-1: Next image spsr = 0x3c9
<here it seems to hang>

any hint or suggestion is very welcome and please let me know in case you need any more information or want me to try something ...

a lot of thanks in advance and best wishes - hexdump

Build failure to create final boot image

Hi @repk ,
thanks for the tools to package u-boot in libre way on recent Linux.

However, following the instructions in the readme I get the following error when attempting to make the final boot image:

command "gxlimg" "-t" "fip" "--bl2" "fip/bl2.bin.enc" "--bl30" "fip/bl30.bin.enc" "--bl31" "fip/bl31.img.enc" "--bl33" "u-boot.bin.enc" "gxl-boot.bin" failed with status 234

I'm attempting to make package definition for the u-boot on Amlogic SoC s905x for GNU Guix. Here's the definition:

 (define (make-u-boot-amlogic-package board)
  (let ((base (make-u-boot-package
               board "aarch64-linux-gnu" #:append-description %u-boot-amlogic-description-64-bit))
         (commit "e0638f1d09b9e9caead4e3909e7dc8aaa41febe1")
		 (revision "1"))
    (package
      (inherit base)
      (version "202301")
      (source (origin
                (method url-fetch)
                (uri (string-append
				"https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/archive/"
				commit "/u-boot-amlogic-" commit ".tar.gz"))
                (patches (search-patches
                     "u-boot-disable-OpenSSL.patch"))
                (sha256
                 (base32
                  "1idgh8qn073p50pi2fan65nzxj7j3r0pq797zbdbrb7gs555b6zy"))
				))
    (inputs
     (modify-inputs (package-inputs base)
       (append gxlimg linux-libre-headers)))
      (arguments
       (substitute-keyword-arguments (package-arguments base)
         ((#:phases phases)
          #~(modify-phases #$phases
		     (add-after 'unpack 'copy-defconfig
			  (lambda* (#:key inputs #:allow-other-keys)
				 (let ((bl2-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl2.bin")
              (sha256
               (base32
                "19pv7v904s66addhxwk9mzybdv26dpkygxc7075xvaqiq2pl9h3b"))))
				 (bl30-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl30.bin")
              (sha256
               (base32
                "0839nrfcbkj64nyn3ji7f1j9xa2p1apd3vn7qvpxyfj884ihspiv"))))
				 (bl31-dl #$(origin
              (method url-fetch)
              (uri
				 "https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/bl31.img")
              (sha256
               (base32
                "0gkdcpn9rvglcpb1h76pb13d718g1vi8qviqzwj8c7fv0n6xs149")))))
			   (substitute* "Makefile"
			   ((".bin.pwd") (search-input-file inputs "bin/pwd"))
			   ((".bin.bash") (search-input-file inputs "bin/bash")))
			   (install-file bl2-dl "fip")
			   (install-file bl30-dl "fip")
			   (install-file bl31-dl "fip")
			   (rename-file (string-append "fip/" (basename bl2-dl))
			   "fip/bl2.bin")
			   (rename-file (string-append "fip/" (basename bl30-dl))
			   "fip/bl30.bin")
			   (rename-file (string-append "fip/" (basename bl31-dl))
			   "fip/bl31.img")
			   )))
             (add-before 'install 'package
               (lambda* (#:key native-inputs inputs #:allow-other-keys)
                 (let ((fip (string-append (getcwd) "/fip"))
				       (gxlimg (search-input-file inputs "/bin/gxlimg")))
				 ;; Sign BL2
				 (invoke "gxlimg" "-t" "bl2" "-s" "fip/bl2.bin" "fip/bl2.bin.enc")


  ;; Encrypt BL3*
  (invoke "gxlimg" "-t" "bl3x" "-c" "fip/bl30.bin" "fip/bl30.bin.enc")
   (invoke "gxlimg" "-t" "bl3x" "-c" "fip/bl31.img" "fip/bl31.img.enc")
   ;; Encrypt u-boot
   (invoke "gxlimg" "-t" "bl3x" "-c" "u-boot.bin" "u-boot.bin.enc")
   ;; Create the final boot image
   (invoke "gxlimg" "-t" "fip" "--bl2" "fip/bl2.bin.enc" "--bl30"
   "fip/bl30.bin.enc"
     "--bl31" "fip/bl31.img.enc" "--bl33" "u-boot.bin.enc" "gxl-boot.bin")
	 (delete-file-recursively "fip")
	 ;; Create USB boot files
	 (invoke "dd" "if=gxl-boot.bin" "of=u-boot.bin.usb.bl2" "bs=49152" "count=1")
	 (invoke "dd" "if=gxl-boot.bin" "of=u-boot.bin.usb.tpl" "skip=49152" "bs=1")
;; Install files
   (install-file "u-boot.bin.usb.bl2" (string-append #$output "/libexec"))
   (install-file "u-boot.bin.usb.tpl" (string-append #$output "/libexec"))
   (install-file "gxl-boot.bin" (string-append #$output "/libexec"))
   ))))))))))

The important parts are https://source.denx.de/u-boot/custodians/u-boot-amlogic as u-boot source with commit e0638f1d09b9e9caead4e3909e7dc8aaa41febe1.
This builds okay without any additional steps.

But I wanted to have already the bootloader in the format the HW expects it so I added additional stage to download the binaries from https://github.com/BayLibre/u-boot/raw/libretech-cc/fip/gxl/* (bl2.bin, bl30.bin and bl31.img).

Then I follow the instructions and run the commands you listed.

Any idea what's wrong?

aml_encrypt_g12b functionality

Hi, this looks great! I've got a HardKernel N2 here with a S922X chip, packaging the boot image is terrible, and aml_encrypt_g12b being only available as a x86_64 binary blob doesn't make it much better.

Here's what the somewhat loosely available only documentation provides for building the images

wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
cp -v $UBOOTDIR/build/scp_task/bl301.bin fip/
cp -v $UBOOTDIR/build/board/hardkernel/odroidn2/firmware/acs.bin fip/
cp -v $UBOOTDIR/fip/g12b/bl2.bin fip/
cp -v $UBOOTDIR/fip/g12b/bl30.bin fip/
cp -v $UBOOTDIR/fip/g12b/bl31.img fip/
cp -v $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
cp -v $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
cp -v $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
cp -v $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
cp -v $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip2/
cp -v $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
cp -v $UBOOTDIR/fip/g12b/piei.fw fip/
cp -v $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
cp -v u-boot.bin fip/bl33.bin

bash fip/blx_fix.sh \
     fip/bl30.bin \
     fip/zero_tmp \
     fip/bl30_zero.bin \
     fip/bl301.bin \
     fip/bl301_zero.bin \
     fip/bl30_new.bin \
     bl30

bash fip/blx_fix.sh \
     fip/bl2.bin \
     fip/zero_tmp \
     fip/bl2_zero.bin \
     fip/acs.bin \
     fip/bl21_zero.bin \
     fip/bl2_new.bin \
     bl2

$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
                                --output fip/bl30_new.bin.g12a.enc \
                                --level v3
$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
                                --output fip/bl30_new.bin.enc \
                                --level v3 --type bl30
$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
                                --output fip/bl31.img.enc \
                                --level v3 --type bl31
$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
                                --output fip/bl33.bin.enc \
                                --level v3 --type bl33 --compress lz4
$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
                                --output fip/bl2.n.bin.sig
$UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
        --output fip/u-boot.bin \
        --bl2 fip/bl2.n.bin.sig \
        --bl30 fip/bl30_new.bin.enc \
        --bl31 fip/bl31.img.enc \
        --bl33 fip/bl33.bin.enc \
        --ddrfw1 fip/ddr4_1d.fw \
        --ddrfw2 fip/ddr4_2d.fw \
        --ddrfw3 fip/ddr3_1d.fw \
        --ddrfw4 fip/piei.fw \
        --ddrfw5 fip/lpddr4_1d.fw \
        --ddrfw6 fip/lpddr4_2d.fw \
        --ddrfw7 fip/diag_lpddr4.fw \
        --ddrfw8 fip/aml_ddr.fw \
        --level v3

Looking at the README.g12b, gxlimg should be suitable to get most of this done. Assuming we have the bl30_new.bin and bl2_new.bin constructed with the blx_fip.sh, these gxlimg commands should yield the same results

gxlimg -t bl30 -s bl30_new.bin bl30_new.bin.g12.enc
gxlimg -t bl3x -s bl30_new.bin.g12.enc bl30_new.bin.enc
gxlimg -t bl3x -s bl31.img bl31.img.sig.enc
gxlimg -t bl3x -s bl32.img bl32.img.enc
gxlimg -t bl3x -s u-boot.bin bl33.bin.enc
gxlimg -t bl2 -s bl2_new.bin bl2.n.bin.sig

Of course the bl33.bin.enc won't be lz4 compressed, but the --bootmk step is missing. I believe this is the -t fib instruction, however we are missing all the ddr arguments? This leaves me with some questions:
(a) the --level 3 argument seems mostly unused?
(b) does not compressing bl33 pose an issue? Do we know if the compression is run before or after the signing?
(c) would it be hard to add the -ddrXXX flags? I see gi_fip_create just learned about bl301.
(d) with respect to (c), does that mean we can sign bl30 and bl301 separately and ignore the first blx_fip.sh step?

any plans for extraction / decryption functionality?

hello repk,

are there any plans to add the reverse functionality to gxlimg, i.e. to be able to decompose an existing boot image into its pieces? this would be very good to extract the bl2 and bl30 parts of existing devices (for which the public available versions do not work) from an existing firmware/emmc to use them for rebuilding a working and up to date mainline u-boot for them. for instance i tried to boot some s905w based tv boxes with a self built mainline u-boot based on the public available bl2 and bl30 images and it often failed in either bl2 (wrong chip message) or bl30 (dvfs does not work well and sending for instance too high clock speeds) - so looks like to make this work, one would have to reuse the bl2 and bl30 of the boxes themself to get a working version and for that one would need to be able to extract them.

in the code i saw functions like gi_bl2_extract with a note that they are not implemented yet, so this brings up some hope that they will be there soon. i looked at the code, but i think for me this would be a bit too complex to get this implemented.

a lot of thanks in advance and best wishes - hexdump

SM1 (S905X3) doesn't boot with gxlimg

Hi,

I am trying to use gxlimg to make bootable image for Odroid-C4 board.
I've successfully used https://github.com/angerman/meson64-tools to make bootable image following this instruction.
However, when I try to substitute meson64-tools with glximg, then I obtain unbootable result:

...
Load FIP HDR from SD, src: 0x00010200, des: 0x01700000, size: 0x00004000, part: 0
Load BL3X from SD, src: 0x00078200, des: 0x01768000, size: 0x0010c000, part: 0
BL31 CHK: 0x00000027 ADDR 01776400
reset...
SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:F;RCY:0;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;

Only bl2 seems to be running fine.

I've not found what is the reason yet. Now I see that bl30_new.bin.enc is little shorter for gxlimg because meson64-tools pads the file with 0 up to 512(?) bytes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.