I would like the source code (project) for serial_flash_loader.bin. Looked but could not find. I would like to use the flash update in my code.
Thanks!
You don't mention which evaluation or development kit board you are working with (or which is closest to your own board project) but if you look in pretty much any StellarisWare release, you will find a directory called boot_loader that contains essentially the same code as is used in serial_flash_loader.bin (I'm assuming that you are talking about the flash loader that is installed on bare parts from the factory here). The boot_loader code contains more function and more customization options - it supports Ethernet, USB, serial and SSI update options via various switches - but does the same job.
To see how to generate a boot loader image, look in the C:\StellarisWare\boards\<your-board> directory for examples named "boot_xxx" where "xxx" represents the communication type that is used in the firmware update. The "boot_serial" example will build a boot loader that accepts updates via the UART, for example. All these boot_xxx examples use the main source in C:\StellarisWare\boot_loader and customize the build via a file called bl_config.h which determines which boot_loader features to enable and sets parameters such as the base address of the downloaded application image.
Thanks Dave,
The board is lm3s2965, I used the top block of 64k flash as a flash updater for the other 3 blocks of 64k. The main program in the lower blocks loads the SRAM with the new flash image (mine is <32k ALWAYS) and then calls the "ROM" in the top of the flash. ERASE-PROGRAM-VERIFY and all is well.
I had a problem getting the long call to work, ended up just moving the address into the PC to jump to the flash updater in high flash address. Seems to always get a fault when the standard method is used.
faults at the bx...
asm("mov.w r4, #0x00030000");asm("mov lr, pc");asm("mov r15, r4");asm("bx r4");
This works...
asm("ldr r4, 0x30000");asm("mov r15, r4");
one other way. faults also...
((void (*)(void))0x30000)();
(using Crossworks RA)
should have been
asm("mov.w r4, #0x00030000");asm("mov lr, pc");asm("bx r4");
I strongly suspect the fault is because you are telling the Cortex-M3 to switch into ARM instruction mode. It doesn't support this so it gives up and faults on you. The "bx" instruction uses the least significant bit of the value in the register to indicate the target operating mode for the processor. If bit 0 is clear, it indicates ARM (32 bit instruction set) mode. If it is set, it indicates Thumb (16 bit instruction set) mode. I bet if you change your first line to "mov.w r4, #00030001" or add an instruction to set bit 0 of R4, this will start working.
The reason your second example works is that your mov into pc (r15) doesn't bother checking bit 0 and trying to perform a mode switch the way bx does.