orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Wed Oct 18, 2017 11:10 am

Hi everyone
I am using Raspberrypi CM3 and I want to have 2 SPI, 2 I2C and 2 UART
I write my Device Tree source (.dts) according GPIO functions in https://elinux.org/RPi_BCM2835_GPIOs and as it is mentioned in [/url]https://www.raspberrypi.org/documentati ... uration.md and like [url] https://github.com/ra ... -blob.dts but I cannot get desire result. I made my dt-blob.bin and I put it on boot Folder and then I restarted the CM3
my .dts file is :

pins_cm3 { // Pi 3 CM3
pin_config {
pin@default {
polarity = "active_high";
termination = "pull_down";
startup_state = "inactive";
function = "input";
}; // pin

pin@p0 { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO4
pin@p1 { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO3
pin@p2 { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SDA
pin@p3 { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SCL
pin@p4 { function = "output"; termination = "pull_down"; }; // RHF_GPIO_DIO1
pin@p5 { function = "output"; termination = "pull_down"; }; // RHF_GPIO_DIO2
pin@p6 { function = "output"; termination = "pull_up"; startup_state = "active"; }; // LAN_RUN
pin@p7 { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO0
pin@p8 { function = "spi0"; termination = "pull_up"; }; // RHF_SPI_CSN
pin@p9 { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_MISO
pin@p10 { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_MOSI
pin@p11 { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_SCK
pin@p12 { function = "output"; termination = "pull_down"; }; // RHF_GPIO_RESET
pin@p13 { function = "output"; termination = "pull_down"; }; // RHF_GPIO_PPS
pin@p14 { function = "uart0"; termination = "no_pulling"; drive_strength_mA = < 8 >; }; // TX uart0
pin@p15 { function = "uart0"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // RX uart0
pin@p16 { function = "spi1"; termination = "pull_down"; }; // RTC_WakeUp //SPI1_CE2_N
pin@p17 { function = "spi1"; termination = "pull_down"; }; // mPCI1_WAKE# //SPI1_CE1_N
pin@p18 { function = "spi1"; termination = "pull_down"; }; // mPCI2_WAKE# //SPI1_CE0_N
pin@p19 { function = "spi1"; termination = "pull_down"; drive_strength_mA = < 8 >; }; //SPI1_MISO
pin@p20 { function = "spi1"; termination = "pull_down"; drive_strength_mA = < 8 >; }; //SPI1_MOSI
pin@p21 { function = "spi1"; termination = "pull_down"; polarity="active_low"; }; //SPI1_SCLK
pin@p22 { function = "sdcard"; termination = "pull_up"; }; //SD0_CLK
pin@p23 { function = "sdcard"; termination = "pull_up"; }; // SD0_CMD
pin@p24 { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT0
pin@p25 { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT1
pin@p26 { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT2
pin@p27 { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT3

// BANK 1 - USER GPIO//
pin@p28 { function = "i2c0"; termination = "pull_up"; }; // mPCI1_I2C_SDA mPCI2_I2C_SDA //SDA0
pin@p29 { function = "i2c0"; termination = "pull_up"; }; // mPCI1_I2C_SCL mPCI2_I2C_SCL //SCL0
pin@p30 { function = "output"; termination = "pull_down"; }; // mPCI1_W_DISABLE#//output
pin@p31 { function = "output"; termination = "pull_down"; }; // mPCI2_PERST# //output
pin@p32 { function = "uart1"; termination = "pull_up"; drive_strength_mA = < 8 >; }; //TXD1
pin@p33 { function = "uart1"; termination = "no_pulling";}; // UART1 FT232_TX mPCI1_UART_TX mPCI2_UART_TX // RXD1
pin@p34 { function = "gp_clk"; termination = "pull_down"; }; // mPCI1_PCM_CLK //GPCLK0
pin@p35 { function = "output"; termination = "pull_down"; }; // mPCI1_PERST# //Output
pin@p36 { function = "output"; termination = "pull_down"; }; // mPCI1_PCM_SYNC //Output
pin@p37 { function = "output"; termination = "pull_down"; }; // mPCI2_PCM_SYNC // output
pin@p38 { function = "output"; termination = "pull_down"; }; // GPS_PULSE //output
pin@p39 { function = "output"; termination = "pull_down" polarity="active_low";; }; //activity LED_3 //Output
pin@p40 { function = "output"; termination = "pull_down"; polarity="active_low"; }; //activity LED_1 //Output
pin@p41 { function = "output"; termination = "pull_down"; polarity="active_low"; }; //activity LED_2 //Output
pin@p42 { function = "gp_clk"; termination = "pull_down"; }; // mPCI2_PCM_CLK //GPCLK2
pin@p43 { function = "output"; termination = "pull_down"; };// mPCI2_W_DISABLE# // output
pin@p44 { function = "gp_clk"; termination = "pull_down"; }; // Lan9514 clock // GPCLK1
pin@p45 { function = "output"; termination = "pull_down"; }; // // output

// pin@p46 { function = "input"; termination = "pull_up"; }; // SMPS_SCL
// pin@p47 { function = "input"; termination = "pull_up"; }; // SMPS_SDA
// pin@p48 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CLK
// pin@p49 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CMD
//pin@p50 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D0
// pin@p51 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D1
// pin@p52 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D2
// pin@p53 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D3
pin@p128 { function = "input"; termination = "no_pulling"; polarity = "active_low"; }; // Hotplug
// pin@p129 { function = "output"; termination = "no_pulling"; polarity = "active_low"; }; // EMMC_ENABLE_N
}; // pin_config

pin_defines {
pin_define@HDMI_CONTROL_ATTACHED {
type = "external";
number = <0>;
};
pin_define@EMMC_ENABLE {
type = "external";
number = <1>;
};
pin_define@NUM_CAMERAS {
type = "internal";
number = <0>;
};
pin_define@POWER_LOW {
type = "absent";
};
pin_define@LEDS_DISK_ACTIVITY {
type = "absent";
};
pin_define@LAN_RUN {
type = "absent";
};
pin_define@SMPS_SDA {
type = "internal";
number = <46>;
};
pin_define@SMPS_SCL {
type = "internal";
number = <47>;
};
pin_define@ETH_CLK {
type = "absent";
};
pin_define@WL_LPO_CLK {
type = "absent";
};
pin_define@USB_LIMIT_1A2 {
type = "absent";
};
pin_define@SIO_1V8_SEL {
type = "absent";
};
pin_define@PWML {
type = "absent";
};
pin_define@PWMR {
type = "absent";
};
pin_define@SAFE_MODE {
type = "absent";
};
pin_define@SD_CARD_DETECT {
type = "absent";
};
pin_define@ID_SDA {
type = "absent";
};
pin_define@ID_SCL {
type = "absent";
};
pin_define@DISPLAY_SDA {
type = "internal";
number = <0>;
};
pin_define@DISPLAY_SCL {
type = "internal";
number = <1>;
};
pin_define@DISPLAY_I2C_PORT {
type="internal";
number=<0>;
};
}; // pin_defines
}; // pins


and the result from sudo raspi-gpio get with a lot of warning about property and ...is :
https://www.photobox.co.uk/my/photo/ful ... 0209847637
and
[url] https://www.photobox.co.uk/my/photo/ful ... 0209845394 [url]

What is my wrong?
Please help me
best regards

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4530
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Wed Oct 18, 2017 12:28 pm

Those image links aren't public, so nothing to analyse there.

Most of the setup should really be done through dtoverlays rather than dt-blob. Certainly i2c and spi can be done that way, including rerouting the pin muxing.
It's not clear what you're driving RHF_GPIO_DIOx and the LEDs with, but again that would be better off done through the Linux kernel claiming and configuring the pins via a suitable driver.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1361
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Wed Oct 18, 2017 12:32 pm

Also, dt-blob.dts is not Device Tree - it just uses the same syntax and compiler.

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Thu Oct 19, 2017 6:11 am

Thank you so much 6by9 because of your attention and time
I am sorry about the links and these are new links for my result
https://ibb.co/mUMYgR
and
https://ibb.co/cTTqT6

RHF_GPIO_DIOx and the LEDs pins with are output pins which are related to my project

I have some questions
what do you mean by "configuring the pins via a suitable driver"? Does it mean I have to install a driver for configuring pins?
Do you have any dtoverlays for configuring SPI , I2C or... or a good guidance how to write it?
How to add new overlays ?
Sorry I am new in raspberry pi :cry:
please help me
best regards
Last edited by orkidelolo on Thu Oct 19, 2017 8:04 am, edited 1 time in total.

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Thu Oct 19, 2017 6:14 am

PhilE wrote:
Wed Oct 18, 2017 12:32 pm
Also, dt-blob.dts is not Device Tree - it just uses the same syntax and compiler.
Thank you PhilE
pardon me, What do you mean?
I am new in rasbpery pi

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1361
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Thu Oct 19, 2017 10:24 am

The difference between dt-blob.dts and Device Tree is like the difference between a poem and a recipe - they are both written in the same language but with different purposes. dt-blob is a Broadcom-specific way of describing the GPIO and clock usage to the firmware, whereas Device Tree is a standard, OS-independent way of describing hardware which is mainly used for buses that don't support device discovery.

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Thu Oct 19, 2017 11:35 am

PhilE wrote:
Thu Oct 19, 2017 10:24 am
The difference between dt-blob.dts and Device Tree is like the difference between a poem and a recipe - they are both written in the same language but with different purposes. dt-blob is a Broadcom-specific way of describing the GPIO and clock usage to the firmware, whereas Device Tree is a standard, OS-independent way of describing hardware which is mainly used for buses that don't support device discovery.
Than you so much PhilE because of your intelligible answer

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4530
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Thu Oct 19, 2017 2:45 pm

orkidelolo wrote:
Thu Oct 19, 2017 6:11 am
Thank you so much 6by9 because of your attention and time
I am sorry about the links and these are new links for my result
https://ibb.co/mUMYgR
and
https://ibb.co/cTTqT6

RHF_GPIO_DIOx and the LEDs pins with are output pins which are related to my project

I have some questions
what do you mean by "configuring the pins via a suitable driver"? Does it mean I have to install a driver for configuring pins?
Do you have any dtoverlays for configuring SPI , I2C or... or a good guidance how to write it?
How to add new overlays ?
Sorry I am new in raspberry pi :cry:
please help me
best regards
All the existing DT overlays are documented in the source tree - https://github.com/raspberrypi/linux/bl ... ays/README.
Documentation on writing overlays is at https://www.raspberrypi.org/documentati ... ce-tree.md and https://www.raspberrypi.org/documentati ... w-guide.md

I2C is enabled with "dtparam=i2c_arm=on" added to /boot/config.txt for i2c-1, and "dtparam=i2c_vc=on" for i2c-0. Enabling i2c-0 means you can't use the camera or 7" display. Those will also deal with pinmuxing GPIOs 2&3 for i2c-1, and GPIOs 0&1 for i2c-0. If you want them on alternate GPIOs then you need to alter that mapping within the kernel device tree as that will override dt-blob.bin. I suspect you want "dtoverlay=i2c0-bcm2708,pins_28_29=1" to remap i2c-0 based on your blob.
You'll most likely want to to add "i2c-dev" to /etc/modules so that you can access I2C from your application rather than just the kernel.

Likewise for SPI, add "dtparam=spi=on".

GPIOs you can export to userspace via sysfs.

Code: Select all

echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
echo 1 > /sys/class/gpio/gpio0/value
That's the official Linux way to access GPIOs, as documented in https://github.com/raspberrypi/linux/bl ... /sysfs.txt

I'm not sure what you're trying to do with the mapping on pins 22-27. Enabling the mapping for the second SD card interface? In which case again you need to add Linux device tree config to specify the driver to use, and that is the place to set up the GPIO mapping.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Sat Oct 21, 2017 8:50 am

6by9 wrote:
Thu Oct 19, 2017 2:45 pm
orkidelolo wrote:
Thu Oct 19, 2017 6:11 am
Thank you so much 6by9 because of your attention and time
I am sorry about the links and these are new links for my result
https://ibb.co/mUMYgR
and
https://ibb.co/cTTqT6

RHF_GPIO_DIOx and the LEDs pins with are output pins which are related to my project

I have some questions
what do you mean by "configuring the pins via a suitable driver"? Does it mean I have to install a driver for configuring pins?
Do you have any dtoverlays for configuring SPI , I2C or... or a good guidance how to write it?
How to add new overlays ?
Sorry I am new in raspberry pi :cry:
please help me
best regards
All the existing DT overlays are documented in the source tree - https://github.com/raspberrypi/linux/bl ... ays/README.
Documentation on writing overlays is at https://www.raspberrypi.org/documentati ... ce-tree.md and https://www.raspberrypi.org/documentati ... w-guide.md

I2C is enabled with "dtparam=i2c_arm=on" added to /boot/config.txt for i2c-1, and "dtparam=i2c_vc=on" for i2c-0. Enabling i2c-0 means you can't use the camera or 7" display. Those will also deal with pinmuxing GPIOs 2&3 for i2c-1, and GPIOs 0&1 for i2c-0. If you want them on alternate GPIOs then you need to alter that mapping within the kernel device tree as that will override dt-blob.bin. I suspect you want "dtoverlay=i2c0-bcm2708,pins_28_29=1" to remap i2c-0 based on your blob.
You'll most likely want to to add "i2c-dev" to /etc/modules so that you can access I2C from your application rather than just the kernel.

Likewise for SPI, add "dtparam=spi=on".

GPIOs you can export to userspace via sysfs.

Code: Select all

echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
echo 1 > /sys/class/gpio/gpio0/value
That's the official Linux way to access GPIOs, as documented in https://github.com/raspberrypi/linux/bl ... /sysfs.txt

I'm not sure what you're trying to do with the mapping on pins 22-27. Enabling the mapping for the second SD card interface? In which case again you need to add Linux device tree config to specify the driver to use, and that is the place to set up the GPIO mapping.
Thank you so much 6by9 because of everything
It is so great
As you know CM v3 has EMMC and it cannot support SD card and I need more than 4 GB capacity, so as I read in https://elinux.org/RPi_BCM2835_GPIOs I can Enable SD card on pins 22-27

gsh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1204
Joined: Sat Sep 10, 2011 11:43 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Sat Oct 21, 2017 10:46 am

CM3 lite does not have eMMC and therefore can support an SD card or eMMC on the additional pins that are only available on the lite version
--
Gordon Hollingworth PhD
Raspberry Pi - Director of Software Engineering

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Sat Oct 21, 2017 12:35 pm

gsh wrote:
Sat Oct 21, 2017 10:46 am
CM3 lite does not have eMMC and therefore can support an SD card or eMMC on the additional pins that are only available on the lite version
Thank you gsh
so I cannot add SD card to CM 3 and I have to buy CM 3Lite

orkidelolo
Posts: 11
Joined: Thu Sep 14, 2017 10:02 am

Re: CHANGING THE DEFAULT PIN CONFIGURATION of CM3

Sat Oct 21, 2017 12:48 pm

6by9 wrote:
Thu Oct 19, 2017 2:45 pm
orkidelolo wrote:
Thu Oct 19, 2017 6:11 am
Thank you so much 6by9 because of your attention and time
I am sorry about the links and these are new links for my result
https://ibb.co/mUMYgR
and
https://ibb.co/cTTqT6

RHF_GPIO_DIOx and the LEDs pins with are output pins which are related to my project

I have some questions
what do you mean by "configuring the pins via a suitable driver"? Does it mean I have to install a driver for configuring pins?
Do you have any dtoverlays for configuring SPI , I2C or... or a good guidance how to write it?
How to add new overlays ?
Sorry I am new in raspberry pi :cry:
please help me
best regards
All the existing DT overlays are documented in the source tree - https://github.com/raspberrypi/linux/bl ... ays/README.
Documentation on writing overlays is at https://www.raspberrypi.org/documentati ... ce-tree.md and https://www.raspberrypi.org/documentati ... w-guide.md

I2C is enabled with "dtparam=i2c_arm=on" added to /boot/config.txt for i2c-1, and "dtparam=i2c_vc=on" for i2c-0. Enabling i2c-0 means you can't use the camera or 7" display. Those will also deal with pinmuxing GPIOs 2&3 for i2c-1, and GPIOs 0&1 for i2c-0. If you want them on alternate GPIOs then you need to alter that mapping within the kernel device tree as that will override dt-blob.bin. I suspect you want "dtoverlay=i2c0-bcm2708,pins_28_29=1" to remap i2c-0 based on your blob.
You'll most likely want to to add "i2c-dev" to /etc/modules so that you can access I2C from your application rather than just the kernel.

Likewise for SPI, add "dtparam=spi=on".

GPIOs you can export to userspace via sysfs.

Code: Select all

echo 0 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio0/direction
echo 1 > /sys/class/gpio/gpio0/value
That's the official Linux way to access GPIOs, as documented in https://github.com/raspberrypi/linux/bl ... /sysfs.txt

I'm not sure what you're trying to do with the mapping on pins 22-27. Enabling the mapping for the second SD card interface? In which case again you need to add Linux device tree config to specify the driver to use, and that is the place to set up the GPIO mapping.
Excuse me 6by9 I face another problems
I can active both I2C as well as you tell to me but when I want to active Uart1, I cannot change the default pin
i want to active uart1 on pins 32-33 but It is active on pins 14-15
for activating uart 1 , I am using uart1-overlay.dts
And my another question is which overlay I have to add for activating SPI1 and SPI2
I am using spi1-3cs-overlay.dts but it has no effect
I added
""
dtparam=spi=on
dtparam=uart0=on
dtparam=uart1=on

"

thank you in advace
best regards

Return to “Compute Module”

Who is online

Users browsing this forum: No registered users and 7 guests