grblHAL / STM32F1xx

grblHAL driver for ST STM32F1xx (Redpill, Bluepill)
Other
40 stars 27 forks source link

Not getting any output from USART with or without USB_ENABLE set #22

Closed dlarue closed 2 years ago

dlarue commented 2 years ago

I figured out what the ioc file is used for and loading it in CubeIDE loaded a visualization of the pin assignments and I see USART_TX on PA9 and USART_RX on PA10. I built and uploaded the firmware and connected a 3.3v FTDI Rx pin to PA9 and see no grbl output. I have set compatibility to 1 in config.h and I tried USB_ENABLE to both 0 and 1 and neither results in any grbl header echoed out USART_TX pin.

To test, I uploaded a grbl32 firmware and upon powerup saw grbl setting and version dump. So the board and aux port is operational.

CubeIDE Symbols:

USE_HAL_DRIVER STM32F103xB RX_BUFFER_SIZE 512 NVS_SIZE 1536 NO_SETTINGS_DESCRIPTIONS OVERRIDE_MY_MACHINE BOARD_CNC3040 USB_ENABLE 1 N_AXIS 3
dlarue commented 2 years ago

I noticed in my_machine.h there was "#define USB_SERIAL_CDC 1" and comment stating to comment it out for UART comm but that made no difference. I also set USB_ENABLE = 0 in the symbols but tried with USB_ENABLE at 1 and still not grbl output on the UART.

terjeio commented 2 years ago

The symbol USB_ENABLE is no longer used in grblHAL due to conflict with some other frameworks, use USB_SERIAL_CDC instead as you have discovered. When USB_SERIAL_CDC is not defined or set to 0 UART comms should be default. One way to check this is to see which part of the code gets compiled in driver.c:

image

Here you can see usbInit() is greyed out and serialInit() is active. Note that sometimes the greyed out parts might be wrong, right click on the project folder in the IDE and select Index > Rebuild to be sure it is correct.

Do you have a ST-Link and can set breakpoints? serialWriteS() in serial.c is the first place to check, is it ever called? If not has the board gone into a hardfault? Press the pause button to check if so.

dlarue commented 2 years ago

I checked and it is flowing through stream_connect(serialInit()) and to be sure I removed USB_ENABLE and set USB_SERIAL_CDC 0 in my_machine.h and still nothing on the serial output.

I am using ST-Link to upload firmware but don't know yet how to use it to set breakpoints. That would be very handy to have working. Currently I'm only using the ST-Link via OpenOCD to upload code. I'll see if I can figure out how to get debugging happening.

terjeio commented 2 years ago

I removed USB_ENABLE and set USB_SERIAL_CDC 0 in my_machine.h

I assume you removed OVERRIDE_MY_MACHINE from the IDE symbols then...

To set a breakpoint just double click to the left of the line number:

image

dlarue commented 2 years ago

I was just covering my ars by making sure it was in both places. :-)

I have debugging working and it's breaking at line 103 in serialWriteS()

dlarue commented 2 years ago

Seems to be wanting to print "error:7"

And wow, this was fairly easy to setup...

terjeio commented 2 years ago

error 7 is failure to read settings, either from flash or EEPROM - I belive I saw that this board has an EEPROM mounted, but possibly interfaced via SPI? grblHAL supports I2C EEPROMs.

If you send a '?' do you get new output in serialWriteS? You can also set breakpoints in the USART1_IRQHandler to see if RX and TX interrupts fires.

dlarue commented 2 years ago

I'm testing this on a Bluepill board so no external EEPROM. I will connect up my FTDI board(3.3V) and minicom and see if there's any reaction.

dlarue commented 2 years ago

ok so this is different. It's in debug mode and I connected the FTDI board and now I'm getting stuff!

? error:7

Grbl 1.1f ['$' for help] [MSG:'$H'|'$X' to unlock] ?<Alarm|MPos:0.000,0.000,0.000|Bf:35,512|FS:0,0|Pn:PXYZRHS|Ov:100,100,100>

and $$ gives me settings. $$ $0=10.0 $1=25 $2=0 $3=0 $4=7 $5=0 $6=0 $9=1 $10=511 $11=0.010 $12=0.002 $13=0 $14=0 $15=0 $16=0 $17=0 $18=0 $19=0 $20=0 $21=0 $22=0 $23=0 $24=25.0 $25=500.0 $26=250 $27=1.000 $28=0.100 $29=0.0 $30=1000.000 $31=0.000 $32=0 $33=5000.0 $34=0.0 $35=0.0 $36=100.0 $37=0 $39=1 $40=0 $43=1 $44=4 $45=3 $46=0 $62=0 $63=2 $64=0 $65=0 $100=250.000 $101=250.000 $102=250.000 $110=500.000 $111=500.000 $112=500.000 $120=10.000 $121=10.000 $122=10.000 $130=200.000 $131=200.000 $132=200.000 $341=0 $342=30.0 $343=25.0 $344=200.0 $345=100.0 $384=0 ok

dlarue commented 2 years ago

it will run through the debugger either single stepping or just running but it will not run when powered via USB. I realized the firmware size was over 64K again( 111K ) and couldn't figure it out. Seems single stepping or running through debug literally loads the code as it runs. Well, I went to see if another programmer besides openocd was around and STM makes one and so I installed it and flashed 111K image and now the Bluepill runs from USB power and with the FTDI connected to a9 and a10.

That took a while but I now have in-circuit debugging working and have another programmer option.

Next step is now figuring out how to move the PWM/spindle to PB0.