I'm trying to use the updater_F02x.c file and project to load my firmware and reset to run it. But the part I'm using is c8051f120.h. I understand the 02 code should work with the 120. I understand to place the code at a specific memory address you use these parameters during link: CODE(1000H, ?PR?MAIN?UPDATER_F02X(1000H)) I want to place this updater code very high in memory, about 4k below 128k, which would be bank 3, addr EFFF. How do I place it at bank 3, addr EFFF. Do I simply forget about the banks and specify the address as if there were no banks, as so? CODE(1F000H, ?PR?MAIN?UPDATER_F02X(1F000H)) I'm new at this kind of thing and would appreciate a response that takes this into consideration. BTW, I am using the Cygnal IDE and it crashes like very 10 minutes. Very annoying!
Ignoring code banking for now since both my bootloader code and the application code both fit into the Common area ... I am doing this in C. I removed the ISR's from my application code and made them into normal functions (I will call them ISR-stubs). I put the ISR's in the bootloader code. The ISR's in the bootloader code has the locations of the application codes ISR-stubs hardcoded. Each ISR in the bootloader code executes the ISR-stubs in the application code via a function pointer. Someone suggested I get rid of main() in the application code because the compiler/linker adds in the startup code and the startup code is not necessary because it's already included with the bootloader code at 0000H. However, the linker spewed many 'address space overflow' errors because without a main(), the linker cannot perform overlaying of DATA variables. Any thoughts on this? The CODE memory for the bootloader code and application code cannot overlap. So the application code is located at 0C00H, above the bootloader code. I put in a function called EntryPoint() that does nothing but call main(). EntryPoint() is located at 0C00H, so it jumps right to main instead of executing the STARTUP code. The DATA memory for the bootloader code and application code cannot overlap. So the bootloader DATA is located at 0064H. This all seems to work. The problem I am now having is how can I upgrade and modify the application code such that all DATA is located below 0064H and the ISR-stubs are always at the address locations the bootloader code has them hardcoded to? I mean, when I update the application code surely I may need to add more variables which will increase the DATA memory. Then I'll have to update the bootloader code. But that defeats the entire purpose, doesn't it? Did I do this wrong? Any ideas? Here is the linker command for my application code: RS(255) PL(68) PW(78) CO(0C00H, ?PR?ENTRYPOINT?MAIN(0C00H)) Here is the linker command for my bootloader code: DA(64H) RS(256) PL(1000) PW(132) Here are the ISR's in the bootloader code calling the ISR_stubs in the application code:
// function pointers to jump to application code static void (*f_main)(); static void (*f_isr)(); void UART_RX_ISR() interrupt 4 { f_isr = (void code*)0x6BFA; f_isr(); } void Timer0_ISR() interrupt 1 { f_isr= (void code*)0x2F60; f_isr(); } void timer2_ISR() interrupt 5 { f_isr = (void code*)0x74FF; f_isr(); } void ASDC0_ISR() interrupt 15 { f_isr = (void code*)0x3A7C; f_isr(); } void main (void) { // disable watchdog WDTCN = 0xde; WDTCN = 0xad; // disable interrupts EA = 0; // launch the application code f_main = (void code*)0x0C00; f_main(); }