 But I'm Jeri Wolf, also known as CircuitDojo. And we're going to be talking about a custom extension that I built for VS Code for working in Zephyr. I like that I'm following Jonathan's talk. If you are using VS Code, I definitely recommend you go back and watch his talk when that becomes available online, because it's a good resource. I even learned some things about VS Code. Well, let's get started. How I got started in Zephyr is I made that board. And I jumped in, and I haven't really stopped since. And it's been a crazy journey. So that is an NRF9160. And it's based on Zephyr. So that's how I got here. I also do live sessions on Zephyr. So if you haven't seen me, I'm on him on YouTube. And that is the link right there. So I'd love to see you there on the live sessions, so you definitely can watch the ones that are already out. So big problem. Getting started with Zephyr, and I've talked about this at Nauseam, can be painful. I think everybody in the room probably understands that. It is the new hotness, though. So it's like, we've got to figure out how to make it work. One of the craziest things and the coolest things is I can write one single unified code base, change the target, and I can be running the same firmware on a completely different platform. That was actually my subject last year. But what we're going to be talking about today is figuring out how to use these tools a little bit easier. The list is long. MC Manager, West, Ninja SC Make. So let's try to roll it into one, if we can, solution. So why don't we make it easier for everybody? I have a lot of questions and concerns, and actually it's just stumbling blocks from all the customers that were trying to work with my board. But I know it's kind of universal across Zephyr in terms of just the frustrations of getting things working correctly. I mean, I had it spelled out in documentation. XYZ do these exact steps. And there is always something on their machine, their Python version, or whatever. It's just like, it was really tough. And you're doing this remotely. It's not like I can sit down next to them. And it's like, hey, you just have the wrong thing installed. It's just like email's back and forth. It's like, all right, let's try to figure this out. So the solution was to create an extension from scratch using some of what other extension makers also had put in place for their extensions. So I was just looking at other extensions and seeing how they did things. So I just took it and ran with it. So the idea here is you're going from zero, so nothing, to getting your tool chain installed, getting all the utilities installed, being able to pull down at least a sample repository, and then compiling it, and then loading it somehow to a device that you might have connected to your machine like I have here, if you see that. And the nice thing is that also one of the main goals is to make sure that it works on everything. And that's probably one of the harder parts is just trying to figure that one point out. So I say 3.5 was an asterisk because I'm mostly talking about Mac and the fact that they changed architectures. So there are some tweaks for that. So I want to hit the easy button. We're talking about making things easy. The building, so originally this was kind of closed source. I was kind of just doing it for customers, but I was like, this could benefit. I mean, just the fact that the room was full earlier is just the fact that it's like, OK, there's a need here to make it easier for people to start using Zephyr and VS Code. That is the link right there. You can definitely check it out. And it is written in TypeScript, which is preferable rather than a JavaScript, in my opinion. At least things are tight. They're crazy. Here it is right here. So you can actually get it on the extension marketplace today if you just go in the extension marketplace search for Zephyr tools. I put a prefix of circuit dojo in there so people kind of understand that it's coming from me, but it's all open source. So let's talk about initialization of a project. Or initialization of your tools. So what will happen here is I have a command here that will set up your, depending on your platform, it will set up all the tools and set up a Python virtual environment in a specific folder in your home folder, no matter what architecture you're on. So Linux, Mac, Windows, and it will put them all in the same place and it knows where they live and it knows how to get to those tools and actually set some paths while you're using it. You can see there in the corner, actually, that was actually, I think I'm doing like a West update in the background there, but. So the only thing you really need for any of this is you need Git and you need Python. That's the only requirement. I tried to tour around it, like trying to figure out how to download Python for you, but that's the one thing that's kind of complicated. So you got to install Python, sorry. And right now it's geared towards ARM. There are some ways you can, I mean, that's one thing that I will put a call out to anybody who's interested, because it is open source, I'd love to make it a tool for everybody to use on all types of different tool chains, so maybe I'll put that call out earlier, if you're interested in helping, please submit a PR. And it'll also download CMake, Ninja, New Manager, so I'm using New Manager only because I had to modify it for my board for Mac. So for whatever reason, MCU Manager will not allow you to use, it's the serial library that they used in Go, it wouldn't let you use anything faster than 152, so in order to transfer any images to NNRF9160, it would take like a minute and a half and that's just not doable. So, and another thing that is there is I created a Zephyr Tools CLI, it's coded in Rust, and essentially it's just a serial monitor and it does some extra features and that's also open source, so you use it for logging, I have it piped out to a log file, so when you're using your console, you'll have also a full log of whatever you're working on, all the output from your device. I've found it really useful for people, for clients, if they're having trouble or something errors, at least it's automatically taking a log so they can just copy, paste, throw it in an email and send it to me or whatever. So, and again, you're gonna have those two things installed beforehand. So one of the concepts that I was working with was all right, so how do I figure out this multi-platform problem? And the idea here is I found, I sourced all of the executables and kind of put them in this manifest format so each platform has its own manifest and it points to the CMake and the Ninja and all these executables, so they're all downloadable, they're all downloading, for the most part, from GitHub and public open locations and the nice thing is this manifest file actually lives in the repo so you actually see where they're being downloaded from. The only one that's being downloaded from somewhere else is the custom MCU manager that is needed for my particular board but otherwise it's just MCU manager. And the nice thing is that it allows kind of fine-grained control over the different architectures and plus I also added, so I had some customers like, hey, we can use this. We got M1 Max, we got M2 Max, it's like, oh, okay, time to make a different option. So not only can you kind of drill down to Linux or in this case for Mac, it's you're drilling down from Mac but you're also drilling down into X8664 in ARM so those are all there they're just providing different binaries. The nice thing about the Zephyr SDK is there are a lot of great, smart and hardworking people that got that working pretty fast so for anybody who thinks M1, I'm talking cellular language here, if you're using an Apple and with a new processor, Zephyr SDK is supported so hopefully everybody knows that. Inside, so this is actually the TypeScript inside the code, this is where we're kind of sorting out the platform. You can just see that depending on, I'm essentially selecting the manifest depending on what is provided in the code itself and then it just selects it and then you have the full list of binaries that'll go and download and put in place and set everything up. As you can imagine, this could be improved or you can go crazy with it, you can go, you can have it so you can select all the different SDKs that are available for Zephyr or other utilities. I know there are a lot of other helper utilities and things that maybe are not included right now so that's also another option but another plug if you would like to contribute. I'd love to help push that forward. So the next step would be to, so this is where I would recommend people where I recommend customers especially to start if they want to just start playing around is initialize a repo and all it does is under the hood a lot of these commands are just running west and it's just gonna initialize to a specific repo and then also update and get you all the prerequisites and also install all the Python requirements because as we're jumping around to maybe different versions of Zephyr you're gonna have to make sure that you have all those prerequisite Python requirements or else things are not gonna work and not build correctly. So this is me just putting in the URL. You can actually specify for this at least you can specify the branch and it'll download everything and get it all installed for you. So this is a little opinionated and I don't know if you saw one of the Galatz talks earlier yesterday they have a certain way of like they have like keeping everything in a certain place or in certain cases actually like downloading the full Zephyr SDK and all those dependencies and keeping them in the local folder and I like doing the same only because I find myself maybe I find myself working in different versions of Zephyr all the time. So if I'm always trying to switch between the two inevitably it turns into a train wreck. So having a specific Zephyr implementation or Zephyr clone for one project and having them kind of all separated just keeps the sanity a little bit the sanity levels a little bit in the good direction. Downside takes up more space. So in the land and I think what Mike said yesterday is like 2.3 gigs. I mean we're living in the world of terabyte hard drives it's not the biggest deals but I know some of you like working with changing your Zephyr base. So one thing that's a new addition to the project is also having the ability to create a project and what what's happening here is you don't really have to do the in it and clone the repo because that actually puts you down the very slippery slope of teaching people to like write your code in like the samples folder which is like the number one mistake that I made when I started playing with Zephyr it's like oh I don't really know how to just like separate my app from everything else so I'm just gonna put it in the samples folder. So what this will do is actually take right now it takes the Blinky sample it clones it's such a West manifest file depending on what flavor of Zephyr you want so you can choose either NCS or Vanilla at this point and Vanilla is just the regular standard Zephyr and then it'll pull your dependencies and set up any of your Python requirements and basically it's a pip install with the requirements make sure you have the right things so here's a quick little drop down and we're just setting it up so in this case I'm just gonna be selecting NRF Connect SDK and here is the actual kind of output of what happens here we're getting a CMakeList PRJ.conf a main file and the West.yaml all very important and this will at least get you started just with the Blinky if you just want to blink some LEDs. One thing so say you want to add a dependency I'm a big fan of West it makes things a lot easier Mike's Dish from Galathe did a great talk on this yesterday too just adding dependencies to your West.yaml and it's as easy as adding those lines and then running the update dependencies command in VS code if you are hopefully some of you are familiar with when you're writing you do like the command shift P or the control shift P and it'll give you that command window where you can run these commands but here I am so this is kind of like the West file that got generated and then you just put the dependency in those lines there below and then we actually do a quick West update and I'll fetch all the dependencies for that library. Now we're talking about building so the cool thing here is for the extension when you do build for the first time it's gonna ask you what's sampled or what application do I want to use and then also what board am I building this for so it does some trickery and it goes and searches through kind of the tree of everything that's downloaded in your kind of dependency folders and it will try to find all the available boards and also the available projects the projects will be limited to whatever application folder you have so that's one downside some people have reached out they're like hey I really wanna build this application and this like sub-folder part of the modules it's like I don't really support that but if you'd like to contribute we can probably get that working so the commands for that are built in and they are the build and also you can build pristine which essentially is build clean for the uninitiated and worst case you're gonna always delete your old folder but yes I did name this app Bobo so we are selecting that target project it just popped it up it's like okay I found a project in this folder let's this is your options so I'm gonna select that and then it gave me a whole slew list of different boards I'm just selecting the circuitry of Feather to enter find even 60 NS and then that will persist no matter what so if you close it and you reopen it it's gonna be there no matter what and if you ever need to change them you can always change them using the change commands for either of them and one thing that let's see and then we're gonna be just running so the currently the flash so we'll go jump over to the flash command so the flash command currently uses the NRF Jprog it's mostly targeted towards Nordic but obviously you can be using different actually I think using West Flash so you might get away with it if you're using different platform but on the back end it's just using West Flash and then another option at least for this is if you are using MCU boot and you do have it connected to either a USB UART or maybe you actually have UART emulating as it's a UART interface you can actually load over MCU boot as well so using MCU manager in this case new manager the console access is handled by those again the separate tools I was referring to those are just the written and rust and essentially just wrapper around some of the serial tools inside rust the nice thing is that you'll be able to connect and kind of do whatever you need to to that device you give some options in terms of plot rates and things like that and I'll save everything kind of like what I was mentioning before so you can see here that's the option and then the output is below it's kind of cut off but you can see the boot banner there for the device so and then that's the output of the log file it's just piping everything to the log file so let's jump out real quick so this guy is bad boy let's see all right so it's all right here there are some changes to it since but what we're going to do I'm going to create a new app a career project I do have kind of a backup here because I do need to change a couple things as we run through it so I'm selecting kind of the target folder for the sake of time and everybody's patience I already have all the dependencies loaded so we're just kind of creating the base folder to get the sample working so we're setting that bad boy up here it's going to just confirm it has everything in the right versions and then you can see here that it was I was checking Python dependencies here actually setting the requirements and this really depends if you're jumping between different versions of Zephyr then this is beneficial for you if your version of Zephyr is not changing very often then it's kind of extra but it'll really only you know it's not going to bother you that much and so we have that in place so we have here I'm going to get rid of the thermal real quick so we have the standard kernel or standard Zephyr blinky sample going on right here and nothing else crazy I am going to let's see if I can get this so I'll just do that so I'm going to throw in a hello world and I also have to configure the boot loader so I'm just going to copy these guys so what I'm doing right here is all I'm doing is enabling the log module and also just making sure that MCU boot is turned on so for NCS, for anybody who maybe have not worked with Nordix Connect SDK is that when you have the boot loader enabled it will build and merge your boot loader with your application so all you have to do is load it once but in this case I want the image that gets created for the purpose of OTA or uploading it via the boot loader over your art so we'll give it a build so I'm moving too fast here, sorry guys this is the build command right here and you can see like if you just type Zephyr tools they're all right here and it's building here in the background so I'm going to check along let's see what else is pertinent here as we go through it so most likely it's already selected the board in the project but we'll make sure when we do actually it has because it's building right now so and then what we'll be doing once it's actually done is we'll load it to the board oh yeah it's complaining about the logger we'll turn this into a printk instead there we go, it's going all right so it's merged it's built and merged and I'm just going to load it and the next thing is that you kind of you have the option to either load it or you have the option to load and actually monitor it so it'll connect it immediately to the device and then the nice thing is like you can actually set up the serial so you can actually pull whatever serial port that you want to be talking to and that persists also so I'm just going to load it one thing that did do on this guy is I wrote a little program actually it's part of the Zephyr tools application so you can definitely check it out but I'm using a Silicon Labs USB UR chip and one of the cool things you can do with it is you can control GPIOs so what I did is I wrote some I wrote some code to talk to that device so it would toggle GPIO without having to press any buttons to put the device in the NC bootloader mode so just an option there but you can see at the output there we have a little hello world that's something we just added so we just went from creating a project to all the way to building and flashing and actually reading out from it pretty quick obviously I've kind of skipped over the whole the setup part but maybe I can show you guys where it lives so this command right here this would actually detect your machine and then download the records at SDK along with all the other tools that are compatible with your processor to actually do these builds so I'm going to show you I can't use that I'm going to make this text a little bit bigger so we're going to the separate tools so this is kind of where everything lives and tree, we'll do a little tree layer three and you can just kind of see there's different places for all the different all the different applications and all we're doing is just setting the path kind of automatically inside the application or inside the extension it actually sets your path to the appropriate location depending on where you are it also caches all the downloads so you actually can you don't have to re-download them every time if maybe you want to kind of reset everything also setting so in this end folder you're going to your virtual environment so those who like setting up a virtual environment for their development it's all right there and you can see just scrolling through here all the important bits that are related so we're just setting up environments for every single every single thing in the manifest see you and one thing, let me see if I can actually pull up the manifest you guys have a better idea of actually what it looks like because I kind of showed the top of it but I didn't actually go into the extent so there's some hooks in here it actually does a hash check so when you're actually downloading everything it'll actually check the hash of the file to make sure it's actually correct and this actually gets bundled with the applications or with the extension but there are certain things like setting suffixes and setting paths and making things a little bit more and setting an environment variable so if you've played around with the Zephyr at all everybody loves the dreaded Zephyr toolchain variant and the Zephyr SDK install directory so all those are getting set as environment variables also to the point of that is not only does it set it as environment variables so you can access it with the tools but it also will allow you to let me see it'll also allow you to access all the... oop, of course not if you have it set up correctly it was complaining about the Zephyr path so I'll have to double check but you can run at least some of the utilities so this is like that you'll get the Python environment that's what it does it'll get you the Python environment so at least you can run West you might have to if you blow away your build folder you might have to reset the the Zephyr environment variables but that's only for the command line so again another plug here if you'd like to see things improved I'd love to see some PRs from the community that'd be awesome to make this kind of usable for everybody let's see I think that... so we got those guys so that's pretty much it for the demo as much as I want to cover so let's jump back into the presentation and if you guys have questions we definitely can go over them so the ultimate summary here is that getting it to the point where it's cross-platform it's easy to set up it applies an opinion way so it might not work with your workflow completely but it's an option if you like the way it is Zephyr makes it so... there's so many ways to use Zephyr so this is just one opinion way of doing it and it's all open-source I got that link in the presentation before and I mean it's a big huge thanks to this Zephyr community and everybody who's been working on this project because I'm standing on the shoulders of giants to some extent here this QR code will get you just... if you'd like to get all the slides you can definitely check out the QR code and head yourself to the list and you'll get those sent right to your mailbox they're also available on the scheduling app so you can definitely download them there as well and yeah, does anybody have any questions? I'm not sure whether you said that but did you actually run that on a Mac with an Intel processor? This is an Intel processor Mac and that is required, is that correct? You can use an ARM Mac or an Intel Mac and it will be... it will look the same? Yeah Really? Okay So the only... I think the only tool that I might not have fully compiled is the MCU manager just because I don't have a machine I can compile it on but all the other tools are like the CMake and the Ninja all those are already pre-compiled for M1 and M2 as far as I understand and I've had customers that do have those machines and they're like, yeah, everything works except for this one thing so... Thanks for the presentation, really nice Not the question but actually note there is a PR for a new team manager which increases the download speed to usable fairly usable time so... Oh, that's awesome So then I don't have to use my custom one anymore? Oh, that'd be great, okay I had the question as well So Nordic has its own VS Code extension to certainly know They don't... I was expecting a little bit more overlap I came here with... There doesn't seem to be that much but have you thought about bundling them together? I'm not sure if... I'm from Nordic so I can ask around but I'm just curious whether you... because they would actually probably be a good combination together, yours and Nordic so I don't know if you've ever thought about it because I think VS Code supports bundles of extensions Yes, that's a good question so that's one thing I failed to mention is that part of downloading this it'll actually suggest you download a bunch of other extensions Tron had actually reached out to me about his extension before it got merged into the extension pack that you guys now have So I was like, this is an awesome extension I'm glad it got merged into theirs because that's one of the... So there are two or three Nordic extensions that get installed when you install this particular extension Okay, great, thanks Yeah, not just this There's actually... I should have mentioned that earlier There's a lot of... So what Jonathan was saying before there's a list of suggested extensions that will get installed when you do install it So it's not just this one Alright, thanks Okay, so I have a question about the... maybe a different scenario if you, for example, have a completely new hardware do you don't have any defined board? Does your tool support such use cases? So starting from scratch, for example, defining device reward and stuff like that how does it look like? That's a good question So right now it scans through every... So if you have your own repository and you have your own boards directory either right now it will actually find it or we might have to add some extra code to make it look forward in the home directory I haven't made a lot of custom boards that are out of tree yet so that I haven't really thought about it but one thing that I have done out of tree a lot of it was like drivers and libraries and things like that So I would have to... I don't have an exact answer because I haven't used that I haven't been in that use case yet but if it's missing and you think it's cool then we can add it Hello, I'd like to ask how this extension compares to the platform you want? The platform IO? Yes So this... the... I haven't used platform IO very much so I know for some people all they want is like the last talk when Jonathan was talking one of the questions was like how can we just get that play button to get it to compile and load and I hope I've gotten to the point where at least you can do that through the commands and maybe there's... I just never got around to creating the buttons and things like that so the hard part for me and the hard part for my experience is getting all the tool chain stuff installed and things like that which I know kind of platform IO is doing as well but it's kind of its own implementation away from platform IO I'm not really reusing any of their technology or anything like that so... Okay, thank you The version and the pass are coded in the manifest, right? The SDK for example the SDK version and the hash so when a new version of the SDK comes do you have to update your plugin? Yeah, if you want to update the SDK then it has to be updated in the manifest as it stands today So it means that you have to monitor the changes around and then to update your plugin every time the new version comes And then you got to test it to make sure it works with the boards that you're mostly supporting Yeah, it can be a nightmare This was kind of what I was going back to what I was saying before this was really hard for some of my customers to come from like they have no idea how Zephyr works they have no clue so it was basically like install this, it'll do everything for you and it's something that I've tested but if it turns into something where there's people in the room that want to like help and contribute then we can make it more advanced and make it do magical things but this is how it stands today And let me see if I can pull this up back to Carl's point there is here's a list of all I don't know if actually I can see you can see all the extensions that oh here we go try to scroll it up so C++ the device tree from Nordic, Kconfig, Nordic and those are just kind of like three but there are a bunch of other ones that are very useful Jonathan went over the talk over this in his talk earlier we have, let's see I don't have them installed on this particular computer but the the debugger the Cortex debug extension is also very handy Cool, any other questions? Okay, thank you very much for your presentation Thanks for coming about