Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Chris Packham
2022-09-18T22:57:30Z

Hi Pali,

On Sat, Sep 17, 2022 at 12:37 AM Pali Rohár <pali@kernel.org> wrote:
>
> On Friday 16 September 2022 22:34:52 Chris Packham wrote:
> > I do wonder if the boot seqence and xmodem stuff could be abstracted out to
> > something that could be reused by other tools.
>
> In the past I was thinking about it... but I come to the conclusion that
> it is easier to write specific tools which implements communication with
> just one BootROM. Trying to write one universal thing just opens a lot
> of issues and at the end it would do same thing like if you implement N
> independent applications and then additional "launcher" application
> which starts the correct one.
>
> It looks like that most Marvell SoCs use xmodem protocol. Except 3720
> which uses WTPTP. But as I figured out, every SoC use slightly modified
> protocol based on xmodem. So well, in theory "sx" would work. But if you
> want to have other features (like progress bar or bootrom output or
> speed change) then all this is bootrom specific and has to be
> implemented directly into xmodem state machine. So either you provide N
> xmodem implementations or try to create something "hookable" and since
> beginning I have feeling that "hooks" would just introduce new bugs and
> make it harder to debug.
>
>
> kwboot is currently in the state that it supports kwbimage v0 and
> kwbimage v1 formats, which IIRC covers all 32-bit widely used SoCs from
> kirkwood, dove, armada and switches which integrates those CPUs, and
> probably also avanta. At lot of stages it expects valid kwbimage and
> that is why there is validation at the beginning. It injects 32-bit ARM
> binary code for changing UART speed and requires above SoC (as it
> touches internal registers, which are same on all those mentioned). It
> also contains workarounds for bugs in Armada 385 BootROMs.
>
> I really think that kwboot is now in state when it is not easily
> possible to extend it for different platform without lot of energy and
> extra testing that it does not break something existing.

Having looked more into mox-imager (and WtpDownloader) I've realised
that the AlleyCat5 uses something called "TIM" but it's different to
the format used by Armada-3700. I suspect what I'm actually dealing
with is a TIMv0 that pre-dates the version used by Armada-3700. All
the more reason to do something new instead of trying to shoe-horn it
into one of the existing places. I'll probably end up making a fork of
your mvebu64boot and adapting it (mox-imager just does too much).