We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello
I'm using Cortex-M3, and because of speed and peripherals, I want to use a dual core MCU.
I realized I have to write two separate code and make two separate executable file.
But I don't know how to merge these executable files.
I have to write down the executable files in separate specific region of flash?
Can anyone help me? I'm a little confused
Thank you
Hello mohammad,
NXP's LPC4300 is a Cortex-M4 + M0 single-chip microcontroller, and I suspect this may be your target.
There is more than one strategy for developing with dual core, and you can find some useful tips < here > as well as example projects labelled "dc" in the lpcopen software packages found < here >.
You do need to separate the executable images in memory, for example using 512K Bank A flash for the M4 core, and the other 512k Bank B flash for the M0. When debugging your application, it is not necessary to merge the executable code for the two cores, you may load them separately. The link scripts (scatter files) are also provided separate memory regions in the examples.
-arw
Yes, I want to use LPC4357
Do you know any dual core design reference from ARM?
Thank you for the replay
mohammad,
There are no books or academic studies on this topic, though it is quite a good idea. General multicore development concepts apply with the dual Cortex-M as with other cores; the necessities were added for inter-processor communication and so forth. The chip user manual is the best place to start today!
Hello Mohammad,
Keil MDK includes a number of examples for the MCB4357 development board that show how to work with the two cores of this chip, including debugging them side by side.
As allenwillson already mentioned, you can build two different executables:
You convert the Cortex-M0 executable to a hex-file and from your Cortex-M4 code, you load the image and start the Cortex-M0 core.
But there is a different way, which has not been covered in any documentation I know of.
I write all the code in assembly language; sometimes I write some files in C for the Cortex-M4, though.
But I write the Cortex-M0 code in assembly language, and I use GCC and GAS for building my project.
I recommend that the first line of your assembly file is...
.syntax unified
Somewhere you want to tell the assembler, that you're about to write Cortex-M0 code, so before your Cortex-M0 code, write the following line:
.cpu cortex-m0
... If you at some point want to write cortex-m4 code in the same source file, just switch ...
.cpu cortex-m4
Then you do not need to convert the code to a hex-file, you still need to start up the Cortex-M0 core from your Cortex-M4 code, but I find it a lot easier this way myself.
Remember: You can share your Cortex-M0 code with the Cortex-M4. The Cortex-M4 can run the Cortex-M0 code, but the Cortex-M0 cannot run the Cortex-M4 code. But you should be careful. If the Cortex-M4 is running the Cortex-M0 code, then the Cortex-M4 is stalling the Cortex-M0, because they're suddenly accessing the same memory space.
-So it's a good idea to keep the Cortex-M0 code in one Flash bank, and the Cortex-M4 code in the other Flash-bank.
(Or: You may want to run some of the code from SRAM, if it needs to run extra fast)
-See "Using GNU Assembler" for more information about what it can do.
Hi jensbauer
Sorry for the latency
How can I add M0 image(Hex file) to M4 project?
Can you please explain how to do that in assembly?
You write a text file ending in .s (or .S), and add it to your Cortex-M4 project like you would add a .c file there.
This file will now be built using the assembler instead of the compiler (.s files are built using the assembler, .c and .cpp files by the compiler).
A short example file showing most of the assembler-directives you would be using:
;/* File: example.s */
.syntax unified /* this makes the assembler automatically generate IT instructions for you */
.cpu cortex-m0 /* this selects the cortex-m0 architecture and helps you avoid using cortex-m3/cortex-m4 instructions */
.text /* this makes sure the code goes into the .text section */
.global m0vectors
.word 0x20004000 /* this defines the initial stack pointer for the Cortex-M0 */
.word m0reset /* the reset exception vector */
/* here you should place your other exception vectors. There are too many to include in this example */
.global m0test /* this exports the symbol m0test, so you can reference it from for instance C */
.func m0test,m0test /* this names the symbol m0test as a function (for the debug-info) */
.type m0test,%function /* this tells the assembler (and linker) what kind of symbol we're generating */
.thumb_func /* this is necessary if pointers use the symbol */
.align /* this makes sure the code is positioned on a 16-bit boundary */
m0test: /* this defines the actual symbol */
ldr r0,=0x01234567 /* example code, load a value into r0 */
bx lr /* return to the calling function */
m0reset:
bl m0test /* this is the startup-code, call our function */
lockup: wfi /* sleep the CPU; it'll wake up if an interrupt occurs */
b lockup /* go back to sleep */
.size m0test, . - m0test /* this tells the linker how big this function is, so it can correctly exclude it if it's unused */
.endfunc /* this marks the end of the function (for the debug-info) */
You can then refer to the code from your C file...
/* File: main.c */
#include <ipc_queue.h>
/* Note: you don't need argc and argv on a microcontroller. */
int main(int argc, const char *argv[])
{
IPC_haltSlave();
SET_SLAVE_SHADOWREG(m0vectors);
IPC_startSlave();
while(1)
asm volatile("wfi");
}
return(0);
I'm not completely sure about the .c file; I haven't tested the code, so expect a lot of errors. It would be something in that direction, though.
Thank you jensbauer
Thank you all, very much
I'd like to let you know that NXP has a nice LPC-related Web-site with downloads and documentation plus a forum, where you can get more information. I strongly recommend exploring the site (and especially the LPC43xx forum), because you will find examples on how to load a Cortex-M0 image using the standard way there too. See some posts related to running dual-core applications on the LPC43xx.
I agree with Jens, LPCware has loads of doc and code you can use.