grblHAL / iMXRT1062

grblHAL driver for NXP iMXRT1062 (Teensy 4.x)
Other
50 stars 35 forks source link

Compile errors with latest code. #49

Closed andrewmarles closed 1 year ago

andrewmarles commented 1 year ago

Trying to publish some updated builds, I am getting some compile errors that seem to be related mainly to the RTC functions. I get these errors even with a completely fresh checkout of the core iMXRT1062 repo.

src\driver.c:2215:16: error: invalid initializer
src\driver.c:2217:13: error: incompatible type for argument 1 of 'rtc_set'
     rtc_set(t);
             ^

src\driver.c: In function 'get_rtc_time':
src\driver.c:2225:20: error: invalid initializer
         time_t t = rtc_get();

src\grbl\nuts_bolts.c: In function 'get_datetime':
src\grbl\nuts_bolts.c:287:22: error: storage size of 'dt' isn't known
     static struct tm dt;
                      ^

src\grbl\nuts_bolts.c:293:27: error: invalid application of 'sizeof' to incomplete type 'struct tm'
     memset(&dt, 0, sizeof(struct tm));
                           ^
terjeio commented 1 year ago

Which Teensyduino version? It compiles and works for me with 1.54 (Arduino IDE).

andrewmarles commented 1 year ago

PlatformIO.ini is pulling down 1.53 from line 47:

platform = ${common_teensy.platform}@4.12

I tried with the latest 4.17 and teensyduino 1.57, but that led to the errors from https://github.com/grblHAL/iMXRT1062/issues/15

Will try it with 1.54.

andrewmarles commented 1 year ago

Modifying the platformIO.ini from the repo to pull in https://github.com/WMXZ-EU/uSDFS I am able to compile with 1.54. It's not completely clear to me if this is the expected resolution for #15 ?

terjeio commented 1 year ago

I was wrong, I have updated to 1.56... 1.57 reintroduces the _'msSCSICapacityt' has not been declared error?

It's not completely clear to me if this is the expected resolution for https://github.com/grblHAL/iMXRT1062/issues/15 ?

It is, the random delay bug was nasty as it did not show up in all grblHAL configurations.

andrewmarles commented 1 year ago

Ok, at least I can claim some small grip on my sanity. I will also try with 1.56.

andrewmarles commented 1 year ago

With 1.56 and the patch it compiles. I'll look at making a PR to update platformio.ini.

agent-r commented 1 year ago

Could someone give a short discription what changes to make in platfomio.ini and what/how to patch?

dresco commented 1 year ago

Could someone give a short discription what changes to make in platfomio.ini and what/how to patch?

Change the platform line to platform = ${common_teensy.platform}@4.15 - this should pull in the 1.56 teensyduino library.

Under lib_deps, remove the two wwatson sources, and add https://github.com/WMXZ-EU/uSDFS. This still needs patching though, so after first build attempt, open up the .pio/libdeps/teensy41/uSDFS folder and copy in the updated files from the included uSDFS.zip.

@terjeio @andrewmarles I suppose the upstream library could be patched at installation with an extra_scripts directive, but perhaps easier to just point to a pre-patched fork?

agent-r commented 1 year ago

Thank you!

terjeio commented 1 year ago

perhaps easier to just point to a pre-patched fork?

Yes I think so, or IMO rather include the source in the driver. A pity that the Arduino IDE is so simple and that it was not possible to get the uSDFS fixed...

BTW building with the new web builder is another alternative? Perhaps ditch Arduino IDE support when web builder is deemed stable?

szaghi commented 1 year ago

Hi @dresco , I have tried to execute your suggestions, but I have failed. In particular I missed the point

remove the two wwatson soruces

Which files have I to remove?

The other modifications should have been done correctly, but I have the following compiling errors:

Compiling .pio\build\teensy41\libd7d\uSDFS\utility\sd_spi.c.o
In file included from .pio\libdeps\teensy41\MSC-non-blocking\src\msc.h:31:0,
                 from .pio\libdeps\teensy41\MSC-non-blocking\src\MassStorageDriver.cpp:29:
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2056:2: error: 'msSCSICapacity_t' does not name a type
  msSCSICapacity_t msCapacity;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2057:2: error: 'msInquiryResponse_t' does not name a type
  msInquiryResponse_t msInquiry;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2058:2: error: 'msRequestSenseResponse_t' does not name a type
  msRequestSenseResponse_t msSense;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2059:2: error: 'msDriveInfo_t' does not name a type
  msDriveInfo_t msDriveInfo;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2078:31: error: 'msSCSICapacity_t' has not been declared
  uint8_t msReadDeviceCapacity(msSCSICapacity_t * const Capacity);
                               ^
compilation terminated due to -fmax-errors=5.
In file included from .pio\libdeps\teensy41\MSC-non-blocking\src\msc.h:31:0,
                 from .pio\libdeps\teensy41\MSC-non-blocking\src\MassStorageHost.cpp:31:
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2056:2: error: 'msSCSICapacity_t' does not name a type
  msSCSICapacity_t msCapacity;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2057:2: error: 'msInquiryResponse_t' does not name a type
  msInquiryResponse_t msInquiry;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2058:2: error: 'msRequestSenseResponse_t' does not name a type
  msRequestSenseResponse_t msSense;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2059:2: error: 'msDriveInfo_t' does not name a type
  msDriveInfo_t msDriveInfo;
  ^
C:\Users\stefa\.platformio\packages\framework-arduinoteensy\libraries\USBHost_t36/USBHost_t36.h:2078:31: error: 'msSCSICapacity_t' has not been declared
  uint8_t msReadDeviceCapacity(msSCSICapacity_t * const Capacity);
                               ^
compilation terminated due to -fmax-errors=5.
Compiling .pio\build\teensy41\liba9e\lwip\api\api_lib.c.o
*** [.pio\build\teensy41\libf4b\MSC-non-blocking\MassStorageDriver.cpp.o] Error 1
*** [.pio\build\teensy41\libf4b\MSC-non-blocking\MassStorageHost.cpp.o] Error 1

Can someone help me to build the firmware?

Kind regards

dresco commented 1 year ago

Which files have I to remove? Can someone help me to build the firmware?

Replace these two lines in platformio.ini with https://github.com/WMXZ-EU/uSDFS

https://github.com/grblHAL/iMXRT1062/blob/f94a0596bfd1fb03a1d5d74a054e5d7115e28ca6/grblHAL_Teensy4/platformio.ini#L32-L33

szaghi commented 1 year ago

@dresco it worked, thank you very much!

szaghi commented 1 year ago

Hi all, I am very sorry to bother you again, but I have a new problem with the latest firmware that I compiled yesterday with the help of @dresco : if I activate the spindle plugin I got the following error:

src\driver.c:1518:34: error: 'spindleConfig' undeclared (first use in this function)
         if(hal.spindle.config == spindleConfig)
                                  ^
src\driver.c:1518:34: note: each undeclared identifier is reported only once for each function it appears in
src\driver.c:1519:13: warning: implicit declaration of function 'spindleConfig' [-Wimplicit-function-declaration]
             spindleConfig();
             ^
*** [.pio\build\teensy41\src\driver.c.o] Error 1

with the previous version I used (4.12) this did not happened. Can someone help me? Kind regards, Stefano

terjeio commented 1 year ago

.. I have a new problem with the latest firmware

@szaghi Sorry, I have indroduced a new bug.

Change this line to: https://github.com/grblHAL/iMXRT1062/blob/f94a0596bfd1fb03a1d5d74a054e5d7115e28ca6/grblHAL_Teensy4/src/driver.c#L1522 to:

#ifdef DRIVER_SPINDLE && SPINDLE_PWM_PIN

as a quick fix.

szaghi commented 1 year ago

@terjeio Thank you very much for the lighting help, it is really appreciated.

I'll test later today. kind regards, Stefano

szaghi commented 1 year ago

.. I have a new problem with the latest firmware

@szaghi Sorry, I have indroduced a new bug.

Change this line to:

https://github.com/grblHAL/iMXRT1062/blob/f94a0596bfd1fb03a1d5d74a054e5d7115e28ca6/grblHAL_Teensy4/src/driver.c#L1522

to: #ifdef DRIVER_SPINDLE && SPINDLE_PWM_PIN

as a quick fix.

@terjeio

It seems to have not affected my error (that indeed seems to be into the function immediately above, line 1518). I still have the compiling error

src\driver.c: In function 'settings_changed':
src\driver.c:1518:34: error: 'spindleConfig' undeclared (first use in this function)
terjeio commented 1 year ago

Oops - wrong line marked, change 1517 instead...

szaghi commented 1 year ago

@terjeio it works!

Thank you again

karoria commented 1 year ago

Thanks to all. This saved me too.

karoria commented 1 year ago

I am not able to compile on platformio with "#define WEBUI_ENABLE 3". I have changed value to 1 also but no luck. Following are console messages:

Warning! Ignore unknown configuration option monitor_flags in section [env] Processing teensy41 (board: teensy41; platform: teensy@4.16; framework: arduino)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html PLATFORM: Teensy (4.16.0) > Teensy 4.1 HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash DEBUG: Current (jlink) External (jlink) PACKAGES:

Environment Status Duration


teensy41 FAILED 00:00:06.278 ============= 1 failed, 0 succeeded in 00:00:06.278 =============

Waiting for help.

terjeio commented 1 year ago

.pio/libdeps/teensy41/uSDFS/src/uSDFS.h:27:17: error: redefinition of 'struct tm'

Is line 8 in this file #define HAVETM? If not then the required patch has not been applied.

karoria commented 1 year ago

@terjeio Thanks for reply. Yes I missed that patch but now I did follow both patches of network and SD card plugins but now compile error changes to something else as follows:

Warning! Ignore unknown configuration option monitor_flags in section [env] Processing teensy41 (board: teensy41; platform: teensy@4.16; framework: arduino)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html PLATFORM: Teensy (4.16.0) > Teensy 4.1 HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash DEBUG: Current (jlink) External (jlink) PACKAGES:

Environment Status Duration


teensy41 FAILED 00:00:07.482 ============= 1 failed, 0 succeeded in 00:00:07.482 =============

Thanks for your time and efforts. Waiting for reply.

terjeio commented 1 year ago

I've updated the iMXRT1062 lwIP patch, not sure if this helps. The driver builds using the Web Builder so there may be something wrong with the platformio.ini file as well. Does it build if you disable the mdns protocol?

karoria commented 1 year ago

Terje, I couldn't find updated lwIP patch. Disabling mdns protocol and compiling gives following error (pasted only critical lines):

src/networking/httpd.c: In function 'http_init_file': src/networking/httpd.c:1959:17: error: 'vfs_file_t {aka struct }' has no member named 'is_custom_file' if (file->is_custom_file && (file->data == NULL)) ^ src/networking/httpd.c:1959:42: error: 'vfs_file_t {aka struct }' has no member named 'data' if (file->is_custom_file && (file->data == NULL)) ^ *** [.pio/build/teensy41/src/networking/httpd.c.o] Error 1 ========================= [FAILED] Took 11.39 seconds =========================

Environment Status Duration


teensy41 FAILED 00:00:11.387 ==================== 1 failed, 0 succeeded in 00:00:11.387 ====================

terjeio commented 1 year ago

I couldn't find updated lwIP patch.

It is here. I guess it should be moved to the networking plugin...

The httpd.c errors above is likely due to lwipopts.h not beeing patched.

karoria commented 1 year ago

OK. Now it compiles without "#define MDNS_ENABLE". I am OK with it as it doesn't add much value but still if you want to close the loop then I am ready to follow your instructions. If I #define MDNS_ENABLE and compile, following errors are shown:

src/enet.c:136:38: warning: 'struct mdns_service' declared inside parameter list static void mdns_device_info (struct mdns_service service, void txt_userdata) ^ src/enet.c:136:38: warning: its scope is only this definition or declaration, which is probably not what you want src/enet.c: In function 'mdns_device_info': src/enet.c:141:5: warning: implicit declaration of function 'mdns_resp_add_service_txtitem' [-Wimplicit-function-declaration] mdns_resp_add_service_txtitem(service, "model=grblHAL", 13); ^ src/enet.c: At top level: src/enet.c:146:39: warning: 'struct mdns_service' declared inside parameter list static void mdns_service_info (struct mdns_service service, void txt_userdata) ^ src/enet.c: In function 'netif_status_callback': src/enet.c:193:9: warning: implicit declaration of function 'mdns_resp_init' [-Wimplicit-function-declaration] mdns_resp_init(); ^ src/enet.c:195:29: warning: implicit declaration of function 'mdns_resp_add_netif' [-Wimplicit-function-declaration] if((services.mdns = mdns_resp_add_netif(netif_default, network.hostname, MDNS_TTL) == ERR_OK)) { ^ src/enet.c:197:13: warning: implicit declaration of function 'mdns_resp_add_service' [-Wimplicit-function-declaration] mdns_resp_add_service(netif_default, network.hostname, "_device-info", DNSSD_PROTO_TCP, 0, MDNS_TTL, mdns_device_info, "version=" GRBL_VERSION); ^ src/enet.c:197:84: error: 'DNSSD_PROTO_TCP' undeclared (first use in this function) mdns_resp_add_service(netif_default, network.hostname, "_device-info", DNSSD_PROTO_TCP, 0, MDNS_TTL, mdns_device_info, "version=" GRBL_VERSION); ^ src/enet.c:197:84: note: each undeclared identifier is reported only once for each function it appears in *** [.pio/build/teensy41/src/enet.c.o] Error 1 Compiling .pio/build/teensy41/src/grbl/maslow.c.o ========================= [FAILED] Took 7.77 seconds =========================

Environment Status Duration


teensy41 FAILED 00:00:07.775 ==================== 1 failed, 0 succeeded in 00:00:07.775 ====================

karoria commented 1 year ago

Oh..It is a problem ! While I compiled without MDNS and flashed to teensy4.1, it shows success as usual but neither USB serial nor Ethernet is working. The device doesn't communicate at all. Any clues?

terjeio commented 1 year ago

@karoria If you flash an image made with the Web Builder does that work? I am away from home at the moment and will not be able to dig into platformio stuff until I am back home, better to use the Arduino IDE until then?

karoria commented 1 year ago

@terjeio, I can confirm that Web Builder also has issues. I have selected T41U5XBB and T41BB5X pro both boards one by one and has selected relevant options in Network/WebUI pane but Ethernet, WS, FTP, HTTP, WebDAV enabled doesn't work. It generates hex file, also flashes well but no communication. I have my old pio project still working and its hex also flashes by teensy loader well and communication just works. I have seen this after above issues to confirm that the board doesn't have any problem. Till the time you come home and look in the matter, I am happy with my old firmware. Thanks a lot again.

terjeio commented 1 year ago

@karoria I forgot one possible issue with littlefs that may cause a hang (an assert is triggered somewhere when an error should be returned). Comment out this line, recompile and reflash - then uncomment again. This will force a format of the littlefs storage area.

karoria commented 1 year ago

Thanks. Will give it a try. I think i will be able to do that tomorrow.

karoria commented 1 year ago

@karoria I forgot one possible issue with littlefs that may cause a hang (an assert is triggered somewhere when an error should be returned). Comment out this line, recompile and reflash - then uncomment again. This will force a format of the littlefs storage area.

Yes! Commenting out and recompile and refresh makes communication. Should I uncomment and refresh again? I am getting web page as per attached screenshot when I open my static IP, but don't know what to do next. Can I use my grblTouch with flash memory? If yes, how? I have and old style www directory which needs to be hosted as http server.

Screenshot 2022-12-08 at 12 28 35 PM

terjeio commented 1 year ago

Should I uncomment and refresh again?

Yes.

but don't know what to do next.

The page presented allows you to upload data to littlefs. This can be whatever you want. If index.html.gz (compressed index.html), favicon.ico, preferences.json or _aplogin.html is found in littlefs they will take priority over files in the www folder in the SD card file system (or in the embedded read-only file system if that is present).

Can I use my grblTouch with flash memory?

Yes, provided that it is is compressed and fits in the available littlefs free space. Use the file upload button to upload.

karoria commented 1 year ago

I confirm that communication works when commented out the said line and flashed. Immediately after that if I compile without commenting and flash, communication doesn't work. What happens if I just flash with commented out line?

Yes, provided that it is is compressed and fits in the available littlefs free space. Use the file upload button to upload.

My files are not compressed but occupies only about 150KB space altogether. If still I need to compress as compulsion, how should do I do it to convert to index.html.gz? I don't understand the method used in ESP3D for compression.

terjeio commented 1 year ago

What happens if I just flash with commented out line?

The littlefs storage area will be reformatted and data lost on every reboot. It is odd that reflashing corrupts the storage area, I have no good explanation for that. Do you somehow erase the complete flash before writing the binary? Or is something else amiss? The lowlevel driver code for littlefs is found here, it expects 8Mb of flash for the Teensy 4.1.

how should do I do it to convert to index.html.gz?

Google gz compression for your OS.

karoria commented 1 year ago

Do you somehow erase the complete flash before writing the binary?

I followed your instructions of flashing with commented line first and then powered off the device and then flashing with uncommented line (as is). I don't know other method for erasing complete flash. Sorry for my incomplete knowledge in electronics area as I am having Mechanical background. I will dig more on low level driver though.

karoria commented 1 year ago

Hi @terjeio, Are you back Home? When you get time please see to the matter. I am totally lost after trying hard. Thanks, Ravi

terjeio commented 1 year ago

I will be back home at the end of January.

Have you tried with moving the storage area down in FLASH, eg. by 1Mb? BTW do you have an EEPROM for settings storage? If not then then it could be that the eeprom emulation code uses an overlapping area and corrupting littlefs data.

karoria commented 1 year ago

I will be back home at the end of January.

Have you tried with moving the storage area down in FLASH, eg. by 1Mb?

BTW do you have an EEPROM for settings storage? If not then then it could be that the eeprom emulation code uses an overlapping area and corrupting littlefs data.

Thanks for taking time out of your busy schedule and guiding. Will see to it. I have not added extra EEPROM to teensy4.1 board. Does it mean I use eeprom emulation code?

terjeio commented 1 year ago

I have not added extra EEPROM to teensy4.1 board. Does it mean I use eeprom emulation code?

Yes. It is possible to disable this but then settings will not survive a cold restart.

terjeio commented 1 year ago

@karoria

and has selected relevant options in Network/WebUI pane but Ethernet, WS, FTP, HTTP, WebDAV enabled doesn't work

This only adds the protocol code to the firmware, but does not enable the protocols. Either reset the settings with $RST=* or enable the respective protocols with $70.

if I compile without commenting and flash, communication doesn't work.

I got the same issue when back home, when connected via USB to my Win10 machine after a update to the latest grblHAL version it constantly tried to enumerate the connection. Likely due to the controller rebooting after crashing in the littlefs code. Forcing a littlefs format cleared the issue and now I am not able to reproduce. PRJC claims that the flash is erased when programming, but this is not the case as any content I save to littlefs survives a programming cycle. So something is (randomly?) corrupting the littlefs storage area - but what? I guess this will take some time to identify and fix...

terjeio commented 1 year ago

@karoria - it seems I have cracked your issue, new build with the fix just commited.

I am closing this, please open a new issue if your problem persists.

karoria commented 1 year ago

@terjeio Sorry, I can't believe why I missed your last messages. Thanks for all you've done. I will let you know in case still I have any issues.