Add better status, fix bug on device.

This commit is contained in:
Brad Nelson
2022-02-06 20:48:27 -08:00
parent c2f2329411
commit d6e0d0033b
8 changed files with 52 additions and 13 deletions

View File

@ -205,7 +205,7 @@ $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
ESP32_BOOT = $(COMMON_PHASE1) \ ESP32_BOOT = $(COMMON_PHASE1) \
esp32/allocation.fs \ esp32/allocation.fs \
$(COMMON_PHASE2) \ $(COMMON_PHASE2) \
esp32/platform.fs esp32/bindings.fs \ esp32/bindings.fs esp32/platform.fs \
posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \ posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \
esp32/registers.fs esp32/timers.fs \ esp32/registers.fs esp32/timers.fs \
esp32/bterm.fs posix/telnetd.fs \ esp32/bterm.fs posix/telnetd.fs \

View File

@ -189,8 +189,11 @@ create input-buffer input-limit allot
: quit begin ['] evaluate-buffer catch : quit begin ['] evaluate-buffer catch
if 0 state ! sp0 sp! fp0 fp! rp0 rp! ." ERROR" cr then if 0 state ! sp0 sp! fp0 fp! rp0 rp! ." ERROR" cr then
prompt refill drop again ; prompt refill drop again ;
variable boot-prompt
: free. ( nf nu -- ) 2dup swap . ." free + " . ." used = " 2dup + . ." total ("
over + 100 -rot */ n. ." % free)" ;
: raw-ok ." v{{VERSION}} - rev {{REVISION}}" cr : raw-ok ." v{{VERSION}} - rev {{REVISION}}" cr
remaining . ." bytes heap free " boot-prompt @ if boot-prompt @ execute then
used . ." bytes dictionary used " ." Forth dictionary: " remaining used free. cr
'stack-cells @ cells . ." bytes x 3 stacks" cr ." 3 x Forth stacks: " 'stack-cells @ cells . ." bytes" cr
prompt refill drop quit ; prompt refill drop quit ;

View File

@ -555,7 +555,8 @@ e: test-esp32-forth-namespace
out: FORTH out: FORTH
;e ;e
e: check-esp32-basics e: check-esp32-platform
out: ok
out: LED out: LED
out: OUTPUT out: OUTPUT
out: INPUT out: INPUT
@ -567,6 +568,9 @@ e: check-esp32-basics
out: duty out: duty
out: adc out: adc
out: pin out: pin
out: default-key?
out: default-key
out: default-type
;e ;e
e: check-esp32-builtins e: check-esp32-builtins
@ -597,6 +601,7 @@ e: test-esp32-forth-namespace
out: out:
out: web-interface out: web-interface
out: httpd out: httpd
check-esp32-platform
out: oled out: oled
out: bluetooth out: bluetooth
out: rtos out: rtos
@ -612,11 +617,6 @@ e: test-esp32-forth-namespace
out: WiFi out: WiFi
out: Wire out: Wire
out: ESP out: ESP
out: ok
check-esp32-basics
out: default-key?
out: default-key
out: default-type
check-phase2 check-phase2
check-allocation check-allocation
check-phase1 check-phase1

View File

@ -56,7 +56,7 @@ transfer{
(do) (?do) (+loop) (do) (?do) (+loop)
parse-quote digit $@ raw.s parse-quote digit $@ raw.s
tib-setup input-limit tib-setup input-limit
[SKIP] [SKIP]' raw-ok [SKIP] [SKIP]' raw-ok boot-prompt free.
$place zplace BUILTIN_MARK $place zplace BUILTIN_MARK
}transfer }transfer
forth definitions forth definitions

View File

@ -16,6 +16,8 @@
vocabulary ESP ESP definitions vocabulary ESP ESP definitions
transfer ESP-builtins transfer ESP-builtins
only forth definitions
forth definitions forth definitions
vocabulary Wire Wire definitions vocabulary Wire Wire definitions

View File

@ -74,7 +74,7 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
YV(ESP, getChipModel, PUSH ESP.getChipModel()) \ YV(ESP, getChipModel, PUSH ESP.getChipModel()) \
YV(ESP, getChipCores, PUSH ESP.getChipCores()) \ YV(ESP, getChipCores, PUSH ESP.getChipCores()) \
YV(ESP, getFlashChipSize, PUSH ESP.getFlashChipSize()) \ YV(ESP, getFlashChipSize, PUSH ESP.getFlashChipSize()) \
YV(ESP, getCPUFreqMHz, PUSH ESP.getCPUFreqMHz()) \ YV(ESP, getCpuFreqMHz, PUSH ESP.getCpuFreqMHz()) \
YV(ESP, getSketchSize, PUSH ESP.getSketchSize()) \ YV(ESP, getSketchSize, PUSH ESP.getSketchSize()) \
YV(ESP, deepSleep, ESP.deepSleep(tos); DROP) YV(ESP, deepSleep, ESP.deepSleep(tos); DROP)

View File

@ -20,7 +20,7 @@ yield-task start-task
forth definitions forth definitions
( Set up Basic I/O ) ( Set up Basic I/O )
internals definitions internals definitions also serial
: esp32-bye 0 terminate ; : esp32-bye 0 terminate ;
: serial-type ( a n -- ) Serial.write drop ; : serial-type ( a n -- ) Serial.write drop ;
: serial-key ( -- n ) : serial-key ( -- n )
@ -36,6 +36,8 @@ also forth definitions
' esp32-bye is bye ' esp32-bye is bye
only forth definitions only forth definitions
also ledc also serial also SPIFFS
( Map Arduino / ESP32 things to shorter names. ) ( Map Arduino / ESP32 things to shorter names. )
: pin ( n pin# -- ) swap digitalWrite ; : pin ( n pin# -- ) swap digitalWrite ;
: adc ( n -- n ) analogRead ; : adc ( n -- n ) analogRead ;
@ -61,5 +63,16 @@ only forth definitions
led OUTPUT pinMode led OUTPUT pinMode
high led pin high led pin
internals definitions also ESP
: esp32-stats
getChipModel z>s type ." "
getCpuFreqMHz . ." MHz "
getChipCores . ." cores "
getFlashChipSize . ." bytes flash" cr
." System Heap: " getFreeHeap getHeapSize free. cr
." " getMaxAllocHeap . ." bytes max contiguous" cr ;
' esp32-stats internals boot-prompt !
only forth definitions
( Setup entry ) ( Setup entry )
internals : ok ." ESP32forth" raw-ok ; forth internals : ok ." ESP32forth" raw-ok ; forth

View File

@ -121,6 +121,27 @@ static cell_t *simulated(cell_t *sp, const char *op) {
cell_t ret = close(*sp); cell_t ret = close(*sp);
*sp = ret ? errno : 0; *sp = ret ? errno : 0;
return sp; return sp;
} else if (op == STR_getChipModel) {
*++sp = (cell_t) "FAKE-ESP32";
return sp;
} else if (op == STR_getCpuFreqMHz) {
*++sp = 240;
return sp;
} else if (op == STR_getChipCores) {
*++sp = 2;
return sp;
} else if (op == STR_getFlashChipSize) {
*++sp = 4 * 1024 * 1024;
return sp;
} else if (op == STR_getFreeHeap) {
*++sp = 90000;
return sp;
} else if (op == STR_getHeapSize) {
*++sp = 320 * 1024;
return sp;
} else if (op == STR_getMaxAllocHeap) {
*++sp = 80 * 1024;
return sp;
} else { } else {
fprintf(stderr, "MISSING SIM OPCODE: %s\n", op); fprintf(stderr, "MISSING SIM OPCODE: %s\n", op);
exit(1); exit(1);