AN 1011: TinyML Applications in Altera FPGAs Using LiteRT for Microcontrollers

ID 848984
Date 4/07/2025
Public
Document Table of Contents

4.2.1.2. Running through Ashling* RiscFree* IDE for Altera® FPGAs Debugger

You can customize the ATF BL2 source code to generate a custom bl2.bin file that allows you to download the SSBL (bl31.bin) and the application manually via the Ashling RiscFree debugger tool

Follow these steps:

  1. Download the ATF source code.
    $ cd $TOP_FOLDER
    $ git clone -b socfpga_v2.11.0 https://github.com/altera-opensource/arm-trusted-firmware atf_tinyml
    
  2. Customize the ATF source code.

    BL2 must be customized in a way that allows the developer to debug the application or use the debugger tools to manually download the SSBL and the application binary files. Without this customization, you can generate the default BL2 version which expects the BL31 and the application to stored in QSPI flash (as shown in Booting from QSPI Flash).

    To generate a BL2 version that can be debugged, follow the steps below:
    1. Navigate to bl2_plat_setup.c file
      $ cd $TOP_FOLDER/atf_tinyml/plat/intel/soc/agilex5/
    2. Before the end of switch (boot_source) function, add the following codes:
      …
      	NOTICE("%s, %s: BL2: Dummy BP for loading next images \n", __DATE__, __TIME__);
      	mmio_write_32(0x10D12224, BIT(1));
      	while (mmio_read_32(0x10D12224) != 0);
      …
      
    3. Save the bl2_plat_setup.c file.
    4. Compile the ATF to generate Bl2 and BL31 binary files using the command below.
      $ cd $TOP_FOLDER/atf_tinyml
      $ ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- make -j$(nproc) 
      PLAT=agilex5 bl2 bl31 SOCFPGA_BOOT_SOURCE_QSPI=1 DEBUG=1 LOG_LEVEL=50 
      PRELOADED_BL33_BASE=0x80100000
      

      Where:

      DEBUG=1 isto enable the debug build.

      LOG_LEVEL=50 is to print some useful debug messages.

After that, you can navigate the build directory to find the required files, as below:
$ cd $TOP_FOLDER/atf_tinyml/build/agilex5/debug/

The above flow generates the required BL2 and BL31 images. These files are used for debug purposes; the BL2 is loaded once the HPS .rbf file is loaded into the board, and BL31 is loaded into the board via Ashling RiscFree debugger tool.