Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the in-application programming for ARM (Cortex M3) work?

I'm working on a custom Cortex-M3-based device and I need to implement in-application programming (IAP) mechanism so that it will be possible to update the device firmware without JTAG (we'll use TFTP or HTTP instead). While the IAP-related code examples available from ST Microelectronics are clear enough to me, I don't really understand how the re-flashing works.

As far as I understand, the instructions are fetched by the CPU from the Flash through the ICode bus (and the prefetch block, of course). So, here's my pretty silly question: why doesn't the running program get corrupted while it re-flashes itself (i.e. changes the Flash memory from which it is being run)?

like image 960
Roman Dmitrienko Avatar asked Nov 03 '11 12:11

Roman Dmitrienko


People also ask

What are the applications of ARM Cortex-M3?

The Cortex-M3 processor is specifically developed for high-performance, low-cost platforms for a broad range of devices including microcontrollers, automotive body systems, industrial control systems and wireless networking and sensors.

What are the operating modes of ARM Cortex-M3?

The processor supports two modes of operation, Thread mode and Handler mode: The processor enters Thread mode on Reset, or as a result of an exception return. Privileged and Unprivileged code can run in Thread mode. The processor enters Handler mode as a result of an exception.

What are the advantages of programming the Cortex-M3 using C language?

For beginners in embedded programming, using C language for software development on the Cortex-M3processor is the best choice. It is to be noted that the use of the C language can often speed up application development.

Is ARM Cortex-M3 microcontroller or microprocessor?

Arm® Cortex®-M3 in a nutshell. The 32-bit Arm® Cortex®-M3 core processor is designed for high-performance, real-time processing in cost-constrained applications and can handle complex tasks. Any Arm® Cortex®-M3 microcontroller offers high scalability combined with an optimal trade-off between performance and cost.


2 Answers

A common solution is to have a small reserved area in the flash, where the actual flashing program is stored. When new firmware has been downloaded just make a jump to the code in this area.

Of course, this small area is not overwritten when flashing firmware, it can only be done by other means (like JTAG). So make sure this flashing-program works good to start with. :)

like image 125
Some programmer dude Avatar answered Sep 17 '22 17:09

Some programmer dude


I'm not familiar with STM implementation, but in NXP chips the IAP routines are stored in a separate, reserved ROM area which can't be erased by user code.

If you're implementing the flash writing code yourself by using HW registers directly, you need to either make sure that it doesn't touch the sectors it's running from, or runs from the RAM.

like image 30
Igor Skochinsky Avatar answered Sep 17 '22 17:09

Igor Skochinsky