How to build an application firmware extension (NAE file)?

Q

The application firmware (NAI file) is located in the internal application flash (IFLASH2) of netX 90, the maximal size of an NAI file is 512K. If the application firmware is bigger than 512K, it is possible to generate an NAE file as the application firmware extension, it should be flashed to external flash(SQI flash).

How to build an application firmware extension in an application project with netX Studio?

A

Hardware requirements

SQI flash, SDRAM

Application project changes

  • wscript

Add the following parameters by firmware build in the wscript under the Targets. (0x64300000 is Hilscher default start address of the NAE (Application firmware extension) file)

    
        segments_intflash           = ".text.nai_header .text.pagereader .text.pageflasher .ARM.exidx .ARM.extab .text .data",
        segments_extflash          = ".nae_header .nae_text",
        headeraddress_extflash  = 0x64300000,
        sdram_split_offset           = 0x00400000,


  • netx90_app_iflash.ld

External SQI flash memory must be added in the MEMORY regions.

/* Linker script to configure memory regions. */
MEMORY
{
  FLASH     (rx)  : ORIGIN = 0x00000000, LENGTH = 512K
  INTRAM    (rwx) : ORIGIN = 0x000B0000, LENGTH = 32K
  SDRAM     (rwx) : ORIGIN = 0x10000000, LENGTH = 8M
  SQIFLASH  (rx)  : ORIGIN = 0x64000000, LENGTH = 1024K
}

Add section .nae_header and section .nae_text between section .text.pageflasher and section .text in the linker file "netx90_app_iflash.ld".  

Note: If there are already sections .nae_header(NOLOAD) and .nae_data(NOLOAD) at the end of the linker file, they should be removed.

   /* Section prepared for the external SQI Flash content */

     .nae_header :
    {
        __qspi_flash_start__ = .;
    /*  KEEP(*(.app_cpu_hboot_boot_header_nae))  is put here by waf automatically */
        KEEP(*(.app_cpu_header_nae))
    } > SDRAM
    
    .nae_text : 
    {
        KEEP(*(.QFlash*))
        . = ALIGN(4);
            
    /* Pull constant, rarely changed code in front. This helps
     * to make some or big fractions of the firmware file constant.
     * This reduces the amount of flash writes and improves
     * flashing speed during development */
       *libcifXToolkit.a:(.text .text.* .rodata .rodata.*) 
       *liblibc_support.a:(.text .text.* .rodata .rodata.*) 
       *libcifXApplicationDemo.a:(.text .text.* .rodata .rodata.*) 
       __qspi_flash_end__ = .;
    } > SDRAM



  • netx90_app_header.c

Correspondingly add boot header, common header and device info of the NAE header, which should be consistent with the NAI header information.

ATTENTION:
If you have Hil_FileHeaderV3.h version $Id: Hil_FileHeaderV3.h 343 2020-11-09 12:24:03Z ABessler $: or higher version, please use the header HIL_FILE_NAI_NAE_APP_HEADER_V3_0_T instead of HIL_FILE_NAE_HEADER_V3_0_T.

Download NAI and NAE files to the flash

After the wscript, linker file and header file are changed accordingly, you can rebuild your application project, an NAI and an NAE file should be generated under the build folder. Flasher tool of netX Studio can be used to download both files to the flash. Flasher will choose the correct flash type and use the default address automatically by detecting the file extension name. If you use other start offset address, you can change the start offset manually.

How to update NAI and NAE files with maintenance firmware (MFW)

It is possible to update NAI and NAE files together with MFW.

The NAI file and the NAE file should be placed under XIP directory of the fwupdate.zip according ZIP container format (Firmware update).

An NAE Area with the correct start address and content type should be defined in the FDL file so that the MFW knows where to download the NAE file to.

SQI flash and SDRAM should be configured correctly in the hardware configuration file.


Use Flasher tool to download FDL file and HWC file before making a firmware update process.

If NAI/NAE update fails, the SYS led bleibs yellow.

netHOST windows utility can be used to check the system error, which helps to find out the reason.

The error code 0xC0001152 means ERR_HIL_NOT_AVAILABLE.

If the FDL or/and HWC files haven't been changed accordingly, then the MFW will fail to copy the NAE file to the desired location. It will cause this error.


The error code 0xC0001151 means ERR_HIL_INCOMPATIBLE.

Inconsistency of the NAI header and the NAE header will cause this error. (e.g. HwOptions are different)


For other error codes please refer to the FAQ page of firmware validation (Firmware validation for LFW(Protocol stacks) and APP-FW --Troubleshooting guide when MFW fails to start the updated firmware)