Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.41k stars 5.3k forks source link

Not work on Arduino DUE #1021

Closed semos2k closed 5 years ago

semos2k commented 5 years ago

I have tried the following steps:

`$ make Build Kconfig config file Creating symbolic link out/board Compiling out/src/sched.o Compiling out/src/command.o Compiling out/src/basecmd.o Compiling out/src/debugcmds.o Compiling out/src/gpiocmds.o Compiling out/src/stepper.o Compiling out/src/endstop.o Compiling out/src/adccmds.o Compiling out/src/spicmds.o Compiling out/src/thermocouple.o Compiling out/src/lcd_st7920.o Compiling out/src/lcd_hd44780.o Compiling out/src/buttons.o Compiling out/src/tmcuart.o Compiling out/src/sam3x8e/main.o Compiling out/src/sam3x8e/timer.o Compiling out/src/sam3x8e/gpio.o Compiling out/src/sam3x8e/spi.o Compiling out/src/generic/crc16_ccitt.o Compiling out/src/generic/alloc.o Compiling out/src/generic/armcm_irq.o Compiling out/src/generic/timer_irq.o Compiling out/src/../lib/sam3x/gcc/system_sam3xa.o Compiling out/src/../lib/sam3x/gcc/gcc/startup_sam3xa.o Compiling out/src/sam3x8e/serial.o Compiling out/src/generic/serial_irq.o Building out/compile_time_request.o Version: v0.6.0-674-gd0f0972-20181219_225507-semos2k-mcu Linking out/klipper.elf Creating hex file out/klipper.bin

$ make flash FLASH_DEVICE=/dev/ttyACM0 Flashing out/klipper.bin lib/bossac/bin/bossac to /dev/ttyACM0 via bossac Erase flash

Done in 0.075 seconds Write 15824 bytes to flash (62 pages) [==============================] 100% (62/62 pages) Done in 3.878 seconds Verify 15824 bytes of flash [==============================] 100% (62/62 pages) Verify successful Done in 3.559 seconds Set boot flash true`

and when it is started klipper shows:

[ printer ] kinematics = cartesian max_velocity = 300 max_accel = 3000 max_z_velocity = 5 max_z_accel = 100

Extruder max_extrude_ratio=0.266081 Starting serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect`

yschroeder commented 5 years ago

Post your Klipper log file so we can take a look at your configuration.

Without the log file it looks like you are not using to the correct serial port.

Also make sure to use the correct of the two USB port on the Due. One is for programming one for (direct) serial communication. I do not know which one is used by Klipper, though...

semos2k commented 5 years ago

This is my actual config and i used the programing port:

[mcu] /dev/serial/by-path/pci-0000:00:06.0-usb-0:2:1.0 pin_map: arduino

[stepper_x] step_pin: ar24 dir_pin: ar23 enable_pin: ar26 step_distance: .0125 endstop_pin: ^ar28

endstop_pin: ^ar34

position_endstop: 0 position_max: 200 homing_speed: 50

[stepper_y] step_pin: ar17 dir_pin: !ar16 enable_pin: ar22 step_distance: .0125 endstop_pin: ^ar30

endstop_pin: ^ar36

position_endstop: 0 position_max: 200 homing_speed: 50

[stepper_z] step_pin: ar2 dir_pin: ar3 enable_pin: ar15 step_distance: .0025 endstop_pin: ^ar32

endstop_pin: ^ar38

position_endstop: 0.5 position_max: 200

[extruder] step_pin: analog7 dir_pin: analog6 enable_pin: analog8 step_distance: .002 nozzle_diameter: 0.400 filament_diameter: 1.750 heater_pin: ar13 sensor_type: EPCOS 100K B57560G104F sensor_pin: analog0 control: pid pid_Kp: 22.2 pid_Ki: 1.08 pid_Kd: 114 min_temp: 0 max_temp: 250

[extruder1]

step_pin: analog10

dir_pin: analog9

enable_pin: analog11

[extruder2]

step_pin: ar51

dir_pin: ar53

enable_pin: ar49

[heater_bed] heater_pin: ar7 sensor_type: EPCOS 100K B57560G104F sensor_pin: analog1 control: watermark min_temp: 0 max_temp: 130

[fan] pin: ar9

[heater_fan nozzle_cooling_fan]

pin: ar8

[printer] kinematics: cartesian max_velocity: 300 max_accel: 3000 max_z_velocity: 5 max_z_accel: 100

jakep82 commented 5 years ago

If you're using a clone Due, you will need to either modify the Arduino by adding a resistor, flashing the 16u2 USB serial converter with modified firmware, or press the reset button by hand. Pretty much every clone has this problem. See the linked thread for more information. You can also buy a genuine Due which doesn't have this problem.

https://forum.arduino.cc/index.php?topic=256771.0

yschroeder commented 5 years ago

I started writing something while @jakep82 came up with a hopefully helpful solution. But I will post my findings nonetheless so it might be helpful for someone else finding this...

Maybe this link gives better info than the Arduino forum (where lots of people seem to have no clue what is going on): https://copperhilltech.com/blog/arduino-due-design-flaw-due-wont-start-after-poweroffon-requires-reset/

The programming port should be the correct one.

Here are some more details I figured out: According to the schematics the ATmega16U2 that is used as a USB/UART bridge is connected to the pins PA8 and PA9 which is the same UART that Klipper uses (see here). The ATmega16U2 sets the baudrate of its hardware UART to the value configured via USB (see here). So it should work like any other USB/UART bridge (e.g. FTDI).

I found nothing wrong, I just wanted to have this documented in case somebody else runs into this again.

semos2k commented 5 years ago

I use a clone, I tried pressing the reset button but the result is the same.

I'm going to test the direct connection to the pins to see if the firmware is being executed.

jakep82 commented 5 years ago

If I remember correctly you need to press the reset button, then issue a firmware_restart right after. I have a clone and found it difficult to get it connected unless I timed it right. I eventually got a genuine Due because pressing the reset button was annoying.

semos2k commented 5 years ago

I tried again and I found something but I'm not sure if the problem is in my installation of linux, from windows and with Arduino IDE I put in the DUE a sketch and it runs correctly.

Then I uploaded the binary (sketch.bin) from the linux with bossac and it kept working, but when I follow the same process with the klipper binary the DUE does not work or at least it does not communicate with the host.

semos2k commented 5 years ago

I think it may be my klipper binary file is corrupted or it is not compiled correctly.

shadrincev commented 5 years ago

And what fee do you use for due? Just due has a feature, if the pins are not defined correctly, it does not start. Example of my configuration due+ramps 1.6:

[stepper_x]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
endstop_pin: ^!ar3
#endstop_pin: ^ar2

[stepper_y]
step_pin: ar60
dir_pin: ar61
enable_pin: !ar56
step_distance: 0.010000
endstop_pin: ^!ar14
#endstop_pin: ^ar15

[stepper_z]
step_pin: ar46
dir_pin: ar48
enable_pin: !ar62
endstop_pin: probe:z_virtual_endstop

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
heater_pin: ar10
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog9

[heater_bed]
heater_pin: ar8
sensor_pin: analog10

[fan]
pin: ar9
pin: ar13

[mcu]
serial: /dev/ttyACM0
baud: 250000
pin_map: arduino 

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 10
max_z_accel: 100

[probe] 
pin: ^!ar18 

[display] 
lcd_type: hd44780 
rs_pin: ar16 
e_pin: ar17 
d4_pin: ar23 
d5_pin: ar25 
d6_pin: ar27 
d7_pin: ar29 
encoder_pins: ^ar33, ^ar31 
click_pin: ^!ar35
kill_pin: ^!ar41
k-davydov commented 5 years ago

I ran into absolutely the same issue. Everything worked fine until about a week ago. I have two arduino due boards (clones) with ruramps4d shield. Earlier I had no issue with flashing them with make flash blah blah blah, but yesterday i tried to reflash them with fresh klipper version with the same sad result:

Starting serial connect Timeout on serial connect Timeout on serial connect Timeout on serial connect

I tried flashing from Orange PI PC with armbian (4.14.78) and from Rock64 with ubuntu 18.04 (4.4.132-1072-rockchip-ayufan-ga1d27dba5a2e). Result is absolutely the same :(

console logs: https://pastebin.com/cQWyZCmB

k-davydov commented 5 years ago

tried flashing manually - no luck:

root@orangepipc:/home/printer/klipper/out# bossac -e -R -w -v -i -b ./klipper.bin --port=ttyACM0 Erase flash Write 15820 bytes to flash [==============================] 100% (62/62 pages) Verify 15820 bytes of flash [==============================] 100% (62/62 pages) Verify successful Set boot flash true Device : ATSAM3X8 Chip ID : 285e0a60 Version : v1.1 Dec 15 2010 19:25:04 Address : 524288 Pages : 2048 Page Size : 256 bytes Total Size : 512KB Planes : 2 Lock Regions : 32 Locked : none Security : false Boot Flash : true CPU reset.

k-davydov commented 5 years ago

Just in case. I'm aware of issue that reqiures non-original due to be reset after flashing. I tried.

I also tried soldering 10k resistor (as recommended here https://forum.arduino.cc/index.php?topic=256771.60) and tried 0.6.0 Klipper release. It all doesn't work. So, maybe, somehow it's not a klipper issue, but something related to avrdude or bossa cli.

semos2k commented 5 years ago

I have used two versions of Bossac which is installed with klipper(1.9) and the one that comes with Arduino IDE(1.6.1-arduino), both have generated the same behavior.

k-davydov commented 5 years ago

I managed to get it working by compiling klipper.bin on external x86 ubuntu server and uploading to DUE. While some guru finds out why it doesn't compile well on arm feel free to use this precompiled klipper.bin (it's for DUE and 250000bps). https://drive.google.com/file/d/1p6ScUZkEzUbrgCOz-G-mnBeLfOH0ujKR/view?usp=sharing

semos2k commented 5 years ago

Please allow me access to the file (semos2k@gmail.com). thx.

k-davydov commented 5 years ago

Please allow me access to the file (semos2k@gmail.com). thx.

please try again, i've corrected permissions

k-davydov commented 5 years ago

Hi

please try again, it must be available now

сб, 22 дек. 2018 г. в 19:58, semos2k notifications@github.com:

Please allow me access to the file (semos2k@gmail.com). thx.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1021#issuecomment-449583907, or mute the thread https://github.com/notifications/unsubscribe-auth/AonRkFu-mIV-SUf6H8_3CII09V0pfNaEks5u7mSigaJpZM4Zbdbm .

semos2k commented 5 years ago

Yes, thx.

semos2k commented 5 years ago

If this firmware works correctly ..... thx, in my tests I use an x86 linux. Did you use any special parameter? @ktotomskru

k-davydov commented 5 years ago

If this firmware works correctly ..... thx, in my tests I use an x86 linux. Did you use any special parameter? @ktotomskru

nothing special, just git clone and make. host is ubuntu 16.04 (4.13.0-37-generic).

KevinOConnor commented 5 years ago

I tried flashing from Orange PI PC with armbian (4.14.78) and from Rock64 with ubuntu 18.04

FYI, The arm compiler on Ubuntu 18.04 is known to be broken - see #443.

-Kevin

semos2k commented 5 years ago

if you're right, I've verified it and it's because of the linux version, I found a temporary solution in stackoverflow.

https://unix.stackexchange.com/questions/453032/how-to-install-a-functional-arm-cross-gcc-toolchain-on-ubuntu-18-04

thx, @KevinOConnor @ktotomskru