2016-09-14 14:17 GMT+02:00 J Mo <jm...@jmomo.net>: > On 09/11/2016 01:39 AM, Mathias Kresin wrote: >> 11.09.2016 03:36, J Mo: >>> On 09/10/2016 10:27 AM, Mathias Kresin wrote: >>>> >>>> 10.09.2016 03:35, J Mo: >>>>> >>>>> --- a/include/image-commands.mk >>>>> +++ b/include/image-commands.mk >>>>> @@ -168,3 +168,19 @@ define Build/sysupgrade-tar >>>>> --rootfs $(call >>>>> param_get_default,rootfs,$(1),$(IMAGE_ROOTFS)) \ >>>>> $@ >>>>> endef >>>>> + >>>>> +define Build/cameo-sig >>>>> + { \ >>>>> + cameo_sig=$(word 1, $(1)) ;\ >>>>> + align=$(if $(2),$(2),64) ;\ >>>>> + oldsize=$$(stat -c %s $@) ;\ >>>>> + sigsize=$$(echo -n $$cameo_sig | wc -c) ;\ >>>>> + padsize=$$(( ( ( ( $$oldsize + $$sigsize ) / $$align ) + 1 ) >>>>> - ( ( $$oldsize + $$sigsize ) / $$align ) )) ;\ >>>>> + newsize=$$(( $$oldsize + $$padsize )) ;\ >>>>> + echo "Appending Cameo signature: \"$$cameo_sig\", >>>>> oldsize=$$oldsize align=$$align sigsize=$$sigsize padsize=$$padsize >>>>> newsize=$$newsize" ;\ >>>>> + dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync ;\ >>>>> + echo -n "$$cameo_sig" >> $@.new ; \ >>>>> + } >>>>> + @mv $@.new $@ >>>>> +endef >>>> >>>> >>> >>> I'm not doing anything obscure here. This should be self-evident. Add a >>> byte-aligned signature. pad-to can't do that. >> >> >> Well if it would be obvious what you are trying to do I wouldn't ask. >> >> I still don't get what and to which boundary you are trying to align. >> After fixing the build errors I do get the following: >> >> Appending Cameo signature: "AP148AR9880-RT-150127-00", oldsize=5901955 >> align=64 sigsize=24 padsize=1 newsize=5901956 >> >> PreFooter size: 5901956 >> PostFooter size: 5901979 >> >> Neither the pre footer image nor the post footer image is padded to a >> multiple of 64 byte. >> >> Do you want to add the signature to a 64 byte padded image or should the >> image + signature padded to a multiple of 64byte? Where does the 64 byte >> does come from? It doesn't seam to be related to the 128k blocksize of the >> flash. >> > > Okay, I apologize. I don't know WTF I was thinking when I did that. It was > actually working before and then I changed it for reasons I can't explain > properly without drugs. > > padsize=$$(( ( ( ( ( ( $$oldsize + $$sigsize ) / $$align ) + 1 ) * $$align ) > - $$oldsize ) - $$sigsize )) ;\ > > This works.
I've to admit, I'm not sure if you try to troll me. I asked you two times to _explain_ what you are trying to do here. The last time I even provided boiler plate answers. I mean how should one check the formula without knowing what they _should_ do. Mathias _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev