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.

TM4C129X Custom Bootloader

Hello Experts,

I am using TM4C129X micro-controller and I am writing custom boot-loader to read the binary stored in on-chip SPI Flash but before that I am trying to debug the UART based code which is embedded with it and can be enabled by removing comment of #define UART_ENABLE_UPDATE.

But the issue I am facing is while debugging using Stellaris In-Circuit Debug Interface the code stops at some instruction and I cannot proceed further such as currently the code stops and freezes in  ConfigureDevice(void) function at instruction HWREG(GPIO_PORTA_BASE + GPIO_O_AFSEL) |= UART_PINS; its assembly instruction is HWREG(GPIO_PORTA_BASE + GPIO_O_AFSEL) |= UART_PINS;
20000090:   490F     LDR             R1, $C$CON4
20000092:   6808     LDR             R0, [R1]
20000094:   F0400003 ORR.W           R0, R0, #3
20000098:   6008     STR             R0, [R1]


My code freezes at line 20000092:   6808     LDR             R0, [R1] and I cannot step further.

Also some times the IDE gives error in dis-assembly window as Memory Map Prevented reading of Memory XXXX code=[yyyy].

  • Hello Gaurav,

    The issue is that you are using TM4C123 boot loader functions instead of TM4C129. On TM4C123 the registers SYSCTL_RCGC0, SYSCTL_RCGC1 and SYSCTL_RCGC2 are now replaced by SYSCTL_RCGCUART and SYSCTL_RCGCGPIO. You would need to make the changes as follows

    replace

        HWREG(SYSCTL_RCGC2) |= SYSCTL_RCGC2_GPIOA;
        HWREG(SYSCTL_RCGC1) |= SYSCTL_RCGC1_UART0;

    by

        HWREG(SYSCTL_RCGCGPIO) |= SYSCTL_RCGCGPIO_R0;
        HWREG(SYSCTL_RCGCUART) |= SYSCTL_RCGCUART_R0;

    Regards

    Amit

  • Thank u very much for your reply Amit.

    How should I get to know the difference between APIs of TM4C129X and TM4C123?

    what is the API of TM4C129X for

    HWREG(SYSCTL_RCC) = ((HWREG(SYSCTL_RCC) & ~(SYSCTL_RCC_OSCSRC_M)) | SYSCTL_RCC_OSCSRC_MAIN);

  • Hello Gaurav,

    You can refer to the following document for differences.

    http://www.ti.com/lit/an/spma065/spma065.pdf

    Regards

    Amit

  • Hello Amit,

    Thank you for all your valuable time and assistance. It really helped me.

    One more thing I would like to ask you that, whenever I am trying to erase a particular memory location (0x00002000) of on-chip flash memory from BSL code (the BSL is located at address 0x00000000) the BSL is itself getting erased.

    I tried to protect the starting 64KB block of flash from BSL but then I was not able to write anything at different location (0x00002000).

    Apart from these things, previously when I was not protecting the BSL area, I was able to update the on-chip flash with the binary I want (it was visible in memory browser of CCS), and when I was trying to jump at that location using ((void (*)(void))0x00002000)(); the code was not getting executed.

    Also when I change the update address from 0x00002000 to 0x00000000 then my updated code was getting executed which was a simple LED blink by simply providing a hardware reset.

    So, the question is how I can update the flash by simultaneously protecting the BSL code area and how I can start my main application which is updated using BSL?

  • Hello Gaurav,

    The TM4C129 memory is 8KB sector size but then it spans over 2 banks making it 16KB (0x4000). Since you tried to erase 0x2000 onwards the entire region from 0x0 to 0x3FFC is erased. Hence please move the code to 0x4000 onwards and then erase from 0x4000 onwards.

    What you need to jump to the application code by loading SP with content of 0x4000 and PC with content of 0x4004. You can write a simple inline assembly code like

    ldr sp, [0x4000]

    ldr pc, [0x4004]

    Regards

    Amit

  • Hi Amit,

    Actually I am facing a bit difficulty. The Bootloader protection problem is solved by moving the Application to address 0x4000.

    I am not able to load the contents of SP and PC.

    I am using in-line assembly as follows:

     NVIC_VTABLE_R = 0x00004000;
    __asm("    ldr     r1, [r0]\n"
            "    mov     sp, r1"); 
      __asm("    ldr     r0, [r0, #4]\n"
            "    bx      r0\n");

    I will look into the issue and try to solve it.

    Thank you very much for providing all your assistance.