Hi, guys!
I'm writing a library that helps in embedded programming. The idea is to make a bunch of macros that expands into MCU-specific registers access. For example for STM32:
mcu.RCC.AHBENR["IOPAEN"] = 1
I have a working sekelton now but I get a problem when try to do a cross-compilation for arm with --os:standalone option. My library actively uses os and other imports to find proper register definitions for specific MCU. All functions used for this are marked with {.compileTime.} pragma. But when I try to compile with --os:standalone I get following error:
Error: OS module not ported to your operating system!
Is it possible in nim to import some libs only for compile-time stuff and not for target code?
Thanks in advance!
@Araq thank you for fast reply! After changing --os:standalone to --os:any I have following error:
Error: Port memory manager to your platform
Not very informative for me. Here is my nim.cfg
define: "EmbedTarget=stm32f334r8t6"
arm.any.gcc.exe="arm-none-eabi-gcc"
arm.any.gcc.linkerexe="arm-none-eabi-gcc"
--passC:"-O3 -g -mtune=cortex-m4 -fno-common -ffunction-sections -fdata-sections -std=c11"
--noMain
--noLinking
--os:any
--cpu:arm
--deadCodeElim:on
--parallelBuild:"1"
Is it possible somehow?
Damn, I thought --os:any would simply work... PRs are welcome.
PRs are welcome.
;)
Could you give me some direction? Should it work without any syntax changes or we need to point such imports with somethink like static import os or import os {.compileTime.}? Some hints of where to look best whould be very useful
Another solution: Use staticExec to run helper programs at compile-time to determine things like MCU-specific registers.
I'm afraid this is not a solution in my case - I have a lot of checks in several places while compilation. For example - is register read-only or not, can we set this MCU frequency for concrete MCU model and so on. I'm trying to start some kind of generic framework for embedded programming and STM32 is just one of platform
Should it work without any syntax changes?
Yes, it should simply work.
Now I think all of them will be included in build even if they are not used in main code
Nah, it's stripped away.