Create your own cape for BBB (i)

Source: Internet
Author: User
Tags manual prepare touch dmesg

See http://blog.csdn.net/wyt2013/article/details/18228095 for the latest updates

This article will take the production of "LCD display Cape" as an example to record the process of making beaglebone black cape. It's not done yet, it's a lot more difficult than you think ... But first of all the problems and precautions to be recorded before it ~why to make cape.

Cape is the Beaglebone officially referred to as the hardware plug-in peripherals (the completely non-concept of students can go to http://elinux.org/Beagleboard:BeagleBone_Capes here to see). The advantage of using cape is that hardware peripherals can be modularized. For example, today I would like to implement a function, plug in the corresponding cape, tomorrow I would like to change a function, plug in another cape. Once cape is ready, there is no need to worry about drivers and hardware problems in the future. One of the big advantages of BBB is that there are many interfaces, and the Angstrom Linux system, which is customized for BBB, also has a number of features that make it easier for us to create and use Cape.
My goal is to add an LCD display to the BBB. Although the official have to sell off-the-shelf LCD cape, but buy back plug on the finished, feel too easy, less fun. I just had a hand with a 2.4 "TFT LCD touch screen that I bought when I purchased Alientek STM32 Development Board, I decided to use it to transform. OK, let's start right away.
something to prepare.
In addition to the LCD, you need to prepare a breadboard, a DuPont line, a number of resistances between 2K and 7K and an EEPROM chip. (I wanted to use the Alientek STM32 Development Board with the 24C02 EEPROM, but because of some strange not to use) EEPROM is every cape on the necessary things. Suppose you have a lot of cape, separate into the BBB, then how does the BBB distinguish between what cape you plug in and what driver to load? is determined by the presence of information in the EEPROM. Alientek LCD module can only be used in 80-port mode, wiring less SPI mode it unexpectedly does not support. Well, you can only connect the 16 and the same line with the DuPont line. So get a little more of the DuPont line.
The resistor is used as the pull-up resistor for the EEPROM i²c interface.
Let's talk about how Cape works.
Angstrom Linux uses device tree to bind hardware and drivers, and to set the multiplexing capabilities of the chip pins, a default device tree (suffix dtb) is stored in the system kernel, which is loaded first at startup. Then use device tree overlay, on the basis of this default device tree "overwrite" (overlay) on the new hardware and driver or remap pin function, to be used to overwrite the file suffix name is Dtbo.
BBB brought a lot of dtbo files, placed in the/lib/firmare/directory, most of the Dtbo file corresponds to the official support of Cape (that is, the previous URL of those cape, because the system already has the corresponding Dtbo file, So we have to buy cape to be able to plug in, we have to do cape, we can only write Dtbo files ourselves.
Then say the system starts. After the default DTB is loaded, the system starts scanning for the overlay to be loaded. The system will be loaded by default two overlay, corresponding to the board of the EMMC chip and HDMI processing chip. If there is no external cape, load the two overlay, and then this step is gone. But let's say that there is a case of external cape.
Say that there is an external cape, in fact, there is an external EEPROM. If an EEPROM is found, and the information stored in it conforms to the format requested by Cape, the system will first load the overlay required to load in the EEPROM (if several eeprom are inserted at the same time, the corresponding overlay is loaded sequentially), Then go to load eMMC and HDMI overlay (note the load order). After loading the overlay, the system then follows the instructions of the overlay to drive the binding and pin multiplexing before continuing with the other startup projects.
After the boot is complete, the hardware and the driver are perfectly matched, and the chip pin function is correct.
(By the way, how do I know that?) Input DMESG will know. )
A few details
1, BBB only supports the simultaneous insertion of 4 EEPROM, their address must be different.
2, the address of the EEPROM must be between 0x54 to 0x57, otherwise the system will not load. Popular Science: No matter what brand of EEPROM chip, their address is the same, high 4 bits is 1010, low 3 bits corresponding to the chip a2,a1,a0 this 3 pin level (some chips only A1 and A0), so through the external circuit can change the address of the EEPROM. That is, the address of the EEPROM can only be 0x50 to 0x57 8, if the A2 remain high, then only 0x54 to 0x57 the 4 addresses are available (this is the SRM (official reference manual) in the EEPROM circuit A2 high level of the reason).
In addition, it seems that all 8 pin EEPROM, their PIN layout is the same. (I bought a 24c256 eeprom today, a look at the markings on the above is not known what is, the internet can not be searched.) I just follow the pin of other brands and find that I can use it. )
3. If you insert more than one EEPROM at a time, you will read it sequentially. To be precise, the reading order is the order from 0x54 to 0x57.
Why do you stress the loading order of overlay? Because once the previously loaded overlay takes up some of the on-chip resources, the other overlay can no longer be used. For example, I want to do the LCD using the default loading of the HDMI pin is overlapping, when the system starts with the first load of the LCD overlay, then HDMI can no longer load.
4, the EEPROM must be connected to the BBB I2C2_SCL and I2C2_SDA pin (see in the system is the i2c-1). Because the default function of the I2C2 two pins is the I²C function. This also tells us that the program should try not to permanently change the function of the two pins to reuse, otherwise it will not be able to load cape.
5, from the above can be seen, Cape is loaded at the time of system startup, so you must first insert the Cape, and then give the BBB power. But. For LCD, because it is used in some of the pins are related to the system startup, so if not to do additional software processing, LCD module can only be installed after the system boot, or the system will not start (the specific performance is the power light on, 4 user led has not been lit). But the EEPROM obviously has to be connected before power is on. This is the official LCD Cape circuit schematic diagram of the buffer chip (74avc32t245), it seems that the input and output of the chip is exactly the same, no effect, but it can prevent those LCD pin level is not stable before starting.
6, insert a sentence, the system runs with Echo * * * > $SLOTS to load Virtual cape if you encounter echo:write Error:file exists hint, does not mean that Cape has been loaded, but some hardware resources have been occupied the meaning. Therefore, you will not be able to load the LCD-related cape After the system starts, because the pins are already occupied by HDMI.
Write your own overlay (DTBO)
The Dtbo file is compiled with DTS files (see my previous log), and I'll briefly explain how to write a DTS file related to a device.
Note that my hypothesis is that the required drivers are already installed in the system. Otherwise, do it yourself. In fact, the BBB custom Angstrom system has a lot of drivers, I have the chip on hand to find the corresponding driver. The general driver will have documentation, especially on how to write DTS, almost all of it. You just need to follow the example inside, combine the BBB existing DTS file (under the/lib/firmware directory), and modify it yourself. BBB customized Angstrom system source code is downloaded here https://github.com/beagleboard/kernel. You need a desktop Linux system (or Mac OS) to unzip and download the kernel file, add up to about 700MB it seems that the download was slow, I was down all night. But this is the essential thing at home, decisive.
Note the notes for several DTS writes:
1, the file name must be the form of Boardname-version.dts, such as Bb-bone-lcd4-01-00a0.dts. The bb-bone-lcd4-01 inside is boardname,00a0 is the version number. (In fact, the name of DTS doesn't matter.) The key is to compile the Dtbo name must be it, in order to unify, it is so stipulated bar).
2, version must be in the form of 00AX, X starting from 0 in order to increase, and, in order to name 00A1, must have 00a0 existence. Cannot span versions.
3, the DTS file will have Part-number and version of the two, its content must match the file name. Part-number is boardname.
In fact, when the system starts to read the EEPROM, it is to read the contents of both the Boardname and version, and then find out if there is a corresponding Dtbo file.
How to compile DTS for DTBO files Please see my previous log. The compiled Dtbo file must be placed in the/lib/firmware/directory. (In fact, I used the 3.8.13 version of the system (can enter UNAME-R to view the system version) seems to have bugs, their own dtbo files, even if placed in the specified directory, the system can not automatically load. I'll solve the problem in the back of the log. )
Finally, the DTS file I used was changed on the basis of/lib/firmware/bb-bone-lcd4-01-00a1.dts. (In fact, basically nothing changed, that is, the name and version number changed a bit.) I don't know how to change the parameters of the LCD. )
Hardware Connection
The EEPROM circuit is not detailed, the circuit can be found in SRM. The connection to the LCD module must match the description in Device tree overlay, so it is connected according to the PIN that is written in the Bb-bone-lcd4-01-00a1.dts. It is important to note that after reviewing TI's am335x manual, the pin has the following correspondence:
Lcd_vsync <-> RS lcd_hsync <-> WR
LCD_PCLK <-> RD
Lcd_ac_bias_en <-> CS
gpio3_19 <-> RST
EHRPWM1A <-> bl_ctr


The rest is the power, ground and 16 heel line. Note that the BL_CDD is 5V. The line is connected to the lcd_data_[0-16] pin of the BBB (note that the order of the pins is changed from LCD_DATA_10). The pins at the beginning of T in the figure are related to the touch function and are temporarily not connected.
There are 5 function keys and a light in the Bb-bone-lcd4-01-00a1.dts, I don't need these for the time being, just ignore them.
The original code is as follows:

	/* State The resources This cape uses */exclusive-use =/* The PIN header uses */"P8.45",/* LCD:LCD_DATA0 */" P8.46 ",/* lcd:lcd_data1 */" P8.43 ",/* LCD:LCD_DATA2 */" P8.44 ",/* lcd:lcd_data3 */" P8.41 ",/* LCD:LCD_DATA4 */"P8.42",/* LCD:LCD_DATA5 */"P8.39",/* LCD:LCD_DATA6 */"P8.40",/* LCD:LCD_DATA7 */"P8.37",/* lcd:lcd_ DATA8 */"P8.38",/* lcd:lcd_data9 */"P8.36",/* lcd:lcd_data10 */"P8.34",/* LCD:LCD_DATA11 */"P8.35",/* l CD:LCD_DATA12 */"P8.33",/* Lcd:lcd_data13 */"P8.31",/* LCD:LCD_DATA14 */"P8.32",/* LCD:LCD_DATA15 */"P8 . ",/* Lcd:lcd_vsync *///rs" P8.29 ",/* Lcd:lcd_hsync *///WR" P8.28 ",/* LCD:LCD_PCLK *///rd" P8.30 ",/* LCD : Lcd_ac_bias_en *///cs "P9.27",/* lcd:gpio3_19 *///rst "P9.12",/* led:gpio1_28 *///led "P9.14",/* PWM:EHRP WM1A *///bl_ctr "P9.15",/* keys:gpio1_16 */"P9.23",/* keys:gpio1_17 */"P9.16",/* keys:gpio1_19 */"P9.21"
		,/* Keys:gpio0_3 *///... 





================================================== This article first write so much, in the back of the log I will continue to write how to write to the EEPROM, write the format is what, How to use Sysfs and PROCFS to check for errors and control the LCD screen and other content.

Finally, I enclose the Cape-related part of the DMESG system startup information, which can verify a lot of what I just wrote. I use # # #号标注在对应行的后面.
[0.250231] bone-capemgr bone_capemgr.8:baseboard: ' a335bnlt,0a5c,3513bbbk2728 '
[0.250272] Bone-capemgr Bone_capemgr.8:compatible-baseboard=ti,beaglebone-black
[0.281252] bone-capemgr bone_capemgr.8:slot #0: No Cape found## #可以看到最多可接4个cape. My EEPROM address is 0x57, which is the last of 4 allowed addresses, so it's loaded into slot # 3rd.
[0.318358] bone-capemgr bone_capemgr.8:slot #1: No Cape found
[0.355467] bone-capemgr bone_capemgr.8:slot #2: No Cape found
[0.385730] bone-capemgr bone_capemgr.8:slot #3: ' alfred,00a1,tju,bb-bone-lcd4-01 ' # # #这就是从eeprom里读取的原始数据
[0.385899] bone-capemgr bone_capemgr.8:slot #4: specific override
[0.385940] bone-capemgr bone_capemgr.8:bone:using override EEPROM data at slot 4
[0.385968] bone-capemgr bone_capemgr.8:slot #4: ' Bone-lt-emmc-2g,00a0,texas instrument,bb-bone-emmc-2g ' # # #默认加载eMMC C Ape
[0.386100] bone-capemgr bone_capemgr.8:slot #5: specific override
[0.386136] bone-capemgr bone_capemgr.8:bone:using override EEPROM data at slot 5
[0.386164] bone-capemgr bone_capemgr.8:slot #5: ' Bone-black-hdmi,00a0,texas instrument,bb-bonelt-hdmi ' # # #默认加载HDMI CA PE One
[0.386312] bone-capemgr bone_capemgr.8:slot #6: specific override
[0.386347] bone-capemgr bone_capemgr.8:bone:using override EEPROM data at slot 6
[0.386375] bone-capemgr bone_capemgr.8:slot #6: ' Bone-black-hdmin,00a0,texas instrument,bb-bonelt-hdmin ' # # #默认加载HDMI Cape II
[0.386927] bone-capemgr bone_capemgr.8:loader:before slot-3 bb-bone-lcd4-01:00a1 (prio 0) # # #从prio优先级可以看出, Cape than the default two excellent First level to high.
[0.386956] bone-capemgr bone_capemgr.8:loader:check slot-3 bb-bone-lcd4-01:00a1 (prio 0)
[0.387091] bone-capemgr bone_capemgr.8:loader:before slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.387116] bone-capemgr bone_capemgr.8:loader:check slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.387242] bone-capemgr bone_capemgr.8:loader:before slot-5 bb-bonelt-hdmi:00a0 (prio 1)
[0.387267] bone-capemgr bone_capemgr.8:loader:check slot-5 bb-bonelt-hdmi:00a0 (prio 1)
[0.387328] bone-capemgr bone_capemgr.8:initialized ok.## #前面检测好了要加载哪些cape, and determines the loading order, which begins to load
[0.389325] Onenand driver initializing
[0.390678] bone-capemgr bone_capemgr.8:loader:after slot-3 bb-bone-lcd4-01:00a1 (prio 0)
[0.390714] Bone-capemgr Bone_capemgr.8:slot #3: Requesting part number/version based ' bb-bone-lcd4-01-00a1.dtbo## #根据e The data of the EPROM generates the name of the DTBO to be loaded, so the file name is so important.
[0.390745] Bone-capemgr bone_capemgr.8:slot #3: Requesting firmware ' Bb-bone-lcd4-01-00a1.dtbo ' for Board-name ' Alfre d ', Version ' 00a1 '
[0.390778] bone-capemgr bone_capemgr.8:slot #3: Dtbo ' Bb-bone-lcd4-01-00a1.dtbo ' loaded; Converting to live tree## #读取完dtbo文件, writing information to the device tree
[0.391665] bone-capemgr bone_capemgr.8:slot #3: #4 Overlays
[0.392824] bone-capemgr bone_capemgr.8:loader:check slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.392876] bone-capemgr bone_capemgr.8:loader:check slot-5 bb-bonelt-hdmi:00a0 (prio 1)
[0.393619] EHRPWM 48302200.ehrpwm:unable to select Pin Group
[0.396508] bone-capemgr bone_capemgr.8:loader:before slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.396539] bone-capemgr bone_capemgr.8:loader:check slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.396569] bone-capemgr bone_capemgr.8:loader:check slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.396905] usbcore:registered new interface driver asix## #绑定 BB-BONE-LCD4-01-00A1.DTBO involved in various drives
[0.397027] usbcore:registered new Interface driver Cdc_ether
[0.397149] usbcore:registered new Interface driver smsc95xx
[0.397239] usbcore:registered new Interface driver net1080
[0.397329] usbcore:registered new Interface driver Cdc_subset
[0.397433] usbcore:registered new Interface driver Zaurus
[0.397597] usbcore:registered new Interface driver CDC_NCM
[0.398492] usbcore:registered new Interface driver CDC_ACM
[0.398510] Cdc_acm:usb Abstract Control Model driver for USB modems and ISDN adapters
[0.398524] Initializing USB Mass Storage driver ...
... # # #绑定了好多驱动, slightly off .....
[0.404045] bone-capemgr bone_capemgr.8:slot #3: Applied #4 overlays.## #3号slot处理完了, start processing Slot # 4th
[0.404071] bone-capemgr bone_capemgr.8:loader:done slot-3 bb-bone-lcd4-01:00a1 (prio 0)
[0.404158] bone-capemgr bone_capemgr.8:loader:check slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.404203] bone-capemgr bone_capemgr.8:loader:check slot-5 bb-bonelt-hdmi:00a0 (prio 1)
[0.404231] bone-capemgr bone_capemgr.8:loader:after slot-5 bb-bonelt-hdmi:00a0 (prio 1)
[0.404326] Bone-capemgr bone_capemgr.8:slot #5: Requesting firmware ' Cape-boneblack-hdmi-00a0.dtbo ' for Board-name ' B One-black-hdmi ', Version ' 00a0 '
[0.404369] bone-capemgr bone_capemgr.8:slot #5: Dtbo ' Cape-boneblack-hdmi-00a0.dtbo ' loaded; Converting to live tree
[0.405239] bone-capemgr bone_capemgr.8:slot #5: Bb-bonelt-hdmi conflict P8.45 (#3: bb-bone-lcd4-01) # # #与3号发生资源冲突, so load failed 。
[0.414850] bone-capemgr bone_capemgr.8:slot #5: Failed Verification
[0.421627] bone-capemgr bone_capemgr.8:loader:failed to load slot-5 bb-bonelt-hdmi:00a0 (Prio 1)
[0.431144] bone-capemgr bone_capemgr.8:loader:check slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.431174] bone-capemgr bone_capemgr.8:loader:after slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.431209] Bone-capemgr bone_capemgr.8:slot #4: Requesting firmware ' Cape-bone-2g-emmc1.dtbo ' for Board-name ' Bone-LT -emmc-2g ', Version ' 00a0 '
[0.431235] bone-capemgr bone_capemgr.8:slot #4: Dtbo ' Cape-bone-2g-emmc1.dtbo ' loaded; Converting to live tree
[0.432641] bone-capemgr bone_capemgr.8:slot #4: #2 Overlays
[0.433438] bone-capemgr bone_capemgr.8:slot #4: Applied #2 overlays.
[0.433466] bone-capemgr bone_capemgr.8:loader:done slot-4 bb-bone-emmc-2g:00a0 (prio 1)
[0.433670] bone-capemgr bone_capemgr.8:loader:check slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.433704] bone-capemgr bone_capemgr.8:loader:after slot-6 bb-bonelt-hdmin:00a0 (prio 2)
[0.433744] Bone-capemgr bone_capemgr.8:slot #6: Requesting firmware ' Cape-boneblack-hdmin-00a0.dtbo ' for Board-name ' Bone-black-hdmin ', Version ' 00a0 '
[0.433780] bone-capemgr bone_capemgr.8:slot #6: Dtbo ' Cape-boneblack-hdmin-00a0.dtbo ' loaded; Converting to live tree
[0.434078] bone-capemgr bone_capemgr.8:slot #6: bb-bonelt-hdmin conflict P8.45 (#3: bb-bone-lcd4-01) # # #同样与3号冲突, load failed
[0.443794] bone-capemgr bone_capemgr.8:slot #6: Failed Verification
[0.450574] bone-capemgr bone_capemgr.8:loader:failed to load slot-6 bb-bonelt-hdmin:00a0 (Prio 2)





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.