Which is the correct name for CB2 GPIOS?

Basic Information:

Printer Model: Custom
MCU / Printerboard: Manta M8P
Host / SBC CB2
klippy.log
klippy.log (2.7 MB)

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

Has anyone configured properly the CB2 GPIOs??

I mean, I’m trying to set their correct names but some of them don’t make sense for me.
I have taken a look at the oficial documentation of bigtreetech and have found this and some other images:


Also this is what the CB2 Manual says:

I don’t know which name take because the following:
If i try to use the first name, for example the ones as “GPIO0_B0”, klipper says that this is not a valid pin name. But for example if i take a look in the ones that are as “gpio1”, it doesn’t make sense because for example the pin 7 and pin 7 and 15 have the same name (gpio1)

Also, I don’t understand the calculation method.

The pins i’m trynig to configure are the following:

# CB2 (gpio) Pins
[board_pins CB2]
mcu: CB2
aliases:
    PIN_7=GPIO3_A1,
    PIN_11=GPIO0_C7,
    PIN_12=GPIO0_B0,
    PIN_13=GPIO1_A0,
    PIN_15=GPIO1_A1,
    PIN_16=GPIO4_C6,
    PIN_18=GPIO4_A3,
    PIN_26=GPIO0_A6,
    PIN_28=GPIO0_B3,

    # Controller fan
    PI_FAN=gpio19 # pin 37 on the manta board's gpio pins

As previous reference… I’m going to use the same pins as the one I used with CB1, which are the following:

# CB1 (gpio) Pins
[board_pins CB1]
mcu: CB1
aliases:
    # Motor alarm
    PIN_7=gpio270,
    PIN_11=gpio271,
    PIN_12=gpio263,
    PIN_13=gpio262,
    PIN_15=gpio260,
    PIN_16=gpio261,
    PIN_18=gpio259,
    PIN_26=gpio267,
    PIN_28=gpio266,

    # Controller fan
    PI_FAN=gpio269 # pin 37 on the manta board's gpio pins

Also mention that I use a pcb i created for extracting these pins:

Any ideas?
Thanks!

1 Like

I cannot really comment on the CB2 GPIOs as I have never used one. I found the GPIOs on CB1 already quite confusing, and the BTT documentation even more so.

But compliments on the tidy wiring work. This is exceptionally well done. Though, one remark on the CAN wiring: You seem to be using shielded cables, which is very good. Just be aware that:

  • Shielded cables have virtually no effect when the shield is not put to GND or PE.
  • You have to put at least one side to GND or PE (signal source side!), but depending on the type of expected interference, even both sides might be needed (especially against magnetic disturbances).
    • At frequencies above 100 kHz, you typically want to use double-sided grounding.
    • Make sure that both ends have the same GND point and GND potential
  • One-side grounding can lead to the shield effectively starting to radiate EMI by itself, while two-sided GNDing can lead to parasitic currents and ground loops if not done properly. No GNDing can even be worse compared to unshielded cables because the introduced energy cannot dissipate.
  • One of the best “short” recommendations I know on this topic is: Cables with shielding: Why do I need it?
1 Like

I’m currently trying to get technical support from bigtreetech, but their response for now is the same documentation that the shown in the website…:sweat_smile::joy:

Thanks! :slight_smile:

About the CAN shield. I don’t expect magnetic interference but maybe other EMI, so as you said, I connect their shield to GND in the source side by using some clips as these ones Clips de pantalla EMC, sueltos para montaje con remaches connected to the metal base of the photo which is also connected to gnd. (These clips are trimmed in the photo and can’t be seen :sweat_smile:)

I’ll take a look in that link!

Thanks as always!!

1 Like

In a project in my professional life, we literally lost weeks due to such topics. We needed to pass “Electromagnetic Compatibility (EMC)” testing and certification as well.
Whatever we did, we either encountered spurious errors due to electromagnetic interference or failed on the emission side. We learned a lot, but it was an expensive lesson.

1 Like

I never got in touch with a CB2.

Maybe this gives you a clue. See the last two posts in that link Power_off GPIO · Issue #49 · bigtreetech/CB2 · GitHub

Good luck, hcet14

1 Like

To add one aspect:
If you are really depending on using the GPIOs, I’d suggest using a Raspberry 4 instead. GPIO handling very much depends on the Linux level and the support provided there.

As another alternative, you can attach another RPi Pico flashed with Klipper, something like:

Thanks!

This only seems to be the configuration for the shutdown pin, not all gpios, but it seems that i need to use the original names (the ones as gpio3_a1…), but for now these still don’t work, so I’ll wait until the support from bigtreetech

I use the GPIOs to manage alarms in my machine and handle a few other tasks. To be honest, since BigTreeTech devices are similar to Raspberry Pi but not quite the same, I’ve run into a lot of issues while configuring them. They don’t follow the same rules, standards, or procedures as Raspberry Pi, which makes things more complicated. Because of that, I’m seriously considering switching to a Raspberry Pi.

As for my future projects, the RPI Pico seems like a great option since I’ll be needing more GPIOs pretty soon.

Many thanks!!

Finally, I have the correct names for these GPIOs!

It turns out that the full name is the written in brackets. For example, according to the photo, pin_7 corresponds to GPIO3_A1 (gpiochip3/gpio1), so the correct name to use is: gpiochip3/gpio1.

Below, I’m listing the pins I have configured as an example, in case it helps anyone:

#CB2 (gpio) Pins
[board_pins CB2]
mcu: CB2
aliases:
    PIN_7=gpiochip3/gpio1,
    PIN_11=gpiochip0/gpio23,
    PIN_12=gpiochip0/gpio8,
    PIN_13=gpiochip1/gpio0,
    PIN_15=gpiochip1/gpio1,
    PIN_16=gpiochip4/gpio22,
    PIN_18=gpiochip4/gpio3,
    PIN_26=gpiochip0/gpio6,
    PIN_28=gpiochip0/gpio11,

    # Controller fan
    PI_FAN=gpiochip0/gpio19 # pin 37 on the manta board's gpio pins

Note: It seems that it is not possible to specify that a pin requires a pull-up resistor. Doing so will return the typical error: “unable to open chip line”. Therefore, make sure to connect only components that do not require a pull-up resistor to these pins.

2 Likes

Also mention that neither a pull down can be specifed. Only can be specified the pin

Aaaaalso other important note:

Some gpio pins in CB2 always remain active, so by default one can’t use them as an input as it is always high.

I guess it is needed to do some overlay or modify some system file in order to set them low. Any ideas?

As stated above, GPIO support using the “Linux MCU” highly depends on the support at the Linux OS level.
There are some shenanigans like exporting GPIOs using the SysFS interface. See here for some details.