Embedded Linux Device Tree and Platform Devices #04

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello yes so in today's video we're going to learn about the vast his apart from diversity there is that now we are going to meet our self-worth recognize that there is some device hitters that are some happy who are working the Fiji okay and foodie batteries we're going to communicate to the colonel that there is a harbor there and that there is a driver that will be responsible to control the device okay hope you guys are going to switch to the board and probably then some slides as well to explain a little bit more about school so we hope you guys enjoy it if you guys like give me thumbs up Phyllis party hats so what we want to learn to be okay with the previous video okay we complete a Manticore okay by the way side decor has been made with this address okay and what this how to crete is asking how to use pattern minutes to create a device driver skeleton okay that is going to detect okay and and we met decide the psychic or to the virtual memory okay basically what you need in order to do that okay imagine that here is a product if I'm okay and we know that the fact they create the beach swim and when when we export the valley project to science SDK furnaces we had a harder description they nearly said that animals besides waiting the device driver skeleton of all these disappear career yes to use this hard description to create what we call a device tree which is just a five okay consider this as a fire that is going to describe the to the kernel what we have available in terms of platform devices okay then with the bit simply the device tree the image and the first we're going to create our image to place in SD card okay so let's see today how to do this I'm going to jump to some slides to explain there what we're going to do and what we need to learn and and then we go to the lab and see how Vegas so continuing our our class about device drivers okay now let's go to the top of device trees okay I read the text then I explained a little bit better to try to give you the best knowledge that I can about this so device trees okay they are a structure text files okay that are compiled we've give to call edtc that is inside your or your Linux source code and giving to the kernel on good time okay when you boot boots the kernel it gives the it boots the claro in which plus a device tree binary image let's say like this okay so they serve to provide some information about the hardware that the kernel will handle okay this is an attempt to tackle the growing number of arm boards that have different different hardware okay that is that the same kernel will run on different boards with different device trees okay the kernel will parse this device tree instantiate all drivers needed okay here we have example of a device tree entry okay what you need to pay attention is this compatible few okay basically the compatible field is used to is used to indicate the kernel which driver will handle this okay this device okay the interrupt is the danger of property okay contains the number of the erq okay of the interrupt and the Reg means what is the physical address in range of that hardware okay so to explain again device tree is just is imagined as XML file okay that is going to be given to the kernel at boot time and you give to the kernel the information on what hardware you have on your board okay and which device driver will handle that that specific harbour okay so platform devices okay and these are really connected to the device tree device trees so on embedded system device are often not connected for a bus allow enumeration hot plugging and and something that provides unique identifiers for a device they are normally connected to the CPU through some kind of AX interface or any memory mapping interface or some kind of AI to ascribe use okay maybe it's better to explain this with an example okay if you plug your USB disk in your Linux machine the the Linux well traumatically detect this USB Drive and enumerate and give him some kind of identifier okay the case of the plataform devices you don't have this okay you have some device that is placed somewhere in the memory in the memory map part of the CPU and you need somehow to to create a device driver that control this guy okay so that is the basically if I could explain simplify what profit platform devices are are simply devices that are not automatically detected by your system okay you need the device tree to indicate the kernel like look Colonel I have some hardware a that is in the certain address or something like this okay here there are some complete examples okay of plataform devices and you can click on them to have a look on see the source code okay when you when we are creating device drivers for plataform device you need to have this structure here okay is the plataform driver okay and the most important thing that you need to do if it is that you need to pass a function pointer to the probe remove okay and this structure driver as well so basically this is the if remember when we look on the f op structure that we need somehow to give to the kernel some function pointers some callbacks that will be called when the probe remove occurs okay so for instance when they probably work your okay imagine that you load the model okay and the model is somehow compatible okay with with some hardware that has been given to the kernel for the device tree okay some actually at least some driving from draw add some device information so when you load the model the kernel will detect that it it has some device that is compatible to that to that to the device driver and that this moment the probe method will be called okay and when this probe method occurs okay there you need to do some stuff like Iowa map or read some information that that also has been passed to device three but we are going to touch this subject in the future okay so just to illustrate a little bit well imagine that here we have a hardware called you of that type UART okay and his basic is compatible with the I am x28 aur driver and the AMX 23 a UART okay some important stuff it it has this physical address you okay with this range okay so will be this address here is really the bare-bones physical address okay it has the DS interrupt number okay and some other information so when you create the device driver to control this hardware here okay basically you need to have this platform driving structure okay that points to the callbacks of prom and stuff like this and you need to have this structure here of device ID that basically you say to each hardware this device driver who control okay and basically this guy here this compatible field need to match to the compatible fuel that you have on the on the device tree okay and after this is detected the probe call is the probe callback is called okay you can use some some default functions to get the for instance the the reg fuel for instance if you just type platform gate resource and you you ask our resource ma'am this basically is going to return this a pointer to the description of this physical address okay if you call as well part of forget you are cue okay is it going to get the interrupts number and stuff like this okay how you create device the device driver in beta Linux okay as you may suspect it beta Linux also have a common to create a skeleton device driver okay so you just want better Linux - Creed - tree model - in the name of a model - - enable okay and these are just create I skeleton of a device driver okay and just restart the only thing that you need to do is to change the the compatible food okay with with something that is located in your new device tree okay then you just do nothing else you just run these commands here Bethel mimics Butte - see who the fest and the name of the model that you create if you want to check some errors you just go to build build log of your project okay and here is just the place where the model will be created so just to analyze a little bit the code that he generated by the way is quite simple here are just the headers that you need to include here is just a structure that you hold the the physical memory address in range of our device we are not going to use the interrupts now but this is just an interrupt handler okay this is the method remove sorry the callback that is going to be called when you remove or you do RM and mod when you uninstall the model of this device driver this guy will be called okay this guy here off device ID is really where we should change to the actually compatible fuel to match some device from your device tree here this structure here is where you point the pull backs of the probe and remove okay what else when we need that with the in need of the model we call product from device driver register - to rush a device driver a platform device driver and actually shall eyes all the all the platform interface for you sorry the platform framework and most important is the probe method as you may imagine okay so what the probe method this first of all he get the drag feud of your device okay let's just go back here to advise device three okay so basically we are interested in this guy here okay and its range as well so that's what is the the probe method is doing after we got this he just allocate the memory we've come came a lock Malik Malik I do not say that to hold the information of your fiscal address but the most important is those two calls here first the request main region okay basically you are asking some you're telling the colonel that that physical address and range will be binded to this Hardware alone okay and the IRA map which basically will give you a view to address that represents that fiscal address that you have here in your advice tree okay so as I mentioned before the when when you are in the model we are we still using virtual address okay so even knowing your fiscal address here at this point here of your sorry here of your IP core you cannot access that directly okay you're going to the colonel not allowed so you access physical memory through the IRA map to a Louisville to address okay after this is done this is actually continuation of the probe method he's just going to to print some information okay and basically this guy here is the most important for you if like it's going to just say the seed model that has the physical address a is mapped to the physical address B and all of your work to control your device should be done reference to this virtual address okay let me just jump because this he's just define the IPO order to create it okay this simple ALU okay here is again this is Cisco address and here will be the result after everything's done okay so B is basically here as I shown he would say when we load this this model okay you say that this fiscal address here has been mapped to this virtual address okay and all the registers that we issued the control for if you guys remember is the racial ABC and up should be offset from these base addresses for this new virtual base address okay here just to show how the how the bare metal version was done okay so if you guys remember we just have some offsets related to our base address but now we'll be actually to be related these address here so we'll be like six zero nine six zero zero zero zero ten okay or something like this what else is cool I'm going to show that now actually this is the first thing that you should do before we create the device driver I just wrongly put this part out of order okay so basically after we went to V value and you generate a bit stream and you did all that you need to somehow inform Bethel he looks okay about the hardware that you are using but basically this guy would be the one who is going to create the device tree for you so basically you just call Pat a Linux config get harder description and you point to the place where your hardware description has been exported okay this is that face when you go to divide when you export the hardware description to the Sonics SDK okay don't worry we're going to do this on the lab so no problem at all after the device tree is created and you do the petal Enix beaut you need to generate the boot dot beam again okay too to include your new bitstream okay otherwise you're going to have the device 3 but the the heart will not be there physically on the FPGA okay and let's stop for today I just showed the lab okay then after this video we're going to put we're going to actually basically he creates all these functions here but using the developer address but let's do some small steps at a time so let's just point pattern UNIX to create the device tree for us basically the hardware that you creatividad and create this device this platter from device driver skeleton with pata Linux and then we put on the set board and we turn on and see what happens okay guys so let's go to the lab ok guys so as we explain it in the in the board the idea of this video K is basically to instruct pata Linux to recognize our hardware okay which is basically our zinc processor and our simple IP core that is just yellow okay that is going to do some arithmetic operations and the most important thing here is that after you generate the bitstream okay we need to export the hardware information okay so just go to file export and well that's it okay so these will create as a list okay a kind of description with your memory address and the IP cores that are there okay and petaline looks you use this with the to create a device a proper device tree that represents our our hardware design okay okay guys so now that we export okay our hardware information okay we're going to use the common petal in Lux config okay - - get harder description okay and we pass the directory where the the V value exported okay the the hurdle information and is normally in the this light name of the project dot SDK design wrapper hardware platform okay so let's press enter by the way if you've odd must be installed in your in your computer okay this this my Linux machine so it's ready already with V valid with pattern Linux installed and after this this is done he's going to generate the device tree okay on this directory here so I'm just going to already already copy this guy and we can take a look later so cool so let's go to this directory and we can see for instance in the PL dot d s I okay we can see that an entry has been added okay and is related to our IP core okay so basically here you just saying that our IP core base address will be here okay and it's going to have this range okay it also said the compatible line so we need to when we create our IP core sorry when we clear device driver we need to to use this okay and well now that it there is also the interrupts that you're going to see in in another video but now up to this point this is enough that okay guys so now that the that we import into pattern linux the information of our hardware okay we need to call this common here pet a linux package okay - - boot - - f SPL and we need to pass basically the the first stage bootloader okay this is normal this is going to be always the same but what is important here is this guy here we basically now asking that pattern in ox create a new let's say the SD card image okay but adding as well the the bitstream okay of the of the IP core that we have now it's better to explain that this bit stream here will have everything that your pattern linux project okay need okay and this pointed in vivid so basically we're just updating we asking you to have the last the last version of the of the fpga okay and include this on our boot image so we just type enter and cool that is a appear this guy is the guys just complaining saying that he does not he cannot found this common here but he's really easy to solve this so basically guys what we need to do is call source okay and point to this script here that is going to configure all the paths all that's needed okay of Avadh in order to create a bit string okay so now we run again our petal unix package again the idea is that we are going to include our bit stream on our on our boot and so then is working okay I already created these this model so I've just say another name like the sink module so petaline excrete - tea models okay - n name of the model - Madison able to automatically add this to your hooter fess okay so let's do it and well the first thing that we need to do after this guy is created okay is that we need to to change the compatible string in our device driver and basically that's it so if we go to that to the directory components models okay we can see that you have now two mods okay this one is is our next video because it's already created there is some logic inside this guy already and if we go to this directory here and we just change what we go to change here guys so basically this part here is the is the compatible part here we need to match on what we have in our in our device tree so let me just go to the previous model that I know that is already working let me just go really to the end and let's just copy this okay by the way guys I'm using VI here but you can use the editor that you want okay just because I don't know sometimes I'm more used to this guy okay so let's close it okay cool here so we just go in your in your subject in your project directory and go to subsystem linux configs and device 3 and we just open the file p.m. the TTS I so here you see they match is the only change that you need to do okay so let's go back to our project directory and now we need to run pattern in looks good okay now we're going to compile our model okay are we going to check because we use enable so in theory when you create the model with enable you should automatically add to the to the hood FS but we can just check it after this is done so compiling again the our Linux and let's see how it goes okay so here you can see that you actually add our our models okay but if you want to check it again we just can go Bethany looks config - see who the face okay and he's going to open the menu configure we can see that you have here both models okay so guys basically now what what else we need to do is go again and copy all the the the directory that we have in the slash TFTP boot okay the boot being I don't know copy all the guys to the SD card put on the set board and and then turn your own and let's see what happens okay okay guys so now let's go to the last part of our our lab okay we already have booted our Z board okay and we have already setup the Ethernet connection so if we just come here and do an ssh 0:10 for instance okay password is hood okay and we go to the directory Libby modules X basically this guy here we have this are actually these are end model but this guy here is the model that we just created now for better Linux okay so let's just run the message to see if there is any other message and it's not the case okay by the way this is ours Edward okay and let's just all this this model here okay and look what happens so if you now run the message again we can see that our model okay this is by the way guys this is call it in the probe callback of our of our device driver okay so basically we can see that this this device here okay on the physical address for 3 C 0 0 0 okay has been mapped to a virtual address 6 0 9 6 0 0 0 0 okay so basically what happens what happens in the in dealings okay so the device tree okay detected that there was the Linux detected that there was indeed a device okay that the device that the device tree expose okay and when we load the model okay the kernel detected are okay so there is there is indeed a device compatible okay with the compatible string of this model that family now so then the probe hit so he called the probe method okay and then the probe method will remap a physical a virtual address from this physical address here okay so for today that's it guys okay the next video we're going to actually add now the logic on the on this model okay which is basically that the the source code of the previous model and hope you guys enjoyed and I'll see you guys in the next video okay any other question just send me a message and if you guys having problem with this as well just send me a message saying what is happening and I'll try to help okay see you guys in the next video bye bye
Info
Channel: The Development Channel
Views: 21,125
Rating: 4.915493 out of 5
Keywords: Linux Kernel (Software), Linux On Embedded Systems, Embedded System (Field Of Study), Computing Platform (Software Genre), Device Tree, GNU/Linux (Operating System), Technology
Id: Jprs69vV5nw
Channel Id: undefined
Length: 30min 58sec (1858 seconds)
Published: Sun Nov 22 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.