diff --git a/Makefile b/Makefile index f8495b3..5d6433c 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,8 @@ WIN_LIBS=user32.lib TARGETS = posix_target \ web_target \ esp32_target \ - esp32_sim_target + esp32_sim_target \ + pico_ice_sim_target TESTS = posix_tests web_tests esp32_sim_tests LSQ = ls 2>/dev/null @@ -807,9 +808,13 @@ CHIP_esp32cam=esp32 # ---- PICO-ICE ---- -pico-ice: $(PICO_ICE)/ueforth_pico_ice.uf2 +pico-ice: pico_ice_target +pico_ice_target: $(PICO_ICE)/ueforth-pico-ice.zip -$(PICO_ICE)/ueforth_pico_ice.uf2: \ +$(PICO_ICE)/ueforth-pico-ice: + mkdir -p $@ + +$(PICO_ICE)/ieforth-pico-ice/ueforth_pico_ice.uf2: \ $(PICO_ICE)/Makefile \ pico-ice/main.c \ pico-ice/builtins.h \ @@ -829,9 +834,25 @@ $(PICO_ICE)/ueforth_pico_ice.uf2: \ $(PICO_ICE)/Makefile: cmake $(PICO_ICE) -S pico-ice -B $(PICO_ICE) +$(PICO_ICE)/ueforth-pico-ice/README.txt: pico-ice/README.txt | $(PICO_ICE)/ueforth-pico-ice + cat pico-ice/README.txt | tools/replace.js \ + VERSION=$(VERSION) \ + REVISION=$(REVISION) \ + >$@ + +$(PICO_ICE)/ueforth-pico-ice/LICENSE: LICENSE + cp $< $@ + +$(PICO_ICE)/ueforth-pico-ice/pico-ice-sdk-LICENSE.md: pico-ice/pico-ice-sdk/LICENSE.md + cp $< $@ + +$(PICO_ICE)/ueforth-pico-ice/pico-sdk-LICENSE.TXT: pico-ice/pico-sdk/LICENSE.TXT + cp $< $@ + # ---- PICO-ICE-SIM ---- -pico-ice-sim: $(PICO_ICE_SIM)/ueforth_pico_ice_sim +pico-ice-sim: pico_ice_sim_target +pico_ice_sim_target: $(PICO_ICE_SIM)/ueforth_pico_ice_sim $(PICO_ICE_SIM): mkdir -p $@ @@ -852,7 +873,7 @@ $(PICO_ICE_SIM)/ueforth_pico_ice_sim: \ $(GEN)/pico_ice_boot.h | $(PICO_ICE_SIM) $(CXX) $(CFLAGS) -DUEFORTH_SIM=1 $< -o $@ -# ---- PACKAGE ---- +# ---- PACKAGE ESP32 ---- $(ESP32)/ESP32forth.zip: \ $(ESP32)/ESP32forth/ESP32forth.ino \ @@ -867,6 +888,16 @@ $(ESP32)/ESP32forth.zip: \ $(ESP32)/ESP32forth/optional/spi-flash.h cd $(ESP32) && rm -f ESP32forth.zip && zip -r ESP32forth.zip ESP32forth +# ---- PACKAGE pico-ice ---- + +$(PICO_ICE)/ueforth-pico-ice.zip: \ + $(PICO_ICE)/ueforth-pico-ice.uf2 \ + $(PICO_ICE)/pico-ice/README.txt \ + $(PICO_ICE)/pico-ice/LICENSE \ + $(PICO_ICE)/pico-ice/pico-ice-sdk-LICENSE.md \ + $(PICO_ICE)/pico-ice/pico-sdk-LICENSE.TXT + cd $(PICO_ICE) && rm -f ueforth-pico-ice.zip && zip -r ueforth-pico-ice.zip ueforth-pico-ice + # ---- Publish to Archive ---- ARCHIVE=gs://eforth/releases @@ -883,6 +914,14 @@ publish-esp32: $(ESP32)/ESP32forth.zip $(ESP32)/ESP32forth.zip \ $(ARCHIVE)/ESP32forth-$(VERSION).zip +publish-pico-ice: $(PICO_ICE)/ueforth-pico-ice.zip + $(GSUTIL_CP) \ + $(PICO_ICE)/ueforth-pico-ice.zip \ + $(ARCHIVE)/ueforth-pico-ice-$(VERSION)-$(REVSHORT).zip + $(GSUTIL_CP) \ + $(PICO_ICE)/ueforth-pico-ice.zip \ + $(ARCHIVE)/ueforth-pico-ice-$(VERSION).zip + publish-linux: $(POSIX)/ueforth $(GSUTIL_CP) \ $(POSIX)/ueforth \ @@ -919,7 +958,7 @@ publish-index: | $(GEN) $(GEN)/archive.html \ gs://eforth/releases/archive.html -publish: publish-esp32 publish-linux publish-web publish-windows publish-index +publish: publish-esp32 publish-pico-ice publish-linux publish-web publish-windows publish-index # ---- DEPLOY ---- @@ -929,6 +968,7 @@ $(DEPLOY): REPLACE = tools/replace.js \ HEAD=@site/head.html \ COMMON=@site/common.html \ + FILES_COMMON=@site/files_common.html \ POSIX_COMMON=@site/posix_common.html \ DESKTOP_COMMON=@site/desktop_common.html \ MENU=@site/menu.html \ @@ -954,6 +994,7 @@ $(DEPLOY)/app.yaml: $(RES)/eforth.ico \ cp out/web/ueforth.js $(DEPLOY)/ cat site/web.html | $(ESP_REPLACE) >$(DEPLOY)/web.html cat site/ESP32forth.html | $(ESP_REPLACE) >$(DEPLOY)/ESP32forth.html + cat site/pico-ice.html | $(UE_REPLACE) >$(DEPLOY)/pico-ice.html cat site/index.html | $(UE_REPLACE) >$(DEPLOY)/index.html cat site/linux.html | $(UE_REPLACE) >$(DEPLOY)/linux.html cat site/windows.html | $(UE_REPLACE) >$(DEPLOY)/windows.html diff --git a/pico-ice/builtins.h b/pico-ice/builtins.h index 6567d13..03d38ba 100644 --- a/pico-ice/builtins.h +++ b/pico-ice/builtins.h @@ -143,6 +143,7 @@ #else # define OPTIONAL_SPI_SUPPORT \ YV(ice, ice_spi_init, ice_spi_init()) \ + YV(ice, ice_spi_init_cs_pin, ice_spi_init_cs_pin(n1, n0); DROPn(2)) \ YV(ice, ice_spi_chip_select, ice_spi_chip_select(n0); DROP) \ YV(ice, ice_spi_chip_deselect, ice_spi_chip_deselect(n0); DROP) \ YV(ice, ice_spi_read_blocking, ice_spi_read_blocking(b1, n0); DROPn(2)) \ diff --git a/site/ESP32forth.html b/site/ESP32forth.html index b973183..998f316 100644 --- a/site/ESP32forth.html +++ b/site/ESP32forth.html @@ -323,6 +323,7 @@ On boot, ESP32forth configures PIN 2 (typically an LED) to be an output and brin
Requires v7.0.7.3+ -- ONLY Posix + ESP32
--cp ( "src" "dst" -- ) Copy "src" file to "dst". -mv ( "src" "dst" -- ) Rename "src" file to "dst". -rm ( "path" -- ) Remove "path" file. -touch ( "path" -- ) Create "path" file if it doesn't exist. -cat ( "path" -- ) Print contents of "path" file. -ls ( "path" -- ) List files or directories in "path". --
Requires v7.0.7.3+ -- ONLY Posix
--cd ( "path" -- ) Change director to "path". -mkdir ( "path" -- ) Create directory "path". -rmdir ( "path" -- ) Remove directory "path". -pwd ( -- ) Print current directory. -- -
Requires v7.0.7.2+
--VISUAL EDIT ( "path" --) Enters a visual editor opening file "path". - -NOTE: On ESP32 requires connection over an ANSI serial terminal like Putty. - -LIMITATIONS: Terminal doesn't know screen dimensions - and is very redraw inefficient. - -Keys: - Ctrl-S -- Save now. - Ctrl-X / Ctrl-Q -- Quit, asking Y/N to save. - Ctrl-L -- Redraw the screen. - Backspace -- Delete a character backwards. - Arrow Keys -- Movement. - PgUp/PgDn -- Scroll up/down a page. --
{{FORTH}} uses a hybrid of Forth-79 and Forth-83 style vocabularies. @@ -127,73 +90,6 @@ DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too). [THEN] ( -- ) Interpret time THEN. -
-USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo -OPEN-BLOCKS ( a n -- ) Open a file as the block file -LOAD ( n -- ) Evaluate a block -THRU ( a b -- ) Load blocks a thru b -LIST ( n -- ) List a block -BLOCK ( n -- a ) Get a 1024 byte block -BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents -UPDATE ( -- ) Mark the last block modified -FLUSH ( -- ) Save and empty all buffers -EMPTY-BUFFERS ( -- ) Empty all buffers -SAVE-BUFFERS ( -- ) Save all buffers -SCR ( -- a ) Pointer to last listed block -- -
EDITOR vocabulary.
-Note the block editor places newlines in the 63rd column of each line
-to make the block file readable in a text editor.
--WIPE ( -- ) Blank out the current block -L ( -- ) List the current block -D ( n -- ) Delete a line in the current block -E ( n -- ) Clear a line in the current block -R ( n "text" -- ) Replace a line in the current block -A ( n "text" -- ) Add (insert) a line in the current block -P ( -- ) Move to the previous block -N ( -- ) Move to the next block -- -
Requires v7.0.7.2+ for UDP
-These words are available inside thesockets vocabulary.
--socket ( domain type protocol -- sock/err ) -setsockopt ( sock level optname optval optlen -- 0/err ) -bind ( sock addr addrlen -- 0/err ) -listen ( sock connections -- 0/err ) -sockaccept ( sock addr addrlen -- sock/err ) -- varies from bsd socks -connect ( sock addr addrlen -- 0/err ) -select ( numfds readfds writefds errfds timeout -- fd/err ) -poll ( pollfds n timeout -- fd/err ) -send ( sock a n flags -- n/err ) -sendto ( sock a n flags addr addrlen -- n/err ) -sendmsg ( sock msg flags -- n/err ) -recv ( sock a n flags -- n/err ) -recvfrom ( sock a n flags addr addrlen -- n/err ) -recvmsg ( sock msg flags -- n/err ) -gethostbyname ( hostnamez -- hostent/0 ) -errno ( -- err ) -- ESP32 only as of v7.0.7.2 - -sockaddr ( "name" -- ) creates a sockaddr structure -->port@ ( a -- n ) get port from sockaddr -->port! ( n a -- ) set port in sockaddr -->addr@ ( a -- n ) get big-endian address from sockaddr -->addr! ( n a -- ) set big-endian address in sockaddr -ip. ( n -- ) Print address as x.y.z.w IP address. - -( Constants ) -SOCK_STREAM SOCK_DGRAM SOCK_RAW -AF_INET -sizeof(sockaddr_in) -SOL_SOCKET -SO_REUSEADDR --
Requires v7.0.6.5+
@@ -290,58 +186,3 @@ Capabilities and limitations:
(LOCAL) is also supported.-
- -
-WARNING: Danger ahead.
-Snapshotting the dictionary may not be stable across reinstallations of the C build of Forth.
-
-A collection of non-standard words is provided that allow snapshotting -the dictionary and restoring it at startup, with a start word. -
- --SAVE ( "name" -- ) Saves a snapshot of the current dictionary to a file. -RESTORE ( "name" -- ) Restore a snapshot from a file. -REMEMBER ( -- ) Save a snapshot to the default file - (./myforth or /spiffs/myforth on ESP32). -STARTUP: ( "name" -- ) Save a snapshot to the default file arranging for - "name" to be run on startup. -REVIVE ( -- ) Restore the default filename. -RESET ( -- ) Delete the default filename. -- -
-Here's an example usage: -
- --: welcome ." Hello!" cr 100 0 do i . loop cr ; -startup: welcome -bye - -( Next boot will run a custom startup message ) - -reset - -( Reset removes the custom message ) -- -
-The INTERNALS vocabulary has some additional words
-for more control.
-
-SAVE-NAME ( a n -- ) Save a snapshot if the current vocabulary to a file. -RESTORE-NAME ( a n -- ) Restore a snapshot from a file. -'COLD ( -- a ) Address of the word that will be run on startup. -REMEMBER-FILENAME ( -- a n ) Deferred word specifying the platform specific - default snapshot filename. -diff --git a/site/files_common.html b/site/files_common.html new file mode 100644 index 0000000..f03f201 --- /dev/null +++ b/site/files_common.html @@ -0,0 +1,174 @@ + + +
Requires v7.0.7.3+ -- ONLY Posix + ESP32
++cp ( "src" "dst" -- ) Copy "src" file to "dst". +mv ( "src" "dst" -- ) Rename "src" file to "dst". +rm ( "path" -- ) Remove "path" file. +touch ( "path" -- ) Create "path" file if it doesn't exist. +cat ( "path" -- ) Print contents of "path" file. +ls ( "path" -- ) List files or directories in "path". ++
Requires v7.0.7.3+ -- ONLY Posix
++cd ( "path" -- ) Change director to "path". +mkdir ( "path" -- ) Create directory "path". +rmdir ( "path" -- ) Remove directory "path". +pwd ( -- ) Print current directory. ++ +
Requires v7.0.7.2+
++VISUAL EDIT ( "path" --) Enters a visual editor opening file "path". + +NOTE: On ESP32 requires connection over an ANSI serial terminal like Putty. + +LIMITATIONS: Terminal doesn't know screen dimensions + and is very redraw inefficient. + +Keys: + Ctrl-S -- Save now. + Ctrl-X / Ctrl-Q -- Quit, asking Y/N to save. + Ctrl-L -- Redraw the screen. + Backspace -- Delete a character backwards. + Arrow Keys -- Movement. + PgUp/PgDn -- Scroll up/down a page. ++ +
+USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo +OPEN-BLOCKS ( a n -- ) Open a file as the block file +LOAD ( n -- ) Evaluate a block +THRU ( a b -- ) Load blocks a thru b +LIST ( n -- ) List a block +BLOCK ( n -- a ) Get a 1024 byte block +BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents +UPDATE ( -- ) Mark the last block modified +FLUSH ( -- ) Save and empty all buffers +EMPTY-BUFFERS ( -- ) Empty all buffers +SAVE-BUFFERS ( -- ) Save all buffers +SCR ( -- a ) Pointer to last listed block ++ +
EDITOR vocabulary.
+Note the block editor places newlines in the 63rd column of each line
+to make the block file readable in a text editor.
++WIPE ( -- ) Blank out the current block +L ( -- ) List the current block +D ( n -- ) Delete a line in the current block +E ( n -- ) Clear a line in the current block +R ( n "text" -- ) Replace a line in the current block +A ( n "text" -- ) Add (insert) a line in the current block +P ( -- ) Move to the previous block +N ( -- ) Move to the next block ++ +
Requires v7.0.7.2+ for UDP
+These words are available inside thesockets vocabulary.
++socket ( domain type protocol -- sock/err ) +setsockopt ( sock level optname optval optlen -- 0/err ) +bind ( sock addr addrlen -- 0/err ) +listen ( sock connections -- 0/err ) +sockaccept ( sock addr addrlen -- sock/err ) -- varies from bsd socks +connect ( sock addr addrlen -- 0/err ) +select ( numfds readfds writefds errfds timeout -- fd/err ) +poll ( pollfds n timeout -- fd/err ) +send ( sock a n flags -- n/err ) +sendto ( sock a n flags addr addrlen -- n/err ) +sendmsg ( sock msg flags -- n/err ) +recv ( sock a n flags -- n/err ) +recvfrom ( sock a n flags addr addrlen -- n/err ) +recvmsg ( sock msg flags -- n/err ) +gethostbyname ( hostnamez -- hostent/0 ) +errno ( -- err ) -- ESP32 only as of v7.0.7.2 + +sockaddr ( "name" -- ) creates a sockaddr structure +->port@ ( a -- n ) get port from sockaddr +->port! ( n a -- ) set port in sockaddr +->addr@ ( a -- n ) get big-endian address from sockaddr +->addr! ( n a -- ) set big-endian address in sockaddr +ip. ( n -- ) Print address as x.y.z.w IP address. + +( Constants ) +SOCK_STREAM SOCK_DGRAM SOCK_RAW +AF_INET +sizeof(sockaddr_in) +SOL_SOCKET +SO_REUSEADDR ++ +
+
+ +
+WARNING: Danger ahead.
+Snapshotting the dictionary may not be stable across reinstallations of the C build of Forth.
+
+A collection of non-standard words is provided that allow snapshotting +the dictionary and restoring it at startup, with a start word. +
+ ++SAVE ( "name" -- ) Saves a snapshot of the current dictionary to a file. +RESTORE ( "name" -- ) Restore a snapshot from a file. +REMEMBER ( -- ) Save a snapshot to the default file + (./myforth or /spiffs/myforth on ESP32). +STARTUP: ( "name" -- ) Save a snapshot to the default file arranging for + "name" to be run on startup. +REVIVE ( -- ) Restore the default filename. +RESET ( -- ) Delete the default filename. ++ +
+Here's an example usage: +
+ ++: welcome ." Hello!" cr 100 0 do i . loop cr ; +startup: welcome +bye + +( Next boot will run a custom startup message ) + +reset + +( Reset removes the custom message ) ++ +
+The INTERNALS vocabulary has some additional words
+for more control.
+
+SAVE-NAME ( a n -- ) Save a snapshot if the current vocabulary to a file. +RESTORE-NAME ( a n -- ) Restore a snapshot from a file. +'COLD ( -- a ) Address of the word that will be run on startup. +REMEMBER-FILENAME ( -- a n ) Deferred word specifying the platform specific + default snapshot filename. +diff --git a/site/linux.html b/site/linux.html index 81a1044..86efdad 100644 --- a/site/linux.html +++ b/site/linux.html @@ -61,9 +61,10 @@ limitations under the License.
+ueforth-pico-ice-{{VERSION}}.zip
+ Version: {{VERSION}} (Beta)
+
+Release Archive + - Prior Releases +
++http://github.com/flagxor/ueforth + - Complete Unprocessed Source Code +
+ ++ +NOTE: Although ueforth is licensed under Apache 2.0, +please be aware that binaries are built with SDKs that include other licenses including +MIT, +Raspberry Pi License, +and possibly others. +Be sure to consult a lawyer before using for comercial purposes. + +
+ ++Copyright 2023 Bradley D. Nelson + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. ++ +
+
+
+Initially µEforth can be interacted with over a serial port (over USB).
+One popular option is to use the serial port option on
+PuTTY.
+Be sure to config the serial port to: baud rate = 115200, data bits = 8, stop bits = 1, and parity = N.
+
internals vocabulary.
++MALLOC ( n -- a | 0 ) System malloc +SYSFREE ( a -- ) System free +REALLOC ( a n -- a | 0 ) System realloc ++ +
+MS ( n -- ) Pause for some number of milliseconds. +MS-TICKS ( -- n ) Time since start in milliseconds. +TERMINATE ( n -- ) Call system exit. ++ +
+R/O ( -- mode ) +R/W ( -- mode ) +W/O ( -- mode ) +BIN ( mode -- mode ) +CLOSE-FILE ( fh -- ior ) +OPEN-FILE ( a n mode -- fh ior ) +CREATE-FILE ( a n mode -- fh ior ) +DELETE-FILE ( a n -- ior ) +WRITE-FILE ( a n fh -- ior ) +READ-FILE ( a n fh -- n ior ) +FILE-POSITION ( fh -- n ior ) +REPOSITION-FILE ( n fh -- ior ) +FILE-SIZE ( fh -- n ior ) ++ +
ice vocabulary.
+See here
+for details on the underlying SDK.
++ice_cram_open ( -- ) Open FPGA config RAM connection. +ice_cram_write ( a n -- ) Write bytes to the FPGA config RAM connection. +ice_cram_close ( -- ) Close FPGA config RAM connection. + +ICE_FLASH_PAGE_SIZE ( -- n ) Get the size of a flash page. +ice_flash_init ( -- ) Init flash connection. +ice_flash_read ( addr a n -- ) Read from a flash address to a buffer. +ice_flash_erase_sector ( n -- ) Erase a flash sector. +ice_flash_program_page ( addr a -- ) Program a flash page. +ice_flash_erase_chip ( -- ) Erase whole flash. +ice_flash_wakeup ( -- ) Wakeup flash. +ice_flash_sleep ( -- ) Put flash in sleep mode. + +ice_fpga_init ( n -- ) Init FPGA to a clock speed in MHz. + Valid inputs: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48 +ice_fpga_start ( -- ) Start FPGA. +ice_fpga_stop ( -- ) Stop FPGA. + +ice_led_init ( -- ) Initialize LED. +ice_led_red ( f -- ) Set on/off state of led red channel. +ice_led_green ( f -- ) Set on/off state of led green channel. +ice_led_blue ( f -- ) Set on/off state of led blue channel. + +ice_spi_init ( -- ) Initialize SPI. +ice_spi_init_cs_pin ( cs_pin active_high -- ) Init selecting more options. +ice_spi_chip_select ( n -- ) Set csn_pin to assert. + Also set the SPI TX and SCK pins to output/drive mode, + and keeps the RX pin to input/high-z mode. +ice_spi_chip_deselect ( n -- ) Set csn_pin to assert. + Also set the SPI TX and SCK pins back to input/high-z mode. +ice_spi_read_blocking ( a n -- ) Read from SPI into buffer. +ice_spi_write_blocking ( a n -- ) Write to SPI from buffer. + +ice_sram_init ( -- ) Initialize SRAM. +ice_sram_get_id ( a -- ) Read SRAM id into 8 byte buffer. +ice_sram_read_blocking ( addr a n -- ) Read from address in SRAM to memory. +ice_sram_write_blocking ( addr a n -- ) Write from memory to SRAM. +diff --git a/site/windows.html b/site/windows.html index d480a46..ba76d62 100644 --- a/site/windows.html +++ b/site/windows.html @@ -67,9 +67,10 @@ limitations under the License.