Hello,
I have a small problem with my bootloader. I finally made my bootloader to run from flash and receiving the data from pc correctly. I am using an XMC4500 with Dave4.
The space reserverd for the bootloader ranges from 0x0C000000 to 0x0C003FFF.
I erase/write with these functions Flash002_EraseSector (uint32 Address) and Flash002_WritePage (uint32 Address, const uint32 pBuf[]) from the FLASH0002 App. I implemented it into my Dave4 Project
Here are some defines. I made the unchaed Base to start at 0x0C004000 because of the offset in the program that should be later loaded into the flash.
The stauts i receive after each write/erase is an Error (0x02). When i define FLASH002_UNCACHED_BASE as 0x0C000000 the status seems successfull, but when i check the memory in the monitor
it always shows that nothing has been written to the address.
The loaded program should start at 0x0C004000.
I made an offset in the linker script file of the program which will be loaded by the bootloader.
is this correct so far?
If there is no incoming sign from the pc side, the program in the flash should be started.
I used this function to jump to the address 0x0C004000.
But this seems not to work. I always get the message
-- No source available for "0x80042b0" --
Can somebody please help me?
I have a small problem with my bootloader. I finally made my bootloader to run from flash and receiving the data from pc correctly. I am using an XMC4500 with Dave4.
The space reserverd for the bootloader ranges from 0x0C000000 to 0x0C003FFF.
I erase/write with these functions Flash002_EraseSector (uint32 Address) and Flash002_WritePage (uint32 Address, const uint32 pBuf[]) from the FLASH0002 App. I implemented it into my Dave4 Project
Here are some defines. I made the unchaed Base to start at 0x0C004000 because of the offset in the program that should be later loaded into the flash.
Code:
#define FLASH002_SIZE 1024U
/** Base address of the uncached area of the Flash array*/
#define FLASH002_UNCACHED_BASE 0x0C004000U
/** Base address of Sector-0*/
#define FLASH002_SECTOR0_BASE FLASH002_UNCACHED_BASE
/** Base address of Sector-1*/
#define FLASH002_SECTOR1_BASE (FLASH002_UNCACHED_BASE + 0x4000U)
/** Base address of Sector-2*/
#define FLASH002_SECTOR2_BASE (FLASH002_UNCACHED_BASE + 0x8000U)
/** Base address of Sector-3*/
#define FLASH002_SECTOR3_BASE (FLASH002_UNCACHED_BASE + 0xC000U)
#if FLASH002_SIZE>=128U
/** Base address of Sector-4*/
#define FLASH002_SECTOR4_BASE (FLASH002_UNCACHED_BASE + 0x10000U)
/** Base address of Sector-5*/
#define FLASH002_SECTOR5_BASE (FLASH002_UNCACHED_BASE + 0x14000U)
/** Base address of Sector-6*/
#define FLASH002_SECTOR6_BASE (FLASH002_UNCACHED_BASE + 0x18000U)
/** Base address of Sector-7*/
#define FLASH002_SECTOR7_BASE (FLASH002_UNCACHED_BASE + 0x1C000U)
#if FLASH002_SIZE>=256U
/** Base address of Sector-8*/
#define FLASH002_SECTOR8_BASE (FLASH002_UNCACHED_BASE + 0x20000U)
#if FLASH002_SIZE>=512U
/** Base address of Sector-9*/
#define FLASH002_SECTOR9_BASE (FLASH002_UNCACHED_BASE + 0x40000U)
#if FLASH002_SIZE>=768U
/** Base address of Sector-10*/
#define FLASH002_SECTOR10_BASE (FLASH002_UNCACHED_BASE + 0x80000U)
#if FLASH002_SIZE>=1024U
/** Base address of Sector-11*/
#define FLASH002_SECTOR11_BASE (FLASH002_UNCACHED_BASE + 0xC0000U)
Code:
/*
* The function programs one page of the Flash using
* WritePage command
*/
status_t Flash002_WritePage (uint32 Address, const uint32 pBuf[])
{
uint32 status = (uint32) FLASH002_ERROR;
uint32 i;
/* <<<DD_FLASH002_API_3>>> */
/*validate the Address*/
if ((Address < FLASH002_UNCACHED_BASE) || (Address > FLASH002_UNCACHED_LIMIT) || \
((Address & FLASH002_PAGE_MASK) != 0U))
{
status = (uint32) FLASH002_INVALID_PARAM;
}
else
{
/* Clear the flash status register */
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000F5U;
/* Enter page mode, program flash*/
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x00000050U;
/* Load Assembly Buffer*/
for (i=0U; i <(FLASH002_PAGE_SIZE/8U); i++)
{
M32(FLASH002_UNCACHED_BASE + 0x55F0U) = pBuf[2U * i];
M32(FLASH002_UNCACHED_BASE + 0x55F4U) = pBuf[(2U* i) + 1U];
}
/*Launch the write Page command*/
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000AAU;
M32(FLASH002_UNCACHED_BASE + 0xAAA8U)=0x00000055U;
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000A0U;
M32(Address)=0x000000AAU;
/*wait until the operation is complete*/
while (FLASH0->FSR & FLASH_FSR_PBUSY_Msk)
{
/*do nothing*/
}
/* Check if any error occurred during the operation*/
if((FLASH0->FSR & FLASH002_FLASH_ERROR_MSK) == 0U)
{
status = (uint32) DAVEApp_SUCCESS;
}
}
return status;
}
Code:
/*
* The function programs one page of the Flash using
* WritePage command
*/
status_t Flash002_WritePage (uint32_t Address, const uint32_t pBuf[])
{
status_t status = (uint32_t) FLASH002_ERROR;
uint32_t i;
/* <<<DD_FLASH002_API_3>>> */
/*validate the Address*/
if ((Address < FLASH002_UNCACHED_BASE) || (Address > FLASH002_UNCACHED_LIMIT) || \
((Address & FLASH002_PAGE_MASK) != 0U))
{
status = (uint32_t) FLASH002_INVALID_PARAM;
}
else
{
/* Clear the flash status register */
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000F5U;
/* Enter page mode, program flash*/
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x00000050U;
/* Load Assembly Buffer*/
for (i=0U; i <(FLASH002_PAGE_SIZE/8U); i++)
{
M32(FLASH002_UNCACHED_BASE + 0x55F0U) = pBuf[2U * i];
M32(FLASH002_UNCACHED_BASE + 0x55F4U) = pBuf[(2U* i) + 1U];
}
/*Launch the write Page command*/
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000AAU;
M32(FLASH002_UNCACHED_BASE + 0xAAA8U)=0x00000055U;
M32(FLASH002_UNCACHED_BASE + 0x5554U)=0x000000A0U;
M32(Address)=0x000000AAU;
/*wait until the operation is complete*/
while (FLASH0->FSR & FLASH_FSR_PBUSY_Msk)
{
/*do nothing*/
}
/* Check if any error occurred during the operation*/
if((FLASH0->FSR & FLASH002_FLASH_ERROR_MSK) == 0U)
{
status = (uint32_t) DAVEApp_SUCCESS;
}
}
return status;
}
it always shows that nothing has been written to the address.
The loaded program should start at 0x0C004000.
I made an offset in the linker script file of the program which will be loaded by the bootloader.
Code:
MEMORY
{
FLASH_1_cached(RX) : ORIGIN = 0x08004000, LENGTH = 0xfc000
FLASH_1_uncached(RX) : ORIGIN = 0x0C004000, LENGTH = 0xfc000
PSRAM_1(!RX) : ORIGIN = 0x10000000, LENGTH = 0x10000
DSRAM_1_system(!RX) : ORIGIN = 0x20000000, LENGTH = 0x10000
DSRAM_2_comm(!RX) : ORIGIN = 0x30000000, LENGTH = 0x8000
}
If there is no incoming sign from the pc side, the program in the flash should be started.
I used this function to jump to the address 0x0C004000.
Code:
void RunFlash(void)
{
__asm(
"ldr r0, =0x0C004000\n"
"ldr r1, =0xE000ED08\n" //VTOR register
"str r0,[r1]\n"
"ldr sp, [r0], #4\n"
"ldr r15, [R0]"
);
}
-- No source available for "0x80042b0" --
Can somebody please help me?