[PATCH 1/3] binman: add sign option for binman
    Ivan Mikhaylov 
    fr0st61te at gmail.com
       
    Fri Sep 16 00:44:53 CEST 2022
    
    
  
On Wed, 2022-09-07 at 15:10 -0600, Simon Glass wrote:
> Hi Ivan,
> 
> Section data comes from the BuildSectionData() method, so you could
> try calling that.
> 
> See also collect_contents_to_file()
> 
> Regards,
> Simon
Simon, I've tried both these ways and they both don't work to me. What
I've got:
def SignEntries(image_fname, input_fname, privatekey_fname, algo,
entry_paths):
    image_fname = os.path.abspath(image_fname)
    image = Image.FromFile(image_fname)
    state.PrepareFromLoadedData(image)
    image.LoadData()
1. BuildSectionData
 
    for entry_path in entry_paths:
        entry = image.FindEntryPath(entry_path)
        try:
            entry.BuildSectionData(True)
        except Exception as e:
            logging.error(traceback.format_exc())
ERROR:root:AttributeError: 'NoneType' object has no attribute 'run'
2. collect_contents_to_file
    for entry_path in entry_paths:
        entry = image.FindEntryPath(entry_path)
        try:
            entry.collect_contents_to_file([entry.name], "prefix",
1024)
        except Exception as e:
            logging.error(traceback.format_exc())
ERROR:root:AttributeError: 'str' object has no attribute
'ObtainContents'
3. GetData
    for entry_path in entry_paths:
        entry = image.FindEntryPath(entry_path)
        print("--- DATA ---")
        data = entry.GetData(True)
        print(data)
        print("~~~ DATA ~~~")
--- DATA ---
Node '/fit/images/u-boot-1/u-boot': GetData: size 0x4
   Node '/fit/images/u-boot-1': GetPaddedDataForEntry: size None
   Node '/fit/images/u-boot-1': GetData: 1 entries, total size 0x4
Node '/fit/images/fdt-1/u-boot-spl-dtb': GetData: size 0x4f7
      Node '/fit/images/fdt-1': GetPaddedDataForEntry: size None
      Node '/fit/images/fdt-1': GetData: 1 entries, total size 0x4f7
Deleted temporary directory '/tmp/binman.z81eqcfz'
binman: 'NoneType' object has no attribute 'run'
There is no problem with getting data from GetData around start of the
year. Maybe some regression?
All this ran with this:
binman -v5 sign -i image.bin -k test_key.key -a sha256,rsa4096 fit
`fit` in entry_paths and image contains FIT section with name `fit`.
binman ls -i image.bin
Name                  Image-pos  Size     Entry-type      Offset 
Uncomp-size
-----------------------------------------------------------------------
--------
main-section                  0   100000  section              0
  fit                     10000      c0a  fit              10000
    u-boot-1              10104        4  section            104
      u-boot              10104        4  u-boot               0
    fdt-1                 101c8      4f7  section            1c8
      u-boot-spl-dtb      101c8      4f7  u-boot-spl-dtb       0
  fdtmap                  10c0a      4f5  fdtmap           10c0a
Seems something went wrong, any ideas? Or did I misuse?
Thanks.
    
    
More information about the U-Boot
mailing list