g g wrote:
How do you combine bootloader with application code?
I work with S19 files (assembly language). If you use CW or some other tool, make it produce S19 files (instead of ELF or whatever other non-ASCII format).
Once you have your two S19 files (one for your bootloader, and one for your application), it's very simple.
Simply remove the S9 record from the first file (but not both) to avoid confusing certain image burning applications that assume S9 is the end of your image, and concatenate the result into a single file. (Depending on your OS, you will have to use appropriate command line commands. Examples (assuming app.s19 is first with S9 record removed):
Under Windows:
copy app.s19+boot.s19 image.s19
Under Linux:
cat app.s19 boot.s19 > image.s19
This can all go into your makefile.
In case of my stand alone bootloader i have NVPROT set at 0xFD (FPS set at 1E - protect 8Kbytes of flash at range 0x0_E000–0x0_FFFF).
I assume 8KB is the size of your bootloader alone, and not the combination of app and bootloader. Because you should only protect the bootloader Flash so that the bootloader can update the app region of the Flash. So, for 8KB bootloader, $1E seems correct. But, because of the FPOP bit in position 0 inside FPROT, you need to shift this value one bit to the left.
So, you need to use $3C for NVPROT value to protect 8KB of Flash, and all EEPROM.
Assuming EEPROM is not to be protected, you need to combine those two EPS bits also (%11000000), and so the final NVPROT value would become $FC, if I did all the math right.
The application should protect as much more Flash as needed. For the DZ128 I used in one project, I only needed EEPROM and no user configuration Flash storage, so my app starts like so (assembly language):
lda #%11000000 ;protect all program Flash
sta FPROT ;leaving EEPROM area unprotected
How i have to set NVPROT register in my application? Does it matter?
No, just in the bootloader. NVPROT is meant to protect the fixed bootloader code.
I want to be sure my application will not change the SN.
The S/N should be within the bootloader then.
Hope this helps.