Forum: Mikrocontroller und Digitale Elektronik Zephyr STM32F103C8 canbus pin mapping


von Eduard I. (eiten)


Lesenswert?

Hallo zusammen,

ich habe bis jetzt Zephyr-CAN Erfahrung mit dem NRF52840 und einem 
MCP2515 am SPI. Jetzt wollte ich mal an einer Blue Pill+ 
(https://github.com/WeActStudio/BluePill-Plus) den integrierten CAN 
controller ausprobieren (zephyr can babbling sample). Allerdings weiss 
ich nicht, wie das pinctrl ausschauen soll, damit ich CANRX/TX auf PB8 
und PB9 kriege.

stm32_min_dev_stm32f103xb_blue.overlay:
1
/ {
2
        model = "STM32 Minimum Development Board (Blue)";
3
        compatible = "stm32_min_dev_blue", "st,stm32f103c8";
4
5
        leds {
6
                led: led {
7
                        gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
8
                };
9
        };
10
        chosen {
11
                zephyr,canbus = &can1;
12
        };
13
};
14
15
&can1 {
16
        status = "okay";
17
};

Da meckert west natürlich:
1
$ west build -b stm32_min_dev@blue
2
-- west build: generating a build system
3
Loading Zephyr default modules (Zephyr base (cached)).
4
-- Application: /home/edi/zephyrproject/projects/babbling
5
-- CMake version: 3.30.2
6
-- Cache files will be written to: /home/edi/.cache/zephyr
7
-- Zephyr version: 3.7.99 (/home/edi/zephyrproject/zephyr)
8
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
9
-- Board: stm32_min_dev, Revision: blue, qualifiers: stm32f103xb
10
-- Found host-tools: zephyr 0.16.8 (/home/edi/zephyr-sdk-0.16.8)
11
-- Found toolchain: zephyr 0.16.8 (/home/edi/zephyr-sdk-0.16.8)
12
-- Found BOARD.dts: /home/edi/zephyrproject/zephyr/boards/others/stm32_min_dev/stm32_min_dev.dts
13
-- Found devicetree overlay: /home/edi/zephyrproject/zephyr/boards/others/stm32_min_dev/stm32_min_dev_stm32f103xb_blue.overlay
14
-- Found devicetree overlay: /home/edi/zephyrproject/projects/babbling/stm32_min_dev_stm32f103xb_blue.overlay
15
-- In: /home/edi/zephyrproject/projects/babbling/build/zephyr, command: /usr/bin/python3;/home/edi/zephyrproject/zephyr/scripts/dts/gen_defines.py;--dts;/home/edi/zephyrproject/projects/babbling/build/zephyr/zephyr.dts.pre;--dtc-flags;'';--bindings-dirs;/home/edi/zephyrproject/zephyr/dts/bindings;--header-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/include/generated/zephyr/devicetree_generated.h.new;--dts-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/zephyr.dts.new;--edt-pickle-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/edt.pickle;--vendor-prefixes;/home/edi/zephyrproject/zephyr/dts/bindings/vendor-prefixes.txt
16
CMake Error at /home/edi/zephyrproject/zephyr/cmake/modules/dts.cmake:311 (message):
17
  gen_defines.py failed with result code: 1 - stderr contents:
18
19
  devicetree error: 'pinctrl-0' is marked as required in 'properties:' in
20
  /home/edi/zephyrproject/zephyr/dts/bindings/can/st,stm32-bxcan.yaml, but
21
  does not appear in <Node /soc/can@40006400 in
22
  '/home/edi/zephyrproject/zephyr/misc/empty_file.c'>
23
24
Call Stack (most recent call first):
25
  /home/edi/zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
26
  /home/edi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
27
  /home/edi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
28
  CMakeLists.txt:4 (find_package)
29
30
31
-- Configuring incomplete, errors occurred!
32
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/edi/zephyrproject/projects/babbling/build -GNinja -S/home/edi/zephyrproject/projects/babbling

Kann mich da mal jemand in die richtige Richtung schubbsen? Ich brauche 
wohl was in der Richtung von
1
can1_rx_pb8: can1_rx_pb8 {
2
    pinmux = <STM32_PINMUX('B', 8, AF7)>;
3
};
4
can1_tx_pb9: can1_tx_pb9 {
5
  pinmux = <STM32_PINMUX('B', 9, AF7)>;
6
};
Aber wie komme ich da auf die AF-Nummer? Ich habe im Datasheet und im 
Manual nichts gefunden.

Danke und Gruss, Edi

: Bearbeitet durch User
von Niklas G. (erlkoenig) Benutzerseite


Lesenswert?

Eduard I. schrieb:
> Aber wie komme ich da auf die AF-Nummer?

Die gibt's bei den alten STM32F1 nicht, bei allen anderen Serien schon.

Müsste es nicht genau so gehen wie z.B. hier:

https://github.com/zephyrproject-rtos/zephyr/blob/23eca6362dce63e52fcf6825f772e7ee7ae5226e/boards/st/nucleo_f303re/nucleo_f303re.dts#L96
1
&can1 {
2
  pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>;
3
  pinctrl-names = "default";
4
  status = "okay";
5
};

: Bearbeitet durch User
von Eduard I. (eiten)


Lesenswert?

Niklas G. schrieb:
>
1
&can1 {
2
>   pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>;
3
>   pinctrl-names = "default";
4
>   status = "okay";
5
> };
Leider nicht, die sind leider nicht definiert:
1
$ west build
2
-- west build: generating a build system
3
Loading Zephyr default modules (Zephyr base (cached)).
4
-- Application: /home/edi/zephyrproject/projects/babbling
5
-- CMake version: 3.30.2
6
-- Cache files will be written to: /home/edi/.cache/zephyr
7
-- Zephyr version: 3.7.99 (/home/edi/zephyrproject/zephyr)
8
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
9
-- Board: stm32_min_dev, Revision: blue, qualifiers: stm32f103xb
10
-- Found host-tools: zephyr 0.16.8 (/home/edi/zephyr-sdk-0.16.8)
11
-- Found toolchain: zephyr 0.16.8 (/home/edi/zephyr-sdk-0.16.8)
12
-- Found BOARD.dts: /home/edi/zephyrproject/zephyr/boards/others/stm32_min_dev/stm32_min_dev.dts
13
-- Found devicetree overlay: /home/edi/zephyrproject/zephyr/boards/others/stm32_min_dev/stm32_min_dev_stm32f103xb_blue.overlay
14
-- Found devicetree overlay: /home/edi/zephyrproject/projects/babbling/stm32_min_dev_stm32f103xb_blue.overlay
15
-- In: /home/edi/zephyrproject/projects/babbling/build/zephyr, command: /usr/bin/python3;/home/edi/zephyrproject/zephyr/scripts/dts/gen_defines.py;--dts;/home/edi/zephyrproject/projects/babbling/build/zephyr/zephyr.dts.pre;--dtc-flags;'';--bindings-dirs;/home/edi/zephyrproject/zephyr/dts/bindings;--header-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/include/generated/zephyr/devicetree_generated.h.new;--dts-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/zephyr.dts.new;--edt-pickle-out;/home/edi/zephyrproject/projects/babbling/build/zephyr/edt.pickle;--vendor-prefixes;/home/edi/zephyrproject/zephyr/dts/bindings/vendor-prefixes.txt
16
CMake Error at /home/edi/zephyrproject/zephyr/cmake/modules/dts.cmake:311 (message):
17
  gen_defines.py failed with result code: 1 - stderr contents:
18
19
  devicetree error: /soc/can@40006400: undefined node label 'can_rx_pb8'
20
21
Call Stack (most recent call first):
22
  /home/edi/zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
23
  /home/edi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
24
  /home/edi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
25
  CMakeLists.txt:4 (find_package)
26
27
28
-- Configuring incomplete, errors occurred!
29
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/edi/zephyrproject/projects/babbling/build -GNinja -S/home/edi/zephyrproject/projects/babbling

Danke Dir für die Antwort.

von Eduard I. (eiten)


Lesenswert?

Hallo zusammen,

ich hab's gefunden, die heissen
1
&can_rx_remap1_pb8
 und
1
&can_tx_remap1_pb9
. Nicht ganz konsistent...

Zur Vollständigkeit:
1
/ {
2
        model = "STM32 Minimum Development Board (Blue)";
3
        compatible = "stm32_min_dev_blue", "st,stm32f103c8";
4
5
        leds {
6
                led: led {
7
                        gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
8
                };
9
        };
10
        chosen {
11
                zephyr,canbus = &can1;
12
        };
13
        buttons {
14
                compatible = "gpio-keys";
15
                button0: button_0 {
16
                        gpios = <&gpioa 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
17
                        label = "User Key";
18
/*                        zephyr,code = <INPUT_KEY_0>;*/
19
                };
20
        };
21
        aliases {
22
                sw0 = &button0;
23
        };
24
25
};
26
27
&can1 {
28
        pinctrl-0 = <&can_rx_remap1_pb8 &can_tx_remap1_pb9>;
29
        pinctrl-names = "default";
30
        status = "okay";
31
};

Ich kann den CAN-Controller jetzt ansprechen, aber ich kriegen einen 
Fehler -114  (ENETUNREACH). Mal schauen.

LG, Edi

von Eduard I. (eiten)


Lesenswert?

FYI: Der Transceiver hatte nen Schuss und nur halb funktioniert...
Mit nem neuen tut jetzt alles!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.