Platformio NXP evk only possible with Zephyr?

I am working with an STM32 dev board which is running the following configuration:

  • FreeRTOS
  • Lwip (using ppp over serial, using an LTE modem)

We are investigating other chips now, and our focus moved to NXP (NXP i.MX RT1020). The idea was to port our firmware (not an insane amount of code yet) to the NXP chip.

In platform IO I see that I am only allowed to use zephyr as framework. I never heard of it, but googling seems that it an emerging alterative to FreeRTOS.

image

Now, because of the “specific” requirements we have with our modem (thus using PPP over serial), I am not sure if this is fully supported in sephyrs implementation.

So as a first step, I much rather prefer to use my current implementation (FreeRTOS + lwip) and thus only “port” the parts where I now use STMs HAL to NXPs HAL.

Is this possible in platformio? Or am I “forced” to work with zephyr when I use this chip in platformio?

Of course I could also try to use NXPs IDE, but if possible I rather stick with VScode too.

Many thanks for any help/pointers/suggestions!

There is a hidden choice: Baremetal Once you generate a project for the RT1020, you can delete the framework = ... line in the platformio.ini, then PlatformIO will not compile in any frameworks (of which Zephyr is the only choice for that chip), only the sourcse from src/ and lib/ (and lib_deps).

That way you can provide your own startup file, linker script and all sources to e.g. put in FreeRTOS. An example of baremetal projects is e.g. atmelavr native-blink or my stm32 blinky or this close to baremetal STM32 FreeRTOS project.

For the RT1060, there is also the choice of mbed-os.

There are open issues to implement a builder script for the Arduino core from Seed that would make these chips usable with Arduino.

If you want it to support also other Frameworks / SDKs, like NXPs MCUXpresso SDK, open another issue there. Mbed-OS for one board, Zephyr for all, or baremetal for all are the only current choices.

Hm interesting, actually there is an unofficial NXP.IMXRT platform from Seedstudio, who also make the Arduino core for, giving one board, based on a RT1052, Arduino core + SDK support! Others might be possible, create a new board definition for that.

Oef, you mention so many things that I don’t fully understand.

  1. Maybe a very stupid question, but what’s the link with Arduino you keep mentioning? Is there a direct relation to how platformio works to how Arduino core works?

  2. If I remove zephyr as framework, I will also remove the entire “NXPs HAL”. So should I get the SDK from Xpresso, and include that as a library?
    image

  3. Again maybe similar question as 1), but what’s the link with Arduino? Are you suggesting to use Arduino core to compile something for an NXP chip?

You asked whether Zephyr is the only choice you have with NXP chips and PlatformIO as tool I said no, there’s mbed-os and also Arduino available for some boards, with the Arduino core additionally exposing some NXP SDK that you can work with directly.

If you chose to do a baremetal framework, the SDK / HAL files that you want to work with have to be in the project somewhere, in lib/ or src/, preferrable with the same compiler flags as the real SDK would use. How you do this or where the files are sourced from is up to you.

1 Like

Alright, yeah I lack knowledge on the Arduino core part so not sure if that would be a nice alternative for. I’ll google a bit more and see if I can make sense out of that.

For the “baremetal” approach then at least that’s clear. I think I will try that first and make it available as library in my project (just as I have freertos and lwip as library).

Thx for your time and helpful answers

Hi Max,

If I can bother you once more. I’ve copied the generated files (sources, headers, linker scripts, startup file) from Xpresso generated project to a library and a project in VScode/platformio.

I also removed the platform=zephyr line in the platform.ini.

I had some compiler (linker) issues because the Xpresso generated linker scripts link to some libraries which are not present or different in the toolchain used by VScode/platformio.

My VScode/platformio uses:
toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)

My Xpresso uses:
gcc/arm-none-eabi/9.3.1

I found this in the .map file in the xpresso project config, so I think the gcc version is 9.3.1 in Xpresso versus 7.2.1 in platformio.

But the good part is, I don’t need these libraries that were included in the linker script:

GROUP (
  "libgcc.a"
  "libc_nano.a"
  "libstdc++_nano.a"
  "libm.a"
  "crtn.o"
  "crtend.o"
)

So when I simply delete the above group in the linker script, i can compile and link without issues.

My main is the most trivial application (just to check if I can run and step through with debugger)

int main() 
{
    while (1) {}
}

When I then upload and debug my program it crashes on boot. I added a while (1) {} in the ResetISR() function to see if it gets there. It doesn’t.

When I debug my program, it hangs here:

??@0x0020b9ca (Unknown Source:0)
??@0x0020c3b6 (Unknown Source:0)

Running this small project from Xpresso and putting breakpoints in ResetISR, I can see that the ResetISR is at 0x600022dc.

The linker script sends the program to external flash:

  __base_BOARD_FLASH = 0x60000000  ; /* BOARD_FLASH */  

Given this information, would you have any idea where to begin? Is this a result of using the wrong tool chain in VScode/pio? As far as I can tell, the code, linker scripts, and startup code are identical. (except from the included libraries in the linker script which I deleted, but I’m pretty sure that’s irrelevant to this problem).

Any hints/thought would be greatly appreciated

You can upgrade the compiler as documented with the available versions.

platform_packages = 
   toolchain-gccarmnoneeabi@~1.90301.0

will give you 9.3.1. Maybe that already solves your problems.

Otherwise I’d need to see the original SDK files and your exact PlatformIO project.

This soudns more like a problem with the vector table being placed wrongly in the flash due to linker script issues. The ISR vector must be the first thing in flash, and pointing to the right functions.

Hi @maxgerhardt ,

I tried 9.3.1, same problem. When I include the libraries as they do in xpresso I get linker errors.

I pushed both my pio experiment as the xpresso project to github:
https://github.com/basprins/nxp-1020-crash-on-boot.git

I left the pio project in the state where it gives compiler errors.

I think I would expect the same, the problem is, I have no clue (apart from the removed libraries in linker script) what could cause the vector table to be wrong. It’s a copy of what the xpresso IDE generated for me.

Thx in advance for any help on this!

Would be thrilled to continue in pio instead of… eclipse offsprings…

Found the problem.

image

This section was defined, but was empty. Don’t fully understand how this works, but I do understand I need to define some boot data. After copying these parts over as well, it works

1 Like