• AVR Freaks

AnsweredHot![SOLVED]UART Bootloader and Application Help needed

Page: < 12 Showing page 2 of 2
Author
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/07/18 22:00:46 (permalink)
0
aschen0866
You need to move kseg1_boot_mem_4B0 into the PFM, presumably 9D00_0000 since there is nothing starting at that location.




Hi,
Thank you for the reply. I changed the code as follows.
 

MEMORY
{
kseg1_boot_mem : ORIGIN = (0x9D000000 + 0x1000 + 0x970), LENGTH = 0x490
kseg0_program_mem (rx) : ORIGIN = (0x9D000000 + 0x1000 + 0x970 + 0x490), LENGTH = (0x80000 - (0x1000 + 0x970 + 0x490))
kseg0_boot_mem : ORIGIN = (0x9D000000 + 0x1000), LENGTH = 0x970
kseg1_boot_mem_4B0 : ORIGIN = 0x9D000000 , LENGTH = 0x1000 - 0x4B0
 
...
 
}
 

 
But I am getting an error,
c:\program files (x86)\microchip\xc32\v2.10\bin\bin\gcc\pic32mx\4.8.3\..\..\..\..\bin/pic32m-ld.exe: section .simple_tlb_refill_excpt loaded at [9d000000,9d00000f] overlaps section .cache_init loaded at [9d000000,9d00019b]
 
#21
aschen0866
Super Member
  • Total Posts : 4496
  • Reward points : 0
  • Joined: 2006/01/08 22:18:32
  • Location: San Diego
  • Status: offline
Re: UART Bootloader and Application 2019/07/18 23:05:04 (permalink) ☼ Best Answerby vibhu 2019/08/07 00:11:56
5 (1)
Try this

 
/*************************************************************************
* For interrupt vector handling
*************************************************************************/
PROVIDE(_vector_spacing = 0x00000001);
PROVIDE(_ebase_address = 0x9D001000);
 
/*************************************************************************
* Memory Address Equates
* _RESET_ADDR -- Reset Vector
* _BEV_EXCPT_ADDR -- Boot exception Vector
* _DBG_EXCPT_ADDR -- In-circuit Debugging Exception Vector
* _SIMPLE_TLB_REFILL_EXCPT_ADDR -- Simple TLB-Refill Exception Vector
* _CACHE_ERR_EXCPT_ADDR -- Cache-error Exception Vector
* _GEN_EXCPT_ADDR -- General Exception Vector
*************************************************************************/
_RESET_ADDR = 0x9D000000; /* app entry */
_BEV_EXCPT_ADDR = _RESET_ADDR + 0x380;
_DBG_EXCPT_ADDR = _RESET_ADDR + 0x480;
 
_SIMPLE_TLB_REFILL_EXCPT_ADDR = _ebase_address + 0;
_CACHE_ERR_EXCPT_ADDR = _ebase_address + 0x100;
_GEN_EXCPT_ADDR = _ebase_address + 0x180;
 
/*************************************************************************
* Memory Regions
*
* Memory regions without attributes cannot be used for orphaned sections.
* Only sections specifically assigned to these regions can be allocated
* into these regions.
*
* The Debug exception vector is located at 0x9FC00480.
* The config_<address> sections are used to locate the config words at
* their absolute addresses.
*************************************************************************/
MEMORY
{
/* reset and C startup */
kseg1_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0x490

/* cache init */
kseg1_boot_mem_4B0 : ORIGIN = 0x9D000490, LENGTH = 0xB70

/* TLB exception, general exception, vector table and user app code */
kseg0_program_mem (rx) : ORIGIN = 0x9D001000, LENGTH = 0x7F000

/* Not used */
kseg0_boot_mem : ORIGIN = 0x9D000000, LENGTH = 0
...
}
 

post edited by aschen0866 - 2019/07/18 23:06:08
#22
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/07/19 06:54:54 (permalink)
0
Hi aschen,
 
Thank you Now the code is getting compiled successfully without any errors.
But the application is not running after programming the controller.
 
#23
aschen0866
Super Member
  • Total Posts : 4496
  • Reward points : 0
  • Joined: 2006/01/08 22:18:32
  • Location: San Diego
  • Status: offline
Re: UART Bootloader and Application 2019/07/19 07:27:20 (permalink)
0
Where does the bootloader go when it is ready to run the app? Your old linker script had the application entry point set at (0x9D000000 + 0x1000 + 0x970). It should be just 0x9D000000 now. Other than this, I can't think of anything else.
#24
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/07/21 00:35:02 (permalink)
0
Hi aschen,
 
There is a code block in my bootloader code in system_config.h

/* APP_FLASH_BASE_ADDRESS and APP_FLASH_END_ADDRESS reserves program Flash for the application*/
/* Rule:
1)The memory regions kseg0_program_mem, kseg0_boot_mem, exception_mem and
kseg1_boot_mem of the application linker script must fall with in APP_FLASH_BASE_ADDRESS
and APP_FLASH_END_ADDRESS
2)The base address and end address must align on boundaries according to the flash page size */
#define APP_FLASH_BASE_ADDRESS (0x9D000000)
#define APP_FLASH_END_ADDRESS (0x9D07FFFF)
/* Address of the Flash from where the application starts executing */
/* Rule: Set APP_FLASH_BASE_ADDRESS to _RESET_ADDR value of application linker script*/
#define APP_RESET_ADDRESS (0x9D000000 + 0x1000 + 0x970) //(APP_FLASH_BASE_ADDRESS)

I am guessing I have to change this also according to the changes which you told in the linker file of the user application.
 
Can you please tell me what changes should I do here inorder to make my code work?
 
I changed the

#define APP_RESET_ADDRESS (0x9D000000 + 0x1000 + 0x970) //(APP_FLASH_BASE_ADDRESS)

 
to 

#define APP_RESET_ADDRESS (APP_FLASH_BASE_ADDRESS)

 
My application is running, but the code flow is not going to bootloader when I try to invoke bootloader on reset. It is always going into the application only. 
 
#25
aschen0866
Super Member
  • Total Posts : 4496
  • Reward points : 0
  • Joined: 2006/01/08 22:18:32
  • Location: San Diego
  • Status: offline
Re: UART Bootloader and Application 2019/07/21 16:21:45 (permalink)
0
You'll have to figure out how your bootloader decides whether to stay in the bootload mode or jump to the application. The Harmony "basic" bootloader has this implementation

/******************************************************************************
Function:
static void APP_Bootloader_ForceEvent (void)

Remarks:
Sets a trigger to be passed to force bootloader callback.
Run bootloader if switch_1 is pressed OR
if memory location == '0xFFFFFFFF' otherwise jump to user
application.
*/
int APP_Bootloader_ForceEvent(void)
{
/* Check the switch press to trigger bootloader */
if (BSP_SWITCH_STATE_PRESSED == BSP_SwitchStateGet(BTL_TRIGGER_SWITCH))
{
return (1);
}
/* Check the trigger memory location and return true/false. */
if (*(uint32_t *)APP_RESET_ADDRESS == 0xFFFFFFFF)
return (1);

return (0);
}

Is this what you have?
#26
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/07/21 21:43:15 (permalink)
0
Hi aschen,
 
I am having the same code with some modifications.
 

int APP_Bootloader_ForceEvent(void)
{
if (*(uint32_t *)APP_RESET_ADDRESS == 0xFFFFFFFF)
return (1);

uint8_t count = 0;
appData.handleUSART0 = DRV_USART_Open(0, DRV_IO_INTENT_READWRITE|DRV_IO_INTENT_NONBLOCKING);

do
{
delay_ms(1000);
count++;
if(count == 5)
break;
app_rx_buf = DRV_USART_ReadByte(appData.handleUSART0);
if(app_rx_buf == '$')
flag = true;
else
flag = false;
}while(app_rx_buf != '$');

if(flag == true)
return(1);
else
return(0);
}

 
I tested the code it was working separately. But now when I send '$' symbol on reset it still goes into the application only, It is not going into the bootloader part.
Please Help !
#27
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/07/23 02:28:45 (permalink)
0
Hi aschen,
 
Can you please help me out
#28
maxruben
Super Member
  • Total Posts : 3354
  • Reward points : 0
  • Joined: 2011/02/22 03:35:11
  • Location: Sweden
  • Status: offline
Re: UART Bootloader and Application 2019/07/23 02:47:19 (permalink)
5 (1)
I am going to repeat my previous advice: Use loadables and debug the bootloader together with the application in order to se what actually happens after a reset.
 
/Ruben
#29
vibhu
Starting Member
  • Total Posts : 86
  • Reward points : 0
  • Joined: 2019/02/25 05:37:34
  • Location: 0
  • Status: offline
Re: UART Bootloader and Application 2019/08/07 00:11:10 (permalink)
0
Thank You so much guys aschen0866, maxruben and ric for helping me out. The problem was with the linker script only and after doing the required changes suggested by aschen it is now working.
#30
Page: < 12 Showing page 2 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5