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 {
[email protected] {
polarity = "active_high";
termination = "pull_down";
startup_state = "inactive";
function = "input";
}; // pin

[email protected] { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO4
[email protected] { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO3
[email protected] { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SDA
[email protected] { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SCL
[email protected] { function = "output"; termination = "pull_down"; }; // RHF_GPIO_DIO1
[email protected] { function = "output"; termination = "pull_down"; }; // RHF_GPIO_DIO2
[email protected] { function = "output"; termination = "pull_up"; startup_state = "active"; }; // LAN_RUN
[email protected] { function = "output"; termination = "pull_up"; }; // RHF_GPIO_DIO0
[email protected] { function = "spi0"; termination = "pull_up"; }; // RHF_SPI_CSN
[email protected] { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_MISO
[email protected] { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_MOSI
[email protected] { function = "spi0"; termination = "pull_down"; }; // RHF_SPI_SCK
[email protected] { function = "output"; termination = "pull_down"; }; // RHF_GPIO_RESET
[email protected] { function = "output"; termination = "pull_down"; }; // RHF_GPIO_PPS
[email protected] { function = "uart0"; termination = "no_pulling"; drive_strength_mA = < 8 >; }; // TX uart0
[email protected] { function = "uart0"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // RX uart0
[email protected] { function = "spi1"; termination = "pull_down"; }; // RTC_WakeUp //SPI1_CE2_N
[email protected] { function = "spi1"; termination = "pull_down"; }; // mPCI1_WAKE# //SPI1_CE1_N
[email protected] { function = "spi1"; termination = "pull_down"; }; // mPCI2_WAKE# //SPI1_CE0_N
[email protected] { function = "spi1"; termination = "pull_down"; drive_strength_mA = < 8 >; }; //SPI1_MISO
[email protected] { function = "spi1"; termination = "pull_down"; drive_strength_mA = < 8 >; }; //SPI1_MOSI
[email protected] { function = "spi1"; termination = "pull_down"; polarity="active_low"; }; //SPI1_SCLK
[email protected] { function = "sdcard"; termination = "pull_up"; }; //SD0_CLK
[email protected] { function = "sdcard"; termination = "pull_up"; }; // SD0_CMD
[email protected] { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT0
[email protected] { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT1
[email protected] { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT2
[email protected] { function = "sdcard"; termination = "pull_up"; }; // SD0_DAT3

// BANK 1 - USER GPIO//
[email protected] { function = "i2c0"; termination = "pull_up"; }; // mPCI1_I2C_SDA mPCI2_I2C_SDA //SDA0
[email protected] { function = "i2c0"; termination = "pull_up"; }; // mPCI1_I2C_SCL mPCI2_I2C_SCL //SCL0
[email protected] { function = "output"; termination = "pull_down"; }; // mPCI1_W_DISABLE#//output
[email protected] { function = "output"; termination = "pull_down"; }; // mPCI2_PERST# //output
[email protected] { function = "uart1"; termination = "pull_up"; drive_strength_mA = < 8 >; }; //TXD1
[email protected] { function = "uart1"; termination = "no_pulling";}; // UART1 FT232_TX mPCI1_UART_TX mPCI2_UART_TX // RXD1
[email protected] { function = "gp_clk"; termination = "pull_down"; }; // mPCI1_PCM_CLK //GPCLK0
[email protected] { function = "output"; termination = "pull_down"; }; // mPCI1_PERST# //Output
[email protected] { function = "output"; termination = "pull_down"; }; // mPCI1_PCM_SYNC //Output
[email protected] { function = "output"; termination = "pull_down"; }; // mPCI2_PCM_SYNC // output
[email protected] { function = "output"; termination = "pull_down"; }; // GPS_PULSE //output
[email protected] { function = "output"; termination = "pull_down" polarity="active_low";; }; //activity LED_3 //Output
[email protected] { function = "output"; termination = "pull_down"; polarity="active_low"; }; //activity LED_1 //Output
[email protected] { function = "output"; termination = "pull_down"; polarity="active_low"; }; //activity LED_2 //Output
[email protected] { function = "gp_clk"; termination = "pull_down"; }; // mPCI2_PCM_CLK //GPCLK2
[email protected] { function = "output"; termination = "pull_down"; };// mPCI2_W_DISABLE# // output
[email protected] { function = "gp_clk"; termination = "pull_down"; }; // Lan9514 clock // GPCLK1
[email protected] { function = "output"; termination = "pull_down"; }; // // output

// [email protected] { function = "input"; termination = "pull_up"; }; // SMPS_SCL
// [email protected] { function = "input"; termination = "pull_up"; }; // SMPS_SDA
// [email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CLK
// [email protected]9 { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD CMD
//[email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D0
// [email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D1
// [email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D2
// [email protected] { function = "sdcard"; termination = "pull_up"; drive_strength_mA = < 8 >; }; // SD D3
[email protected] { function = "input"; termination = "no_pulling"; polarity = "active_low"; }; // Hotplug
// [email protected] { function = "output"; termination = "no_pulling"; polarity = "active_low"; }; // EMMC_ENABLE_N
}; // pin_config

pin_defines {
[email protected]_CONTROL_ATTACHED {
type = "external";
number = <0>;
};
[email protected]_ENABLE {
type = "external";
number = <1>;
};
[email protected]_CAMERAS {
type = "internal";
number = <0>;
};
[email protected]_LOW {
type = "absent";
};
[email protected]_DISK_ACTIVITY {
type = "absent";
};
[email protected]_RUN {
type = "absent";
};
[email protected]_SDA {
type = "internal";
number = <46>;
};
[email protected]_SCL {
type = "internal";
number = <47>;
};
[email protected]_CLK {
type = "absent";
};
[email protected]_LPO_CLK {
type = "absent";
};
[email protected]_LIMIT_1A2 {
type = "absent";
};
[email protected]_1V8_SEL {
type = "absent";
};
[email protected] {
type = "absent";
};
[email protected] {
type = "absent";
};
[email protected]_MODE {
type = "absent";
};
[email protected]_CARD_DETECT {
type = "absent";
};
[email protected]_SDA {
type = "absent";
};
[email protected]_SCL {
type = "absent";
};
[email protected]_SDA {
type = "internal";
number = <0>;
};
[email protected]_SCL {
type = "internal";
number = <1>;
};
[email protected]_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: 5557
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: 1822
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: 1822
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: 5557
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: 1302
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 2 guests