Is there a way for a program to know if it's executed under the simulator and not on an actual CPU?
Then maybe you haven't looked very thoroughly. Let me point your attention to the Project->Manage->Components,... dialog, and the fact it has a list of Project Targets for you to manage.
Wow, that couldn't be hidden better!.. But again you have to remember to switch targets and recompile the program every time you want to launch it in the simulator... Multi-Project Workspaces is probably even more convenient as it allows you to compile all your targets at once.
Anyway, thanks for the hint, I was unaware of that feature :)
You wrote that most flash programming tools do that checksumming you intend to base your solution's design on. Someone replied that only tools for one particular brand of ARM micro controllers really do that..
I thought I was clear enough when I wrote "here's my solution for LPC2xxx chips" that this solution applies to one particular brand of ARM microcontrollers :) And, I admit, it was probably a mistake to write that "most" flash programming tools do that checksumming. In fact, all of them that work with that brand and use ISP should do it.
So where exactly does your sudden confidence come from that this will always be the case? How do you plan on excluding the possibility that your program will, at some point, by somebody you've never spoken to, be flashed by a programming tool that doesn't follow that scheme?
I'm afraid I'll have to explain the boot process on the LPC2xxx...
All LPC2xxx chips (OK, all that I know of) come with a boot loader. The boot loader does two things: 1) provides an interface with flash programming software ("In-System Programming") and 2) actually executes the user program. Before execution, the boot loader checks user code validity with the very procedure I wrote in the second post. If the code isn't valid, it doesn't get executed. And what makes the user code "valid" is the flash programming software that modifies the program's image appropriately before flashing it.
That means that a program with no correct checksum just can't be running on a real word LPC2xxx, but that happens on the simulator.
Once again, to make it absolutely clear, my method is valid if:
1) it's an LPC2xxx 2) it has a boot loader
I'm not sure if 2) necessarily follows from 1), but so far I'm fine with both :)
You dare to explain something to Hans-Bernhard Broeker?
I surprise myself :)