 Yw'r ffordd yma y mae'r gweithio'r labiaid yma o'r ddweud. Ydych chi'n gwneud o'r labiaid, eich bod yn cyd-dweithio, yn cyfloedd i'r gweithio, yn cyd-dweithio, i'ch ddweud o'r dyfodol. Y mae'n gwneud o'r labiaid o'r colli'r adeg, ac yn cyflawnio'r adeg. Yma'r arweithio'n gwneud y labiaid yn cyflawnio'r gweithio'n mynd i'r Linux host on our laptop and the Linux running on our target board and we'll reboot our target board so that we can see that we've got the communications and we'll be able to observe the kernel boot log as the Linux on our target board boots up. This is all done using the SDK, which is already installed. The main objective of the lab is to compile a simple Linux application, so a Hello World application and then we're going to transfer that binary from our Linux host using a memory stick to our target board and then we're going to send the commands down to our target board to run the application on our target board. Now as we progress through all these slides, because most of the time we'll have a terminal window open connected to our target board and a terminal window open for commands running on our host, we've colour coded these commands. So anything that you're typing on your host terminal window will be in the yellow box or the yellow coloured box with a red border and any commands that we want you to type directly to your target board will be in the terminal window, which is the blue coloured box with the black border. So we'll try to segment it so that when you go back to your offices and labs you can remember from the slides which of the two you're supposed to be typing in. Also in the top left corner, where you can see the little empty circle at the moment, you will either have one of these two icons which are in the bottom right. It'll be a theory icon which means there's no actions for you to do on that slide or it'll be a practice icon which means you have to copy or paste or type something onto one of your screens or terminal windows. So that's really just to guide you through the rest of the labs and this will be relevant for all the other labs as we go through the rest of the day with this course. Now the first item you need to do is copy across the input lab material and workshop slides from the memory sticks to your host linux. So you'll need to start your linux on your laptop, connect your USB stick, if it doesn't automatically appear in the linux side you might have to go into the little down arrow next to player, removable devices and tell it to connect the USB stick so it's visible to your linux host and then you need to drag and drop those two files input lab material and workshop slides to the desktop so it has to go to the home and desktop. The reason we want it on home and desktop is that any of my screen captures if you want to copy and paste during the rest of the hands-ons for the day are expecting the lab material to be in home and desktop. So if we look at my linux system I've already copied these two files across so I've got my input lab material and my workshop slides on my desktop. So once you've copied those files across we then need to set up the hardware. We've already done all this from the getting started lab but you will need your MP157C-DK2 development board. On that development board it should have it's microSD card connected. You'll need your micro USB cable to connect the ST link and you'll need a USB type C cable to power the board. Hopefully as I say this is already done from the previous section but if you're starting at this point and you haven't done the first lab then you need to check to make sure your two switches on the bottom side of the board are selected to the on position. This means that you'll boot from the SD card. You need to make sure that your SD card is plugged in correctly sometimes it does spring out a little so make sure that your SD card is plugged in correctly. You connect your micro USB side for our ST link to your laptop so that we can communicate with the target board and then finally you power the board with the type C connector that's next to the ethernet socket. Be careful that you don't accidentally eject your micro SD card as you're plugging in this connector. So this is a summary of what those previous slides were so that you can connect your target board to the laptop and it should hopefully all boot up and you should get the default configuration on your target board. If you're using an older laptop that doesn't have type C to type C then you'll be on like myself. I'm using a type A connector to a type C to power my board. Older laptops have some power limitations on this configuration with type A is going to type C's. If you're using a lot of USB target devices plugging into your discovery board so your MP157C-DK2 then you might get some power warning errors to say that there's not enough power and potentially for older laptops it could damage the USB port that's actually powering your type C connector. So in the case of my board I'm using a powered hub to make sure that I can deliver the correct amount of power but what we're going to do today it shouldn't be a problem we're not actually plugging much else into our target board so a laptop should be able to power the whole of the discovery board but when you're doing your developments in your lab you might want to switch over to a power source for your type C connector. So now we need to connect the ST-Link to our Linux environment so windows might have grabbed hold of it so we need to go into player and removable devices and make sure our ST-Link is connected to our Linux. So if I go into player, removable devices, I will go and connect my ST-Link. So now that we've got a channel that can talk to our board we're now going to launch a terminal window and open a channel to our board. So first thing you need is to launch the terminal window and then we need to start a Minicom connection from our host side so remember this is the host screen at the moment so we're going to type Minicom and we're going to get our connection between our Linux host and our Linux device on our target board. So if I start a terminal window there we go so I've now got a connection to the root of our MP1 board so I'm now in communications with the Linux on our target board and now what we need to do is reset our target board which is the black button nearest the audio connector and this should start the communications of the kernel log booting on our target device. So we should see that scroll through our terminal window so if I go back to my Linux and press my reset button there we go we can now see that the Linux kernel on our target board is now starting to boot. You can see all the different steps as it goes through U-boot, loading all the drivers in for OpenST Linux and then it's going to scroll up all the rest of the information for the booting of our target board and hopefully on your screen you will see it go through all the different screens and eventually you should come back to the default screen that we have for our demo which we played with at the start of the day. So that's your terminal window now for your target board. We're now going to open a new terminal window for the host side. So we now need to open a second terminal window in our Linux. In this terminal window we now need to configure our environment on our host to make sure that when we build something it's targeting the correct target board. So we can copy and paste that command in to our terminal window and if there's no errors then you just get your command prompt instantly comes back to you. So we've now configured our host environment to be targeted to the correct board and we just need to now validate which version of the environment that we've got. So this one will provide a return value and hopefully the return value should be 8.2.0. So if I copy the second command now and there we go we can see that my GCC compiler is 8.2.0. So I know that I've configured the system and I've got the correct version of the GCC compiler to achieve what I want to achieve in the coming steps as we build our application. Now we want to copy the lab material from the desktop directory to our SDK. So again we can just do the straight copy and paste of these commands. Now we want to change directories so that we're in the directory that we've just copied into. So again you copy the next command. And now we can use an application on our host called gEdit and we can open the C file so we can see what our Hello World application is going to do. So in this application we can see that we're going to print a widget on the screen. That widget is going to be a window of dimensions of 200 by 200. It'll have a button with a label called Hello World. And when you click that button it'll do nothing so it's null. And then when you've clicked it it'll then terminate the window. So it's a fairly simple demonstration of drawing something on the screen, something that you can interact with by clicking it and then it'll close itself down. So don't have to do anything in this screen. It's just purely to show you what we're actually going to be doing in this hands-on. So now we can close the gEditor. If you go up to the top bar and hit the little red cross, as I say we don't need to edit anything in there so we can go and close that window. And now we need to make the project. So we just type in our box make and hit enter. So eventually it'll go off and it'll build using that GCC compiler we've got our binary file. So it's gone off, you've seen it scroll through there and it's now generated our binary file. So now we want to transfer that binary file to our target board. And to do this we'll use a USB stick. So you can use the same USB stick you had earlier. You can highlight the current path in your terminal window and copy. And then if you press Ctrl L and you can paste the path in so that you can get to the binary file. And then once you've pasted the path in you'll see the binary file and then you can drag and drop the binary file onto your memory stick. So if we go and do that now on my side, I'll plug in a memory stick. The memory stick is connected. There we go. So we can see our memory stick is already there. In the previous workshop I already have the item there but I'll follow the slides through. I will copy my path. So it's right click and copy. And then right click and paste, yep sorry. Ctrl C and Ctrl V don't work. So there's my binary file that we've just created. And I now need to drag and drop that. Drag and drop that onto my USB disk. I'm going to overwrite a file that was generated back in September with one that's just been generated now. My time is there 10.26 so it was 10.21. I'll replace. Now I can unmount my memory stick and now I want to plug in my memory stick to my target board. So this is what you'll see in your Minicom terminal when you plug in a memory stick. You will see something happens on your Minicom terminal. You'll see that my Minicom terminal has recognised a USB device. And now we want to mount the USB device on our target board. So we're now in the second terminal window and we now want to copy the mount command onto our target board. And this terminal window now, paste. Volume not properly mounted. Okay. That means at some point I didn't unmount this memory stick correctly. We now need to copy the binary across. There we go. So the file's copied. And now we want to sync. So we need to refresh the system on our target device. So we need to do the sync command. Now we need to change directory to where we've just copied it to. And now we need to run the binary that we've just copied across. So two lines so we need to make sure the mode is set correctly for execution and then we need to run the command. Don't forget the little dot at the start when you're doing this copy of this one, please. So hopefully now on your target board you should see the new window, which is our application. So down here in the bottom right, so we should see the new window opened with the button that says Hello World. And that should now be running on your target board. And if you use the touchscreen on your target board and click on the Hello World button, the little window will automatically disappear because that's what the actual window is designed to do. So as soon as you press that word Hello World, it'll instantly disappear. So we've now built an application, copied it across to our target board and run an application on our target board. So all the tools, communications and functionality of our board is now available for you to do anything. So you can now build any Linux-based application, copy it across in binary form and then run the application that you've got.