Paciente8159 / uCNC

µCNC - Universal CNC firmware for microcontrollers
https://github.com/Paciente8159/uCNC/wiki
GNU General Public License v3.0
265 stars 60 forks source link

[BUG] Compiling Error with STM32 Blackpill (Arduino AND Platformio) #671

Closed BetaAsPhuck closed 5 months ago

BetaAsPhuck commented 5 months ago

Describe the bug Compiling error with Blackpill in Both Arduino and Platformio:

I tried Uploading the code into my STM board, but I couldn't do it, because I got an error on line 3630, on uCNC-master\uCNC\src\hal\mcus\stm32f4x\mcumap_stm32f4x.h <--------

What I do understand is that I'm getting an unrecognized variable on line 3630, which causes the compiling to fail, but I lack the knowledge to fix this, since it's not really as simple as changing the "DIO##X##_##Y" to "DIO50_GPIO" like the suggestion

Error: "In file included from uCNC\src\modules../hal/boards/../mcus/mcudefs.h:41, from uCNC\src\modules../hal/boards/boarddefs.h:177, from uCNC\src\modules../cnc_hal_config_helper.h:50, from uCNC\src\modules../cnc.h:130, from uCNC\src\modules\ic74hc595.c:20: uCNC\src\modules\ic74hc595.c: In function 'ic74hc595_shift_io_pins': uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3630:32: error: 'DIO0_GPIO' undeclared (first use in this function); did you mean 'DIO50_GPIO'? 3630 | #define indirectex(X, Y) DIO##X##_##Y | ^~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3631:28: note: in expansion of macro 'indirectex' 3631 | #define indirect(X, Y) indirectex(X, Y) | ^~~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3748:35: note: in expansion of macro 'indirect' 3748 | #define mcu_clear_output(diopin) (indirect(diopin, GPIO)->BSRR = ((1UL << 16) << indirect(diopin, BIT))) | ^~~~ uCNC\src\modules\ic74hc595.c:55:17: note: in expansion of macro 'mcu_clear_output' 55 | mcu_clear_output(IC74HC595_LATCH); | ^~~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3630:32: note: each undeclared identifier is reported only once for each function it appears in 3630 | #define indirectex(X, Y) DIO##X##_##Y | ^~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3631:28: note: in expansion of macro 'indirectex' 3631 | #define indirect(X, Y) indirectex__(X, Y) | ^~~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3748:35: note: in expansion of macro 'indirect' 3748 | #define mcu_clear_output(diopin) (indirect(diopin, GPIO)->BSRR = ((1UL << 16) << indirect(diopin, BIT))) | ^~~~ uCNC\src\modules\ic74hc595.c:55:17: note: in expansion of macro 'mcu_clear_output' 55 | mcu_clear_output(IC74HC595_LATCH); | ^~~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3630:32: error: 'DIO0_BIT' undeclared (first use in this function); did you mean 'DIO3_BIT'? 3630 | #define indirectex(X, Y) DIO##X##_##Y | ^~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3631:28: note: in expansion of macro 'indirectex' 3631 | #define indirect(X, Y) indirectex(X, Y) | ^~~~ uCNC\src\modules../hal/boards/../mcus/stm32f4x/mcumap_stm32f4x.h:3748:86: note: in expansion of macro 'indirect' 3748 | #define mcu_clear_output(diopin) (indirect(diopin, GPIO)->BSRR = ((1UL << 16) << indirect(diopin, BIT))) | ^~~~ uCNC\src\modules\ic74hc595.c:55:17: note: in expansion of macro 'mcu_clear_output' 55 | mcu_clear_output(IC74HC595_LATCH); | ^~~~ *** [.pio\build\STM32F4-Blackpill-F401CC\src\src\modules\ic74hc595.c.o] Error 1"

Describe your hardware:

  1. What's your board

    STM32F401CCU6

  2. Paste your "Grbl/µCNC settings"

Paciente8159 commented 5 months ago

That type of error indicates you are trying to use a pin that was not defined.

You seem to be trying to use the 74hc595 IO expansion module but without your config files it's hard to eval.

What are you trying to config? Are you using the web config tool? If yes send me the config json file.

BetaAsPhuck commented 5 months ago

Yes Im using the Web Config tool, here's the json: ucnc_build.json

BetaAsPhuck commented 5 months ago

Now I noticed that for some reason I had these selected, I don't really remember adding these in so maybe it was a drunk mistake lol. SNippp

Paciente8159 commented 5 months ago

Let me know if you run into any problem

BetaAsPhuck commented 5 months ago

I uploaded the code successfully and physically grounded the Estop pin.

My computer doesn't seem to recognize the Board when I plug it in, the device manager isn't showing a new Device, except when I run it as BOOTLOADER.

Am I missing some required drivers? (I'm entirely new to STM32)

I tried Universal Gcode Sender and ioSender, but they don't detect the Board either.

I tried installing USB Drivers on the Board using Zadig, but it didn't really work either.

The board only shows up when it's run as Bootloader.

Am I missing something obvious? or does my Firmware simply not enable the USB CDC stack for some reason?

Paciente8159 commented 5 months ago

I need some more information. Which board are you using? Is it a standard blackpill? Which type of MCU is in it (STM32F401, 407, 411???)

BetaAsPhuck commented 5 months ago

THE MCU is STM32F401CCU6. That's what I bought and what's written on the chip itself. Although Arduino and STlink Utility see it as "STM32F411xC/E" which is a bit odd.

20240328_162559

USB speed : Full Speed (12MBit/s) Manuf. ID : STMicroelectronics Product ID : STM32 BOOTLOADER SN : 377639583439 DFU protocol: 1.1 Board : -- Device ID : 0x0431 Device name : STM32F411xC/E <<<<<<<<<<<< As you can see the Device name differs Flash size : 512 KBytes (default) Device type : MCU Revision ID : --
Device CPU : Cortex-M4

This is the Config I Uploaded, the only thing I changed was line 52 in cnc_config.h into -> #define BOARD BOARD_BLACKPILL

ucnc_build.json

Paciente8159 commented 5 months ago

that is very odd indeed. Do you have a USB to serial cable to connect to pins A9 and A10? Is the blackpill led blinking every second? That is an indicator that the firmware is running.

BetaAsPhuck commented 5 months ago

I used a USB to USB C cable to program the board, by "DFU". I haven't used the Serial cable , I'll get one today and try that.

Once I've uploaded the code and give power externally to the board (or still via the USB-C), the Diode doesn't blink every second. The Power LED shines, but the PC13 Builtin LED Doesn't.

Update:

OK So here's the thing, I tested uploading just the basic LED code onto the chip to see if it works, and it didn't.

I Erased All memory from the chip using STLink Utility and STLink V2 Board. And then the LED Sketch worked, I tried uploading the uCNC Code right after. Didn't light up again.

I Erased All memory again, uploaded uCNC to the Clean memory and then everything worked perfectly.

This may be a normal STM32 thing or a counterfeit thing that I just wasn't aware of. (Also the board came locked in RDP_1 for some reason so definitely a sketchy board with all these things combined)

Conclusion: Reuploading isn't a thing on this board, only uploading the code after erasing all memory makes the code actually run.

Anyway, my problems are resolved, the board is recognized via my USB-C Cable, and works with ioSender.

Paciente8159 commented 5 months ago

That behavior is very odd indeed. Glad you figured the issues.