public inbox for rulkc@linuxtesting.org
 help / color / mirror / Atom feed
* [rulkc] [PATCH v1 00/11] Amlogic: ADNL and Optimus protocols support
@ 2025-07-29 18:28 avkrasnov
  2025-07-29 18:29 ` [rulkc] [PATCH v1 01/11] arch: arm: meson: sm: add commands to reboot device in different modes avkrasnov
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: avkrasnov @ 2025-07-29 18:28 UTC (permalink / raw)


This patchset adds support of two Amlogic firmware burning protocols:
ADNL and Optimus. Each protocol is supported on the following SoC:

axg, g12a, g12b, sm1 - Optimus.
a1, s4, a5, c1, c2, c3, sc2, t3, t7, p1 - ADNL.

Both work in fastboot manner, but significant feature is that they are
supported by current Amlogic BootROMs. As transport both use USB:
device is switched to gadget mode and then it can communicate with PC.
On PC side protocols are supported by:

1) https://github.com/superna9999/pyamlboot (with some limitation)

   For example:
   pyamlboot/./ubt.py --img <image> --wipe all --reset

   Note, image has special format, specific for Amlogic.

2) Proprietary vendor tools.

As protocols are supported by BootROM, it allows to "resurrect" devices
when boot image (BL2, Uboot) missed/invalid. Typical flow for such cases
is (both protocols):

      DEVICE                       PC

                          *-------------------*
                          |                   |
                          | Runs update tool, |
                          | waits for device  |
                          |    on USB bus.    |
                          |                   |
                          *-------------------*
                                    |
*---------------------*             |
|      Power on       |<-----<------/
*---------------------*
          |
          |
*---------------------*
|                     |
| Boot ROM switches   |
| device to USB gadget|>----->------\
| mode and waits for  |             |
| commands.           |             |
|                     |             |
*---------------------*             |
                                    |
                          *-------------------*
                          | Detects device on |
                          |     USB bus.      |
                          *-------------------*
                                    |
                                    |
                          *-------------------*
                          |  Sends BL2 image  |
                          |     over USB.     |
                          *-------------------*
                                    |
*---------------------*             |
|     Boot ROM runs   |<-----<------/
|       BL2 image.    |
*---------------------*
          |
          |
*---------------------*
|    BL2 waits for    |>----->------\
|  Uboot image (FIP). |             |
*---------------------*             |
                                    |
                          *-------------------*
                          | Sends Uboot image |
                          |     over USB.     |
                          *-------------------*
                                    |
*---------------------*             |
|  BL2 runs received  |<-----<------/
|     Uboot image.    |
*---------------------*
           |
           |
*---------------------*
|   Uboot waits for   |>----->------\
|      commands.      |             |
*---------------------*             |
                                    |
                          *-------------------*
                          | Sends commands to |
                          |    over USB.      |
                          *-------------------*
                                    |
*---------------------*             |
| Uboot processes     |             |
| commands: erases,   |             |
| writes NAND, checks |<-----<------/
| CRC of written data |
| etc.                |
*---------------------*
           |
           |
*---------------------*
| Uboot does reboot   |
*---------------------*

There is also another mode to operate both protocols when  we run not
from BootROM, but from Uboot shell. To do that, we enter protocol
specific command in shell ("adnl" or "optimus"). In this case Uboot
switches device to gadget mode, write some value to special register
and does reboot. Then BootROM checks above mentioned register and then
switches device to gadget mode. After that flow from above is executed.
This mode has same purposes as image update by 'fastboot'.

Limitations:
1) Only limited set of each protocol commands are supported -
   it is enough to update image. But, for example 'secureboot'
   feature is not implemented.
2) ADNL was tested on A1 SoC only.
3) Optimus was tested on AXG SoC only.

For more details of each protocol pls see the following:
ADNL - drivers/usb/gadget/amlogic/adnl/f_adnl.c
Optimus - drivers/usb/gadget/amlogic/optimus/f_optimus.c.

Arseniy Krasnov (8):
  arch: arm: meson: use 'meson_sm_call()' in 'meson_sm_pwrdm_set()'
  usb: gadget: fastboot: make part of USB fastboot code shared
  usb: gadget: amlogic: common code for Amlogic flashing commands
  mtd: rawnand: meson: move some defines to dedicated header
  arch: arm: meson: bootloader write support
  arm: meson: a1: add A1_SYSCTRL_SEC_STICKY_REG2
  usb: gadget: amlogic: implement ADNL protocol
  arm: meson: a1: ADNL protocol support

Vladimir Mitrofanov (3):
  arch: arm: meson: sm: add commands to reboot device in different modes
  usb: gadget: amlogic: implement Optimus protocol
  arch: arm: axg: Optimus protocol support

 arch/arm/include/asm/arch-meson/a1.h          |  19 +
 arch/arm/include/asm/arch-meson/axg.h         |  12 +
 arch/arm/include/asm/arch-meson/nand.h        |  34 +
 arch/arm/include/asm/arch-meson/rawnand.h     |  38 +
 arch/arm/include/asm/arch-meson/sm.h          |  98 +-
 arch/arm/include/asm/arch-meson/spinand.h     |  43 +
 arch/arm/mach-meson/Kconfig                   |  31 +
 arch/arm/mach-meson/Makefile                  |   4 +-
 arch/arm/mach-meson/board-a1.c                |  32 +-
 arch/arm/mach-meson/board-axg.c               |  12 +
 arch/arm/mach-meson/board-common.c            |  32 +
 arch/arm/mach-meson/rawnand.c                 | 291 ++++++
 arch/arm/mach-meson/sm.c                      |  43 +-
 arch/arm/mach-meson/spinand.c                 | 158 ++++
 cmd/Kconfig                                   |  14 +
 cmd/meson/Makefile                            |   2 +
 cmd/meson/adnl.c                              |  27 +
 cmd/meson/gadget.c                            | 183 ++++
 cmd/meson/gadget.h                            |  28 +
 cmd/meson/optimus.c                           |  21 +
 drivers/mtd/nand/raw/meson_nand.c             |  13 +-
 drivers/sm/meson-sm.c                         |   3 +
 drivers/usb/gadget/Kconfig                    |   2 +
 drivers/usb/gadget/Makefile                   |   4 +-
 drivers/usb/gadget/amlogic/Kconfig            |  12 +
 drivers/usb/gadget/amlogic/adnl/Kconfig       |  29 +
 drivers/usb/gadget/amlogic/adnl/Makefile      |   4 +
 drivers/usb/gadget/amlogic/adnl/adnl.h        | 124 +++
 .../gadget/amlogic/adnl/adnl_buff_manager.c   | 316 +++++++
 drivers/usb/gadget/amlogic/adnl/adnl_media.c  | 235 +++++
 .../usb/gadget/amlogic/adnl/adnl_storage.c    | 140 +++
 drivers/usb/gadget/amlogic/adnl/f_adnl.c      | 835 ++++++++++++++++++
 drivers/usb/gadget/amlogic/optimus/Kconfig    |  12 +
 drivers/usb/gadget/amlogic/optimus/Makefile   |   7 +
 .../usb/gadget/amlogic/optimus/f_optimus.c    | 687 ++++++++++++++
 .../gadget/amlogic/optimus/optimus_download.c | 188 ++++
 .../gadget/amlogic/optimus/optimus_download.h |  86 ++
 drivers/usb/gadget/f_fastboot.c               | 295 +------
 drivers/usb/gadget/f_fastboot_common.c        | 320 +++++++
 drivers/usb/gadget/f_fastboot_common.h        |  71 ++
 include/meson/sm.h                            |   3 +
 41 files changed, 4202 insertions(+), 306 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-meson/nand.h
 create mode 100644 arch/arm/include/asm/arch-meson/rawnand.h
 create mode 100644 arch/arm/include/asm/arch-meson/spinand.h
 create mode 100644 arch/arm/mach-meson/rawnand.c
 create mode 100644 arch/arm/mach-meson/spinand.c
 create mode 100644 cmd/meson/adnl.c
 create mode 100644 cmd/meson/gadget.c
 create mode 100644 cmd/meson/gadget.h
 create mode 100644 cmd/meson/optimus.c
 create mode 100644 drivers/usb/gadget/amlogic/Kconfig
 create mode 100644 drivers/usb/gadget/amlogic/adnl/Kconfig
 create mode 100644 drivers/usb/gadget/amlogic/adnl/Makefile
 create mode 100644 drivers/usb/gadget/amlogic/adnl/adnl.h
 create mode 100644 drivers/usb/gadget/amlogic/adnl/adnl_buff_manager.c
 create mode 100644 drivers/usb/gadget/amlogic/adnl/adnl_media.c
 create mode 100644 drivers/usb/gadget/amlogic/adnl/adnl_storage.c
 create mode 100644 drivers/usb/gadget/amlogic/adnl/f_adnl.c
 create mode 100644 drivers/usb/gadget/amlogic/optimus/Kconfig
 create mode 100644 drivers/usb/gadget/amlogic/optimus/Makefile
 create mode 100644 drivers/usb/gadget/amlogic/optimus/f_optimus.c
 create mode 100644 drivers/usb/gadget/amlogic/optimus/optimus_download.c
 create mode 100644 drivers/usb/gadget/amlogic/optimus/optimus_download.h
 create mode 100644 drivers/usb/gadget/f_fastboot_common.c
 create mode 100644 drivers/usb/gadget/f_fastboot_common.h

-- 
2.30.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-07-31  1:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-29 18:28 [rulkc] [PATCH v1 00/11] Amlogic: ADNL and Optimus protocols support avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 01/11] arch: arm: meson: sm: add commands to reboot device in different modes avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 02/11] arch: arm: meson: use 'meson_sm_call()' in 'meson_sm_pwrdm_set()' avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 03/11] usb: gadget: fastboot: make part of USB fastboot code shared avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 04/11] usb: gadget: amlogic: common code for Amlogic flashing commands avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 05/11] mtd: rawnand: meson: move some defines to dedicated header avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 06/11] arch: arm: meson: bootloader write support avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 07/11] arm: meson: a1: add A1_SYSCTRL_SEC_STICKY_REG2 avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 08/11] usb: gadget: amlogic: implement ADNL protocol avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 09/11] arm: meson: a1: ADNL protocol support avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 10/11] usb: gadget: amlogic: implement Optimus protocol avkrasnov
2025-07-29 18:29 ` [rulkc] [PATCH v1 11/11] arch: arm: axg: Optimus protocol support avkrasnov
2025-07-31  1:07 ` [rulkc] [PATCH v1 00/11] Amlogic: ADNL and Optimus protocols support slava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®