Git Product home page Git Product logo

ueforth's Introduction

µEforth / ESP32forth

This EForth inspired implementation of Forth is bootstraped from a minimalist C kernel.

Building from Source

To build from source:

sudo apt install ninja-build gcc-arm-none-eabi
git clone https://github.com/flagxor/ueforth
cd ueforth
./configure.py
ninja

The resulting output will have this structure:

  • out/deploy - A copy of the eforth.appspot.com / esp32forth.appspot.com ready to deploy.
  • out/esp32 - A source build for ESP32.
  • out/esp32-sim - A POSIX build approximating ESP32 for testing.
  • out/pico-ice - A build for pico-ice.
  • out/pico-ice-sim - A POSIX build approximating pico-ice for testing.
  • out/gen - Intermediate / generated files.
  • out/posix - A build for Linux / POSIX.
  • out/resources - Intermediate / generated resources.
  • out/web - A build for Web.
  • out/windows - A build for Windows.

Individual platforms can be built as follows:

ninja posix
ninja esp32
ninja pico-ice
ninja win32
ninja win64
ninja web

A build that excludes the slower components can be configured with:

./configure.py -f

To install to /usr/bin on Linux / POSIX do:

ninja install

ESP32 boards can be compiled and flashed with:

ninja esp32-flash
ninja esp32s2-flash
ninja esp32s3-flash
ninja esp32c3-flash
ninja esp32cam-flash

Set PORT=com3 etc. to select board.

ueforth's People

Contributors

flagxor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ueforth's Issues

SPACES behaviour

In utils.fs SPACES is defined as:

: spaces ( n -- ) for aft space then next ;

This works for n=0 but not n<0. Correct action is to display nothing.

modification for login

There is one point on which a small modification should be made.

It's in this definition:

: login ( z z -- )
WIFI_MODE_STA Wifi.mode
WiFi.begin begin WiFi.localIP 0= while 100 ms repeat WiFi.localIP ip. cr
z" forth" MDNS.begin if ." MDNS started" else ." MDNS failed" then cr ;

Except to recompile all the ESP32Forth code, no way to change "forth" to the MDNS. It's annoying if you want to communicate with multiple ESP32forth boards on the same network.
One solution would be to have a vectorized word:

defer myMDNS
: MDNSforth s" forth" ;
' MDNSforth is myMDNS

: login ( z z -- )
WIFI_MODE_STA Wifi.mode
WiFi.begin begin WiFi.localIP 0= while 100 ms repeat WiFi.localIP ip. cr
myMDNS MDNS.begin if ." MDNS started" else ." MDNS failed" then cr ;

That's what I suggest. If you can see better, no problem.

Cordially

Compile fail

Brad,
I get an immediate compile failure:
arduino.template:1:1: error: expected unqualified-id before '{' token
{{opcodes}}
^

[Question] v7.0.6.6 & ESP32-S2 & SPIFFS

Do you know if the SPIFFS already could work with the ESP32-S2?
Because when I add a word like ": SPACES 0 do emit 32 loop ;"
and save it on a ESP32-S2 (ESP32forth v7.0.6.6) with REMEMBER I didnt get a error-message
but after a BYE the command isnt in WORDS / available to use.

On a normal ESP32 (WeMOS D1 R32) with ESP32forth v7.0.5.4 or v7.0.6.6 the command SPACES is available after a BYE

Thanks for the information in advance!

BTW: ESP32-Filesystem-Uploader Plugin Update which supports not only ESP32 but the new chipssets via function getchip :)
https://github.com/lorol/arduino-esp32fs-plugin

see throws Guru meditation error

Version 7.0.6.9

: logfilename s" 1234567890123456" ;

String is 16 chars long. longer or shorter string works fine.

see logfilename

throws
: logfilename s" 1234567890123456" Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x400f1bf0 PS : 0x00060f30 A0 : 0x800e86a9 A1 : 0x3ffb2560
A2 : 0x3ffbdd5c A3 : 0x93ec2e1c A4 : 0x3ff40000 A5 : 0x3ffb25a4
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x0000005a A9 : 0x0000005a
A10 : 0x60000000 A11 : 0x3ff40000 A12 : 0x3ffc38b4 A13 : 0xb33fffff
A14 : 0x00000001 A15 : 0x00000001 SAR : 0x00000001 EXCCAUSE: 0x0000001c
EXCVADDR: 0x93ec2e1c LBEG : 0x400f1bf0 LEND : 0x400f1bfa LCOUNT : 0x00000059

Backtrace:0x400f1bed:0x3ffb25600x400e86a6:0x3ffb2580 0x400e8e95:0x3ffb25d0 0x400e2c0a:0x3ffb2600 0x400e10bd:0x3ffb2620 0x400d4001:0x3ffb2640 0x400d59d5:0x3ffb2800 0x400e2530:0x3ffb2820

word r| doesn't work.......

Hello,
Example code:

r|
\ ....here my FORTH code.....
|

If the code is on several lines, the FORTH interpreter does not find the delimiter "|" at the end of the line. Arrived at the third line, the character "|" is seen as an unknown word. Interpreter messages:

--> r|
OK
1073640238 0 --> \ ....here my FORTH code.....
OK
1073640238 0 --> |
ERROR: | NOT FOUND!
ERROR
OK

use VGA Terminal and PS2Keyboard from FabGL

Hello with FabGL and ueforth, we can easily get a standalone forth computer!

Any plan to integrate FabGL into ueforth? In a basic form a 2 color text Terminal running on VGA2Controller can be used, and advanced support for drawing add audio could be added for gaming programming.

Thanks!

I figured out that change the default I/O to a VGA Terminal is simple:

*** ESP32forth.ino.orig	2022-10-30 17:12:44.579464479 +0800
--- ESP32forth.ino	2022-10-30 17:08:28.536010233 +0800
***************
*** 21 ****
--- 22,23 ----
+ #include <fabgl.h>
+ 
***************
*** 90 ****
!   V(rtos) V(SPIFFS) V(serial) V(SD) V(SD_MMC) V(ESP) \
--- 92 ----
!   V(rtos) V(SPIFFS) V(serial) V(terminal) V(SD) V(SD_MMC) V(ESP)	  \
*************** static cell_t ResizeFile(cell_t fd, cell
*** 470 ****
--- 473 ----
+   REQUIRED_TERMINAL_SUPPORT \
*************** static cell_t ResizeFile(cell_t fd, cell
*** 520 ****
--- 524,532 ----
+ fabgl::PS2Controller PS2Controller;
+ fabgl::VGA2Controller DisplayController;
+ fabgl::Terminal Terminal;
+ #define REQUIRED_TERMINAL_SUPPORT \
+   XV(terminal, "Terminal.available", TERMINAL_AVAILABLE, PUSH Terminal.available()) \
+   XV(terminal, "Terminal.write", TERMINAL_WRITE, n0 = Terminal.write(b1, n0); NIP) \
+   XV(terminal, "Terminal.read", TERMINAL_READ, PUSH Terminal.read()) \
+   XV(terminal, "Terminal.flush", TERMINAL_FLUSH, Terminal.flush())
+ 
*************** forth definitions
*** 1776 ****
--- 1789,1792 ----
+ vocabulary Terminal  Terminal definitions
+ transfer Terminal-builtins
+ forth definitions
+ 
*************** ARGS_MARK flags'or! LEAVE
*** 1956 ****
! forth definitions 
--- 1972 ----
! forth definitions
*************** also forth definitions
*** 2163 ****
!    dup 0= if 2drop exit then 
--- 2179 ----
!    dup 0= if 2drop exit then
*************** internals definitions also serial
*** 2678 ****
--- 2695,2702 ----
+ 
+ internals definitions also terminal
+ : terminal-type ( a n -- ) Terminal.write drop ;
+ : terminal-key ( -- n )
+    begin pause Terminal.available until Terminal.read ;
+ : terminal-key? ( -- n ) Terminal.available ;
+ 
+ 
*************** also forth definitions
*** 2680,2682 ****
! : default-type serial-type ;
! : default-key serial-key ;
! : default-key? serial-key? ;
--- 2704,2706 ----
! : default-type terminal-type ;
! : default-key terminal-key ;
! : default-key? terminal-key? ;
*************** static cell_t TimerIsrRegister(cell_t gr
*** 3858 ****
--- 3883,3884 ----
+ 
+ 
*************** void setup() {
*** 3859 ****
--- 3886,3892 ----
+   PS2Controller.begin(PS2Preset::KeyboardPort0);
+   DisplayController.begin();
+   DisplayController.setResolution(VGA_640x480_60Hz);
+   Terminal.begin(&DisplayController);
+   Terminal.connectLocally();
+   Terminal.enableCursor(true);
+ 

It looks like this :)
x

SPI words is vital

Hello,
I integrate the SPI management words:

#define ENABLE_SPI_SUPPORT
//.......
OPTIONAL_SPI_SUPPORT \
//......
// *** Support SPI ***
#ifndef ENABLE_SPI_SUPPORT
# define OPTIONAL_SPI_SUPPORT
#else
# include <SPI.h>
# define OPTIONAL_SPI_SUPPORT \
  XV(SPI, "SPI.begin", SPI_BEGIN, SPI.begin((int8_t) n3, (int8_t) n2, (int8_t) n1, (int8_t) n0); DROPn(4)) \
  XV(SPI, "SPI.end", SPI_END, SPI.end();) \
  XV(SPI, "SPI.setHwCs", SPI_SETHWCS, SPI.setHwCs((boolean) n0); DROP) \
  XV(SPI, "SPI.setBitOrder", SPI_SETBITORDER, SPI.setBitOrder((uint8_t) n0); DROP) \
  XV(SPI, "SPI.setDataMode", SPI_SETDATAMODE, SPI.setDataMode((uint8_t) n0); DROP) \
  XV(SPI, "SPI.setFrequency", SPI_SETFREQUENCY, SPI.setFrequency((uint32_t) n0); DROP) \
  XV(SPI, "SPI.setClockDivider", SPI_SETCLOCKDIVIDER, SPI.setClockDivider((uint32_t) n0); DROP) \
  XV(SPI, "SPI.getClockDivider", SPI_GETCLOCKDIVIDER, PUSH SPI.getClockDivider();) \
  XV(SPI, "SPI.transfer",   SPI_TRANSFER, SPI.transfer((uint8_t *) n1, (uint32_t) n0); DROPn(2)) \
  XV(SPI, "SPI.transfer8",  SPI_TRANSFER_8,  PUSH (uint8_t)  SPI.transfer((uint8_t) n0); NIP) \
  XV(SPI, "SPI.transfer16", SPI_TRANSFER_16, PUSH (uint16_t) SPI.transfer16((uint16_t) n0); NIP) \
  XV(SPI, "SPI.transfer32", SPI_TRANSFER_32, PUSH (uint32_t) SPI.transfer32((uint32_t) n0); NIP) \
  XV(SPI, "SPI.transferBytes", SPI_TRANSFER_BYTES, SPI.transferBytes((const uint8_t *) n2, (uint8_t *) n1, (uint32_t) n0); DROPn(3)) \
  XV(SPI, "SPI.transferBits", SPI_TRANSFER_BITES, SPI.transferBits((uint32_t) n2, (uint32_t *) n1, (uint8_t) n0); DROPn(3)) \
  XV(SPI, "SPI.write", SPI_WRITE, SPI.write((uint8_t) n0); DROP) \
  XV(SPI, "SPI.write16", SPI_WRITE16, SPI.write16((uint16_t) n0); DROP) \
  XV(SPI, "SPI.write32", SPI_WRITE32, SPI.write32((uint32_t) n0); DROP) \
  XV(SPI, "SPI.writeBytes", SPI_WRITE_BYTES, SPI.writeBytes((const uint8_t *) n1, (uint32_t) n0); DROPn(2)) \
  XV(SPI, "SPI.writePixels", SPI_WRITE_PIXELS, SPI.writePixels((const void *) n1, (uint32_t) n0); DROPn(2)) \
  XV(SPI, "SPI.writePattern", SPI_WRITE_PATTERN, SPI.writePattern((const uint8_t *) n2, (uint8_t) n1, (uint32_t) n0); DROPn(3))
#endif

......
vocabulary SPI   SPI definitions
transfer SPI-builtins
forth definitions


The addition of SPI management words would be of real interest to manage interfaces...
thanks in advance

autoexec hang on error

Using v7.0.7.3 on an ESP32, I noticed that if I had a stack error or command unknow error when running autoexec.fs on boot, the interpreter would hang, no ok prompt, no serial i/o. I'd prefer the console to be usable so I can make changes online.

Forget the fact that I'm testing bug filled code that is stored in autoexec.fs, Im trying to make the interp more robust on edge cases encountered during code development.

My quick solution is to add QUIT to the end of the definition of autoexec as here:

: autoexec
   300 for key? if rdrop exit then 10 ms next
   s" /spiffs/autoexec.fs" ['] included catch 2drop drop 
   ['] revive catch drop quit ;

This may not be the most correct solution, but it's working so far. Better suggestions are welcome.

SEE stops decompiling prematurely at word EXIT

A minor issue with SEE - I just tested the new word RECURSE with this example whilst adding it to the ESP32FORTH glossary:-
: FACTORIAL DUP 2 < IF DROP 1 EXIT THEN DUP 1- RECURSE * ;
When I check the word with SEE, the output is shorter than expected:-
: FACTORIAL DUP 2 < 0BRANCH DROP 1 ;

Error in path-join

Thanks for ueforth! I've been enjoying it immensely! I ran into an issue and would like to share my findings.
I was unable to include one file from another using full paths. For example, if file1.fs contains: "include /sd/file2.fs", entering "include /sd/file1.fs" will fail.
I found the cause in common/including.fs, in the word path-join.
The third line determines if the file name is a full path, and if so zeros the directory name length. However, the combined string length has already been calculated and is not corrected. This results in the correct string being returned, but with an excessive length, resulting in a file not found error.
I found that simply moving the third line of path-join to the beginning of the word fixes the problem. There are a few other very minor issues in this word; slightly too much memory is allocated from the heap for paths that begin with ./ and ../ .
I would be happy to prepare a pull request if you like.

Initial stack for interrupt handlers

First of all, thank you for ESP32Forth. It's perfect for the project I'm doing. As my first forth, I'm enjoying learning about the internals of the implementation as well as the language.

I love the ease of adding existing Arduino libraries. As part of adding ESP-NOW support I need a way to pass arguments received in an interrupt routine into forth. I'm using your existing pinchange and HandleInterrupt code as a template. However for me the one-item stack that is set up in HandleInterrupt in lines 496 and 498 is not making it into forth.

My simple test:

interrupts
: chg  depth . cr ;
' chg 13 pinchange
--> -38717

I think the DROP on line 31 of forth_run may be interfering with things but I'm not very familiar with the memory layout. If this is indeed a bug I'm happy to work on a fix but I could use some guidance.

Thanks in advance.

https://github.com/flagxor/eforth/blob/168f68963164f2df65c483da0cc31d5717419f62/ueforth/esp32/bindings.fs#L150-L151

https://github.com/flagxor/eforth/blob/168f68963164f2df65c483da0cc31d5717419f62/ueforth/esp32/template.ino#L489-L501

https://github.com/flagxor/eforth/blob/168f68963164f2df65c483da0cc31d5717419f62/ueforth/common/interp.h#L21-L40

Forth does not start

Code compiles, loads but no "ok". This stopped after the addition of camera support. Booting begins:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
.......
But a continuing full points across the screen

rerun and interval don't work

Hello,
I'm trying this example:

timers
: hi ." hi" cr 0 rerun ;
' hi 1000000 0 interval ( run hi every second )

It don't work with version 7.0.6.18

It's work with older versions....

BR

Enhancement Request - case statement

I've tried to implement an ANS-FORTH case statement based on the following code which uses if-else-thens:

: testcode 0 over = if drop ." 0" cr else 1 over = if drop ." 1" cr else 2 over = if drop ." 2" cr drop then then then ;

If I look at what this code generates using "see":

see t
: testcode 0 OVER = 0BRANCH DROP s" 0" type cr BRANCH 1 OVER = 0BRANCH DROP s" 1" type cr BRANCH 2 OVER = 0BRANCH DROP s" 2" type cr DROP ;

This is what I came up with but it doesn't work. What am I doing wrong?

"( Case support )\n"
": case 0 ; immediate\n"
": of ' over , ' = , ['] if , ' drop , ; immediate\n"
": endof ['] else , ; immediate\n"
": endcase ' drop , begin ?dup while ['] then , repeat ; immediate\n"

New timer code for esp32c3

Since the new timer code in 7.0.7.10 now uses the Arduino libs for initialization and register setup, there are just two minor adjustments that need to be made for the esp32c3.

First, the RISCv esp32c3 only has 2 timers available versus the 4 timers in the Xtensa variants. Initialization of the second two timers results in a harmless error:

E (6611) timer_group: timer_init(273): HW TIMER NUM ERROR
E (6615) timer_group: timer_init(273): HW TIMER NUM ERROR

This could be remedied with something like

0 0 timer_init_null
0 1 timer_init_null
# !defined(CONFIG_IDF_TARGET_ESP32C3) 
1 0 timer_init_null
1 1 timer_init_null
#endif

Second, since the esp32c3 doesn't support edge triggered interrupts, I just changed the definition of onalarm to use ESP_INTR_FLAG_IRAM instead of ESP_INTR_FLAG_EDGE

: onalarm ( xt t ) swap >r t>nx r>
                   0 ESP_INTR_FLAG_IRAM timer_isr_callback_add throw ;

and the interval timer works as intended on this chip.

visual edit: saving with CTRL+S

hello,

in the visual editor, I suppose it works fine from a windows terminal, but on most unix system, CTRL+S will block the terminal, cf. https://unix.stackexchange.com/questions/137842/what-is-the-point-of-ctrl-s

dup [char] S [char] @ - = if drop save update exit then

I understand there isn't really another obvious shortcut, but maybe it would be possible to use alt+S?

For my part I've remapped it to CTRL+P, and I've also added a visual "saved" message which will help to make sure it tried to save:

 dup [char] P [char] @ - = if drop save update ." saved" exit then

LICENSE

Can you please clarify the license terms for this software. Thanks.

FOR NEXT loop, bug?

Hello,
I'm usin a simple FOR NEXT loop... Example:
: myLoop 5 for r@ . next ;
It's display 5 4 3 2 1 0
The problem: this loop make 6 iteration... No 5 iterations as attempted.
On otehr FORTH versions with for..next structure, tehy make only 5 iterations.
B R

in V 7.0.7.4, CASE...ENDCASE has a bug.....

Hello Brad,
Your version of CASE OF ENDOF ENDCASE has a bug.
I have tried this simple code:
: day ( n -- addr len )
CASE
0 OF s" Sunday" ENDOF
1 OF s" Monday" ENDOF
2 OF s" Tuesday" ENDOF
3 OF s" Wednesday" ENDOF
4 OF s" Thursday" ENDOF
5 OF s" Friday" ENDOF
6 OF s" Saturday" ENDOF
ENDCASE
;

And the leghth of the string is poped from stack....

My version of case.endcase work fine:
https://github.com/MPETREMANN11/ESP32forth/blob/main/tools/caseEndcase.txt

With best regards

httpd doesn't run as a task

httpd does not run as a task, throwing a LoadProhibited exception:

ESP32forth v7.0.6.15 - rev 74125fc19e0ce05838c7
ESP32-D0WDQ5   240 MHz   2 cores   4194304 bytes flash
     System Heap: 201620 free + 346224 used = 547844 total (36% free)
                  98152 bytes max contiguous
Forth dictionary: 80956 free + 26692 used = 107648 total (75% free)
3 x Forth stacks: 2048 bytes each
 ok
--> wifi WIFI_MODE_STA wifi.mode z" guest" z" password" wifi.begin 4000 ms wifi.status
 ok
3 --> web-interface
 ok
3 --> : webs 80 server ;
 ok
3 --> ' webs 1500 300 task wui
 ok
3 --> wui start-task
 ok
3 --> Listening on port 80 
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d2ca7  PS      : 0x00060c30  A0      : 0x800d301c  A1      : 0x3ffb1de0  
A2      : 0xffffffff  A3      : 0x3ffe67e4  A4      : 0x3ffe4388  A5      : 0x00000000  
A6      : 0x3ffe67d4  A7      : 0x3fff0898  A8      : 0x800d19de  A9      : 0x3ffe6748  
A10     : 0xffffffff  A11     : 0x00000000  A12     : 0x400d2ca3  A13     : 0x3ffc5ca8  
A14     : 0x3ffc5cbc  A15     : 0x00000000  SAR     : 0x0000000b  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  

ELF file SHA256: 0000000000000000

Backtrace: 0x400d2ca7:0x3ffb1de0 0x400d3019:0x3ffb1f90 0x400d9519:0x3ffb1fb0 0x4008b71a:0x3ffb1fd0

Rebooting...

When you run the exception through the ESP exception decoder you get this:

Decoding 8 results
0x400d2ca7: forth_run(int*) at /tmp/ESP32forth/ESP32forth.ino line 1210
0x400d2ca3: forth_run(int*) at /tmp/ESP32forth/ESP32forth.ino line 1210
0x400d2ca7: forth_run(int*) at /tmp/ESP32forth/ESP32forth.ino line 1210
0x400d3019: loop() at /tmp/ESP32forth/ESP32forth.ino line 2706
0x400d9519: loopTask(void*) at /tmp/.arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/main.cpp line 23
0x4008b71a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 355 (discriminator 1)

Can't build for Windows on WSL

I'm trying to build ueforth for Windows on a Windows Subsystem for Linux Ubuntu 22.04 LTS command line. It found the compiler but seems to be missing a header file dependency:

$ make win32
"/mnt/c/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x86/cl.exe" /c /Foout/windows/uEf32.obj -O2 -I ./ -I out -I "c:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Include" -I "c:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/include" -I "c:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/ucrt" windows/main.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30145 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
windows/main.c(16): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
make: *** [Makefile:413: out/windows/uEf32.obj] Error 2
$ make win64
"/mnt/c/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe" /c /Foout/windows/uEf64.obj -O2 -I ./ -I out -I "c:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Include" -I "c:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/include" -I "c:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/ucrt" windows/main.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30145 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.c
windows/main.c(16): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
make: *** [Makefile:433: out/windows/uEf64.obj] Error 2

Can I build for Windows on WSL? If not, how do I build for Windows on a Windows machine?

Something broken with telnetd

It appears telnetd support may have regressed.
putty works but getting reports that telnet on linux doesn't work on a first boot.

Extra task words

I'm not sure of the usefullness of these words, but it was fun trying to figure them out.

stop-task will stop a running task. It's actually a suspend, as you can restart the task and then the stopped task will continue where it left off. It just takes the task out of the circular task list. ie: mytask stop-task

: stop-task ( t -- ) task-list @ begin 2dup @ = if swap @ swap ! exit then @ dup task-list @ = until ;

.ts works like .s but for a task. If your task has a pause in it to allow the webui to stay responsive, then .ts will show the stack at the pause and print the name of the next word after the pause. If I have multiple pauses, then I usually define empty marker words like : mark1 ; and place this after each pause so that .ts will indicate at which mark it is at, using a different mark word for each pause. ie: mytask .ts

: tdepth ( t -- n ) dup 4 + @ swap 8 +  - cell/ ;  ( current stack depth for a task )
: .ts ( t -- ) dup dup ." <" tdepth 1 - n. ." > " tdepth 0 max for aft dup 4 + @  r@  cells - @ r@ 0= if ."  -> " @ @  >name type else . then then next drop ;

Output example: <4> 2 66 7 1 -> mark1

Problem with MOV, syntax in Xtensa assembler

Hello,

I'm testing XTENSA assembler.

And I've a problem with MOV,

My test:

    a8 a2       MOV,

ESP32forth display:

-->     a8 a2       MOV,
STACK UNDERFLOW ERROR

I use only ar as registers before MOV, because in ISA XTENSA, I read this:

image

In this documentation, MOV need only two registers.....

With best regards

How do you use local variables or local variables are very broken

First let me say ESP32forth is a great tool which I am really looking forward to using in many projects.
Also, I am a big fan of named parameters and named local variables which make Forth a whole lot easier to program in.

Maybe I don't understand how to use locals in ESP32forth so my problems might be of my own making. Here is a short test that I cannot get to compile:

: bytearray ( size -- ) ( i -- addr ) create allot does> + ;

\ Define an array of pixel values
\ Three bytes are required for each pixel
10 3 * bytearray pixels

\ Convert indiviual RGB color components into 24 bit color
: color24 { r g b }
r 16 <<
g 8 <<
b
or or
;

\ Set pixel using a 24 bit color value
: setPixelColor { color24 pixelNum }
color24 16 >> 255 and
color24 8 >> 255 and
color24 255 and
pixelNum setPixelRGB
;

My issues with locals, besides the above not compiling, are:

  1. if you do something like { color24 pixelNum --- } , they don't work
  2. If you define some locals and use them in a do .. loop, they don't work.
  3. You cannot store to them or change their values

If I am using locals wrong, please enlighten me. In the past I have used pForth which has both named parameters and local variable support which was rock solid. That might be a good model to use in ESP32forth.

Remarkable!

Is exactly the word I would use to describe this project!

100% CPU load

I've seen even when idle, the ueforth REPL is running at 100% CPU. Maybe it could be possible to detect if there is no activity and then be lighter on the CPU?

Numerical formating

There is an odd issue while using numerical formating at the console, either serial or webui. I havn't tried telnet.

--> 10 <# #s #> type
10 ok

which is correct. However, if you perform the formatting without the type, leaving the counted string on the stack, then issuing type afterward, you get an incorrect output.
This is on an ESP32C3 v7.0.7.4:

--> 10 <# #s #> 
 ok
1070269430 2 --> type
00 ok
-->

Running ueforth v7.0.7.3 on Linux:

-->  10 <# #s #>
 10 <# #s #>
 ok
134494982 2 --> type
type
82 ok

Its different but still incorrect, however it's not a show stopper. It was just driving me nuts when I was working out a simple formatted number at the console and the results were not what I expected. Now that I know, I just always add the type at the end.

More problems with locals

I think there is still a problem with locals. I tried to compile the following code and the compilation fails in setPixelRGB where it complains that pixelNum is not found. On my machine compilation fails 100% of the time. However if I change the name of the variable to _pixelNum then the code compiles cleanly.

Go figure

: bytearray ( size -- ) ( i -- addr ) create allot does> + ;

\ This changes depending upon number of pixels being controlled
64 constant NUM_NPS

\ Define an array of pixel values
\ Three bytes are required for each pixel
NUM_NPS 3 * byteArray pixels

\ Set a pixel to an RGB color value
\ pixelNum 0 .. MAX_PIXELS
\ red grn blu are 8 bit values
\ Assume color order of GRB
: setPixelRGB { red grn blu pixelNum -- }
pixelNum 3 * pixels >r
grn r@ c!
red r@ 1+ c!
blu r> 2 + c!
;

\ Convert indiviual RGB color components into 24 bit color
: makeColor24 { r g b -- color24 }
r 16 <<
g 8 <<
b
or or
;

Issue with compiling (eForth) under Arduino

Nice job by the way!
(Checked out your french bread formula .. going to try your ratios)
2 basic things I don't understand (but I'm good at making bad assumptions)
The {{opcodes}} ,{{calling}}, {{core}}, etc. I assume are macros to to be filled in automatically by some external data? At this point I REM'd them out. (They cause compiler error.)
Also "cell_t" errors with "not defined in this scope."
I copied "typedef uintptr_t ucell_t;" and " from esp32forth file. Seems to have fixed this.
Then finally, "'g_sys' was not declared in this scope."
Can't seem to fix this.

I can't figure out what I'm not seeing.
It would be wonderful if you could help me out.
Thanx,
Frank

timers error....

Hello,

timers
: test1 ." hello" cr ;
' test1 1000000 0 interval

it fails with this error:

E (85734) timer_group: timer_isr_register(262): HW TIMER NEVER INIT ERROR

Extending UART to UART2, possible?

Hello,
Thank you first for your great work on ESP32Forth
Do you plan to extend UART to UART2 on ESP32Forth?
In my developments, I use this UART2 port thanks to this modified code:

#define REQUIRED_SERIAL_SUPPORT
X("Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP)
X("Serial.end", SERIAL_END, Serial.end())
X("Serial.available", SERIAL_AVAILABLE, PUSH Serial.available())
X("Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP)
X("Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP)
X("Serial.flush", SERIAL_FLUSH, Serial.flush())
X("Serial2.begin", SERIAL2_BEGIN, Serial2.begin(tos); DROP)
X("Serial2.end", SERIAL2_END, Serial2.end())
X("Serial2.available", SERIAL2_AVAILABLE, PUSH Serial2.available())
X("Serial2.readBytes", SERIAL2_READ_BYTES, n0 = Serial2.readBytes(b1, n0); NIP)
X("Serial2.write", SERIAL2_WRITE, n0 = Serial2.write(b1, n0); NIP)
X("Serial2.flush", SERIAL2_FLUSH, Serial2.flush())

This code has been tested and verified with communication to a LoRa transmitter.
cordially

mouse --> getMousePosition

\ The word mouse delivers the position of the mouse pointer from the origin x y (0, 0) 
\ of the HTML page and not from the origin of the canvas.
\ The word getMousePosition retrieves and recalculates the relative position of the 
\ mouse pointer from the origin of the canvas.
JSWORD: getMousePosition { -- mousex mousey }
    var offset = {x: 0, y: 0};
    var node = context.ctx.canvas;
    while (node) {
        offset.x += node.offsetLeft;
        offset.y += node.offsetTop;
        node = node.offsetParent;
    }
    return [context.mouse_x-offset.x, context.mouse_y-offset.y];
~

autoexec not working

Autoexec.fs worked in the past but not now. Puzzled
I have /spiffs/autoexec.fs but it does not execute. How should detect if the file exists in the esp32 ?

adding ellipse in eFORTH web

\ draw ellipse
JSWORD: ellipse { x y rx ry angle div }
context.ctx.ellipse(x, y, rx, ry, Math.PI * 2 * angle / div, 0, 2 * Math.PI);
~
\ usage, draw ellipse with red border
\ $ff0000 color!
\ 100 100 75 30 0 360 ellipse stroke

timers register address calculation bug

There is timers register calculation word TIMGn
$3ff5f000 constant TIMG_BASE
( group n = 0/1, timer x = 0/1, watchdog m = 0-5 )
: TIMGn ( n -- a ) $10000 * TIMG_BASE + ;
For group 1 it gives uncorect address $3ff6f000, corect according ESP32 documentation is $3ff60000. So correct definition should be
: TIMGn ( n -- a ) $1000 * TIMG_BASE + ;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.