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

Pali Rohár
2022-09-16T12:37:07Z

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.