Hello world, I am using P89LV51RD2 micro-controller and using u-vision V2.40a! I want to remotely update user application on the micro-controller.
For doing it,first I need to download user-application image into the external flash. Once the user application is downloaded, I want the bootloader to write the downloaded image into internal flash of the micro-controller.
On power-reset, the bootloader has to check whether the user-application has to be upgraded or not. If the user-application has to be upgraded, then the bootloader has to write downloaded user application image into the internal flash.
Where should I add the bootloader? Can I modify the STARTUP.A51 file to add the bootloader routine just before when the instruction "LJMP ?C_START" is executed? After bootloder executes,How can make sure that interrupt vector table gets redirected to a given location in user application,Can I get help regarding this?
describing the principle org 0 jump starttest org 3 if boot jump EI0ISR // bootloader ISR else jump appbase+3 org b if boot jump T0ISR else jump appbase+6 ... ...
starttest if boot jump to the beginning of the startup.a51 linked with the bootloader else jumo appbase+0
then the application is linked to start a appbase org appbase jump to the beginning of the startup.a51 linked with the application jump to EI0ISR ....
everything in the app done with the noiv qualifier
Erik
Thanks Erik :)!!
I do have a query
In main.c,When I want to update the user application,I will be setting a byte @location 3100H in the internal flash and will do a software reset. When micro-controller starts,In the STARTUP.A51 routine before the control gets shifted to ?C_START, I do call a c routine BOOT_UPDATE.In this routine,I check the content of the address 3100H in the internal flash. If this location is set, I do use the IAP routines to write into the internal flash from the external flash. From location 2000H to 37FFH, I do reserve this area for routines for updating the user application.During user application update, I dont want to erase the area between 2000H and 37FFH. I just want to erase area beyond 3800H. When I modify the existing user application by adding few variables and compare the hex files, I do see the the code area between 2000H and 37FFH getting affected. I do not change anything in the routines that are present between 2000H and 37FFH ! Why does the code segment affected when I add variables in the routines which are defined beyond the location 3800H?
TYPE BASE LENGTH RELOCATION SEGMENT NAME -----------------------------------------------------
* * * * * * * D A T A M E M O R Y * * * * * * * REG 0000H 0008H ABSOLUTE "REG BANK 0" DATA 0008H 000CH UNIT ?DT?_WRITEDATA_TOFLASH?EXTERNAL_FLASH_ROUTINE DATA 0014H 0004H UNIT ?DT?MAIN REG 0018H 0008H ABSOLUTE "REG BANK 3" BIT 0020H.0 0001H.1 UNIT ?BI?MAIN BIT 0021H.1 0000H.1 UNIT ?BI?_WRITEDATA_TOFLASH?EXTERNAL_FLASH_ROUTINE BIT 0021H.2 0000H.1 UNIT ?BI?EXTERNAL_FLASH_ROUTINE BIT 0021H.3 0000H.1 UNIT _BIT_GROUP_ 0021H.4 0000H.4 *** GAP *** DATA 0022H 000BH UNIT _DATA_GROUP_ DATA 002DH 0009H UNIT ?DT?_STRCAT?STRCAT DATA 0036H 0007H UNIT ?DT?_PRINTHEXADDRESS?MAIN DATA 003DH 0001H UNIT ?DT?BULK_ERASE_AND_CONFIGURE?EXTERNAL_FLASH_ROUTINE IDATA 003EH 0001H UNIT ?STACK
* * * * * * * X D A T A M E M O R Y * * * * * * * XDATA 0000H 00A5H UNIT ?XD?BOOTCHECK XDATA 00A5H 0004H UNIT ?XD?_WRITEDATA_TOFLASH?EXTERNAL_FLASH_ROUTINE BL51 BANKED LINKER/LOCATER V5.03 02/21/2011 12:49:08 PAGE 2
XDATA 00A9H 0003H UNIT ?XD?WRITE_DATA_RW_ADDRESS?EXTERNAL_FLASH_ROUTINE XDATA 00ACH 0003H UNIT _XDATA_GROUP_ XDATA 00AFH 0002H UNIT ?XD?EXTERNAL_FLASH_ROUTINE 00B1H 344FH *** GAP *** XDATA 3500H 0218H UNIT ?XD?MAIN
* * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE CODE 0003H 0016H UNIT ?PR?_WAITZZZ?EXTERNAL_FLASH_ROUTINE 0019H 000AH *** GAP *** CODE 0023H 0003H ABSOLUTE CODE 0026H 008FH UNIT ?C_C51STARTUP 00B5H 1F4BH *** GAP *** CODE 2000H 02FBH UNIT ?C?LIB_CODE 22FBH 0005H *** GAP *** CODE 2300H 0015H UNIT ?PR?_STRLEN?STRLEN CODE 2315H 0058H UNIT ?PR?_STRCAT?STRCAT 236DH 0093H *** GAP *** CODE 2400H 013CH UNIT ?PR?BOOT_UPDATE?BOOTCHECK CODE 253CH 033FH UNIT ?PR?WRITE_BOOT_IMAGE?BOOTCHECK 287BH 0085H *** GAP *** CODE 2900H 016CH UNIT INTERNAL_FLASH_ROUT 2A6CH 0094H *** GAP *** CODE 2B00H 0039H UNIT ?PR?LARGE_WAIT_FLASH?EXTERNAL_FLASH_ROUTINE CODE 2B39H 002AH UNIT ?PR?WRITE_ENABLE?EXTERNAL_FLASH_ROUTINE CODE 2B63H 01D2H UNIT ?PR?_WRITEDATA_TOFLASH?EXTERNAL_FLASH_ROUTINE CODE 2D35H 00B2H UNIT ?PR?_READDATA_FROMFLASH?EXTERNAL_FLASH_ROUTINE CODE 2DE7H 0019H UNIT ?PR?READ_STATUS?EXTERNAL_FLASH_ROUTINE CODE 2E00H 0056H UNIT ?PR?WAIT_FLASH?EXTERNAL_FLASH_ROUTINE CODE 2E56H 00B5H UNIT ?PR?_UPDATE_FLASH_ADDRESS?EXTERNAL_FLASH_ROUTINE CODE 2F0BH 003EH UNIT ?PR?WRITE_DATA_RW_ADDRESS?EXTERNAL_FLASH_ROUTINE CODE 2F49H 007DH UNIT ?PR?BULK_ERASE_FLASH?EXTERNAL_FLASH_ROUTINE CODE 2FC6H 009DH UNIT ?PR?_EARSE_FLASH_SECTER?EXTERNAL_FLASH_ROUTINE CODE 3063H 003BH UNIT ?PR?BULK_ERASE_AND_CONFIGURE?EXTERNAL_FLASH_ROUTINE 309EH 0262H *** GAP *** CODE 3300H 008BH UNIT ?C_INITSEG 338BH 0075H *** GAP *** CODE 3400H 00E9H UNIT ?PR?SERIAL_INTERRUPT?MAIN 34E9H 0317H *** GAP *** CODE 3800H 0052H UNIT ?PR?MAIN?MAIN CODE 3852H 0186H UNIT ?CO?MAIN CODE 39D8H 002FH UNIT ?PR?CYCLE_SAVE?MAIN CODE 3A07H 0012H UNIT ?PR?_WAIT?MAIN CODE 3A19H 006BH UNIT ?PR?RECEIVE_OK?MAIN CODE 3A84H 00DEH UNIT ?PR?_PRINTHEXADDRESS?MAIN CODE 3B62H 000DH UNIT ?PR?TIMER2_INIT_9600?MAIN
Hello world, I do have some routines, which I will not modify and these routine occupy memory locations from 2000H-32FFH.I have routines that are defined at locations beyond the address 3300H. When I add any new functions at location beyond 3300H, the code memory content between 2000H-32FFH doesnt get affected.But when a local variable is defined, the code memory gets affected! Why does this happen? Is there any method through which I can control the memory allocation for local variables?
When I define global xdata or global static xdata, I dont see the code memory content getting modified. When I add a local variable in the new routine defined at address beyond location 32FFH or global volatile bit,the code memory content between 2000H-32FFH gets affected.
How can I control this?
Remember that the Keil compiler converts auto variables into global variables for non-reentrant functions, which means that it is very easy to introduce changes that does change the generated code.
This is a workaround for the very limited stack capabilities of the 8051 and makes this processor not so suited for advanced programming where you mix fixed code with recompiled code. When having two precompiled blocks that are expected to interface with each other, it's normally best to create a BIOS-style interface. Either using a table of jump vectors, or a common entry function that routes to the correct function. Just ot make sure that you reduce the amount of binding between the two code blocks.
You shouldn't be trying to. You're trying to fight the tools instead of using them. You'll lose that fight.
Among all the CPU architectures still in active use today, the '51 is about the worst possible you could use for what you're trying to do. That limitation can be overcome by experts, if absolutely necessary, but I rather heavily doubt you're really in that situation.
Whatever your actual problem is: you need to re-think your approach to it from square one.
Thanks Per Westermark and Hans-Bernhard Broeker for your valuable inputs :) !! Once I do complete,will be revert back to discussion forum :) !