A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
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. ）
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 *///...
Start building with 50+ products and up to 12 months usage for Elastic Compute Service