The "weak" reference just means that the routine will be replaced by a routine in your code of the same name. When using C this is simple, the names will always be identical but C++ name mangles the functions (for function overloading etc) so the compiled name will probably not match the default ISR name. You need to wrap the function (or at least a forward reference, I'm not sure of specifics I mostly work in C) in an extern "C" wrapper to force the compiler to not mangle the name.
extern "C" {
void SysTick_Handler(void)
{
// do whatever
}
}
It is possible. I've done it. But 8051 variants really don't like doing this. If you're interested in why they don't like doing this, read up on Harvard Architecture.
The first reply in the thread you linked actually told you the two different ways this can be achieved. The first, mapping XDATA over your code memory and then using the XDATA assembly instructions to write into that space is more trouble than it's worth. I say this because your micro does contain those "magic instructions" that the poster references.
You need to link in a library that you can get from the Atmel website and then you can make calls to these magic instructions and write to the flash via In-System Programming (ISP) also called In-Application Programming (IAP) in the literature.
Have a look at the datasheet. You should probably read all of Section 24. But the important part is Section 24.10.
24.10 API Call Description
The IAP allows to reprogram a microcontroller on-chip Flash memory
without removing it from the system and while the embedded application
is running.
The user application can call some Application Programming Interface
(API) routines allowing IAP. These API are executed by the bootloader.
To call the corresponding API, the user must use a set of Flash_api
routines which can be linked with the application.
Example of Flash_api routines are available on the Atmel web site on
the software application
note:
C Flash Drivers for the AT89C51RD2/ED2
The API calls description and arguments are shown in Table 24-10.
24.10.1 Process
The application selects an API by setting R1, ACC, DPTR0 and DPTR1
registers.
All calls are made through a common interface “USER_CALL” at the
address FFF0h.
The jump at the USER_CALL must be done by LCALL instruction to be able
to comeback in the application.
Before jump at the USER_CALL, the bit ENBOOT in AUXR1 register must be
set.
Best Answer
A bootloader is no different from a normal program. You will need to think of the following things first:
There is no single "bootloader" - it depends on your requirements.