 Oh Hi, everyone. If you're not watching this live make sure and check the notes for timestamps We're starting a smidge early because I have to end late. So I thought I'm set up. I might as well get started I won't do housekeeping until Seven minutes for now or so. So if you are watching this later Check that out live on twitch. Thank you, mr. Certainly and Hello, love the factory So a spook has a vet appointment this afternoon after this so That's why I got to get out of here by 3 30 Or at least get off by 3 30 to give enough time to round them up and get over to the vet So I thought I'd start a little early But I don't want to dive too deep into it. I want to give some time time for folks to catch up Hello Chadwick, hello Patrick Thank you, mr. Certainly for letting me know where we are live and you can obviously hear me I Folks have any questions before we dive into stuff. Go ahead and plop those in there Well, we get started. I Do have a smidge of a mail bag, which is exciting Actually, did I show the sensor? I Showed it on show-and-tell Um, it's too late. Oh, maybe you should that next time I Did get a bit distracted before here. We'll see Any questions to start with I've been doing lots and lots of flash stuff Hello Charles It was sunny here. Although it just looks like it got overcast. I got out for a bit of a walk around the block Which is really nice No data Did I stop? YouTube's okay, right? OBS looks okay, but YouTube says no data Good afternoon Gary Mr. Certainly says I just want to thank you Scott. You cost me some money the other day your Pomona SOIC 8 grabber inspired Me to replace my low-quality ones with the box set from Pomona Hello, Nino. Hello Rodrigo Rodrigo says I just got my RP 2040 yesterday and it's amazing All right, excellent condition. Okay. I don't know why it was telling me no data Did it let me know if it's hitching at all. It looks fine from my end But I like to live on the wild side and I tend to update I Tend to update My box right before James says five by five QT pie says yep John says good evening from the UK. Can anyone recommend a feather with a 433 megahertz Laura plus circuit Python John You're gonna be better off if I do we have a 433 megahertz feather wing I would recommend the wing instead of having it built in because I Think all of the the feathers with with the radios Directly are a little underpowered at this point But if you get the wing then you can upgrade it as you go along and you can also use more powerful ones Uh, Davey says hello from Colorado Granaful says hello Scott first time catching the stream just started working on my feather our 2040 excited awesome. Yeah, I love the feather the feather 2040s are great And they're going to get better here shortly They're actually they're gonna be a little bit slow right now Because of the flash stuff that I'm doing Naradoc confirms that says yeah, they are non-express M zero so the the radio feathers are I don't recommend them get the feather wings if you can Dexter says a three and a half TFT feather wing just arrived connecting it to a feather s2 Which is exciting All right, we're about there. Let's see is David or is David in the dock yet? We're gonna have to sync time codes at some point Okay Let's I guess wait two more minutes any other folks working on the RP 2040s Having a good time with them. Ah, David is in the chat. Hi David You're you're you're coming up in all the chats now Be the graph says look for looking forward to the QT small form factor. Yes. I a hundred percent There's a little bit of a delay on the QT pie and it's a bit see simply because the more was Trying to decide what flash footprint to use and then once she decided it She discovered that a lot of the flashes are out of stock right now So I think she found some so that should be kind of unblocked Hi Bruce Hopefully it's this nice up in Vancouver It's quite nice here today Hi, King of North I King of North I've noticed you do a lot of videos on YouTube about circumvent on you should make sure and add them to the newsletter That goes out every week. We'd love to share them Mr. Certainly says yeah, I have a bunch of old M zero Laura feather where feathers wish I got the feather wings instead All right, let's get to show on the road because like I said, I'm I usually go I usually go Two hours or so but today I only have 90 minutes Johnny says hi there Scott so 2040 today as well. Yeah, I feel you Okay, let's let me Looks right right enough Okay, so housekeeping Hello everyone, my name is Scott and I work for Adafruit on circuit Python Circuit Python is an open source version of Python designed for low-cost microcontrollers Called well computers called microcontrollers Here is an example of one This is a Raspberry Pi Pico and has the RP 2040 chip on it as designed by the Raspberry Pi Foundation oh Yeah, I was I was exactly two o'clock PST to wasn't it great so Boards like this are designed by Adafruit and we sell them So if you want to support me and support Adafruit go to Adafruit comm and purchase all the different electronics that you can find on there and if you want to Look for different projects to do with electronics learn to Adafruit comm is a great place as well So Adafruit is an open source hardware and software company So all all the work they pay me to do is open source, which is awesome. Awesome. Awesome So if you want to chat with me and a lot of other folks we have a discord server, which is the gray box over here That is you can go to the URL adafru to it slash discord to check that out We'd love to have you. It's a ever-growing community of awesome folks So this is a deep dive. It happens every week nearly every week Normally Fridays at 2 p.m. Pacific, but occasionally shifted to Thursdays at 2 p.m. In particular next week will be on Tuesday We're gonna do our last Last ski day, I think on Friday next week. So Next week will be on Thursday after John Park's workshop. We do tend to start a little bit late depending on how a lot late John goes It typically goes for two hours or more questions are welcome and encouraged But beware that today is only 90 minutes or so because the cat has a vet That I had to take into after it's just his annual checkup I was meant to do it in December and then I didn't get around to scheduling it until January and then by the time I called them in January. They're like, we're really busy How about March? So that's what that's what's going on today and speaking of the cat The last bit of housekeeping is that he is epileptic Which means he has seizures occasionally. He has had them during the stream But he's been doing really well. So I don't expect that to happen But just know that if if I'm watching him and not paying attention. That's why Um Ah David G says hi, sorry and late. I was watching say name McDonald from Pimerone first live stream on the Kibo 2040 Oh neat. That's good. That would be great to add to the newsletter as well And speaking of the newsletter King of North confirmed that and has been adding most of them to the newsletter As well. So if you don't know there is a Python for microcontrollers newsletter done by Adafruit But drafted in the open So if you have any Python-y stuff to add to that, you are welcome to make pull requests to the draft You can go to github.com slash Adafruit slash Slash circuit Python dash weekly dash newsletter. I think is where it is And that goes out to like I think it's like 8,000 folks last time I checked. So It is interesting. And so we just want stuff related to that So a couple more. Hello's hello to the ship who hello to Tom twist who says to Pico's just arrived today Johnny says good knob and to The ship who tabletronics waves high tabletronics Emmett Ray says hi Scott ordered Pico, but the postal office burned with my Pico and other stuffs Oh, I feel yeah, I I think I was telling folks about an Osh Park order. I did with USPS and it just Just like got lost and then all of a sudden showed up in Tennessee Which is nowhere between where it was coming from Oregon and here, but it did finally make it which is good Mark Gavler says hello Keith E says hello. Hope all as well and Bruce says snow rain and whistler today Just got off the hill awesome day running in as I type. Yeah, hopefully I was thinking about that I need to check the weather since we are planning on skiing next week Okay, so I think I have a quick mail bag So I just thought I this is an order that I ordered long ago, but I thought I would just hold it up Because it's not that exciting David says I've had great success with USPS for most of my effort orders. Yeah, generally they work well So the first thing I got is another Compute module board. I'll take it out of the bag so it doesn't reflect I don't want the bag anyway, so I got if you've been keeping track I do have one of these already when Adafruit got it in stock I know or Adafruit had the modules in stock and then did you key had the the IO boards in stock But I actually ordered this before that I back ordered it through Newark thinking they would get it first So I got that and if that's any indication of what the other two things are I thought I would just look So I got to I got to commute compute modules to go with it So here's a compute module and it doesn't actually tell you which one it is except it's the CM4 1 0 2 0 0 0 which I don't remember. Oh, I guess I threw away the bag that said what it was Let's see this bag does not Say. Oh, yeah, this one's I Don't think I can reach the bag with headphones on so I don't know what that I don't know what the other one is but this one is a let's see it's a CM4 1 0 4 0 1 6 Which the bag says is a our our pie module for 4 gigs of RAM 16 gigs emmc Wi-Fi So this is I got one that was like pretty bare bones and one that was not so bare bones so I have more pie for stuff for when I finally get around to Finally get around to doing native Native circuit Python on the Raspberry Pi although I was talking to David about it earlier So maybe I'm hoping somebody beats me to it But I'm like about to turn the corner into Bluetooth land, which is super exciting it's something that I wanted to do for a long long time and The nice stuff about the Bluetooth the Bluetooth stuff that I want to do In the next couple weeks start in the next couple weeks is Trevor our iOS dev is also Like in pace or in sync so it's gonna be him and I and maybe some other folks teaming up and really hope it Hopefully doing all this Bluetooth work Bad Abby says I'm excited for the pie you nor our carrier board to come out. Yeah me too It was my idea. So I'm excited super excited to see Timon Come out with it and see what people think 12 DJ 6 says just got Pico's from Canadian Digi key took four weeks for lead time But then one day for shipping nice Pico's are exciting Johnny says woohoo mail bag. I did get more stuff, but I actually already put it away I got a new soldering iron, which is very exciting. I haven't used it yet But I cleaned this a bit last night and there as well And then the shirt is Hacktoberfest So Hacktoberfest is something that digital ocean runs every October usually and It is if you contribute Like so many PRs to open source projects. They'll send you a t-shirt The last one was either a t-shirt or planting a tree and I was like I hate the earth I want the t-shirt. So I this is 2019s, but I do have a 2021 as well So we'll keep doing that we do that and as part of circuit Python as well Moto team is says I only wish the pie you nor I had the PE PE header. I assume that's what I pee you yeah Mark went with the t-shirt to Okay, so let's So I splurged on a so mr. Certainly asked which iron did I get? and It looks like You're like 30 seconds off David So I'll just pop that in there Maybe my time is running too fast. So I splurged a little bit What got me thinking about originally was Chris Gamble talking about getting a thermal tronics But then when I looked at the thermal tronics is I was a little wary of How they were all out of stock on Amazon? So I Let me pull it up I went with a JBC Which is like twice the cost But I had seen a Thread here that I'm pulling up on So Jeff Kaiser here desktop Asked to folks about like JBC irons and there's a lot of a lot of folks who are in this electronics world saying like JBC is the best Really awesome. So I went with the JBC And I got the I haven't used it yet, so I can't tell you what I think but I'm quite excited I got the compact station here and It's funny. I actually realized after figuring out that they're in Barcelona that I like been in their lobby I like met a drone company there when I was in Europe Right after I started working for Adafruit and I had been doing drone stuff prior to Adafruit so I visited somebody there and JBC is in the same complex So I was like I remember looking at all the equipment and how expensive it wasn't being like I'll never get this but I don't know if these compact ones were ever there, but they were There it was like $600 total, but I've been doing more As I've been doing more soldering recently. So I was I really wanted something that was much quicker When you hit like a ground plane and you have to pump out heat So these are supposedly really good for that. So That is what I got. I haven't tried it yet I'm supposed to it was a it was a bride for me finishing this part of the office that I haven't actually finished yet I have to do I think I'm gonna do one more kind of feathering of the paint And then I'll be done and be able to like put this all back together, but I'm gonna do that tomorrow So technically I can't play with it until then I think Okay, so if you have questions feel free to ask them But I thought I would just I Detour this morning. Let me show you what I detoured in so Logic is here So logic is A logic analyzer software and Sorry, I don't have that overhead hooked up because I actually need it. Oh, let me This is where I keep my Like stream status is like right below the the screen edge there Okay, so this is Logic and I have a logic pro 16. I've showed this before so if you want to see my setup check one of the previous streams But What I'll do is I'll just I've got a feather Sorry, I can't show this because it's all hooked up But I have a feather I have my feather with the the spy socket on it and then it's going into this alie So I just want to do a capture because I want to show you what I did is I worked on my spy flash Analyzer so if I hit reset and hit start and then let go it'll capture And I'll just hit stop So what I was working on is I actually added simple parallel support to the spy flash Analyzer that I have so now what we can do is we can zoom in here and One thing that's interesting is that the code up highest running is a blink and it blinks every 400 millisecond So you can see when code is I know that's kind of small But there's a gap of 400 milliseconds between flash loads, which is when it's loading code off the flash and so if you want to see what it's loading what you can do it now is you can zoom in and It's doing a quad access, but when I just added support so that not only is it analyzing the quad reads But it knows quad word read which is a special mode that the giga device stuff supports Which has only two dummy bite two dummy cycles instead of four Which means that you sit you save two cycles and then It now also does It does the continuation stuff that the RP 2040 uses so the way that the RP 2040 And it works and we'll kind of dig into this because this is what I want to wrap up is like I Have everything working I think and so all I've got to do is like one make one more final pass over all my changes for the flash Stuff and probably add some docs and and fix the CI, but I should be able to get a pull request out for The support for different flash chips on circuit Python on their RP 2040 So that's that's kind of like the work that I'm wrapping up But I said even in the title of the stream like we're wrapping this up today I'm ready to move on So I thought we like we've done that before where we look at all the changes And so I have to do that anyway before I make the pull request Moto Tima says Jason Crider from beaglebone.org was asking you about the state of Circuit Python on Zephyr and I realized I never heard the two in the same sentence We haven't done any work on it Micro Python has a Zephyr port. I don't know the state of it I know that Marines been keeping it up to date. So that's been cool But For a while they didn't have a way to do like dynamic pinmuxing and I think they added an API for it But I haven't actually looked So it might be doable now, but I'm not sure Not sure We tend to do our own thing like we're we're very tied to tiny USB instead I'm much more of a person of having like a lot of repos that are independent. Hi Sean. Happy Friday Okay, so I don't I Mean maybe saliers are expensive for everybody and they are but they're they're a worthwhile tool, especially if you're doing flash stuff So you can see here that like it's doing a read And then checking status register and then you can see that it's going into quad word reads He probably meant micro Python. I don't know. I've talked with Jason about circuit Python. Hopefully he wants circuit Python Hello unexpected maker Um David asks what bandwidth do you need for this analysis? So, you know one for for doing this sort of capture You don't actually need that much bandwidth Because you can actually like with flash chips you rarely actually have You rarely actually have issues if you just slow it down like everything will run slower But it will run the same. So if you do have a logic analyzer that can't be super quick you can just You can you can just slow down the flash and and then look at everything that's happening Unless you're having signal integrity issues and then that will be that will be different Unexpected maker says DS logic is a solid and cheaper alternative for a logic analyzer Yeah, I haven't tried it. I really would like I have this tiny logic friend project that I mean to get back to Like there's no reason that all these micros can't be low low-end logic analyzers on their own Like somebody just needs to make an open source protocol across the two that that captures like Pin naming and stuff across the protocol. Yeah, I've started working on it and I need I want to get back to it at some point but like Pulse views great. I had to fix a bug when I was looking at it, but Yeah, like pulse view already has a quad spy Analyzer, but I mean logic to this is like the newer logic to and they've done a great job And it's all Python which is great. So it's just like a the analyzer that's doing all this is all Python It's just unfortunate because you have to like plug a low-level analyzer in and then then you can get The output of that into Python. So there's a couple tricks that have to happen here but like if you're ever doing spy flash and you're having reliability issues being able to see what's going on is like super helpful and Jeff and and the more lady that have already started just kind of circled back to the imxrt and like we're going to be doing some flash stuff for that as well Okay, so let's go And if you want to install it if you if you are a salier user what you can do is if you if you click extensions here You'll see that I have this spy flash One here and it says it's local That's my local version. Yes, this is under Anthony asks is this under Linux. Yes, it is I'm running on Arch and logic to is like What's it called the like chrome thing Um But if you if you have logic to you installed what you can do is you can Scroll down and you'll find the The other version here the spy flash version Um, and this is the wrong version zero point eight zero is the older one But it emailed me to tell me it got nine. So you want zero nine zero if you want the quad spy stuff um It has the update up to date read me. So I don't know quite right why it's Not everything but That's should be super handy. Um, and I'm I had this code written for quad analysis already Where I was just taking in a csv export and then I realized that like I could probably just do it in here using a parallel And so I I did that this morning. And so it's good. It'll be helpful the next time I do spy flash stuff as well Or if anybody else is doing it too Okay, so Here's my here's the I have two main browser Windows open right now and this is my flash one. It's just like a ton of data sheets for flash um Anthony asks what hardware interface are you using? I have a a salier logic 16, which is like the top end um It's like not cheap Uh, but it's it's pretty awesome I don't know why they don't just tell you Yeah, so the logic pro 16 can do 16 inputs I I rarely use an oscilloscope. This is I hate these pop-ups um But yeah, it's it's pretty been pretty awesome Tan says my favorite friday stream. Hello Welcome to the your favorite friday stream. Uh, okay, so They're pricey, but this analyzer or yeah, it should work with that too with the lower the lower ones um Let me know if it doesn't Okay, so let's pull up my changes and go through them So what I've done is I've um Mr. Certainly points out salier and digilent have had several price increases over the past few years So my two cents is if you need something get it sooner than later. They're not going to be cheaper Yeah, but hopefully in the future we have much cheaper options. Uh that aren't salier like Yeah, especially as we get into imx that one of the exciting things about the imx rt is that they're used to be high speed So you should be able to pump like more Sampling data out of that as well um Yeah, there's there's plenty of hardware that could do it. It's a software problem not a hardware problem Yeah, unexpected maker says salier is an awesome kit but super pricey Which is why I got a ds logic, but I'm keen to see how your project mcu based version evolves Yeah, I mean I'd like to do it like so much of what I want to do is just software bottlenecked um But I think I think it's always important to to point out that like Yeah, salier is like hundreds of dollars like maybe almost a thousand but like If you're working like I do in this in this space like You quickly that your time that you save quickly adds up to hundreds of dollars So having good tools is is important um And underrated I think too I think yeah Some people consider their time free and it's important to realize that your time isn't free um, and so if you can have tools that make it make it better then They could be worth it Okay, so let's look at this rp2040 flash and I'm going to get a unicorn here as I compare I think um Because my my personal fork is a was forked originally from micro python. I get this like terrible Terrible offset and then when I switch it to ate a fruit circuit python as my base now it's on master, which is an old version um Keithy says there's a real cost of fighting software. Just getting something that works is so helpful Yeah, it is for sure Okay, so if I switch it to mean this will work Okay, so um, here's how we have it set up so Uh, let's just go over this. This is also going to be my like before I make a pull request sort of thing um I do want to actually see it looks like It it doesn't look like the um The ci ran it all so I'm going to want to do that too. I might make it an open Uh, after let's let's go over this and then I'll make a draft pull request and see I kind of suspect the ci will will not be happy Um, okay, so I've temporarily switched pico stk to the ate a fruit version. The reason is is um I had to make uh pico stk Function call that is usually that is static currently non static so we can use it It's the call to um run a command to the flash And the reason that I need that is because oh, and I should test that as well I don't think I actually test that code. Um But what I've done for the rp20 40 is we actually don't bake the size of the flash into the binary anymore um, what I have it doing is I have it reading a A standard id from the flash that tells us how big it is Um, and then that will dictate how big we make the file system Um, so that's something I should test um Okay, so that looks good, so I'm just going to collapse them as I look So you'll notice here that I also added a sub repo for under data So data is a new top level folder and I'm adding this nvm toml Um, I just got pinged by what's that? Okay, so there I added the data slash nvm toml I added this d raspberry pi This is switching indentation So I've added some build stage stuff. So whereas we were taking a stage 2.c from um The pico stk now what we're doing is I'm running a python script to generate it instead. So This python script is called gen stage 2 And it takes a ginger file, which is like a standard pretty common templating system for python And it it takes that c file Ginges it and then generates a a stage 2.c which then gets compiled as normal um And this is related to so what I also added doing for the pico is I'm moving We have some code already designated as itcm and dtcm which is stuff I did for the imxrt which is tight tcm is tightly coupled memory and on the on the imx there's Because it's a cortex m7 it fetches instructions differently from data. It's got like two separate memory ports um So, uh It's ginger with a j j a n j a um So, uh Yeah, so what I'm doing is I'm I I'm using those designations for stuff that should be in tightly coupled memory And I'm putting it in I'm I'm using it on rp2040 to put code in ram and the reason I'm doing that is if if the code is in ram Then I don't need to I don't need to load it from the flash as I want to execute it Which means that the stuff that's cached from the flash Doesn't need to include the stuff that's in ram so the idea the hope is that like By taking the code that you're always going to use like the vm And putting it in ram instead instead of leaving it in flash It means that like you'll free up more space for caching in the cache itself Um, so I'm doing that in this in this change as well And that's what so this dash r means that the binary doesn't include the dtcm bss section Um, which makes it like The binary really really big it makes it like 250 megabytes large because of the address space Um, so I had to remove that Okay, so let's collapse that Next up we have changes to all the board files. So you'll see we're removing total flash size Um internal flash file system equals one is moved to the port configuration because like all of them are going to do that And now we also have this external flash devices Which is the same definition that we have in other ports like the atmel samt for the external flash It works differently, but it's defined the same way, which i'm pretty happy about um, so here we're just removing and defining And these id's here have to match the id's that are in the nvm toml I think I don't think I I think all this python-y stuff is new Um, but I'm pretty excited about I'm pretty happy with it. Um, having a central location So here we can see that I had to copy the boot stage to linker script into our um Into our folder out of the stk because I it adds these dot stars Um Because our section names are not just dot entry. They're like dot entry dot the the section Um, so we have it ourselves and this is what tells us when we've overflowed, which was nice Um, and then this is a new script. I don't think I showed it last week. I'm not sure how far I was last week um But this is the script that takes in the the ginga template and produces the the actual c file. So Um, I'm using typer, which is something I used uh for cascade toml as well And it basically automatically creates, uh, cli interface command line interface Based on python and python types So it will automatically take like the two first two arguments and make sure that there are paths And then this last argument is an optional string with the default of um empty string So What you could do is if there's a If there's a comma in skews we split it. Otherwise, we just have a list of one um, and then we we filter We create a a set of filters that we passed. So cascade toml I think as I showed it last time was just a It was just a command line application, but what I've done is I've split it apart a bit so that um You can basically use it as a library instead of it using it as a command line So you can see I'm importing cascade toml, and then I'm calling filter toml So I give it the path. So this is the root path. So this is where Uh, all of the toml definitions for nvm, which is non volatile memory is and then I give it skews Which is now the filter for everything. So what it returns is a list of fully cascaded definitions for all the flash So it's basically like given these flash skews give me all the settings for each of them And then what this Script is doing is it's figuring out the least kind of the least common denominator for all the flashes that you've picked So if all of your flashes can do Quad word read like e7 Then it will produce code that does e7 if some of them can do e7 But some of them can't but they could all do uh eb, which is um the quad read with four dummy bytes Then it'll produce that and if it can't do that Then you'll it'll fall back to the zero three, which is like a very slow read But the all flash all flashes should be able to do So uh, we're just checking that they're worse skews to begin with and then a couple helpers all have make sure that They all have a particular key and that it's true uh, and all match make sure that uh All of them polyfill for spy. Yeah, basically um All match make sure that uh, they all have the same value Um, so you can see here. We're checking quad enable status byte. This is which status byte quad enable is in Bitmask tells you which bit it is continuous status write uh is one way of setting the quad enable Split status write is the other way. Some can do both. Some can do one or the other It turns out. Um And so this figure is this will then figure out like Is there a way for us to do uh the status writes for all the flashes? That's the same if not it falls back to zero three again Um, and then there's this e seven quad word read as well Which all the giga devices could do which is on the feather rp 2040. That's why I support it Then we figure out the max clock speed which I don't think I'm actually using You can see here that um I'm saying if so, there's actually three states to these two status write ones. There's true false and and none um none meaning uh that They're mixed. Uh, they don't all agree so, um Continuous status write is none and split status write is none means that for all the flashes we picked There's no one way to write the quad enable bit Or write the status register Therefore we can't do quad. We can't set the the quad enable bit um Otherwise and I think Yeah, there's also quad okay here as well. So there's this check that says The enable status byte and the enable bit mask also have to be the same in order to do quad Um, so we default to read command with zero weight cycles If quad is okay, and we and we can do Um quad word read then we'll do quad word read rate two. Otherwise, we'll do eb and four And then you just throw that in a dictionary and then load the template render the template and write it back out um So that's what gen stage two does Here's the linker changes for doing the itcm and dtcm stuff Um, so it takes about I think 10k of ram, but it should be worth it. It should make execution faster, which is the goal Here's internal flash file system Here are the changes I made to the stk, which I actually have a pull request out to the raspberry pi people to incorporate Maybe they'll pick it up. There's a comment that says like maybe make this public So I think they have to have some debate about whether that's actually what they want Okay, so here's the stage two dot c ginger, and I think this is where I was last Last week. I was trying to get the quad stuff all going Maybe I also spent some time trying to read the the capacity at that point as well um Let's just go over this so we have some includes And some defines I changed some of the defines at the top here based on whether we're doing quad or not Um Because they're like used in multiple places So, um, that's all the same So g this is all ginger stuff. So if you see like It looks like it's gonna pick out. It's highlighting with based on ginger. So we'll we'll be able to see that um Regular like commands astraic data I think I I went over this right so we store the link register because we need to know Whether we're coming from real coder from the bootloader. We'll do that at the end um We set up the data lines and if we're doing quad we'll set all of the data lines rather than just the uh the input line Um disabled as a size set the baud rate or the divider which is implies the baud rate. We delay one um And then basically what it does is you have to kind of like you switch modes as you start up Depending on the the commands that you want to do So this is the most basic and this is this is the setting that we need in order to just like set the status register Um, so we'll set that mode. We'll enable it and then what we'll do is depending on the status register here And I don't know I don't think I tested all of this code, but It worked on it works for the cases where we're using it. We can fix it later otherwise So this is like depending on which status byte you have either read the first one or the second one Then you get the quad enable bit mask as well And then if if it doesn't match it means that quad enables not enabled So what you do is then you set write enable you We have wait and read so it like it waits until everything's done Which means chip select has gone back high and then it reads the the fifo of whatever it is I had one bug where I wasn't matching my rights to reads like I was I was Writing two bytes and reading one which meant the thing later that was trying to like Know the second byte was something was was wrong. So like getting those matching was was a pain um And then here you can see like if we're doing split status, right? We do this thing Which allows us to just do one write So we we write the command and then we write the value Otherwise, we if we can't do a split status, right? We do a status one, right? But if we're writing to the second byte, we do an empty zero first before we give the quad enable byte and then we wait Um, and then we wait for the right to complete which is another issue. I was having This was not working correctly which meant I was getting to this later stuff And it was failing because it was in the middle of actually doing a write So we disable so that's at this point the quad enable set Which means we can now switch to quad if we're doing quad So we disable again. We set up to do a single read But this format here Is also the same format as if if we're not doing quad. So this gets used if we're not doing quad um Or that's shared. There's two control zeros, which is really confusing So if we're doing quad, we have this intermediate state where we re enable We send our write send our the read command we're going to do and make sure we read zero zero zero zero With the continuous read mode set Which is basically a way to save the eight clock cycles to send the command again So that's why you have to do like one special read at the start for the flash to like get into the continuous read mode And then once you're in there, you can set your final settings, which means that There's like if you look at the datasheet They say like we modified this peripheral to do this fancy thing. So if Instruction length will be zero in that case, which means that it actually puts the command after the address not before Um, which is a bit of a hack, but it allows you to send that like yeah, keep keeping the same mode bit um And this is where we set weight cycles. We say how long the address is and read instruction If you're doing quad read instruction will actually be that continuation mode. It won't actually be the the instruction itself And then transaction type tells it whether it's quad or not And then we re enable and basically we're all set up at this point So the first read that we'll see is actually this one here So no, I take that back. This is making the pointer um, and then we set The vtor. So this is the vector table offset this changes where All the interrupt handlers mapping is is located And then this is the first read we actually do we do we read the first entry of the vector table into the stack pointer Because that's what is stored there And then the second entry is the reset handler address So we read it and then we branch to it and we're done We have two helpers. We have weight and read which is just weight until The transmit fifo is empty So that will be zero when everything's out of the fifo And then we wait for busy to finish. So the busy bit is high as it's transmitting it drops low Um, and this I had an issue with as well I wasn't correctly waiting. So what I was seeing it in the in the sale. I was I was seeing like Five of eight bits being done and I was like we should be waiting for this. Why aren't we? And it was because of this This check was these two loops were wrong. These are correct now And then I have the the read part. So For given count we read in the result, but we only return the last one And then to read the status we send status twice and then we wait and read too Okay, so that's the gingefile and that should I think cover kind of all of our bases currently Um There's a chance, you know One thing that we're not really handling is that there's a chance that boards may want to do dual mode Which is a mode that a lot of these flashes can do where they it works like quad, but it's only two lines instead of four Um, but it's all different commands. So it wouldn't be hard to support But I don't think any of the rp20 40 boards use it yet um So it would have to be added there and and all the data to nbm tumble as well um Any questions I don't know how many more files I've got I'll keep going through it so far. It's looking good. So I you know, it's a Once I get all the way through it. I'll be able to do uh Make the pr I do need to test erasing and re recreating the file system I think that's the only time we actually need it But then again, you know me I kind of work in the way of like I'm pretty sure it's correct and then we get it out. We find the issues when we fix them um, okay So here what we're doing is restoring flash slides statically This is in port's raspberry pi supervisor internal flash. So that only applies to rp20 40 We uh, this binary info is fixed in the in the flash image So we just pretend to that we have a one megabyte um Block device just to the pico tool Uh, it won't work won't be correct, but It's fine And then what we do is we do a read here that reads the rd id register And the fourth or the third byte back is uh power of two size And we just validate that like the the data we get back is within the kind of Reasonable range because there is one manufacturer that does it wrong Um, and so it'll default to 21 which is uh two megabytes um Otherwise it says power of two to that and then flash size is is one to the power of two And then you can see here that the one place where we were using total flash size We replace it with the static flash size Which should happen after uh flashing it So that's that Okay, so this in port is the The dtcm itcm stuff So basically as we do port in it before we call any of those functions We need to copy the contents of those functions So I just cribbed this kind of straight from the imxrt stuff This usually happens in reset handler, but because we're using the pico stk We don't actually have access to the reset handler But everything that we're storing in that region is like has to do with running the vm So by the time port and it is called like port and it's the very first thing in main So it's still plenty early um Oh, yeah kmatch says hopefully hopefully we get an appearance from trevor on the deep dive when the ble stuff gets integrated with phone apps Yeah, hopefully, um I know trevor is in new york, so i'm not sure how How well the timing works for that, but I could ask him about it And he's a new dad too, so he's pretty busy um, but yeah, so this is just the The case where we copy From the flash version to the ram destination, and then what we also do is we um Set the flash copy to zero, which should flush the that line out of the cache um So I was starting to think about like the execute place cash stuff So that's that Um, and then I had to change a few things because we're doing internal flash file system with external flash Devices, so I had to be morris. I had to change a few of these checks here um This is the thing that changes the macros for the tcm stuff, and I added raspberry pi blah blah blah Again, this is just changing a check. Um, yeah, and that's it. It looks really clean to me so the last thing I want to check is um Actually, let me just see if the the erase works while i'm thinking of it So let me I'll toggle data on So circuit pi popped up And one of these is I guess it's it's this one. So if we look at properties We can see that it's three megabytes, which is not correct. Actually, it might be correct Because this is the the feather that has the uh It has the I don't know what flash chip I actually have in the socket Um, okay, let's just eject it and we'll run erase file system. It should be three I mean that looks right. It's not the default Um, and we had two acms and one of them is the time codes This one is hello world. So this is the feather arp 2040. So I'm gonna import storage Oh, hopefully this is working Erase file system and it disconnects And then it should erase and then it should restart. Yep. There we go And now we're on there again And let's just do the same thing we just did which is click it And we have another hello world and properties And now it's seven megabytes. Okay, so I must have an eight megabyte in there Maybe it was wrong before um It's possible that that could be lying to me, but I think it's correct I don't actually know what this flash chip is, but That's good enough for me. I just wanted to make sure that it that it worked well enough People will test it and let me know if I got it wrong Um, all right, so that's looking really good. Um Um, I'm actually very pleased with that. So the the other two things I wanted to check were This is adding Uh, python dependencies to the build. So I actually just want to go over the learn guide about building circuit python Um, what does the chip id say? What do you mean? I can't read the Chip itself Yeah, this says 64 on it. So this this is an eight megabyte chip So that was correct It was correct to flash it to that The four megabytes originally might have been from a previous version. So um Yeah, the electric the electronic id does indicate the flash size. Let me show you I've got if only I could find a flash data sheet here Uh, here's one Um, so one of if you're Have I have I not shown a flash data sheet? Let me just Let me just go over this Because I have a ton of them here. I don't think I have have I So this is for the wind bond 25 q 32. So 32 is bits Which means it's uh divide by eight for how many Bytes it is Or megabytes So Uh table of contents is really handy as always if you can have a a reader That's that does this too. It's really nice to skip around data sheets um So let's see sections wise we had general description package types pinded descriptions block diagram status status register Handslap says hi y'all just got out of a meeting my new chair rocks if anyone was wondering what chair did you get? That's that's the follow-up question Um, okay, so if we're looking at a flash data sheet which confirmed to me folks that I haven't gone over this but um So the the two the two spots that I Look the most is status and configuration registers This will tell you what status byte and what bit quad enable is so that can be really handy And then the instructions in particular the start of the instruction section is usually really helpful um Here you can see actually see uh Oh, I I didn't didn't see this so there's this device id and instruction set table. So This is actually what 9f is loading. So it gets an ef and then it loads these two bytes um Which is Not Not right. That's not what I'm thinking I don't know what that's for. Uh, oh so instruction So it So it returns 16 Which actually seems kind of low to me I thought it should be higher than that So what we can do is look in the nvm tom all wind bond 32 jvi q. Yeah, it says 16 my my My math is not right Let me double check internal flash I said between 20 and 30 But it should be returning 16 What is 21? Okay, let's get python out python One to the 16 65 5 5 5 3 6 Yeah, that's that's that's definitely not right I Don't think that's right. I would expect it to be like this data sheet must be wrong like one to the 21 is two two megabytes One megabyte is one to the 20 Yeah, so it doesn't support anything below a megabyte But this data sheet is not right But that's weird because this capacity lists it Oh, you know, it's hex 16 That's what's messing me up It's 22. Okay hex is complicated Hemslav has a chair that was highly rated on tom's hardware and knows 154 dollars in amazon Check the discord if you want to see that Okay, so capacity we can load from the chip and it's just like the The power of two for the capacity And it's generally correct But it's not always correct. So I that's why I bound it a bit um So that's all correct That works Oh, I was looking at I was looking at the data sheet, wasn't I? So the other thing that's really handy is this overview of all of the commands that you could do So you can see here that like 9 0 is this one and has two dummy bytes of 0 and then manufacturer an id But we the jdeck id is the one that we use Which is 9 f and then these things and then read read unique id 4b is also used. This is actually how we get a unique id Uh for for the rp20 40 because the rp20 40 chips don't have a unique id at all um Oh AT makers bill asks how consistent are these commands? Is there a standard? There is a standard um by jdeck but it's uh It varies some It varies some so, uh Some of these you're you're just going to find on everything like I think 9 f is like Always going to be the same right enables going to always be the same like the core Commands are the same where a lot of the variation comes is What's quad modes are supported and then also how you enable quad mode? So if we go back to package types, what we see here is like The eight pin flashes that have these pins that do kind of two things like that. This is wp is right protect Yeah, luke luke ren says there are many standards not just one standard And that's part of the problem Um, and that's something that i'm trying to capture here, uh in the nvm toml So if you look in nvm toml, there's an nvm template dot toml And I have comments here for all of these different settings that are captured in it So you can see here quad enable status byte says status byte number that contains the quad enable bit One base to match flash docs This one says supports writing 16 bits to the status registers first two bytes via command zero So the template is actually very handy for knowing what all of these settings are um, and so this this is meant the nvm toml nvm toml is meant to be a like use case agnostic database and i've said this before of Human human modifiable and readable but also machine modifiable and readable And i've been pretty happy with it I added some i added like a rename command to the cascade toml as well for like renaming some of these So I started doing that Um, but it's meant to just be a catalog of stuff Um, and it's working out pretty well, so That yeah, so so one of the things that varies is how you switch these pins like Right protect from right protect to being i o2 and then hold or reset from from that to i o3 Um, and so that's where this status and configuration register gets really Is really handy and what you're looking for in particular is the quad enable bit Um, it's usually qe so you can see here It's it's status nine, which means it's in the second byte and it's the second bit of the second byte Um, and then we we ignore all these others all the other all the other ones um And then like I said this instruction table is really handy because it can show you what the instruction is and then also like the pattern of how to use it So like what comes after it? And you can see here like all the different, um, modes for reading as well um, so here you can see like eb is Three bytes of address and then a dummy, but this dummy has a a super 11 and then there's two more dummies and the super 11 says The first dummy is m7 Through m0 and it should be set to fx h um Which is interesting because it's actually a0 h for continuous stuff um But yeah, so this is a great way to look at um Great way to look at different flash, uh Sheets the other thing I guess ordering information could be really handy as well um Good afternoon paul Espressif has an esp 32 s2 hmi dev kit. Is that hdmi or hmi? Paul says I just ordered among other stuff to feather rp20 40 is awesome Hope you like them. I'm really happy with mine. Even though one of them's been quite abused Um ordering information is really handy because it helps you decode what the the skews are um, and I'm still not quite sure With the wind bonds in particular there's cues and m's And cues and if you look in their website, they've got if you look here In this tab that I've got open You'll notice that they have a regular part number and a dtr part number and they're both Production and they have two data sheets And it's not clear to me whether like all parts are dtrs as well Or or these are just for old stuff. Um It's confusing to me and I tried to order some but you can see here that like if it ends and I If it ends in q it's A fixed quad enable so we don't actually have to set it And then it's backwards compatible, which i'm not sure whether that means that like some of the Changes oh human machine interface, okay For the s2 And then m is is uh, you have to set quad enable And it has a different device id so in nvm toml. It has two entries one for each um because the device id they're the nvm toml stuff originates from what circuit python had and um circuit python had device id it it what the way that Its external flash stuff tries to work is it it loads the rd id jdeck id And then it tries to pick it from its options and only if it matches verbatim will it actually use it Uh, which is why we're i'm trying to like move away from that so that we just trust the capacity Um of it instead Okay, so I think that's about All of the flash stuff the last thing I want to do is I actually want to just make sure that um People will still be able to build circuit python now that i'm adding these dependencies so um one thing I want to check is just um GitHub.com a different circuit python I just want to look in here Documentation code search Contributing so I think contributing here is old um Let's just give this Way to contribute Um Build instructions here. Okay, perfect. So this just links to The build instructions um Hamsab says lamor was talking about erasing the flash taking a long time in manufacturing Might have been on desk of lady aida this chip has a Had this flash has a chip erase command that is quicker than doing it block by block Yes Chip erase tends to be But if she was using uf2, which you might have been uf2 does it does the erase block by block Um, which is what you want because if you did it all Together you you would like blow away your file system When you did just a portion of it The tinkerer says about to solder the headers in the rb2040 feather. Awesome Isn't the most recent built python built info here? I don't know Probably not paste and go What does this say? I think we're better about keeping Oh, no, it has pre-commit in it This is the problem So I do want to have this there so Yeah, we're one thing we want to do is better be better about this as well How do we get there though? Like this is This is where I link people Okay, so here's something interesting. It has this pit three install huffman I think what I want to do is I want to add a requirements dot txt Into circuit python and then have all the requirements so that this line like wouldn't have to change Found it. Todd found it by trawling the repo So that's not where I look but I think randy's advertising that they have their own pico breakout board Okay, um, so I'll I can update this And although I don't know if it Says what directory you're in In a terminal window do that? Let's just take a look at So this does pit three install brew install of usl And you'll set up All right, so I think I think is it requirements dot txt or dev requirements dot txt. That's the right File to add fetch the code Oh We're gonna want to do this first When to make clean when in doubt make clean Okay Choosing a different files Spy flash chip There we go That's handy What a good guide. All right, let's just look at dev requirements See if there's a a proper Oh, it's requirements dash dev Like requirements dot txt I think that's what we want, right? See what this says Could you indicate in that guide that a pre-compiled mpy cross exists? I don't know if that's the right guide because I mean we could But like that's not really library like that guide specific to building circuit by the core Okay, I think we can just do Requirements dot txt I just want to make it simpler to install stuff So text I think that's the last thing I need to do and then I can Pull it. I always like It's it's a little weird because I'm adding like the ginger dependency and I'm adding um The cascade toml dependency, but I had both Dan and Jeff looking at it and neither of them said like this is bad Which I kind of expected them to be like, well, what are you doing? Uh, so I'm pretty excited about the nvm toml stuff like Jeff was already like, oh, we should use that on imx as well So I'm hoping I'm hoping I hit it Like designed it right Um, okay, so let's just what what is this setup dot pi? Oh, look at that Wait, can we just Build it Does this just work? This is for um Let's just do requirements dash dev. This is for pushing circuit python steps Which we should definitely do Um, I just don't know if it's working still And I only want to have one Requirements dash dev dot txt Okay, we require huffman We require cascade Toml and we require ginger 2 I think that's it ports Raspberry pi So anything that those things depend on will be installed as well But we can keep this list to a minimum Let's just look at here. Am I importing a oh typer? Um, so we'll do typer as well Okay, so those are all the things that we need to build And I think that's all I need to do need to add Where is this other doc building? All I might as well update this Debugging code quality checks I think maybe I'll leave that 18 makers bill says is there a separate build process etc for just the blink of libraries does this impact that this does not impact them at all No, and in fact We want to better We want a better, um Document all the pre-commit stuff for all the libraries so that we might make it I may take an interlude at the start of next week to just Write basically this code quality thing up in all the read-me's if it's not there already Um You know, I think I needed p.o. Live as well For pre-commit. Um, so I'm just gonna add that as well I'm remembering right And let me just do in my repo Get status Okay, so I have a new SDK commit because I had a typo and I'm Source there pip install requirements dev Well, bam, okay, so I installed Huffman because I didn't know that install But it validated that it could install all the things that I listed, which is good Okay, so that looks good Uh, let me I'll add it to the building as well Although I feel like I should also Oh This links out to the building. This is a quick start only Some module sync All right, well, we'll do that Johnny says just a heads up scott. You've been streaming for 80 minutes Indeed I've got an alarm on my phone set for a 3 30 though So I'm I won't forget and it's like that time gives me some time to get like he's just sleeping He's easy to grab It's the nice thing about having the door closed too is he can't get away from me too much um Foaming guy says I'm joining in late, but I So I'm not sure of all the fault of context what I'm working on But I don't think like the libraries typically need to be built. They're python only I believe Yes, so I think that's one reason to re Look at the the read means I think we need to be clear that libraries tend to not need to be built Only if they're going to be distributed. Do you need do you need to do that? Okay, so I don't actually want to update the learn guide quite yet because It's not checked in But let's uh Oh, you know, the other thing we need to check is the ci Because the ci will break and all of these boards will stop building If we don't fix it, so let's see what build ci does It sets up python And then it does pip install Oh, yeah Look at that long long list You know what I think what we should do is let's just move all of these into there control x And then we'll do pip install r and we should be in the right directory requirements dev dot txt And in here, let's do Like I just want to have like these are all the things that you should have installed I think we can put comments in here too for docs Check if I fork circuit python and make a local change will the ci run and compile it for me on my repo I believe so. Yes I think these are for pre-commit These might be old too, but that's why I'm sure what these are exactly for but We shall unify towards one thing Po-lib twice. Thank you gareth so huffman is for String compression and this is for nvm.toml Yeah, that's what like requirements dot txt is nice for it's just like I just want All the things we need for the environment Yeah, so those must be for these other checks Which is fine mpy cross mac. Okay, so we might have We won't need it for mpy cross. We will need it here Pip install. Let's make sure that all these are Hi daniel Thanks for joining in I'm just about to wrap up and take the cat to the vet But I think I my timing should be really good. I should be able to get I should be able to get this pr out Here we go Might just alphabetize it. Yeah, I could do that too. I do like to say what they're for Let's check these others Although these don't build so maybe it's okay. The repository is gonna be there It's like, yeah, I'm gonna install extra stuff as a result but Then I only have one place to worry about Request such a click set of tools AWS CLI I don't think AWS CLI is actually for there for pre-committed but This is for uploading artifacts. All right, good enough. Let's just run the Requirements install one more time And I'm getting AWS CLI and stuff. That's fine. It worked Okay We want all of this Failed. What did it change? Any questions for the last eight minutes? This should be exciting. It should make it really easy to maintain Flash info for all of our circuit python stuff So I'm quite excited and I don't think I need to rebase Quite excited to have a central database of settings for flash Even if I haven't moved everything over yet I restarted my computer and let's make this pull request. I won't even draft it I should be able to This comparison Is there a toml parser for circuit python or is it is it just c python? There is not for circuit python. That's a good question There's a couple for There's a couple for regular python though And there's the one that I like to use is called toml kit And the reason I like to use it is that it preserves enough information for formatting So it allows you to round trip with minimal Like it preserves all the comments and stuff, which is really nice And so I'm using that and you'll see that like oh you want these three things and we're merging it together Like it merges comments together too, which is really nice Like I like the output a lot as a result Okay, so this got both commits And We haven't actually tested the um We haven't tested the ci but This will test the ci for us a best case stage two For all the possible flashes And we'll work With others Have the same capability as well flash size Are there other languages like circuit python like circuit c plus plus or circuit j s No, I mean there there are there is a javascript I think it's called esparino. It's kind of like the equivalent And then um if you're down in sea land, um you can use Like circuit python has c level apis that mirror the python apis Which is what we use internally Based on the flash There is lua javascript several lists several fourths This is this Also moves some code And data into ram So that it's space is freed All right labels Enhancement rp2 And some basics Uh lady aida just asked if Wanted to jump in This also moves tcn designated code and data into ram six four requests. Yeah next week Oh lady aida says they just put in 700 rp20 40 feathers So if you want to get them get them now And it's aida fruit dot com slash product slash four eight eight four Tiny go Garrett says circuit python is the standout choice for getting started with microcontrollers Um AT makers bill says we are looking for a way to do config files on both Arduino and cp for now We're just using json christian is working on pulling the config out of the arcada libraries to use standalone Was wondering about the toml format. The nice thing about toml is that it has comments Jason does not but json is supported. I just need one for my rma. Did you have a bad one? Um, I'll put the link in the youtube as well and for completeness Um, let's wrap up Um, let's go All right. Well, thank you everybody for hanging out. Sorry. It wasn't the full two hours and uh, we missed lady aida Which is a bummer Next week will be on thursday because we're going skiing. Hopefully uh next week Um, I just have to remind lady aida. So you all are now tasked with the job of reminding me to remind lady aida as well About thursday next week um Let's see, uh, super happy to conclude this flash stuff. I think it's in the right direction And hopefully, you know, folks will find cascade toml and the nvm toml really useful for other projects as well The goal is that it's it's you know, kind of a project agnostic Repository, so I would love to see it become the tiny usb of Flash settings, I guess um Looking like next week. We might like take a look at library process stuff a little bit, uh, but then uh getting on to billy billy workflow stuff is next up on the list If you are using rp2040, um, I recommend always keeping the latest dan just released beta 4. So thank you dan Um, and we're like very close and dan's pushing to doing a 6 2 um A 6 2 thing as well. So there's my alarm um Yeah short stream there's I have a vet appointment in 45 minutes So I wanted to make sure and give myself time to to get everything ready and throw him in as crate and stuff. So um Interesting um Awesome. Well, thank you all. Uh, we'll see you next week on thursday. Uh, again, we're in the discord A D a f r u dot i 2 slash discord And also, um, if you want to support me support adafruit by going to adafruit.com Now's a great time because the feather rp2040s are in stock um, so Feel free to check that out and um with that I'll give spooks and pets Even well, he has nowhere to run and he doesn't realize that he's going to the vet So I'll give spooks and pets to to wrap up and we'll see y'all next week It's just his annual. It's just his annual checkup. It's no big deal. He's just got to get his rabies booster Um, and he's been doing so well. So I'm I I hope they say that he's been doing well too All right, thanks everyone. Oh, he's like dad pet me more