LP-AM243: How to write XIP image to Flash in SBL processing?

Part Number: LP-AM243
Other Parts Discussed in Thread: SYSCONFIG, UNIFLASH

Tool/software:

Hello TI experts,

I am trying to modify SBL to write firmware (XIP format) to Flash.
The SDK version is MCU+ SDK v10.00.00.20.

I have two problems here, and I would appreciate it if you could answer them.

<No.1>
I cannot write to Flash in the SBL process. (The return value of Flash_write() is an error.)
The steps I took are as follows.

  1. I removed the firmware read process from the SBL example[*1] and added a Flash write process.

  2. I referred to the OSPI example[*2] for the Flash write process.

  *1: examples/drivers/boot/sbl_ospi
  *2: examples/ospi/ospi_flash_io

The resulting source code (main.c) is as follows.

The Flash writing process starts on line 135.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (C) 2018-2022 Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The execution result is as follows.

Fullscreen
1
2
3
4
5
6
7
DMSC Firmware Version 10.0.8--v10.00.08 (Fiery Fox)
DMSC Firmware revision 0xa
DMSC ABI revision 4.0
Erase Flash (200000)...block=[8], page=[0]
Writing to Flash (src: 70075008, dst: 200000)...Done. status=[-1]
Some tests have failed!!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The Flash writing process has been confirmed to work correctly when running the OSPI example[*2] alone.

The cause of the error in SBL is unknown, so if you have any clues, please let me know.


<No.2>
I want to use the Bootloader module to perform XIP operation on each core,
but when writing the XIP format to Flash, what address should I write the .appimage_xip to?

Should I overwrite it to the same address as the .appimage?

Please tell me the procedure.

Regards,

TAKEDA Taro

  • Hello,

    1. Please change the Region Attributes from the default "NonCached" to "Strongly Ordered" in the SBL_OSPI Sysconfig as shown below:

    2. May I know the use case for using XIP image?

    The SBL OSPI is generally used to boot the normal appimage.

    Regards,

    Prashant

  • Hello Prashant,

    Thank you for your reply.

    I would like to try it, but please wait until mid-January for a reply due to my vacation.

    Regards,

    TAKEDA Taro

  • Hello Prashant,

    Sorry, please wait until around February for a response as I have other work that has a higher priority.

     

    Regards,

    TAKEDA Taro

  • Hello Prashant,

    Thank you for waiting.

    1.
    I was able to write to Flash correctly by following your instructions!
    Thanks!


    2.
    > May I know the use case for using XIP image?
    > The SBL OSPI is generally used to boot the normal appimage.
    In order to minimize the amount of RAM used, I thought about starting the execution binary for each core from ROM.
    Also, since switching DIP-SW is troublesome, I would like to give the SBL the function to write the XIP binary received via serial to the Flash.

    If you have any examples or tips of how to achieve this, please let me know.


    Regards,

    TAKEDA Taro

  • Hello,

    In order to minimize the amount of RAM used, I thought about starting the execution binary for each core from ROM.

    The ROM only boots the SBL. The SBL would boot the application for each core.

    Have you already tried booting the normal appimage? If yes, what is the exact issue you have that you would like to use XIP?

    Regards,

    Prashant

  • Hello Prashant,

    >Have you already tried booting the normal appimage?

    This comment made me realize that there was a serious mistake. Thank you.
    It was that I had not assigned the Code and Text sections to Flash in the MEMORY CONFIGURATOR settings in SysConfig.

    When I assigned them, the size of the output .appimage_xip increased, so I thought that writing it to Flash would be correct.

    However, it did not work.
    The function Bootloader_parseMultiCoreAppImage returns an error.

    If there are any points I should check to XIP working, please let me know.

    Regards,

    TAKEDA Taro

  • Hello Prashant,


    Thank you.

    After reading this guide, I checked the linker command file (linker.cmd) and it was as intended, so there seems to be no problem with the XIP binary I created.

    However, as I mentioned earlier, when I write the serial received XIP file (.appimage_xip) to Flash, it does not work.

    Here, the guide has the following sentence

    The file containing XIP sections is additionally flashed to the flash using the special flash-xip command passed to the flash writer

    I think I could write to Flash in the same way as the flash writer (probably uart_uniflash.py) in the statement, but I don't know how to write it in code.

    Is this idea correct?

    Also, if it is correct, please tell me if there is any code to write XIP files to the Flash.


    Regards,

    TAKEDA Taro

  • Hello Prashant,

    Do you have any information about this?

    Regards,

    TAKEDA Taro

  • Hello,

    The SBL_UART_UNIFLASH uses the following API for writing XIP images to the flash:

    https://github.com/TexasInstruments/mcupsdk-core/blob/next/source/drivers/bootloader/bootloader_uniflash/bootloader_uniflash.c#L144-L144

    You may use the same for your SBL.

    Regards,

    Prashant