I want to do baremetal programming on a Raspberry Pi 2 Model B (quad-core ARM Cortex-A7). I don't have much experience on multi core programming. I have a question regarding bare metal multi core programming.

My assumption is that a Quad Core CPU will have 4 Program counters so that I can point them to 4 different codes in flash memory and run them in parallel.

Is this correct ? Could any one explain how this quad core CPU(quad-core ARM Cortex-A7) works ?

  • 1
    Logic should indicate that using 4 CPUs with 1 program counter would be somewhere between ridiculous and impossible (inclusive). I'm not saying this to be condescending, but because if you want to go down this path, it is probably worth investing in a recent textbook on operating system design. I'm sure you can't point to "different codes in flash memory", if you mean something other than RAM (which is not flash). You can only point to main memory addresses. – goldilocks Aug 18 '15 at 19:34

Yes, each core is a CPU in its own right and will have its own registers, stack pointer, program counter, flags etc.

I'm afraid modern CPUs can not be described in a few paragraphs.

See the Cortex-A7 MPcore Processor Reference Manual (you will have to enable JavaScript for the link to work).

| improve this answer | |
  • I checked the manual. I didn't find any where explicitly mentioning that there are individual program counters for each CPU. Could you please show it to me -if possible ? My main question is that how can I access Core 1 PC register, Core 2 PC register etc ??? – robomon Aug 20 '15 at 8:15
  • 2.1.1. Processor components gives information about each core. I have no idea of the mechanics of bare metal programming. I have had no need to work at that level for 30 years. – joan Aug 20 '15 at 8:17

There are four completely separate cpu cores, not four program counters, four complete processors. naturally at some point the cores begin to share busses and eventually share with the gpu's busses to share peripherals and ram, etc.

start with bare metal on one processor core, the other three are sitting idle waiting/watching an address to jump to then they start executing that code, that is at least what someone figured out and I have successfully tried myself (there is a baremetal forum at the raspberry pi website).

once you go multi core you are basically writing programs for four computers that share resources, so you have to design it such that each talk to each other (shared memory, etc) or that some resources are completely owned by one core and the others code wont touch it. or one core owns a resource and the others ask that one core to do stuff for them. like four people in a car, ideally only one is driving, but maybe two can control the radio and thermostat, maybe everyone shares control over the dome light. If you dont etablish some rules then the radio is constantly changing volume and channel, the temp is going up and down, etc. in programming that simply means creating the rules and designing the software to those rules.

the arm docs spell it out. What is not spelled out is how you start up each of the cores as to some extent if not completely that is chip vendor specific and not an ARM thing. if you want to do baremetal programming reading chip vendor docs and schematics is a significant percentage of the job. For arm based products you need the correct arm docs for that core, and the chip vendors docs, unfortunately for the raspberry pi 2 they refused to (allocate resources to) make those docs (nor complete schematics) but we have learned how to spin up the other three cores (fairly trivial). if you are someone who is in the business of buying a significant number of those chips from broadcom for a product well that is another story, you sign the NDA and you get what you need, all the secrets.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.