SSD_OTA Upgrade Reference


1. Overview

This article introduces the upgrade solution provided by Sigmastar's platform, which mainly includes the process of packaging, unpacking and upgrading in OTA upgrade. Support partition packaging and partition upgrade.

Upgrade package background server maintenance, terminal download and management, please combine third-party services.


2. Partition packaging process


2.1. Packaging tool introduction

The packaging tool is executed on a Linux server, and the running environment is ubuntu 16.04. Only the required file headers will be generated based on the file currently being upgraded.

The directory where the bin of the packaging tool is located:

project/image/makefiletools/bin/otapack

otapack tool command parameter introduction:

-c --create: Creates an empty upgrade package file header. This command creates the file header and can use -b or -e to add a script to start or end the upgrade.

-b --begin-script: Specify a shell script file on the server and package it into the upgrade package for the script to be executed by the board before the upgrade.

-e --end-script: Specify a shell script file on the server and package it into the upgrade package for the script to be executed by the board after the upgrade is complete.

-a --append: Append new header information to the already created upgrade package. When adding new information, you must inform the upgrade related information . For specific methods, please refer to the example, or in the remaining parameter descriptions as needed configuration.

-s --src-file: Specifies the source file path on the server that needs to be updated.

-d --dst-file: Specify the target file to be updated or the path of the partition node in the target board.

-t --dst-file-size: The size of the target file or partition to be updated, in bytes, which can be expressed in 16/10 hexadecimal.

-m --file-mode: Specify the updated file permissions, refer to Linux mode_t.

--block-update: Set the source file specified in the server as raw partition data.

--ubi-update: Set the source file specified in the server as the volume of the UBI file system.

--file-update: Set the source file specified in the server to be a single file update.

--file-add: Set the source file specified in the server as the newly added file in the target board.

--file-delete: Only update the packaged data header and delete the specified target file on the board.

--dir-update: Scan the contents of the old and new folders, compare the differences, increase and decrease, and then pack them in batches.

--help: Print help information.

--debug: Enable debug information.

Introduction to otaunpack tool command parameters:

-x: unpack and upgrade compressed files

-r: unpack and upgrade uncompressed files


2.2. Examples of general packaging process

  1. Create an empty header

    otapack -c SStarOta.bin
    
  2. If necessary, you can use the -b/-e command to add a script

    otapack -c SStarOta.bin -b start.sh -e end.sh
    
  3. Update the header data according to the files that need to be packaged

    otapack -a SStarOta.bin -s ./images/kernel -d /dev/mtdblock8 -t 0x500000 --block-update
    
  4. Execute step 3 in a loop to package all files

  5. Compress the upgrade package

    gzip SStarOta.bin
    

2.3. Packaging in ALKAID

The OTA packaging process has now been integrated into the Makefile.

When the program is compiled and packaged, enter the command under project:

make image-ota

The following interactive interface will appear, specifying the script path executed on the board, you can choose to add or not to add:

Start scripts:

End scripts:

When packing a partition, the packed partition data is listed:

Make ipl ? (yes/no)

After making the relevant selections, SStarOta.bin.gz will be generated under project/image/output/images/

In the config file that configures the partition, the partition will be configured for packaging.

Example:

File spinand.ubifs.p2.partition.config has variables: OTA_IMAGE_LIST

Append the name of the partition to be packaged after this variable, and add the field xxx$(OTABLK) to the configuration of the partition to configure the path of the target node to be upgraded for the partition.

Only when the partition name is added to OTA_IMAGE_LIST, will the partition be asked for ota upgrade during make image-ota .

All the logic of the partition packaging script is implemented in image/ota.mk , and you can study it yourself if you are interested.


2.4. RAW DATA packaging without file system

Most of the partition upgrade steps are similar. Fill the files to be upgraded into the corresponding mtdblock , and the packaging process is the same. The difference is that in the RAW DATA partition packaging, the creation of the upgrade header and data filling must be realized by itself. Here is an example of the IPL kpartition pacaging of spinand:

define makeota
@read -p "Make $(1) ?(yes/no)" select;  \
if [ "$${select}" == "yes" -o "$${select}" == "y" ]; then   \
    $(foreach n,$(3),$(PROJ_ROOT)/image/makefiletools/bin/otabinheader -s $(2) -d $(n) -t $(4) -p $(5) -a $(IMAGEDIR)/SStarOta.bin;cat $(2) >> $(IMAGEDIR)/SStarOta.bin;) \
fi;
endef

ipl_spinand_mkota_:
    $(call makeota,$(patsubst %_spinand_mkota_,%,$@),$(IMAGEDIR)/ipl_s.bin,$($(patsubst %_spinand_mkota_,%,$@)$(OTABLK)),$($(patsubst %_spinand_mkota_,%,$@)$(PATSIZE)),0)

2.5. ubifs/ squashfs/ jffs2 packaging

If these partitions are newly created and added to OTA_IMAGE_LIST , there is no need to add special processing in ota.mk, and this type of partition upgrade file will be processed uniformly.

The partition upgrade method of UBIFS is slightly different from the other two formats, so please use --ubi-update when packaging UBIFS when packaging


2.6. Individual file packaging

The option to package individual files is --file-update. Currently, there is no package specifically for file update in ALKAID, so users need to add them manually.


3. Partition update process


3.1. Upgrade process


3.2. Note before partition upgrade

Make sure the partition umount is successful before partition upgrade. The relevant umount actions can be made in the start scripts script. To update a file, make sure the file is in a read-write filesystem and has write permissions.

Please find FAE for the otaupack tool.


3.3. Compressed upgrade package update

otaupack -x SStarOta.bin.gz

3.4. Uncompressed upgrade package update

otaupack -r SStarOta.bin

3.5. Upgrade UI display

When upgrading, you can specify a full-screen background image and paste it on the framebuffer. The image supports jpg and png formats. At the same time, the progress bar is drawn in the framebuffer. After version 0.2, otaunpack supports the progress bar and text UI rotation. Set the -s parameter 0/½/3 to support None/90°/180°/270° rotation.

otaunpack -x SStarOta.bin.gz -p upgrade.jpg

3.6. Get upgrade status

The status of the upgrade can be obtained by using the internal variable OTA_STATUS in the END script.

If OTA_STATUS is 0, the upgrade is successful, otherwise -1.


3.7. SPI-NAND Bad Block Handling

In the program packaged and upgraded using the --block-update command, if the mtdblock block device node is set, this operation will not process bad blocks. It is recommended to use this node for nor flash upgrade. If spinand needs to be upgraded and process bad blocks at the same time, Please use --block-update to set the character device node of mtd. The otapack and otaunpack applications can support the use of mtd-utils to deal with bad blocks during upgrade after version 0.2. Please enable nand_write and flash_eraseall in busybox.