Radarcape:Devicetree

From Beast Wiki
Jump to: navigation, search
For Experts The tasks described in this manual require expert knowledge of Unix/Linux and embedded systems.

This chapter describes how the Radarcape is attached into the Linux system of the Beaglebone. It is only informational, as this is already done on all Radarcapes provided to customers. You just need it if you bring up Linux from zero or want to learn how this step is done.

Device Tree Overlays

Step 0: Get the device tree compiler:

1 # when using Angstrom
2 opkg install dtc
3 
4 # when using Debian
5 apt-get install device-tree-compiler

see also: link

Device Tree Overlay for Beaglebone (white)

Step 1 - Beaglebone (white): Create ~/BB-W-Radarcape.dts:

 1 /*  
 2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 3 *
 4 * This program is free software; you can redistribute it and/or modify
 5 * it under the terms of the GNU General Purpose License Version 2 as
 6 * published by the Free Software Foundation
 7 *
 8 * Original from: github.com/jadonk/validation-scripts/blob/master/test-capemgr/ 
 9 *
10 * Modified by Guenter Koellner for the Radarcape
11 * using: UART5 handshake signals and some GPIOs             
12 * with a great thanks to Derek Molloy - http://derekmolloy.ie/beaglebone
13 *
14 * As on the Beaglebone Black pins beeing used are occupied by eMMC and HDMI,
15 * it will require a different setting (and obviously, a different cape hardware) 
16 */
17 
18 /dts-v1/;
19 /plugin/;
20 
21 /{
22     compatible = "ti,beaglebone";
23     part-number = "radarcape";
24     version = "00A0";
25 
26     fragment@0 {
27         target = <&am33xx_pinmux>;
28             
29         __overlay__ {
30             pinctrl_radarcape: radarcape_Pins {
31                 pinctrl-single,pins = <
32 
33                     /* GPIO Values: */
34                     /* GPIO 0x07 Output         */
35                     /* GPIO 0x27 Input pullup   */
36                     /* GPIO 0x37 Input pulldown */
37                     /* GPIO 0x2f Input no pull  */
38                                                                      
39                     /* Watchdog retrigger output */
40                     0x078 0x07  /* P9_12 GPIO1_28 #60 Output Mode7 */            
41  
42                     /* GPS 1PPS Input */
43                     0x040 0x37  /* P9_15 GPIO1_16 #48 Input  Mode7 pullup    PPS1 input */
44                     
45                     /* FPGA Pins */ 
46                     0x018 0x37  /* P8_3  GPIO1_6  #38 Input  Mode7 pullup    CONF_DONE  */
47                     0x01c 0x07  /* P8_4  GPIO1_7  #39 Output Mode7           DCLK       */
48                     0x008 0x37  /* P8_5  GPIO1_2  #34 Input  Mode7 pullup    nStatus    */
49                     0x030 0x07  /* P8_12 GPIO1_12 #44 Output Mode7           DATA0      */
50                     0x014 0x07  /* P8_22 GPIO1_5  #37 Output Mode7           nCONF      */
51 
52                     /* UART5 CTS/RTS as addon to the default UART5 device tree settings */ 
53                     0x0d8 0x36  /* P8_31 UART5_CTSN   Input  Mode6 pullup    CTS input  */
54                     0x0dc 0x06  /* P8_32 UART5_RTSN   Output Mode6 no pull   RTS output */
55                 >;
56             };
57         };
58     };
59 
60     fragment@1 {
61         target = <&ocp>;
62         __overlay__ {
63             test_helper: helper {
64                 compatible = "bone-pinmux-helper";
65                 pinctrl-names = "default";
66                 pinctrl-0 = <&pinctrl_radarcape>;
67                 status = "okay";
68             };
69         };
70     };
71 };


Step 1 - Beaglebone-Black: Create ~/BB-B-Radarcape.dts:

 1 /*
 2  * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 3  *
 4  * This program is free software; you can redistribute it and/or modify
 5  * it under the terms of the GNU General Purpose License Version 2 as
 6  * published by the Free Software Foundation
 7  *
 8  * Original from: github.com/jadonk/validation-scripts/blob/master/test-capemgr/
 9  *
10  * Modified by Guenter Koellner for the Radarcape
11  * with a great thanks to Derek Molloy - http://derekmolloy.ie/beaglebone
12  *
13  * Beaglebone Black Version
14  * requires Radarcape cape board version 3.0 or later
15  *
16  * compile using
17  * dtc -O dtb -o BB-B-Radarcape-00A0.dtbo -b 0 -@ BB-B-Radarcape.dts
18  */
19 
20 /dts-v1/;
21 /plugin/;
22 
23 /{
24     compatible = "ti,beaglebone-black";
25     part-number = "radarcape-v3";
26 
27     version = "00A0";
28 
29     fragment@0 {
30         target = <&am33xx_pinmux>;
31 
32         __overlay__ {
33             pinctrl_radarcape: radarcape_Pins {
34                 pinctrl-single,pins = <
35 
36                     /* GPIO Values: */
37                     /* GPIO 0x07 Output         */
38                     /* GPIO 0x27 Input pullup   */
39                     /* GPIO 0x37 Input pulldown */
40                     /* GPIO 0x2f Input no pull  */
41 
42                     /* Watchdog retrigger output */
43                     0x078 0x07  /* P9_12 GPIO1_28 #60 Output Mode7 */
44 
45                     /* GPS 1PPS Input */
46                     0x040 0x37  /* P9_15 GPIO1_16 #48 Input  Mode7 pullup    PPS1 input */
47 
48                     /* FPGA Pins */
49                     0x034 0x37  /* P8_11 GPIO1_13 #45 Input  Mode7 pullup    CONF_DONE  */
50                     0x03c 0x07  /* P8_15 GPIO1_15 #47 Output Mode7           DCLK       */
51                     0x038 0x37  /* P8_16 GPIO1_14 #46 Input  Mode7 pullup    nStatus    */
52                     0x030 0x07  /* P8_12 GPIO1_12 #44 Output Mode7           DATA0      */
53                     0x07c 0x07  /* P8_26 GPIO1_29 #61 Output Mode7           nCONF      */
54 
55                     /* UART5 CTS/RTS as addon to the default UART5 device tree settings */
56                     0x0d8 0x36  /* P8_31 UART5_CTSN   Input  Mode6 pullup    CTS input  */
57                     0x0dc 0x06  /* P8_32 UART5_RTSN   Output Mode6 no pull   RTS output */
58                 >;
59             };
60         };
61     };
62 
63     fragment@1 {
64         target = <&ocp>;
65         __overlay__ {
66             test_helper: helper {
67                 compatible = "bone-pinmux-helper";
68                 pinctrl-names = "default";
69                 pinctrl-0 = <&pinctrl_radarcape>;
70                 status = "okay";
71             };
72         };
73     };
74 };

Device Tree Overlay Compilation and Installation

Step 2: Compile (on Beaglebone)

# Beaglebone White
dtc -O dtb -o BB-W-Radarcape-00A0.dtbo -b 0 -@ BB-W-Radarcape.dts

# Beaglebone Black
dtc -O dtb -o BB-B-Radarcape-00A0.dtbo -b 0 -@ BB-B-Radarcape.dts

Step 3: Copy to /lib/firmware

cp BB-%-Radarcape-00A0.dtbo /lib/firmware

Step 4b: Create a shortcut to the slots

export SLOTS=$(find /sys/devices -name slots)

Step 4b: Verify slots before appyling

cat $SLOTS

Must result in:
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—

Step 5: Apply the pinmux patches

echo BB-W-Radarcape > $SLOTS

Step 6: The dmesg command will inform you about what has been done (in case that you do that over serial console, you already will have seen this output)

dmesg -s 20

Must result in:
[ 31.862078] bone-capemgr bone_capemgr.8: part_number 'BB-W-Radarcape', version 'N/A'
[ 31.874269] bone-capemgr bone_capemgr.8: slot #4: generic override
[ 31.880473] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 4
[ 31.887937] bone-capemgr bone_capemgr.8: slot #4: 'Override Board Name,00A0,Override Manuf,BB-W-Radarcape'
[ 31.904636] bone-capemgr bone_capemgr.8: slot #4: Requesting part number/version based 'BB-W-Radarcape-00A0.dtbo
[ 31.926576] bone-capemgr bone_capemgr.8: slot #4: Requesting firmware 'BB-W-Radarcape-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[ 31.952355] bone-capemgr bone_capemgr.8: slot #4: dtbo 'BB-W-Radarcape-00A0.dtbo' loaded; converting to live tree
[ 31.967771] bone-capemgr bone_capemgr.8: slot #4: #2 overlays
[ 31.983656] bone-capemgr bone_capemgr.8: slot #4: Applied #2 overlays.

Step 7: Verify if all is correct

cat $SLOTS

Must result in: 0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-W-Radarcape

Step 8: Apply the rest of the interfaces from standard device tree files

echo BB-UART5 > $SLOTS
echo BB-UART2 > $SLOTS

Step 9: verify if all is correct

cat $SLOTS

Must result in:
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-W-Radarcape
5: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART5
6: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART2

On Beaglebone-Black it will show up like:
root@rc301:~# SLOTS=$(find /sys/devices -name slots)
root@rc301:~# cat $SLOTS

0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART5
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART2
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-B-Radarcape

Slot #5 and #6, both showing up with HDMI, are not indicated as Loaded.