On Fri, 2022-11-18 at 13:50 -0700, Simon Glass wrote: > Hi Ivan, > > On Thu, 15 Sept 2022 at 13:44, Ivan Mikhaylov <fr0st6...@gmail.com> > wrote: > > > > 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'
Hi Simon, sorry for long delay. binman: 'NoneType' object has no attribute 'run' Traceback (most recent call last): File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in RunBinman ret_code = control.Binman(args) File "/home/fr/upstream_uboot/tools/binman/control.py", line 684, in Binman SignEntries(args.image, args.file, args.key, args.algo, args.paths) File "/home/fr/upstream_uboot/tools/binman/control.py", line 469, in SignEntries entry.BuildSectionData(True) File "/home/fr/upstream_uboot/tools/binman/etype/fit.py", line 426, in BuildSectionData if self.mkimage.run(reset_timestamp=True, output_fname=output_fname, 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' > > This seems to be getting a string instead of an entry object. Can you > try -D to see? See 'Writing new entries and debugging'. Yea, you're right, seems I've added here entry.name instead of entry but result still messy. entry here is FIT container which is 'fit': <binman.etype.fit.Entry_fit object at 0x7f6b239cfe20> <class 'binman.etype.fit.Entry_fit'> binman: [Errno 2] No such file or directory: 'u-boot.bin' Traceback (most recent call last): File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in RunBinman ret_code = control.Binman(args) File "/home/fr/upstream_uboot/tools/binman/control.py", line 686, in Binman SignEntries(args.image, args.file, args.key, args.algo, args.paths) File "/home/fr/upstream_uboot/tools/binman/control.py", line 471, in SignEntries entry.collect_contents_to_file([entry], "prefix", 1024) File "/home/fr/upstream_uboot/tools/binman/entry.py", line 1253, in collect_contents_to_file if not entry.ObtainContents(fake_size=fake_size): File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 250, in ObtainContents return self.GetEntryContents(skip_entry=skip_entry) File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 696, in GetEntryContents job.result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in result return self.__get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result raise self._exception File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 668, in _CheckDone if not entry.ObtainContents(): File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 250, in ObtainContents return self.GetEntryContents(skip_entry=skip_entry) File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 696, in GetEntryContents job.result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in result return self.__get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result raise self._exception File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 668, in _CheckDone if not entry.ObtainContents(): File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 52, in ObtainContents self.ReadBlobContents() File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 82, in ReadBlobContents data = self.ReadFileContents(self._pathname) File "/home/fr/upstream_uboot/tools/binman/etype/blob.py", line 74, in ReadFileContents indata = tools.read_file(pathname) File "/home/fr/upstream_uboot/tools/patman/tools.py", line 467, in read_file with open(filename(fname), binary and 'rb' or 'r') as fd: FileNotFoundError: [Errno 2] No such file or directory: 'u-boot.bin' > > > > > 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' > > This might be trying to call tools.run() so use -D to see where the > error is. > --- 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.0x74lr_s' binman: 'NoneType' object has no attribute 'run' Traceback (most recent call last): File "/home/fr/upstream_uboot/tools/binman/binman", line 133, in RunBinman ret_code = control.Binman(args) File "/home/fr/upstream_uboot/tools/binman/control.py", line 684, in Binman SignEntries(args.image, args.file, args.key, args.algo, args.paths) File "/home/fr/upstream_uboot/tools/binman/control.py", line 468, in SignEntries print(entry.GetData()) File "/home/fr/upstream_uboot/tools/binman/etype/section.py", line 362, in GetData data = self.BuildSectionData(required) File "/home/fr/upstream_uboot/tools/binman/etype/fit.py", line 426, in BuildSectionData if self.mkimage.run(reset_timestamp=True, output_fname=output_fname, AttributeError: 'NoneType' object has no attribute 'run' This one strange to me because mkimage exists in tools directory and has the symbolic link to /usr/local. > > > > 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? > > Can you please push a tree somewhere so I can try this? Sure, https://github.com/fr0st61te/u-boot/tree/signfit , rebased to current master. Thanks.