This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDS570LS31HDK: Update Status Manually (instead of GPIO trigger)

Part Number: TMDS570LS31HDK
Other Parts Discussed in Thread: HALCOGEN

APP_STATUS_ADDRESS - can you change the value (0x5A5A5A5A) manually from inside the application instead of waiting for a trigger from GPIO?

I'd like to send a command to the application, change the status, reset, and the bootloader sees the status change and prepares to receive a new firmware.

I understand you need to be in privileged mode (SVC), but the Fapi_setActiveFlashBank method is hanging before an attempt to write a value in that location.

void RaisePrivilege()
{
//    __asm volatile
//    (
//        "   movs pc, r14_svc                     \n"
//    );

    __asm volatile
    (
        "   mrs     r12, spsr                              \n"
        "   ands    r0, r12, #0x0F      ; return value     \n"
        "   orreq   r12, r12, #0x1F                        \n"
        "   msreq   spsr_c, r12                            \n"
        "   bx      r14                                    \n"
    );
}

  • The current UART bootloader example does not support this feature. You can modify the example code to receive the status from UART terminal. The memory locations for status words should be erased before programming. 

  •  Fapi_setActiveFlashBank is hanging -- the user application is in user mode -- do I need to be in privilege mode to change the status (APP_STATUS_ADDRESS)? And if so -- how do you enter privilege mode?

  • Yes, all the F021 Flash APis should be run in a privileged mode. 

    Once you enter User mode you cannot simply switch to System or Supervisor mode like is shown above. From user mode, an exception is required to enter privilege again thus giving a controlled entry point back from User to Privilege.

    There are two ways software can initiate this: (a) using an SVC call, which will put you into the SWI handler and into supervisor mode, (b) using the System Software Interrupt of the system module (SSI) which will generate an IRQ interrupt for you and put you into the IRQ mode.

  • Thanks but I keep reading that SVC is what I need with NO instructions HOW to do it.  I don't want to return from privilege mode, I want to set the value and reboot. 

  • R14_svc is R14 when system is in Supervisor mode. Please use R14 instead of R14_svc.

    Please use the example code in the application note:

    https://www.ti.com/lit/an/spna218/spna218.pdf?ts=1624563017717&ref_url=https%253A%252F%252Fwww.google.com%252F

  • How important are the alignments in the section configuration? The default an app is created with is align(32), the code in the application note is built with palign(8).

    ; default
    	.intvecs : {} > VECTORS
        .text   align(32) : {} > FLASH0
        .const  align(32) : {} > FLASH0
        .cinit  align(32) : {} > FLASH0
        .pinit  align(32) : {} > FLASH0
        .bss     : {} > RAM
        .data    : {} > RAM
        .sysmem  : {} > RAM
        
    ; app note code
        .intvecs : {} palign(8) > VECTORS
        .text    : {} palign(8) > FLASH0 | FLASH1
        .const   : {} palign(8) > FLASH0 | FLASH1
        .cinit   : {} palign(8) > FLASH0 | FLASH1
        .pinit   : {} palign(8) > FLASH0 | FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM
    	.sysmem  : {} > RAM

  • I've implemented code from the app note, when trying to switch to supervisor - switchCpuMode, I'm getting "Break at address "0x8" with no debug information available, or outside of program code.". Address 08 is SVC but it seems to be missing the code by an offset?

    Update: I tried one of the pre-built link files (TMS570LC43xxFlashLnk.cmd) and the app jumped to _svc when the code reached switchCpuMode. Is there a requirement that VECTORS has to be set to origin=0x00000000 ? If I am to use this app with the bootloader, it needs to be origin=0x00020020.

  • I just tested the code from the app note, it works expected.

    1. copy svc.c, svc.h and _svc.asm to your project

    2. add _svc interrupt ISR to the exception vector table. 

        

  • I have it working too.  But the problem is that this application must work with the bootloader (VECTOR set for APP_START_ADDRESS 20020). It seems the VECTOR must be at zero (0) for the _svc to be in the right place?

    // VECTOR set for bootloader address - APP_START_ADDRESS
        VECTORS (X)      : origin=0x00020020 length=0x00000020 fill=0xFFFFFFFF
        FLASH0  (RX)     : origin=0x00021020 length=0x00027D20 fill=0xFFFFFFFF
        FLASH1  (RX)     : origin=0x00200000 length=0x00200000
        STACKS  (RW)     : origin=0x08000000 length=0x00001300
        RAM     (RWX)    : origin=0x08001300 length=0x0007ED00

    Note: To be clear, this is discussion of the link file for the application that gets updated when uploaded to the bootloader!

    In other words, this works for use with the bootloader, but NOT for SVC:
    VECTORS (X)      : origin=0x00020020 length=0x00000020 fill=0xFFFFFFFF

    this works for SVC but not for use with the bootloader:
    VECTORS (X)      : origin=0x00000000 length=0x00000020 fill=0xFFFFFFFF

    Update:  I set VECTORS to:
    VECTORS (X)      : origin=0x00000050 length=0x00000020 fill=0xFFFFFFFF

    And the resulting disassembly shows that SVC is at 58... 
    20 b _svc
    00000058: EA009586 b _svc

    Which seems to indicate that the interrupts rely on VECTOR being at zero (0) -- not relocatable... even HalCoGen lists SVC at location 00000008.

  • _coreInitRegisters_(); at start-up puts the Hercules into SVC (Supervisor mode) - can you leave it in that mode? I looked at HL_sys_core.asm and I couldn't tell where it returns to User mode.

    Stepping through the startup - CPSR->M is always 1111.