Compiling pForth for Atmel Processors

106 views
Skip to first unread message

Maxwell

unread,
Feb 15, 2017, 12:04:47 PM2/15/17
to pforthdev
Hi,

I have successfully compiled pForth (using Atmel Studio) for arduino.org's Tian board (which has a ATSAMD21G18 MCU - 32Kb of SRAM installed).

My problem is that pForth's crashes on the MCU with an out of memory error, and sometimes it will just hang! My question is that how much SRAM does pForth need to work (.text .data .bss .stack), and is there anyway of reducing it's memory footprint on these types of MCUs? I've defined PF_NO_MALLOC as well as using Atmel's own pAlloc library, however, the device still doesn't work, and the only messages you see are as follows:

pForth Embedded
                                               PForth V27-LE/LE/32, built Feb 15 2017 16:04:05 (static)

and:

CreateTaskContext: insufficient memory


Regards

Phil Burk

unread,
Feb 15, 2017, 12:53:02 PM2/15/17
to pforthdev
Hello Maxwell,

I would love to see pForth running on an Arduino. But it might be tricky.

PForth was designed in 1995 for a 32-bit game console with 3 MB of RAM. I most often use pForth on my laptop, which has 16GB of RAM. Note that a $35 Raspberry Pi has 1 GB of RAM.

32KB is a tight squeeze. You can reduce the amount of pForth's own heap by setting PF_MEM_POOL_SIZE={numbytes}

   http://www.softsynth.com/pforth/pf_ref.php#Compiler-Options

The size control in pForth needs some work. The size declarations are here:

   https://github.com/philburk/pforth/blob/706b5e4b7faffb3fb4c58651be5df3e4bd2be794/csrc/pf_core.c#L77

Note the "ToDo". Those should be in a pfconfig.h.

Also the dictionary uses 32-bit tokens. That is optimized for efficiency not memory. I have been thinking of having an option for using single byte tokens for kernel primitives in the dictionary and maybe a 16-bit reference for secondaries. That would save some space.

It would be interesting to compile pForth for a similar architecture using gcc and then looking at the linker map.

Phil Burk
> --
> You received this message because you are subscribed to the Google Groups "pforthdev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pforthdev+...@googlegroups.com.
> To post to this group, send email to pfor...@googlegroups.com.
> Visit this group at https://groups.google.com/group/pforthdev.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages