Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this code functional for anyone #10

Closed
m-g-m opened this issue Nov 21, 2021 · 84 comments
Closed

Is this code functional for anyone #10

m-g-m opened this issue Nov 21, 2021 · 84 comments

Comments

@m-g-m
Copy link

m-g-m commented Nov 21, 2021

Honest question before I waste more hours debugging endless guru meditations.
Does this code work for anyone ? If so what hardware are you using ?
Thanks !

@terjeio
Copy link
Contributor

terjeio commented Nov 21, 2021

Oops, the latest version is broken - I'll try to get a fix out with an update later today.

If you want to give it a try now then the fix is replacing all occurences of #ifndef VFD_SPINDLE with #if VFD_SPINDLE != 1 in driver.c and in the selected board map file if present there.

@troth530
Copy link

I have been trying to get this compiled and working with a ESP32-WROVER-B. Had an issue with Ethernet and SDCard and may be related to FTP. Here is the issue. but now cannot get WIFI working. So I don't know if WEBUI is working and not sure if this is ready to go out of the box.

@terjeio
Copy link
Contributor

terjeio commented Nov 22, 2021

The version I committed yesterday works for me:

image

FTP is not started unless enabled with $70, 15 enables all protocols.

@troth530 - what are your settings in CMakelists.txt?

@m-g-m
Copy link
Author

m-g-m commented Nov 22, 2021

OK, success with the latest check-in from today 11/21/21. It compiled after fixing the board include file #ifdef VFD_SPINDLE statement(s). Basic machine stepping is working with ESPDUINO32 and protoner-style shield.

@troth530
Copy link

@terjeio I need to build with SDcard hardware to verify FTP functionality works which I haven't done yet.

In CMakelist.txt, I am using default for everything except Networking (line 18) and SDCard (line 21) set to ON. I am using ESP32-WROVER-B and WIFI is not broadcasting a SSID or working at all as far as I can tell.

@terjeio
Copy link
Contributor

terjeio commented Nov 22, 2021

@troth530 Default wifi mode is station, you will have to enable access point (AP) mode to make it broadcast anything:

OPTION(SoftAP "Enable soft AP mode" OFF)

I have not tested this in a long time, hopefully it still works...
Station mode works, for that you have to enter SSID and password in settings to connect to a access point:

$help wifi
---- WiFi:

$73: WiFi Mode:
    0 - Off
    1 - Station

$74: WiFi Station (STA) SSID, max: 64

$75: WiFi Station (STA) Password, max: 32
ok

@troth530
Copy link

@terjeio
Thank you for your help.
Yes, I've tried that setting in CMakelist,txt as well but it is still not broadcasting a SSID.
With SoftAP set to ON. This is my result.
Also settings in my_machine.h do not seem to trigger a need to recompile.

[VER:1.1f.20211029:]
[OPT:VNMSL,35,1024,3,0]
Target buffer size found
[NEWOPT:ENUMS,RT+,TC,SED,WIFI,SD]
[FIRMWARE:grblHAL]
[NVS STORAGE:*FLASH]
[DRIVER:ESP32]
[DRIVER VERSION:211029]
[BOARD:BDRING v4]
[WIFI MAC:24:6F:28:45:74:14]
[IP:0.0.0.0]
[PLUGIN:SDCARD v1.02]
ok
[MSG:WIFI STA DISCONNECTED]
[MSG:WIFI AP SCAN COMPLETED]
$73
$73=1
ok
$74
$74='GRBL'

@terjeio
Copy link
Contributor

terjeio commented Nov 22, 2021

AP mode works for me, both WebUI and FTP
Try a settings reset: $RST=* to set default values for AP mode, then restart - I had to do that.

image

The FTP port will not show up for you unless you have todays commit. Earlier versions uses port 21.

@troth530
Copy link

@terjeio I think your code is different, for example $73 had 4 options for me, I pulled from your repo about 2 weeks ago using these commands.
git clone --recursive git://github.com/grblHAL/ESP32
git pull --recurse-submodules
git submodule update --remote

Thank you!

$help wifi
---- WiFi:
$73: WiFi Mode:
0 - Off
1 - Station
2 - Access Point
3 - Access Point/Station
$74: WiFi Station (STA) SSID, max: 64
$75: WiFi Station (STA) Password, max: 32
$76: WiFi Access Point (AP) SSID, max: 64
$77: WiFi Access Point (AP) Password, max: 32

@terjeio
Copy link
Contributor

terjeio commented Nov 23, 2021

The $help wifi command outputs available commands/options and those depend on AP mode option enabled or not.
When enabled I get:

---- WiFi:
$73: WiFi Mode:
    0 - Off
    1 - Station
    2 - Access Point
    3 - Access Point/Station
$74: WiFi Station (STA) SSID, max: 64
$75: WiFi Station (STA) Password, max: 32
$76: WiFi Access Point (AP) SSID, max: 64
$77: WiFi Access Point (AP) Password, max: 32

which is the same as you get.

Did you reset the settings with $RST=* and try again?
Is $73 set to to 2? Other settings are ok to? The settings shown in the screen dump above are those that works for me.

I commited an update yesterday, if the one you have is not working please update to that.

@troth530
Copy link

@terjeio, I stashed what I had, updated to the latest commit and it compiled with
Networking, SDcard and SoftAP all 3 set to ON. I believe this will meet my needs, but need to confirm.
With the 3 above including SDcard set ON, FtpDaemon set ON will not compile, but I don't know if it's needed.
I will confirm the hardware behaves as expected.
Yet, any changes to my_machine.h does not force it to recompile, are all changes intended through CMakeList.txt?
I will close the other issue.
Thank you!

@terjeio
Copy link
Contributor

terjeio commented Nov 23, 2021

With the 3 above including SDcard set ON, FtpDaemon set ON will not compile, but I don't know if it's needed.

You get compilation errors?

Yet, any changes to my_machine.h does not force it to recompile, are all changes intended through CMakeList.txt?

Yes, since my_machine.h is disabled in CMakeLists.txt by default.

@troth530
Copy link

@terjeio here is the error with FtpDaemon set ON (SDcard set ON).
I see my_machine.h disabled now in the board section.
Thank you!

Compile error snippet
...
^~~~~~~
[52/57] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/wifi.c.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/wifi.c.obj
ccache C:\Users\troth530.espressif\tools\xtensa-esp32-elf\esp-2021r2-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DBOARD
...

@terjeio
Copy link
Contributor

terjeio commented Nov 23, 2021

@troth530 This compiler error makes no sense for me, no line number where it fails?
Corrupted file? Submodules not up to date? Does it go away if you disable FTP?

@terjeio
Copy link
Contributor

terjeio commented Nov 23, 2021

@troth530 I believe I've found the reason, the networking plugin somehow was not updated yesterday. My local master were not pushed by the script I use, I have now done it manually.

@troth530
Copy link

@terjeio I believe there is more missing.
I recall I had to manually enable FatFS dependency on a Teensy build. Here is the error.
Thank you!

[56/57] Linking CXX executable grbl.elf
FAILED: grbl.elf
cmd.exe /C "cd . && C:\Users\troth530.espressif\tools\xtensa-esp32-elf\esp-2021r2-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\grbl.elf.rsp -o grbl.elf && cd ."
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(ftpd.c.obj):(.literal.cmd_cdup+0x4): undefined reference to f_chdir' c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(ftpd.c.obj): in function cmd_cdup':
c:\users\troth530\esp\esp-idf\esp32\build/../main/networking/ftpd.c:640: undefined reference to f_chdir' c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(ftpd.c.obj): in function cmd_cwd':
c:\users\troth530\esp\esp-idf\esp32\build/../main/networking/ftpd.c:635: undefined reference to f_chdir' c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(vfs.c.obj):(.literal.vfs_getcwd+0x0): undefined reference to f_getcwd'
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(vfs.c.obj): in function vfs_getcwd': c:\users\troth530\esp\esp-idf\esp32\build/../main/networking/vfs.c:155: undefined reference to f_getcwd'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

@terjeio
Copy link
Contributor

terjeio commented Nov 24, 2021

@troth530 That helps, same issue here as with the iMXRT1062 - ffconf.h has to be edited and #define FF_FS_RPATH changed to 2. I see now that I did that back in may when I started porting ftpd.
On my machine ffconf.h is located in esp\esp-idf\components\fatfs\src in the ESP SDK, on my machine the SDK is in my user folder. I will add a note about this in the readme.

It is a pity that the FatFs source is not written in a way that allow setting configuration symbols like this in CMakeLists.txt, perhaps the author ChaN should be asked to change that?

@troth530
Copy link

@terjeio correct. In fact on the Teensy I used your patched utility/sd_sdhc.c and had to #define FF_FS_PATH to 2. In addition to those items you had documented, for the Teensy I had to make several manual changes so the include statements would point to the correct location I'd placed the FatFS- maybe due to how I organized the files manually and my inexperience with GIT.

On my computer there is also ffconf.h in the same location as yours in the ESP SDK and I made the change to FF_FS_PATH=2. Do you believe it is preferred to use the one in the SDK or FatFS by WMXZ-EU?

However it still does not explain my issues with wifi not broadcasting, am I missing a manual step to turn wifi on for this device due to my inexperience? FTPDaemon=ON compile error seems a downstream artifact of wifi not working and possibly something different in my code versus your code. Confirming that I have used $RST=* and $73 is set to 2, I cannot set $70 to 15 (only can set o 7). I have confirmed same behavior of wifi not broadcasting with both ESP WROVER-B and WROOM.

@terjeio
Copy link
Contributor

terjeio commented Nov 25, 2021

Do you believe it is preferred to use the one in the SDK or FatFS by WMXZ-EU?

The SDK is used by the ESP32 driver, the WMXZ-EU by the iMXRT1062 driver - they cannot be swapped around as there is low level driver code added by the framework used by the drivers that is MCU specific.

However it still does not explain my issues with wifi not broadcasting, am I missing a manual step to turn wifi on for this device due to my inexperience?

Add your CMakelists.txt and your settings here, preferably as attachments, and I'll check. If you are on Windows and have ioSender installed use Help > About > To clipboard to get both $I and $$ output and paste the result into a file,.

@troth530
Copy link

@terjeio
The only setting changes are those in CMakeList.txt, if you'd like any other settings please let me know. As always, Thank you!

settings.txt
CMakeLists.txt

@terjeio
Copy link
Contributor

terjeio commented Nov 26, 2021

Settings looks ok, I have flashed with your settings and it works for me. Can you try with the binary I made? I have uploaded it as grblHAL ESP32 FTP.zip here.

There is one snag likely due to the fact that I run the ESP32 "naked" (not inserted in a breakout board) - it crashes in a loop when I connect the SD card. I guess this is due to some missing pull-up resistors... When I run it when compiled for and inserted in my CNC Boosterpack board this does not happen.

Here is the output to a terminal I get when I connect and run a short WebUI session, after I connected I issued a $I command from the terminal.

ets Jun  8 2016 00:22:57

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:2
load:0x3fff0030,len:4
load:0x3fff0034,len:1380
load:0x40078000,len:11140
ho 0 tail 12 room 4
load:0x40080400,len:3864
entry 0x40080658

GrblHAL 1.1f ['$' or '$HELP' for help]
[MSG:WIFI AP READY]
[MSG:WIFI AP CONNECTED]
[VER:1.1f.20211125:]
[OPT:VNMSL,35,1024,3,0]
[NEWOPT:ENUMS,RT+,TC,SED,WIFI,FTP,SD]
[FIRMWARE:grblHAL]
[NVS STORAGE:*FLASH]
[DRIVER:ESP32]
[DRIVER VERSION:211124]
[BOARD:BDRING v4]
[WIFI MAC:3C:71:BF:4C:98:78]
[IP:192.168.5.1]
[PLUGIN:SDCARD v1.03]
[PLUGIN:ESP32 WebUI v0.03]
ok
[MSG:WEBSOCKET STREAM ACTIVE]
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ|Ov:100,100,100>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
<Idle|MPos:0.000,0.000,0.000|Bf:35,1023|FS:0,0|Pn:PXYZ>
[MSG:SERIAL STREAM ACTIVE]

@troth530
Copy link

@terjeio your bin file works great, I used ESP download tool to program. For now, I am running my development boards naked as well.

With my bin file no Wifi, no SSID broadcast. I also tried fresh install on another computer using esp-idf-tools-setup-offline-2.12.exe Still no Wifi when I compile.

WifiWorkTerjeioBin
.

@terjeio
Copy link
Contributor

terjeio commented Nov 27, 2021

@troth530 What is your IDF version? You can find it in components\esp_common\include\esp_idf_version.h

I am using 4.2 and compiling with VSCode.

@troth530
Copy link

troth530 commented Nov 27, 2021

@terjeio ESP IDF Version is 4.3.1. I did some looking around in WebUI with your build (the bin file you uploaded) and the machine does not respond to jog commands, commands at the User Interface or read back grbl settings. It does however show information in the ESP Status window as you've shown.

Do you have instructions how to downgrade IDF version and install VSCode?
(Update)
I can download 4.2 from here, I will follow instructions for installing submodules as well
https://github.com/espressif/esp-idf/releases
(end of Update)

Thank you.

@terjeio
Copy link
Contributor

terjeio commented Nov 27, 2021

@troth530 Please wait a bit - I have rewritten the event handling to not use deprecated calls, I want you to try that first. I will complete that tomorrow.

What is the status shown in the WebUI? Is it "IDLE"? If in "ALARM" state this could be the reason there is no reaction to jog commands. Check this wiki page for more.

Here is the console output when I execute a jog:

image

What do you get?

@troth530
Copy link

@terjeio , I get no response in WebUI, I can see the $J input commands but no response from the ESP32.
IOSender and Lightburn jogging works as expected, so it's not coming up in alarm state .
Could be related to default Windows 10 firewall settings, I'll look into some SSH settings.
Thank you!

@terjeio
Copy link
Contributor

terjeio commented Nov 27, 2021

Port 81 for the websocket is blocked? Try connecting with ioSender to that.

@terjeio
Copy link
Contributor

terjeio commented Nov 28, 2021

@troth530 In IDF versions after 4.2 Espressif have changed the returned wifi mode in a call that leads to AP mode not beeing set up:

ESP32/main/wifi.c

Lines 390 to 416 in 52f2d83

if(esp_wifi_get_mode(&currentMode) == ESP_ERR_WIFI_NOT_INIT) {
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
aplist_mutex = xSemaphoreCreateMutex();
// TODO: add error messages on fail?
if(esp_event_loop_init(wifi_event_handler, NULL) != ESP_OK)
return false;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
if(esp_wifi_init(&cfg) != ESP_OK)
return false;
if(esp_wifi_set_storage(WIFI_STORAGE_RAM) != ESP_OK)
return false;
if(esp_wifi_set_mode(WIFI_MODE_NULL) != ESP_OK)
return false;
}
wifi_config_t wifi_config;
if(currentMode != settingToMode(wifi.mode) && (wifi.mode == WiFiMode_AP || wifi.mode == WiFiMode_APSTA)) {

The test at line 416 fails due to this. Add currentMode = WIFI_MODE_NULL; before line 412 to fix it.I'll add it in the next commit.

@troth530
Copy link

@terjio
This addition before line 412 (currentMode = WIFI_MODE_NULL; to wifi.c) in fact does turn on WiFi finally!

I still cannot compile with FtpDaemon=ON here is the error, same as before may be an IDF compiler error.

../main/networking/ftpd.c:419:37: error: 'vfs_stat_t' {aka 'struct '} has no member named 'st_mtim'; did you mean 'st_mtime'?
s_time = gmtime(&st.st_mtime);
^~~~~~~~
ninja: build stopped: subcommand failed.

Bluetooth=ON makes the device constantly reboot

Connecting to HTTP 192.168.5.1:80 still has same behavior and jogging does not work in WebUI
I can connect to IOSender using websocket 81 with my bin file, I previously could not connect to IOSender with your bin file using websocket 81.
Here is what I see in WebUI, looks like a configuration file is missing or I need to login as Admin?

GrblConfigError

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Nov 29, 2021

I still cannot compile with FtpDaemon=ON here is the error, same as before may be an IDF compiler error.

See issue #8 - the latest commit has a workaround for this IDF/compiler issue.

Bluetooth=ON makes the device constantly reboot

I'll try this again - enabling Bluetooth on a "naked" board may trigger an ESP32 issue that has not been resolved. It has been reported by several people, including myself.

Here is what I see in WebUI, looks like a configuration file is missing or I need to login as Admin?

No, it is due to the websocket connection not established/not working.

I you have a terminal window open when you start the WebUI do you get this message:
[MSG:WEBSOCKET STREAM ACTIVE]
followed by status reports?

Which browser are you using? Is compatible with the WebUI?

@troth530
Copy link

@terjeio interesting. Slowing the speeds and accel way down seems to keep the Guru from showing himself, but does it make sense that the ESP32 can only spool gCode at half the speed of STM32? I am now getting around 1:11 via USB/UART and I observed better using websocket around 1:00. This is now in a practical range of operation for some machines but not all. Basically limited to 200mm/sec, with accel approximately 2000mm/s/s. I did observe that it was sensitive to acceleration, so I changed the M4 to M3 to see if it helped and it did, but that may imply a processing issue, not a communications issue.

@terjeio
Copy link
Contributor

terjeio commented Dec 12, 2021

... but does it make sense that the ESP32 can only spool gCode at half the speed of STM32?

Over a USB connection yes it does, ESP32 has an USB <> UART chip in between the USB port and the MCU so the configured baud rate is real, with the USB stack in the MCU there is no such bottleneck and the baud rate setting usually has no meaning. I have seen transfer rates > 150Kbytes/s with iMXRT1062, ESP32 is limited to 115Kbits/s (which is ~11Kbytes/s) as it is configured now. The baud rate setting can be increased for ESP32 here if you want to try that:

serial_stream = serialInit(115200);

I did observe that it was sensitive to acceleration, so I changed the M4 to M3 to see if it helped and it did, but that may imply a processing issue, not a communications issue.

Hopefully the workaround I made will fix that - I will commit that later as it required changes to the core.

@troth530
Copy link

@terjeio

Over a USB connection yes it does, ESP32 has an USB <> UART chip in between
Makes perfect sense

Unfortunately, increasing Baud shows no benefit tried 460800 and no benefit.

Hopefully the workaround I made will fix that - I will commit that later as it required changes to the core.

Looking forward to that.

For the control pins- reset_pin, feed_hold_pin and cycle_start_pin, are external pullups required? For some reason reset pin does not perform control reset when pulled low (so I used the reset pin on the ESP32) but it's behavior is a full controller restart. feed_hold works, but then cycle_start does not restart execution of the gCode. To complicate matters I should mention that on the WROVER device I am using, GPIO36 and 39 are senseVP and senseVN.

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 13, 2021

Unfortunately, increasing Baud shows no benefit tried 460800 and no benefit.

I halved the time to transfer data in Check mode when I went to 230400, to 460800 showed no improvement over 230400.

The workaround is now committet alongside a lot of other changes that I hope does not break anything. These are a using new core based stream switcher (from UART to Websocket to SD Card etc. and back), support for ganged/auto squared axes, Trinamic stepper driver support++

For the control pins- reset_pin, feed_hold_pin and cycle_start_pin, are external pullups required?

IMO yes. Relying on the weak internal pullups is inviting problems. More current through the switches are generally better, at least above the wetting current. A capacitor across the switch may help increasing the wetting current too. I see some using optocouplers adding the capacitor on the transistor side of the optocoupler for noise filtering, better to have it accross the switch as most optocouplers act as a low-pass filter anyway.

For some reason reset pin does not perform control reset when pulled low (so I used the reset pin on the ESP32) but it's behavior is a full controller restart. feed_hold works, but then cycle_start does not restart execution of the gCode.

Does the LED indicators change in ioSender depending on the switch state?
Also, there is some interlocking betwteen the switches, e.g. if feed hold is asserted cycle start will not work.

To complicate matters I should mention that on the WROVER device I am using, GPIO36 and 39 are senseVP and senseVN.

I'll have to check this as I do not know what senseVP and senseVN is for.

@troth530
Copy link

@terjeio Control pins are working as expected, some minor errors on my end. senseVP and senseVN work fine as inputs only (limits switches)

Latest build I am unable to compile with FTP turned on. But I don't need it, was just trying to help provide cross-feature feedback for you.

As I have expanded testing to hardware, I find that using 3 axes works fine, if I set N_AXES to 4 in config.h not only does the A axis not work, but it disables the Z axis (or I should say the Z axis no longer moves). Commands like G0A10 are accepted but do not enable the step enable, direction or step pins on A axis and Z axis has same behavior. The pins assigned to A axis, can be swapped over to the Z axis with N_AXES set to 3, so it appears the hardware is not at fault. It seems like it could be a copy paste error in the driver???

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 21, 2021

I have fixed a mistake introduced when I added support for ganged/auto squared axes - I only tested auto squaring so I missed it. Up now.

FTP compiles for me but is a bit unstable at times. To be investigated.

FYI I got bitten by what is likely silicone bug when I switched to my CNC Boosterpack test jig with limit and control inputs open - I got a hard limit alarm with wifi enabled and hard limits disabled. It is due to a spuroius interrupt intermittently generated by the radio. The workaround suggested by Espressif does not help.

As I have expanded testing to hardware, I find that using 3 axes works fine, if I set N_AXES to 4 ...

Which board map are you using then? Your own?

@troth530
Copy link

troth530 commented Dec 21, 2021

@terjeio, I am using my own board map to get 4 axes, cutting probe and flood to get step and direction pins for A axis.

I tried FTP again and it now compiles, and I don't know why it was not compiling before.

Now testing bluetooth and it shows this error
../main/bluetooth.c:83:3: error: 'io_stream_t' {aka 'const struct '} has no member named 'connected'
.connected = true,
^~~~~~~~~

I will try your latest updates and verify if bluetooth compile error remains.

@troth530
Copy link

@terjeio , the latest build (Dec20) does not move any motors, even with 3 axes.
Dec 03 build works with 3 axes, with FTP.
Bluetooth ON does not compile with Dec 03 build or the Dec 20 build
Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 22, 2021

the latest build (Dec20) does not move any motors, even with 3 axes.

$4=15? or 7 with 3 axes configured.

Bluetooth ON does not compile with Dec 03 build or the Dec 20 build

It compiles for me, but suddenly started to send the welcome message repeatedly. ESP32 can drive you crazy...
Any compiler error message?

@terjeio
Copy link
Contributor

terjeio commented Dec 22, 2021

Espressif cannot count or keeps errors secret to later let the Guru annoy you. Errors? Which errors?

image

@troth530
Copy link

@terjeio definitely was using $4=15, by #define INVERT_ST_ENABLE_MASK AXES_BITMASK in config.h. None of the motors move, but the controller believes they have moved, I will hook up a scope tomorrow to see if the issue is enable pin or step/dir pins not getting signals

On Dec03 build the Bluetooth compile error is:
../main/bluetooth.c:83:3: error: 'io_stream_t' {aka 'const struct '} has no member named 'connected'
.connected = true,
^~~~~~~~~
On Dec 21 build the Bluetooth compile error is
[66/67] Linking CXX executable grbl.elf
FAILED: grbl.elf
cmd.exe /C "cd . && C:\Users\troth530.espressif\tools\xtensa-esp32-elf\esp-2021r1-8.4.0\xtensa-esp32-elf\bin\xtensa-
esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\grbl.elf.rsp -o grbl.elf && cd ."
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-
elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: grbl.elf section .dram0.bss' will not fit in region dram0_0_seg'
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-
elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-
elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.
c:/users/troth530/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-
elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: region `dram0_0_seg' overflowed by 30360 bytes
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Much of the behavior I see with ESP32 makes no sense, and above expected even for a new device. aIssues not always repeatable. It's a very moody device.
Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 22, 2021

Post your map file. Do you enable bluetooth and wifi at the same time? - asking since the error is for not enough DRAM (overflowed by 30360 bytes).

I have tested bluetooth with all the board maps that can be run "naked" - and I can connect to all. My CNC Boosterpack map causes spurious interrupts triggering reset and may reenter main() repeatedly without the Guru reporting anything at all. And no joy connecting via bluetooth. To be investigated further...

This issue is revealing that the Guru may in fact be a Demon?

@terjeio
Copy link
Contributor

terjeio commented Dec 22, 2021

Pin 36 and 39 fire regular interrupts at roughly 500ms interval when bluetooth is enabled. I use those for feed hold and cycle start. This comment sums it up?

A settings reset cured the bluetooth connect problem with my CNC Boosterpack, my bad not doing that earlier. This with feed hold and cycle start pins remapped (not using pin 36 and 39).

@troth530
Copy link

troth530 commented Dec 25, 2021

@terjeio yes, I see there are lots of problems, CPUs like ESP32 make you perform a lot of magic tricks that otherwise should not be required.

Is there any way to be able to use Bluetooth with Networking enabled? I think the DevKits are limited to 4Mb, but it looks like I need 8Mb which will mean I need to make my own DevKit using a 8Mb WROVER module. Can it be done with a change to the partition table for the 8Mb WROVER module?

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 26, 2021

Is there any way to be able to use Bluetooth with Networking enabled?

I do not know, if you search for that some says it can be done some not. When I compile with both enabled the ESP32 reboots itself endlessly with no reason given - the Guru beeing fast asleep. Maybe not enough RAM, not detected/reported by the linker?

Can it be done with a change to the partition table for the 8Mb WROVER module?

There is plenty of flash available, your issue is abour RAM so no. When I check RAM with the WebUI interface I have 100K free, how much do you have?

@troth530
Copy link

@terjeio I will see what can be done to resolve the compilation error with both Bluetooth and Networking, but in the end, I may run into the same issue with the ESP32 that you have observed.

As a general grblHal question, I have observed that Z and A axes seem to be negative axes. By that I mean that with soft limits enabled after homing jogging is only allowed in negative direction (attempts to jog in + result in soft limit error). Is there a simple $ setting to adjust?

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Dec 27, 2021

Is there a simple $ setting to adjust?

Yes, use $22=9 (1 + 8) to set machine origin to 0. Output from $$=22 (or $help homing):

$22: Homing cycle as bitfield where setting bit 0 enables the rest:
    0 - Enable (1)
    1 - Enable single axis commands (2)
    2 - Homing on startup required (4)
    3 - Set machine origin to 0 (8)
    4 - Two switches shares one input pin (16)
    5 - Allow manual (32)
    6 - Override locks (64)
    7 - Keep homed status on reset (128)

Enables homing cycle. Requires limit switches on axes to be automatically homed.

When `Enable single axis commands` is checked, single axis homing can be performed by $H<axis letter> commands.

When `Allow manual` is checked, axes not homed automatically may be homed manually by $H or $H<axis letter> commands.

`Override locks` is for allowing a soft reset to disable `Homing on startup required`.
ok

@troth530
Copy link

@terjeio I now have dedicated hardware and my latest testing shows disconnect from wifi through windows 10 and windows 7 Network settings will panic the core and cause the guru to meditate. Have you observed clean wifi disconnects. I hesitate to post this since my build is a little behind your latest commits.

Still trying to get Bluetooth and WiFi working together and checking for why Z and A (non-homed axes are effectively negative) with $22=9, I have been using $22=11.

@terjeio
Copy link
Contributor

terjeio commented Jan 27, 2022

Have you observed clean wifi disconnects.

I do not use a ESP32 based controller myself, and it is not my goto platform for development as it is painfully slow to work with due to the snowflake guru and the lack of a debugger. So no I have not seen any.

I hesitate to post this since my build is a little behind your latest commits.

Please update then.

... and checking for why Z and A (non-homed axes are effectively negative) with $22=9, I have been using $22=11.

Not sure what you mean by this. All axes are set to machine position 0 on a cold start regardless of their physical position. After homing the homed axes are changed to 0 or -(max travel - pulloff distance) depending on the configuration.

@troth530
Copy link

@terjeio To clarify- when I connect to the AP I can open and close the Webgui properly, but disconnecting from the AP through windows Network Settings makes the Guru rear its ugly head (both on Win 7 and Win10). I would suspect that even moving out of wifi range while connected would also cause the crash. I will also check Android.

Disregard the homing issue, with the latest build it behaves properly.

Thank you!

@troth530
Copy link

@terjeio crash reports
Notice only difference between Android is Win 7 does not return the serial stream

Android when disconnecting from AP
[MSG:WIFI AP CONNECTED]
[MSG:WEBSOCKET STREAM ACTIVE]
...........
[MSG:SERIAL STREAM ACTIVE]
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00000000 PS : 0x00060b30 A0 : 0x80166b6e A1 : 0x3ffbb7f0
A2 : 0x00000000 A3 : 0x3f4005e1 A4 : 0x3f40c040 A5 : 0x3ffe7e34
A6 : 0x400e6ee4 A7 : 0x00000000 A8 : 0x800e6f81 A9 : 0x3ffbb7d0
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x3ffb27fc
A14 : 0x3ffb25ac A15 : 0x3ffbad8c SAR : 0x00000016 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace:0xfffffffd:0x3ffbb7f0 0x40166b6b:0x3ffbb810 0x40166c36:0x3ffbb860
ELF file SHA256: 06b59b3382e60bb3
CPU halted.

Windows 7

[MSG:WIFI AP CONNECTED]
[MSG:WEBSOCKET STREAM ACTIVE]
....
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x00000000 PS : 0x00060b30 A0 : 0x80166b6e A1 : 0x3ffbb7f0
A2 : 0x00000000 A3 : 0x3f4005e1 A4 : 0x3f40c040 A5 : 0x3ffe7d30
A6 : 0x400e6ee4 A7 : 0x00000000 A8 : 0x800e6f81 A9 : 0x3ffbb7d0
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x3ffb27fc
A14 : 0x3ffb25ac A15 : 0x3ffbad8c SAR : 0x00000015 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace:0xfffffffd:0x3ffbb7f0 0x40166b6b:0x3ffbb810 0x40166c36:0x3ffbb860
ELF file SHA256: 06b59b3382e60bb3
CPU halted

terjeio added a commit that referenced this issue Jan 31, 2022
@terjeio
Copy link
Contributor

terjeio commented Jan 31, 2022

@troth530 - another commit is just up. Issue was likely due a regression caused by consolidationg stream handling in the core.

@troth530
Copy link

troth530 commented Feb 2, 2022

@terjeio The latest commit does in fact fix the crash during AP disconnect, but gCode that previously could run in about 60 seconds now takes over 14:20. The last time I tested the speed may have been around Dec 20,2021 before you fixed the 4th axis issue.

Thank you!

@terjeio
Copy link
Contributor

terjeio commented Feb 3, 2022

Change this line to:
xTaskCreatePinnedToCore(vGrblTask, "Grbl", 5120, NULL, 1, NULL, 1);

that should improve speed a bit. However, I cannot get this driver to to achieve transfer speeds that others can. E.g. the iMXRT1062 driver tops out at over 600Kbytes/s in check mode over a websocket connection and is rock solid. It runs "bare metal" though - no RTOS. The MSP432E401Y driver runs as a FreeRTOS task and manages 75Kbytes/s - again rock solid.

The ESP32 manages a whopping 38Kbytes/s if it does not mess up the data stream, which it does regularly for some reason my aging brain cannot understand. Maybe somebody else can figure out what I am doing wrong?

For a fair comparison the MSP432E401Y has a single core 120MHz M4 processor, the ESP32 a dual core 240 MHz processor.

Here are the relevant ioSender settings I have used when tesing:

image

And the websocket code pre a refactoring I did late december:

websocketd.zip

I have renamed the file and some functions so it can be used with the current codebase.

@terjeio
Copy link
Contributor

terjeio commented Feb 3, 2022

@troth530 Increasing the task priority caused the watchdog to start barking out a stack trace at irregular intervals without crashing the MCU. I then found out that the FreeRTOS scheduler was running at a tick rate of only 100Hz. So I gave it another go by increasing the tick rate to 1KHz and once again trying to figure out why this MCU is so slow and unstable when it comes to network traffic.

By adding a critical section around some code in the telnet and websocket daemons I could increase the polling frequency and bingo now it seems to be stable and a bit faster to boot! It now manages a transfer rate of about 84 Kbytes/s - not super impressive but tolerable?

I have just committed the changes and I hope this is the end of this saga.

@troth530
Copy link

troth530 commented Feb 4, 2022

Hi @terjeio, yes booting is very much faster and you did improve the speed from 14:20 to 6:20 for the same Gcode I uploaded greyscale_raster_test_500.nc .
Recall that gCode previously ran 1:00 using earlier builds such as Dec 12, 2020 build that had an issue of disconnecting from the AP would crash.

With the latest code, with no motors it runs in 6:20 with speed and accel turned very high. In Check Mode it runs in 0:50. The behavior is also much more stable. Is it possible that the issue is something as simple as the spindle spinning up?

Anyway hoping I am giving you enough hints to help you sort this out and hopefully not confusing you.
Thank you!

@terjeio
Copy link
Contributor

terjeio commented Feb 4, 2022

Another regression from a requested change...

Add
sys.mode = settings.mode;
to grbl/grbllib.c at line 253 to fix it.

In Check Mode it runs in 0:50.

For me it runs in 0:08 after the latest changes, a bit strange that you get 0:50. A sender issue?

And you may have to tune the planner buffer size to get high engraving speeds. Some have set this as high as 1000+ for the iMXRT1062 driver but I doubt the ESP32 is able to handle that. Start with 200 - 300?
The iMXRT1062 runs the file in 0:27 with max feed rate at 50000, accel at 5000 and planner buffer size at 900.

@troth530
Copy link

troth530 commented Feb 5, 2022

@terjeio that was the correct fix. Prior to the fix it worked in Check Mode in 0:50, now 0:08 and impressive times with other senders at high velocity and accel. Yes, I'm very aware of the tuning needed and it was that fix you posted.

If you would like someone to test your future releases with hardware, I can give you my email.

Impressive work. Thank you!

@terjeio terjeio closed this as completed Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants