Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59BD1C433EF for ; Thu, 2 Jun 2022 18:10:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C2CC83EFE; Thu, 2 Jun 2022 20:10:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jA/K6wUF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0C1F8432E; Thu, 2 Jun 2022 20:10:09 +0200 (CEST) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E81183B15 for ; Thu, 2 Jun 2022 20:10:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ed1-x535.google.com with SMTP id o10so7293290edi.1 for ; Thu, 02 Jun 2022 11:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Y2uXsqt+TBdCQ9gmVzsXZXFFtifVFnliZaBlGJCBKfo=; b=jA/K6wUFJW7NLXoJfpYIcT2erRftr5mWJVA95L+QE3t2zRVKtHhfIgasVerAuFwbWx 0wdLMoi8lmiNvoFiKhkbiFfO79LQroZ5IL0WncqcNoO9HxXUNvD7Vs0duUX4l9nhYEBv vjtoOHfxWF3GCiw0Uo3A1HgeGBunLax4pS9E7ZVdYq1yklgi8Eb5maYjmJz+jkuxx8hO gvzQ2gO8y2j6BBXG9sK9wdsYBgerPdmhfef3ve3qBduIZHFpUYR/sWRahuxEbnBgHaFo RKgdoD0O+S2AFo9yvO+NXqdCPVX2AhMaM1O1pcYyHTE3viIeZ+jj1HwEleR6crD6CuoJ JOtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Y2uXsqt+TBdCQ9gmVzsXZXFFtifVFnliZaBlGJCBKfo=; b=mxQlTS8n89v7xXseyE8Sdy/l2uTFeRY20VZX3sq3RwetyPO8bAkxq/0isRB8ZZTSf8 ZGTVn+IkjlVBpBbwLTti3Oshy1cCF1vPwfFXletL3usoTfhN83pEVxDTIYoaFooq2JEx v2kuy/JGOSd2eB5V7hVWYm1ceYBQJ6q3KttNbtTC6nQxaYIHn917/ZtY57zveM1OwUZI 2VxDc5KGMepasgyZW/CwJpdbdW8qJJiu7zXaJN6pBiLC/7NH93bHkE2uSVQK0sYUqT90 EDfL3IS9nd7LaCCxCSiCMqykZm8PV4MTwNVJ0eMsDtlbHza3RxVdwjHuNAX0QNs6fZFo ljgQ== X-Gm-Message-State: AOAM533T/4UMM9Z72yoL1/X0WYJfVipU3/YuSKmvooviEaEcrJ71Uaax 5m5G1lu2WZ2Zok2u1wBUo5Y= X-Google-Smtp-Source: ABdhPJxC/Qcam+n5MXLjpVvliB9gXOCjIM6WOAwSYbint5SoHXrlyol4ippuwMe2wVolQ+SM/hDV7w== X-Received: by 2002:a05:6402:a41:b0:42b:e6ed:4170 with SMTP id bt1-20020a0564020a4100b0042be6ed4170mr7006341edb.344.1654193406674; Thu, 02 Jun 2022 11:10:06 -0700 (PDT) Received: from [192.168.0.74] ([178.233.178.185]) by smtp.gmail.com with ESMTPSA id k9-20020a1709061c0900b006fec27575f1sm1949586ejg.123.2022.06.02.11.10.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jun 2022 11:10:06 -0700 (PDT) Message-ID: Date: Thu, 2 Jun 2022 21:10:02 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: binman: Why is the first word the compressed size in compressed data Content-Language: en-US To: Stefan Herbrechtsmeier Cc: Michal Simek , U-Boot Mailing List , Simon Glass References: From: Alper Nebi Yasak In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 01/06/2022 11:29, Stefan Herbrechtsmeier wrote: > Hi Simon, > > I want to compress a FPGA Image on the fly via binman but this doesn't > work. I have add a bintool implementation for gzip, add gzip support to > comp_util.py and set `compress` and `compression` property in the binman > node of the u-boot dtsi: > > fpga-2cg { > compatible = "u-boot,fpga-legacy"; > description = "FPGA"; > type = "fpga"; > compression = "gzip"; > load = <(CONFIG_SYS_TEXT_BASE + 0x4000000)>; > > blob-ext { > compress = "gzip"; > filename = "2cg.bit.bin"; > }; > }; > > It works if I remove the `compress` property and use a `2cg.bit.bin.gz` > or remove the header for gzip [1]. > > Regarding the code binman add the compressed size as first word to the > data [2]. The code in spl-fit.c doesn't remove the size [3]. Why is this > size added? I looked into this a tiny bit, git blame eventually ends up at: > commit eb0f4a4cb40264a90a91e10e3ec00d1e0da7fb66 > Author: Simon Glass > Date: 2019-07-20 12:24:06 -0600 > > binman: Support replacing data in a cbfs > > At present binman cannot replace data within a CBFS since it does not > allow rewriting of the files in that CBFS. Implement this by using the > new WriteData() method to handle the case. > > Add a header to compressed data so that the amount of compressed data can > be determined without reference to the size of the containing entry. This > allows the entry to be larger that the contents, without causing errors in > decompression. This is necessary to cope with a compressed device tree > being updated in such a way that it shrinks after the entry size is > already set (an obscure case). It is not used with CBFS since it has its > own metadata for this. Increase the number of passes allowed to resolve > the position of entries, to handle this case. > > Add a test for this new logic. > > Signed-off-by: Simon Glass For the record, I dislike the size header, since as you found out it turns the standard formats into custom formats that nothing else knows. But I'm not familiar with binman's compression parts, I don't know what would go wrong if the header is removed and how. I'm also not sure what happens in the 'obscure case' the commit message mentions.