Skip to content

Commit

Permalink
scripts: fixed c2 bundle format (#1889)
Browse files Browse the repository at this point in the history
* scripts: fixed c2 bundle format
* scripts: copro.py: small refactoring

Co-authored-by: あく <[email protected]>
  • Loading branch information
hedger and skotopes authored Oct 18, 2022
1 parent f61a8fd commit 4942bd2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/flipper/assets/copro.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from io import BytesIO
import tarfile
import xml.etree.ElementTree as ET
import posixpath
import os

from flipper.utils import *
from flipper.assets.coprobin import CoproBinary, get_stack_type
Expand All @@ -23,6 +25,8 @@


class Copro:
COPRO_TAR_DIR = "core2_firmware"

def __init__(self, mcu):
self.mcu = mcu
self.version = None
Expand Down Expand Up @@ -50,9 +54,8 @@ def loadCubeInfo(self, cube_dir, cube_version):
raise Exception(f"Unsupported cube version")
self.version = cube_version

@staticmethod
def _getFileName(name):
return os.path.join("core2_firmware", name)
def _getFileName(self, name):
return posixpath.join(self.COPRO_TAR_DIR, name)

def addFile(self, array, filename, **kwargs):
source_file = os.path.join(self.mcu_copro, filename)
Expand All @@ -61,6 +64,9 @@ def addFile(self, array, filename, **kwargs):

def bundle(self, output_file, stack_file_name, stack_type, stack_addr=None):
self.output_tar = tarfile.open(output_file, "w:gz", format=tarfile.USTAR_FORMAT)
fw_directory = tarfile.TarInfo(self.COPRO_TAR_DIR)
fw_directory.type = tarfile.DIRTYPE
self.output_tar.addfile(fw_directory)

stack_file = os.path.join(self.mcu_copro, stack_file_name)
# Form Manifest
Expand Down

0 comments on commit 4942bd2

Please sign in to comment.