 Let's start the USB master edge device lab. I really like this one. We will just create a USB key with our STM32. Not a very clever one because when you unpower it, it will erase all the data. But let's see the details after. Just the structures of the stack. So the organization is always the same. You can see that on the device cluster is much more files than during the VCP hands-on. Here we see some SCSC command. It's important. I will just give you a couple of words just after that. Always keep in mind we will work during this lab in the USB storage interfaces here. Quite simple, you will see. The SCSC is a standard, I will say, just to access file and create master edge. Not file, so much more on the master edge. Mainly it requires four commands. Initialization, is it ready? What is the size? And the read and the write. So it's worth five commands, sorry. So on the lower level of the USB as we already talked it was using bulk transfer. For the master edge what we need? We need to ensure that the data is correct. We need to have some acknowledgement on each changes. But we don't have any time constraints. I mean we want to copy it as fast as possible but there is not some kind of synchronization needed. So the master edge mainly used for the USB flash key. I think it's a most known example. No drivers from Microsoft Windows. So in the example we use an internal sram of our STM32 for the storage. I think now we can launch TubeMix and start this labs. Okay, so let's take a new project. Okay, we are on F446Z. And we've got the nuclear one here. Okay, first step let's activate the OTG full speed and in device only. You remember we need an external clock to achieve the accuracy of the clock needed for the USB. So in RCC we've got clock sources in bypass mode because it's coming from the STL link on our neclio. Then it's okay for the clocking, for the pinout. Now let's configure the middleware. Here just say okay, it was a master edge places. I think that's it. Let's align the clock configuration now. Here we know it was eight kilohertz for the HSA and we want to achieve 168 megahertz. And let's work TubeMix to find what is the proper parameters to set this configuration. So we have got this window on my side. Yes, another clock system. Perfect. So if we go in the configuration can have short look about USB device parameters. Nothing special, nothing strange. I think we don't have to modify anything there for sure. So let's go okay. Let's do the setting of the project on 7th. So let's call it MSC device, USB, MSC device. Okay, location is good. We want to work with TrueStudio and let's increase the IP to two thousands. References okay, package okay, regenerate. My PC is a little bit slow. Okay, so now let's launch Atolic and let's import this project. Existing project for sure. Okay, we put it in a USB training and USB master edge. So we got it. Nothing is to change. Just import everything. So as previously described, we can find again all those files and the SCS1 with a level of abstraction. The core for the signalization for sure. And yeah, we've got our application with the storage interfaces as I already told you. Here, you can find how we organize the memory. And you've got the different commands. So the innate get capacity to know if it's ready or not. Is it protected or not. Read, write, and maxlunit was a logical unit. So in our case, it will be one. So now I think we can modify this and create our USB key. So the number of logical units, it will be one for us here for sure. And the block size is 512. So I know that on this device, we've got 128 kilobyte of SRAM. So let's say half of this. So just 64 kilobyte. Okay, because it was 128 multiplied by 512. So here it's an orientation, the number of blocks and the size of our blocks. So let's create our buffer where we will store all the data locally. So as declared here, it will be in the SRAM for sure. So the size of it will be the block number multiplied by the size of one block. Really bad example thing. So now we can go through the different function. Storage unit, I will say we've got nothing to do here. Because it's already initialized as it was just in SRAM. Get capacity, it's already down by the code generators. Is ready, it's always ready. Write protect. Okay, nothing. And okay, now is a read and the write. It's a two function that we need to modify. So first, if we need to read something from our memory, we just simply do a copy, a mem copy. Okay, and we'll do a mem copy from our buffer to this buffer that's coming through the interfaces. So just put there the destination of the mem copy. Then the sources is a buffer. But we need to find the block address. So the block address is a block number. So to know in our buffer, we need to multiply it by the size of one block. So it will be the bell block address multiplied by the storage size we defined at the beginning of this file. Unfortunately, it should be the address of this one. Now the size we need to copy. Again, this is here. Sorry, I just increased. Block length is a number of blocks. So here again to know the size to copy, we need to multiply it by the storage size. Okay, I think it should be good for the read. So the right would be exactly the same command, but we just need to switch the both parameters, the first and the second. So I'm a little bit lazy. I will just use some copy past here. Okay, let's see if I was able to write properly or if I missed something. Sorry, my page is a little bit slow today. Okay, it seems to be good. We'll finish properly. So let's download it to the target. So I plug my targets, I'm launching it, and we will switch to the debug view. I launched the code. And now I will plug my USB connectors, the bottom one of my nuclear. And let's see if Windows detects some mass storage. I will see flash stick. So I just plug it in. Okay, I've got this pop up. In fact, the memory is not formatted from Windows point of view. So you would like to know if you can format it for sure. Let's do it. The capacity, it was 64 kilobyte as we define. Let's do a quick format. It should be enough. Format is completed. So now you can see this new volume. You can create some file in it. And we can write inside also. So typically we now have a USB key. If I unplug it, okay, it disappears. If I plug it again, we can find it again with our file. So good. If I unpower my board, and if I plug it again, let's wait a little bit. Okay, it's updated. If I power it again, I still have, I should have the fact that you need to format. And it's gone back. Because everything have been eras as it was in the S round for sure. I would say mainly that it's, we created this first USB key with our nuclear. So quite simple. You can see that just in the interfaces. So just imagine that now you are using external memory or something inside or just putting the flash, the things. And you've got a USB key. Okay. Thanks. I think that's all for these labs.