William Gaatjes
Lifer
Hi, i made a small bootloader that can load an application through xmodem 1k and store that application in flash memory.
Programming works, i have made a small memory dump function to compare the content of the memory with the application binfile. I verified it with a hexviewer and the data is the same. The application i made is really simple, it just makes a pin low so a led will start to emit light. And then hangs into a loop. I have done this in assembly as a test. But as soon as i jump to the application address, my MCU stops responding. Unfortunately i have no JTAG device so i cannot see what is going on.
The clock and both uarts are running as is the PIO controller that controls the state of the output pins. This is all setup in the bootloader.
I have one uart setup as a debug uart where all data is dumped to, to see what is going on. The other connects to TERA TERM so i have a small terminal emulator in the bootloader with some commands such as to upload the application bin file and to start the application.
The first 64KB is for the bootloader and the application starts at address 0x00110000. The flash memory has a size of 256KB, so i have enough space.
The flash starts at 0x00100000.
I have tried everything, but i do not know why it hangs. I tested for misalignment by reading the data at 32bits wide to see if that goes wrong but it is ok.
My MCU is a sam7s256.
What could i have forgotten ?
Here are some code snippets :
I tried it both in c and with inline assembly. But it does not work.
A 32 bit read of the address works :
Programming works, i have made a small memory dump function to compare the content of the memory with the application binfile. I verified it with a hexviewer and the data is the same. The application i made is really simple, it just makes a pin low so a led will start to emit light. And then hangs into a loop. I have done this in assembly as a test. But as soon as i jump to the application address, my MCU stops responding. Unfortunately i have no JTAG device so i cannot see what is going on.
The clock and both uarts are running as is the PIO controller that controls the state of the output pins. This is all setup in the bootloader.
I have one uart setup as a debug uart where all data is dumped to, to see what is going on. The other connects to TERA TERM so i have a small terminal emulator in the bootloader with some commands such as to upload the application bin file and to start the application.
The first 64KB is for the bootloader and the application starts at address 0x00110000. The flash memory has a size of 256KB, so i have enough space.
The flash starts at 0x00100000.
I have tried everything, but i do not know why it hangs. I tested for misalignment by reading the data at 32bits wide to see if that goes wrong but it is ok.
My MCU is a sam7s256.
What could i have forgotten ?
Here are some code snippets :
I tried it both in c and with inline assembly. But it does not work.
Code:
#define APP_START_ADDRESS (*((volatile uint32_t *) 0x00110000)) // =FLASH BASE + 64k.
Code:
static void (*fp)(void); //Execute from address.
void StartApplication(void)
{
uint32_t *p;
AT91C_BASE_AIC->AIC_EOICR = 0xFFFFFFFF; //Disable all interrupts.
AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
AT91C_BASE_PIOA->PIO_SODR = LED1 | LED2 | LED3 | LED4; //set leds off.
p = (uint32_t *)&APP_START_ADDRESS;
Sci1_Puts("Start address = ");
Sci1DumpHex2((uint32_t)p);
Sci1_Puts("\r\nExecute...");
asm volatile(
"mov r0, #1114112 \r\n"
"mov lr,pc \r\n"
"mov pc,r0 \r\n"
);
/*
fp = (void (*)(void))*p;
fp();
*/
A 32 bit read of the address works :
Code:
void Test(void)
{
uint32_t *pointer;
uint32_t t;
pointer = (uint32_t *)&APP_START_ADDRESS;
Sci1_Puts("DUMP address = ");
Sci1DumpHex2((uint32_t)pointer);
Sci1_Puts("\r\n");
Sci1_Puts("DUMP data = ");
t = *pointer;
Sci1DumpHex2(t);
Sci1_Puts("\r\n");
}
Last edited: