This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to generate update files (*.dat *.bin) without zipping them?

Is there some way to configure nrfutil to produce the *.dat and *.bin files as such, without bundling them into a zip file? I tried going through the help and did some quick search but could not find any way to do this.

We are using UART DFU in our design and the host needs to have the *.dat and *.bin files separately, unzipped. When I create the update files for a new fw version I use nrfutil.exe to produce the zip file. Then I use 7-Zip in a script to extract the zip and do some further processing on the *.dat and *.bin files.

This solution works but it is a bit clumsy and not very portable. Would be very convenient to have the *.dat / *.bin files as such, without any zipping because the zip file is not needed at all in our DFU process. 

Any ideas?

EDIT: while hacking the nrfutil code I noticed that it uses the zipfile library and extracting a zip in Python is really easy. My post-build scripts are written in Python so having the zip file as intermediate format is not that bad after all. In my script, I extract the zip file with:

with ZipFile(zip_path, 'r') as pkg:
	pkg.extractall(dirname)
 

So in the end I'm better off using the nrfutil as it is and do the unzip in my own post-build scripts. Kudos to Nordic for making nrfutil available in source code Thumbsup

Parents
  • Hi Jaakko, 


    Thanks for your report. I will report this request internally. 

  • Thanks!

    I had a look at the internal workings of the nrfutil code and it uses a temporary working directory where the *.dat / *.bin files are stored. At the end of the process, the temporary directory is removed. on Windows, the temp folder is created in randomly named folder such as: 

    C:\Users\<username>\AppData\Local\Temp\nrf_dfu_pkg__xoaa8t8

    I was able to hack the code so that the unpacked files are available. It's not pretty but it works at least somehow and requires only one additional line of code. This is inserted in package.py, at the end of generate_package function:

            # Package the work_dir to a zip file
            Package.create_zip_package(self.work_dir, filename)
    
            # ADDED: copy the entire content of temp directory to the working directory...
            shutil.copytree(self.work_dir, "./unpacked/")
            
            # Delete the temporary directory
            self.rm_work_dir(preserve_work_dir)

    The idea is that I simply copy the entire temp directory to the same folder where I'm running nrfutil. It's not a clean solution, for example if the "unpacked" directory already exists then copytree will fail. In any case, this may be helpful if someone else is trying to get access to the unpacked files.

      

Reply
  • Thanks!

    I had a look at the internal workings of the nrfutil code and it uses a temporary working directory where the *.dat / *.bin files are stored. At the end of the process, the temporary directory is removed. on Windows, the temp folder is created in randomly named folder such as: 

    C:\Users\<username>\AppData\Local\Temp\nrf_dfu_pkg__xoaa8t8

    I was able to hack the code so that the unpacked files are available. It's not pretty but it works at least somehow and requires only one additional line of code. This is inserted in package.py, at the end of generate_package function:

            # Package the work_dir to a zip file
            Package.create_zip_package(self.work_dir, filename)
    
            # ADDED: copy the entire content of temp directory to the working directory...
            shutil.copytree(self.work_dir, "./unpacked/")
            
            # Delete the temporary directory
            self.rm_work_dir(preserve_work_dir)

    The idea is that I simply copy the entire temp directory to the same folder where I'm running nrfutil. It's not a clean solution, for example if the "unpacked" directory already exists then copytree will fail. In any case, this may be helpful if someone else is trying to get access to the unpacked files.

      

Children
No Data
Related