ryannining / karyacontroller

4 axis CNC, 3D, Laser Controller
GNU General Public License v2.0
58 stars 26 forks source link

Compiling for bluepill (stm32) #7

Open amit-nath30 opened 4 years ago

amit-nath30 commented 4 years ago

Hello me again, can you instruct me how to compile using arduino ide, I have installed Stm core from board manager

ryannining commented 4 years ago

you can show here the error message.

amit-nath30 commented 4 years ago

getting error in motion.h

just open the karyacontroller.ino using arduino ide, selected the board bluepill and hitting verify cause this error

In file included from sketch\gcode.h:4, from sketch\gcode.cpp:1: motion.h:30:13: error: expected unqualified-id before numeric constant 30 | #define Z 2 | ^ C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/core_cm3.h:214:14: note: in expansion of macro 'Z' 214 | uint32_t Z:1; /!< bit: 30 Zero condition code flag / | ^ motion.h:30:13: error: expected unqualified-id before numeric constant 30 | #define Z 2 | ^ C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/core_cm3.h:271:14: note: in expansion of macro 'Z' 271 | uint32_t Z:1; /!< bit: 30 Zero condition code flag / | ^ In file included from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/analog.h:45, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h:8, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:41, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36, from sketch\platform.h:3, from sketch\motion.h:38, from sketch\gcode.h:4, from sketch\gcode.cpp:1: C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:162:5: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 162 | timerObj_t _timerObj; | ^~~~~~ | timer_t In file included from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/analog.h:45, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h:8, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:41, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36, from sketch\karyacontroller.ino.cpp:1: C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:162:5: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 162 | timerObj_t _timerObj; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:166:8: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 166 | extern timerObj_t HardwareTimer_Handle[TIMER_NUM]; | ^~~~~~ | timer_t In file included from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/analog.h:45, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h:8, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:41, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36, from sketch\platform.h:3, from sketch\common.h:3, from sketch\common.cpp:1: C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:162:5: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 162 | timerObj_t _timerObj; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:168:8: error: 'timer_index_t' does not name a type; did you mean 'timer_init'? 168 | extern timer_index_t get_timer_index(TIM_TypeDef htim); | ^~~~~ | timer_init C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:166:8: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 166 | extern timerObj_t HardwareTimer_Handle[TIMER_NUM]; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:166:8: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 166 | extern timerObj_t HardwareTimer_Handle[TIMER_NUM]; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:168:8: error: 'timer_index_t' does not name a type; did you mean 'timer_init'? 168 | extern timer_index_t get_timer_index(TIM_TypeDef htim); | ^~~~~ | timer_init C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:168:8: error: 'timer_index_t' does not name a type; did you mean 'timer_init'? 168 | extern timer_index_t get_timer_index(TIM_TypeDef htim); | ^~~~~ | timer_init In file included from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/analog.h:45, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h:8, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:41, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36, from sketch\platform.h:3, from sketch\eprom.cpp:1: C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:162:5: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 162 | timerObj_t _timerObj; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:166:8: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 166 | extern timerObj_t HardwareTimer_Handle[TIMER_NUM]; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:168:8: error: 'timer_index_t' does not name a type; did you mean 'timer_init'? 168 | extern timer_index_t get_timer_index(TIM_TypeDef htim); | ^~~~~ | timer_init In file included from sketch\common.cpp:1: sketch\common.h: In function 'void serialwr(uint8_t)': common.h:72:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 72 | Serial.write(s); | ^~ | Serial9 In file included from sketch\eprom.cpp:3: sketch\common.h: In function 'void serialwr(uint8_t)': common.h:72:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 72 | Serial.write(s); | ^~ | Serial9 In file included from sketch\gcode.cpp:2: sketch\common.h: In function 'void serialwr(uint8_t)': common.h:72:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 72 | Serial.write(s); | ^~ | Serial9 sketch\common.h: In function 'void serialwr0(uint8_t)': common.h:76:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 76 | Serial.write(s); | ^~ | Serial9 sketch\common.h: In function 'void serialwr0(uint8_t)': common.h:76:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 76 | Serial.write(s); | ^~ | Serial9 sketch\common.h: In function 'void serialwr0(uint8_t)': common.h:76:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 76 | Serial.write(s); | ^~ | Serial9 In file included from D:\3d_printer_controller\karyacontroller\karyacontroller.ino:7: sketch\common.h: In function 'void serialwr(uint8_t)': common.h:72:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 72 | Serial.write(s); | ^~ | Serial9 sketch\common.h: In function 'void serialwr0(uint8_t)': common.h:76:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 76 | Serial.write(s); | ^~ | Serial9 D:\3d_printer_controller\karyacontroller\karyacontroller.ino: In function 'char gcode_loop()': common.h:83:20: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 83 | #define serialav() Serial.available() | ^~ D:\3d_printer_controller\karyacontroller\karyacontroller.ino:829:9: note: in expansion of macro 'serialav' 829 | if (serialav()) | ^~~~ D:\3d_printer_controller\karyacontroller\karyacontroller.ino: In function 'void setup()': common.h:84:26: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 84 | #define serialinit(baud) Serial.begin(baud) | ^~ D:\3d_printer_controller\karyacontroller\karyacontroller.ino:932:3: note: in expansion of macro 'serialinit' 932 | serialinit(BAUDRATE); //115200); | ^~~~~~ sketch\gcode.cpp: At global scope: gcode.cpp:536:1: error: 'File' does not name a type 536 | File fme; | ^~~~ In file included from sketch\main.cpp:1: motion.h:30:13: error: expected unqualified-id before numeric constant 30 | #define Z 2 | ^ C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/core_cm3.h:214:14: note: in expansion of macro 'Z' 214 | uint32_t Z:1; /!< bit: 30 Zero condition code flag / | ^ motion.h:30:13: error: expected unqualified-id before numeric constant 30 | #define Z 2 | ^ C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/core_cm3.h:271:14: note: in expansion of macro 'Z' 271 | uint32_t Z:1; /!< bit: 30 Zero condition code flag / | ^ In file included from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/stm32/analog.h:45, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/board.h:8, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:41, from C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36, from sketch\platform.h:3, from sketch\motion.h:38, from sketch\main.cpp:1: C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:162:5: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 162 | timerObj_t _timerObj; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:166:8: error: 'timerObj_t' does not name a type; did you mean 'timer_t'? 166 | extern timerObj_t HardwareTimer_Handle[TIMER_NUM]; | ^~~~~~ | timer_t C:\Users\amitn\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/HardwareTimer.h:168:8: error: 'timer_index_t' does not name a type; did you mean 'timer_init'? 168 | extern timer_index_t get_timer_index(TIM_TypeDef htim); | ^~~~~ | timer_init In file included from sketch\main.cpp:3: sketch\common.h: In function 'void serialwr(uint8_t)': common.h:72:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 72 | Serial.write(s); | ^~ | Serial9 sketch\common.h: In function 'void serialwr0(uint8_t)': common.h:76:3: error: 'Serial' was not declared in this scope; did you mean 'Serial9'? 76 | Serial.write(s); | ^~ | Serial9 exit status 1 expected unqualified-id before numeric constant

amit-nath30 commented 4 years ago

another error i got

gcode.cpp:536:1: error: 'File' does not name a type

File fme;

^

exit status 1 'File' does not name a type

amit-nath30 commented 4 years ago

made the changes to compile successfully, but now it the ram overflow issue

ryannining commented 4 years ago

yu mean, can compile but use more ram so cannot be uploaded to stm32 ?

amit-nath30 commented 4 years ago

yes, but solved the issue by lowering the gcode buffer

amit-nath30 commented 4 years ago

is there any plan for clearing the code?? i would love to help, but could not under stand

ryannining commented 4 years ago

of course so much help will be needed.

but i dont really familiar with github, i just use it put my software. And because looks i am the only using it right now... hahahahahha. I have 3 CNC router machine, many 3D printer and 1 C02 Laser CNC using this karyacontroller and karyacnc (CAM).

But maybe we can clean per section.

  1. Serial data buffer and Gcode decoder
  2. Motion calculation
  3. Motion buffer
  4. Timer (AVR, ARM, ESP, maybe add other such ESP32)
  5. Heater and PID (for 3d printer).
ryannining commented 4 years ago

And i love using ESP3866, because its cheap, WIFI, bigger RAM and have Storage 3M for storing jobs for CNC. And even for 3D printer if the code less than that (compressed using karyacnc).

ryannining commented 4 years ago

/home/ryan/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld: region `ram' overflowed by 5712 bytes collect2: error: ld returned 1 exit status Using library EEPROM in folder: /home/ryan/arduino/arduino-1.8.12/hardware/Arduino_STM32-master/STM32F1/libraries/EEPROM (legacy)

I just install STM32 build on my ubuntu and get this result. Ram overflow... maybe because many feature added after my last stm32 bluepill machine work long time ago. To focus on ESP8266

But its weird that its compiled OK on arduino UNO. with less ram

ryannining commented 4 years ago

Looks like the MESH leveling zbuffer feature doesnot fit on other than ESP8266. Also the RASTER data (for laser bitmap rendering) is take lots ram

on gcode.h line 84

#define g_str_len 64
#elif defined( __ARM__)
#define g_str_len 2000
#else
#define g_str_len 14000
#endif
amit-nath30 commented 4 years ago

mainly the motion.cpp and gcode.cpp need to be cleaned, this 2 file is beyond my capibility as i dont know the algo involved in it other files i can handle the clean up

ryannining commented 4 years ago

yeah, its ok to clean other files first. I will upload the latest file tonight. It contain latest code especially for Constant power Laser burn. And i have test to compile on Uno, STM32, Esp8266

motion.cpp is a mix between GRBL and my own command buffer, and S-curve using constant Jerk implementation. i think what make it complicated is because long time ago i want to implement non linear motion, like DELTA 3d printer, SCARA, etc. I think its to much to clean... i myself sometimes confuse if read that file.

As for GCODE i get the core code from teacup, because its small. and i implement the decoding gcode and add some new gcode there.

amit-nath30 commented 4 years ago

yes i have also port teacup to stm32 bluepill using SPL library, it was steep learning curve. need to test when i will make my hardware for 3d printing

ryannining commented 4 years ago

Hahaha, tosss, i was start from Teacup too, but then add Back and forward planner put me on the GRBL, REPETIER, TinyG, etc.

And since i was using my firmware for all my workshop machine, that keep motivation to me to make it work. Also, you can see i have Inkscape path to Gcode too, karyacnc. Both are used for my workshop laser cutting and CNC router working.

amit-nath30 commented 4 years ago

I will also like to add lcd support for printing through sd card without pc

ryannining commented 4 years ago

I will also like to add lcd support for printing through sd card without pc

it will be great ! is it enough PIN left for SDCARD and LCD ?

amit-nath30 commented 4 years ago

for stm32, ad uno dont have extra pins, and i dont have esp

ryannining commented 4 years ago

ESP8266 have less pin

RepRapThailand commented 4 years ago

Hello, I would like to propose ESP32

ryannining commented 4 years ago

yes, that will be nice

RepRapThailand commented 4 years ago

yes, that will be nice

Is it possible? If you will come to develop with ESP32

ryannining commented 4 years ago

Well i think we need to research about how to use hardware timer in esp32, other than that i think all are same.

ryannining commented 4 years ago

Just write a quick timer code and some definition for ESP32, and its compiled. I dont know if its correct on implementation, but i think i need to make the board first.

#ifdef ESP32
#define USETIMEROK

hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;

void IRAM_ATTR tm() {
  portENTER_CRITICAL_ISR(&timerMux);
  int d = timercode();
  if (d < 6)d = 6;

  timerAlarmWrite(timer, d, true);
  timerAlarmEnable(timer);

  portEXIT_CRITICAL_ISR(&timerMux);

}

void timer_init()
{
  timer = timerBegin(0, 80, true);
  timerAttachInterrupt(timer, &tm, true);
  timerAlarmWrite(timer, 12000, true);
  timerAlarmEnable(timer);
}

#endif //esp32

.....

Linking everything together...
/home/ryan/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-gcc -nostdlib -L/home/ryan/.arduino15/packages/esp32/hardware/esp32/1.0.4/tools/sdk/lib -L/home/ryan/.arduino15/packages/esp32/hardware/esp32/1.0.4/tools/sdk/ld -T esp32_out.ld -T esp32.common.ld -T esp32.rom.ld -T esp32.peripherals.ld -T esp32.rom.libgcc.ld -T esp32.rom.spiram_incompatible_fns.ld -u ld_include_panic_highint_hdl -u call_user_start_cpu0 -Wl,--gc-sections -Wl,-static -Wl,--undefined=uxTopUsedPriority -u __cxa_guard_dummy -u __cxx_fatal_exception -Wl,--start-group /tmp/arduino_build_713206/sketch/DIO2.c.o /tmp/arduino_build_713206/sketch/backup.cpp.o /tmp/arduino_build_713206/sketch/common.cpp.o /tmp/arduino_build_713206/sketch/eprom.cpp.o /tmp/arduino_build_713206/sketch/gcode.cpp.o /tmp/arduino_build_713206/sketch/gcodesave.cpp.o /tmp/arduino_build_713206/sketch/karyacontroller.ino.cpp.o /tmp/arduino_build_713206/sketch/main.cpp.o /tmp/arduino_build_713206/sketch/motion.cpp.o /tmp/arduino_build_713206/sketch/pid.cpp.o /tmp/arduino_build_713206/sketch/temp.cpp.o /tmp/arduino_build_713206/sketch/timer.cpp.o /tmp/arduino_build_713206/libraries/EEPROM/EEPROM.cpp.o /tmp/arduino_cache_973785/core/core_c39d0c267da2e8a8e3a55ec13b4a0ec5.a -lgcc -lesp32 -lphy -lesp_http_client -lmbedtls -lrtc -lesp_http_server -lbtdm_app -lspiffs -lbootloader_support -lmdns -lnvs_flash -lfatfs -lpp -lnet80211 -ljsmn -lface_detection -llibsodium -lvfs -ldl_lib -llog -lfreertos -lcxx -lsmartconfig_ack -lxtensa-debug-module -lheap -ltcpip_adapter -lmqtt -lulp -lfd -lfb_gfx -lnghttp -lprotocomm -lsmartconfig -lm -lethernet -limage_util -lc_nano -lsoc -ltcp_transport -lc -lmicro-ecc -lface_recognition -ljson -lwpa_supplicant -lmesh -lesp_https_ota -lwpa2 -lexpat -llwip -lwear_levelling -lapp_update -ldriver -lbt -lespnow -lcoap -lasio -lnewlib -lconsole -lapp_trace -lesp32-camera -lhal -lprotobuf-c -lsdmmc -lcore -lpthread -lcoexist -lfreemodbus -lspi_flash -lesp-tls -lwpa -lwifi_provisioning -lwps -lesp_adc_cal -lesp_event -lopenssl -lesp_ringbuf -lfr -lstdc++ -Wl,--end-group -Wl,-EL -o /tmp/arduino_build_713206/karyacontroller.ino.elf
python /home/ryan/.arduino15/packages/esp32/hardware/esp32/1.0.4/tools/gen_esp32part.py -q /home/ryan/.arduino15/packages/esp32/hardware/esp32/1.0.4/tools/partitions/default.csv /tmp/arduino_build_713206/karyacontroller.ino.partitions.bin
python /home/ryan/.arduino15/packages/esp32/tools/esptool_py/2.6.1/esptool.py --chip esp32 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o /tmp/arduino_build_713206/karyacontroller.ino.bin /tmp/arduino_build_713206/karyacontroller.ino.elf
esptool.py v2.6
Using library EEPROM at version 1.0.3 in folder: /home/ryan/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/EEPROM 
/home/ryan/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-size -A /tmp/arduino_build_713206/karyacontroller.ino.elf
Sketch uses 249825 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 33124 bytes (10%) of dynamic memory, leaving 294556 bytes for local variables. Maximum is 327680 bytes.```
amit-nath30 commented 3 years ago

are you using platform.io for compiling??

ryannining commented 3 years ago

I will also like to add lcd support for printing through sd card without pc

Hi, i found a way to use IR remote (1 pin) and I2C oled (2 pin TX RX) and now it have offline display. But the code still messy ... and perhaps now it wont compile on other than ESP8266....

amit-nath30 commented 3 years ago

yes i have just now seen your youtube video, excellent job

amit-nath30 commented 3 years ago

i still haven't able to develop the code is busy with a project i got, i am a freelance you see

amit-nath30 commented 3 years ago

what library did you use for LCD menu???

ryannining commented 3 years ago

esp8266 sd1306 by thingpulse, other library not work on my oled