MP Image

MP image is used for chip Calibration and Test during mass production.

To meet diverse user requirements, the SDK provides two types of MP image: Shrink MP Image and Expand MP Image. Their differences are as follows:

Image Type

Size

Download Area

Lifetime

Description

Shrink

Small

Flash

Retained after power-off

  • Only includes calibration-related code and peripheral driver.

  • Combined with application image for download.

RAM

Lost after power-off

  • Only includes calibration-related code and peripheral driver.

  • No bootloader required.

  • Downloaded separately, not combined with application.

Expand

Large

Flash

Retained after power-off

  • Includes full SDK code for complex testing.

  • Combined with application image for download.

  • Supports embedding application code to run both calibraction test and customer application in a single image (optional).

Generate Image

Below are the steps to generate MP image:

  1. Refer to Configuring SDK (menuconfig) to modify the project configuration.

    1. Enter CONFIG Mass Production, check Enable MP > MP Mode > shrink to set the MP type to shrink.

    2. Return to the MENUCONFIG FOR General page, check CONFIG WIFI > Enable Wifi to enable Wi-Fi.

    3. Return to the MENUCONFIG FOR General page, check CONFIG BT > Enable BT to enable Bluetooth.

    4. Save and exit.

  2. Refer to Building Code to build the project.

Note

The generated MP image xxx_app_mp.bin is located in {SDK}\amebaxxx_gcc_project.

Combine and Download Image

Typically, MP image does not include application code, it needs to be combined with the application image to switch to the customer application after completing Calibration and Test .

Below are the steps to combine image:

  1. Prepare km4_boot_all.bin, km0_km4_app_mp.bin, and km0_km4_app.bin.

  2. Use Image Tool to combine the images.

    1. Open the Generate tab and input the paths of the three files mentioned above.

    2. Set the Offset according to the Flash Layout in {SDK}\component\soc\usrcfg\amebadplus\ameba_flashcfg.c.

      const FlashLayoutInfo_TypeDef Flash_Layout[] = {
          /*Region_Type,      [StartAddr,     EndAddr]                */
          {IMG_BOOT,          0x08000000, 0x08013FFF}, //Boot Manifest(4K) + KM4 Bootloader(76K)
          //Users should modify below according to their own memory
          {IMG_APP_OTA1, 0x08014000, 0x081F3FFF}, //Certificate(4K) + Manifest(4K) + KM4 Application OTA1 + Manifest(4K) + RDP IMG OTA1
      
          {IMG_BOOT_OTA2, 0x08200000, 0x08213FFF}, //Boot Manifest(4K) + KM4 Bootloader(76K) OTA
          {IMG_APP_OTA2, 0x08214000, 0x083DCFFF}, //Certificate(4K) + Manifest(4K) + KM4 Application OTA2 + Manifest(4K) + RDP IMG OTA2
      
          {FTL,                       0x083DD000, 0x083DFFFF}, //FTL for BT(>=12K), The start offset of flash pages which is allocated to FTL physical map.
          {VFS1,                      0x083E0000, 0x083FFFFF}, //VFS region 1 (128K)
          {VFS2,                      0xFFFFFFFF, 0xFFFFFFFF}, //VFS region 2
          {USER,                      0xFFFFFFFF, 0xFFFFFFFF}, //reserve for user
      
          /* End */
          {0xFF,                      0xFFFFFFFF, 0xFFFFFFFF},
      };
      
    3. Click the Generate button at the bottom to generate the combined image Image_All.bin.

      ../../_images/mp_image_combine_dplus.png
  3. Use Image Tool or 1-N MP Tool to download Image_All.bin to the chip.

Note

km0_km4_app.bin is the customer application image, and km4_boot_all.bin is the bootloader image, both located in {SDK}\amebadplus_gcc_project. Typically, the MP image shares the same bootloader with the application image.

Boot and Switch Image

  1. After downloading Image_All.bin to the chip, reboot the chip. By default, it will run OTA1 (MP image).

    [BOOT-I] IMG2 BOOT from OTA 1, Version: 1.1
    ...
    [WLAN-A] Init WIFI
    [WLAN-A] MP driver
    
  2. Execute Calibration and Test . After completion, enter AT+OTACLEAR to clear the signature of the current image to invalidate the MP image.

  3. Reboot the chip. It will run OTA2 (customer application image).

    [BOOT-I] IMG2 BOOT from OTA 2, Version: 1.1
    

Calibration and Test

Wi-Fi and Bluetooth Calibration

There are two methods for calibrating chip’s Wi-Fi and Bluetooth: Standard Calibration and Fast Calibration. Both methods apply to different test conditions and are included in Shrink MP Image and Expand MP Image.

Calibration Method Comparison

Calibration Method

Cost

Test Duration

Accuracy

Description

Standard Calibration

High

Long

High

Uses professional test equipment for wired tests.

Fast Calibration

Low

Short

Low

Uses Realtek-provided signal board for wireless tests.

Note

  • Only RTL8721Dx supports Fast Calibration.

Standard Calibration

Refer to WS_RTL8721DA_RTL8721DC_RTL8721DG_MP_FLOW.pdf for details.

Fast Calibration

Refer to WS_RTL8721DA_RTL8721DC_RTL8721DG_Fast_MP_FLOW.pdf for details.

Custom Test

Besides Wi-Fi and Bluetooth calibration, MP image supports adding custom tests.

For example, to test GPIO functions of specific pins, implement using APIs defined in {SDK}\component\soc\amebaxxx\hal\src\gpio_api.c. Others like {SDK}\component\soc\amebaxxx\hal\src\serial_api.c and {SDK}\component\soc\amebaxxx\hal\src\spi_api.c apply to UART and SPI function test.

Note

For adding custom AT commands in SDK, refer to AT Commands.

User Data

Besides image, user data can be optionally downloaded to chips during mass production.

Different download methods exist based on data type:

For common data such as audio files, it is recommended to refer to Combine and Download Image to combine it with image into a single file and download to the chip.