Well, I thought I had found the reason for the crashing but it seems I haven't. I suspected that the .bin file crashed the linker because it was 8 bytes too long for the slot, however on investigation that was not the case, the .bin file I'm using is the correct length.
What's more, I am now doubting the output from CW based on the .bin/.rbin file.
Using CW7.2 we have a compiled bootloader.bin file which starts at address 0x0000000 with the data from vectors.s:
0x20010000 (initial SP)
0x00000C70 (initial _asm_startup)
...(rest of vectors.s)
When this file is included in our original project built in CW7.2 the resulting s-record output is:
S3FD000000002001000000000C70....
Which looks to me like the 0x20010000, 0x00000C70 is being written to address 0x00000000 and 0x00000004 respectively.
Perhaps most importantly, neither of these numbers are the length of the .bin file (0x4000) or the address offset (0x00000000) which the explanation above says they should be, and CW7.2 writes this data straight into the .s19.
However, if I include the .rbin file (first 8 bytes of .bin removed) it jumps straight in with line 3 of vectors.s at address 0x00000000.
Which then compiles to the same in the .s19:
S3FD00000000000042C4000042C4....
(0x42C4 is the asm_exception_handler which is not where we want to start at reset!)
Yet the explanation above suggests that we should be producing the same code from a .bin file in CW7 and from an .rbin file in CW10.
So, it looks like there is another discontinuity in CW's behaviour or documentation thereof - possibly with CW7.2 rather than CW10 - that the .bin file generated by CW7 does NOT include the length/offset data.
This brings several issues out:
- CW10's linker crashes when given the original file renamed ".rbin" despite the fact that it is the correct length and contains only the raw binary data.
- If we delete 8 bytes from the end (all 0xFF's) of the .bin file, the linker then works correctly.
- Because of the way the debugger works it would be very easy to miss the fact that the bootloader code had been broken by this problem
- Although we can "fix" the resulting .s19 with a text editior, it would be nice not to have to.