0

I have been developing code for an older device which has an NXP i.MX28 single core CPU which is ARM-based. The device runs Embedded Linux.

I am now upgrading to a better device which has an NXP i.MX6UL quad core processor, of course ARM-based also, and also running Embedded inux.

Is it normal that the same toolchain which I was using for the for building the code for the i.MX28 will also work for the i.MX6UL, even though the i.MX6UL is more advanced with more cores etc.?

I have built my code now for a test with the same compiler and even run it on a Rasberry Pi which seems to run ok. The Rasberry Pi uses a Broadcom BCM2711 SoC with an ARM Cortex-A72 processor which again is a different CPU.

I therefore must ask, will any ARM toolchain build code and be able to run on any type of ARM device regardless?

Engineer999
  • 3,683
  • 6
  • 33
  • 71
  • After compiling/linking you get a bunch of instructions from standardised instructions set. In you case instruction set is aarch32. So far as you not asking for optional extensions (like Neon, Crypto) that might be or might not be present on particular SoC, why there should be difference ? – user3124812 Oct 29 '21 at 02:32
  • @user3124812 The fact that the i.MX28 is a single core and i.MX6UL is a quad core, would this make a difference to the instructions etc.? – Engineer999 Oct 29 '21 at 08:13
  • Please clarify in your question whether you are writing and building software for Linux or whether it is a bare-bone implementation (without operation system). This is crucial for your question and for answers. – Codo Oct 29 '21 at 08:46
  • "would this make a difference to the instructions" - of course no. – user3124812 Oct 29 '21 at 10:06

1 Answers1

1

CPUs differ by the core architecture (incl. instruction set) and set of peripherals. Difference in the peripherals is solved by drivers and HALs. Difference in core arch is solved by the toolchain.

If the toolchain "knows" new arch it will emit the corresponding assembly code, that will run on the new CPU. So, compilers will not produdce the same assembly, but the same source code will run after rebuild, that's the idea of high-level languages.

Problems emerge when old code contains an inline assembly, or uses some specific DSP instructions or libraries

Flexz
  • 686
  • 1
  • 3
  • 13
  • So far the code compiled with the compiler used for the i.MX28 seems to work on different targets. However, how is this the case if one CPU has a single core and the other multiple cores? Where does it get decided to run which part of the application across different cores? Or does it? Thanks – Engineer999 Oct 29 '21 at 08:16
  • Cores utilization depends on the OS used. If your app is barebone (no OS, or very basic one), then utilizing multiple cores got to be implented manualy, otherwise all the code would run on the first core. – Flexz Oct 29 '21 at 08:33
  • So in that case, Linux code aimed for a single core CPU will be different to that of a muli-core CPU? At least some low-level part of the kernel? – Engineer999 Oct 29 '21 at 08:42
  • It comes to the linux kernel options, a vast topic itself. The kernel could (and usualy is) be built to detect number of CPU cores and act accordingly (i.e. run different apps or drivers on different cores). A higher level application can use num_online_cpus() function to find the number of cores available. Perhaps you should ask under linux tag to get attention of more qualified it this area users. – Flexz Oct 29 '21 at 09:01
  • Thanks for your replies. – Engineer999 Oct 29 '21 at 18:09