Bootloader + FreeRTOS + SAM7X

I am trying to use FreeRTOS with a bootloader residing in my AT91SAM7X256 flash.  I can succesfully reprogram the flash section of my processor with FreeRTOS code.  Then, my booloader jumps into RTOS code and goes through inits.  I can create tasks, but the program seems to stop when it is time to load the first task.  Does anyone have an idea?  Is there an initilisation I must do before jumping in RTOS code without resetting my processor?

Bootloader + FreeRTOS + SAM7X

is the processor in supervisor mode.

Bootloader + FreeRTOS + SAM7X

I have found out the processor was not reinitiliazed correctly before starting FreeRTOS. I have used the reset peripherals command before jumping to RTOS code and it seems to run now! The only problem that remains is with USB: my bootloader only uses serial port.  Since I am using the AT91SAM7X dev board, the processor is USB powered.  When I connect the USB cable, the device is not answering, thus not recognized by my PC.  Is there a way to resend the information to the PC when FreeRTOS starts or do I have to initialize USB connection in my bootloader?

Bootloader + FreeRTOS + SAM7X

It depends on the wiring of your hardware. Some hardware allows you to toggle the USB pull up resistor to indicate to the host that the USB has been disconnected then reconnected again. The Atmel SAM7S dev kit lets you do this, the SAM7X dev kit doesn’t because the resistor is just hard wired.

Bootloader + FreeRTOS + SAM7X

I have modified the demo board hardware, and have modifies RTOS code so that I can toggle the pull-up and it works! Thanks for the advice.

Bootloader + FreeRTOS + SAM7X

I am writing a SD bootloader for SAM7X512. The bootloader resides in flash from 0x0000 to 0x8000 and the FreeRTOS application start from 0x8000. The FreeRTOS app linker script is modified as follows: …
MEMORY
{
flash : ORIGIN = 0x00108000, LENGTH = 480K
ram : ORIGIN = 0x00200000, LENGTH = 128K
}

                   . = 0x8000;
startup : { *(.startup)} >flash
… The bootloader jumps 0x8000 as follows: asm(”mov r3, #1n”);
asm(”lsl r3, r3, #15n”);
asm(”bx r3n”); After jumping the app did not start. I think I am missing something. I am very much appreciated if somebody can give helps.

Bootloader + FreeRTOS + SAM7X

Actually after bootloader jumping to 0x8000, the application starts and all tasks were created, but all interrupt seemed gone so that vPreemptiveTick was not triggered any more. Do I need remap the interrupt vectors or something else? Currently I just simple modified the linker script. Both bootloader and application ld files are same as that of FreeRTOS AT91SAM7x demo provided except changing one line for booltloader below and two lines for app given in the previous message: …
MEMORY
{
            flash : ORIGIN = 0x00100000, LENGTH = 32K
            ram : ORIGIN = 0x00200000, LENGTH = 128K
} I would be grateful if someone could give some hints how to fix the problem.

Bootloader + FreeRTOS + SAM7X

You will almost definitely have to remap the vector table if you are using a bootloader. Regards.

Bootloader + FreeRTOS + SAM7X

Hi Richard, Thank you very mich for your suggestions. Previously I was using PIC and Renesas chip. SAM7 chip is reletive new for me and I do not know how to remap the exception vectors (I tried to remap them in boot.s to staring from 0x00, but the app could not start). Could you please give me a codesnip to remap vector table you mentioned? For PIC, remapping all vectors can be done in the linker script. For SMA7, is remapping vectors done in boot.s?  Thank you again for your help.

Bootloader + FreeRTOS + SAM7X

Hi Richard, I did not describe clearly in the last email. I added the following piece of code in the boot.s:
/*===================== Vector table remap ===========================*/
    .global  .reset_start
    .global  .vectors_end
    .equ  __excVecStart, 0x108000   /* .reset_start = 0x108000 */
    .equ  __excVecEnd,   0x108038   /* .vectors_end = 0x108038 */
    .equ  __ramStart,    0x200000
    .equ  __AT91C_BASE_MC, 0xFFFFFF00
    .equ  __AT91C_MC_RCB,  0x01
    .equ  __MC_RCR,        0x00
    ldr     r0, =__excVecStart
    ldr     r1, =__ramStart
    ldr     r2, =__excVecEnd
copy:
    ldr     r3, [r0], #4
    str     r3, [r1], #4
    cmp     r0, r2
    bne     copy
    /* Remap exception vectors at address 0*/
    ldr     r0, =__AT91C_BASE_MC
    ldr     r1, =__AT91C_MC_RCB
    str     r1, [r0, #__MC_RCR]
/*=====================================================================*/
I insert the above code between

msr   CPSR_c, #MODE_SYS|I_BIT|F_BIT /* System Mode */
mov   sp, r0
<inserted code above>
/* We want to start in supervisor mode.  Operation will switch to system
    mode when the first task starts. */
msr   CPSR_c, #MODE_SVC|I_BIT|F_BIT The vector addresses are copy from map file see below:
                0x00008000                . = 0x8000 startup         0x00108000       0x38
*(.startup)
.startup       0x00108000       0x38 C:UsersyhuangAppDataLocalTempccClEVET.o
                0x00108000                .reset_start
                0x00108038                .vectors_end prog            0x00108038    0x20424
*(.text)
.text          0x00108038      0x100 obj/main.o It seems to me the vector table has been copy to address 0, but the application does not start. It stops in the first vPortISRStartFirstTask. I guess no time tick interrupt. Any suggestion? Thank you. Yuantu

Bootloader + FreeRTOS + SAM7X

Hi Yuantu Huang! How you solved your problem?

Bootloader + FreeRTOS + SAM7X

Hi Yuantu Huang! How you solved your problem?