 The story so far. I am porting Fusix to the ESP8266 Currently I have it in a state where it boots quite happily and runs all the way up to the login prompt The file system is on a SD card There is a reasonable amount of flash, but it's too slow to run off due to the rather Swap heavy nature of the system boot time is respectable. Let me just hit the reset button and demonstrate There you go At some point I should get a full stick working So nearly everything works including a timer, although it's not very accurate due to Quite a lot of stuff happening with interrupts turned off It's running in single-tasking mode due to the limitations of the system, but actually I can probably run it in Multi-tasking mode the swaps fast enough. So Today we're going to work on the last major piece of the puzzle, which is You can't actually interact with it, which makes it a little tricky to use First, however, let's just do a little bit of Maintenance on the flash Now that we're no longer Copying the file system on to flash We can make the image bigger so current this thing has four megabytes of flash Which is five hundred and twelve Let me start that sentence again, it's got four megabytes of flash the flash it's the file system partition starts at one megabyte and Extends for five twelve arrays blocks, which is Two megabytes so we can actually extend that If we have this that means the file system now starts at 512 K's into the flash giving us five twelve K for the code We're actually using about forty eight K of that, but this gives us lots of buffer if we need more and So that's three and a half megabytes, which is the three five eight four K, which is 896 arrays blocks so you can actually do this and Make the flash file system bigger. It's slow, but it's there so we might as well support it and There we go two and a half megabytes of Usable flash It's just created a new file system This does this if there's no file system found But when I say file system, I mean at the FTL logical block device has been created There are no partitions and no physics file system Let's commit that Okay, so we want to make the TTY work well Right now I'm using the ROM routines to read and write bytes Well, I'm using ROM routines to write bytes. We're not reading yet The way the TTY works in physics is it strictly interrupt driven? You notice that there is no TTY get see way it works is Once the TTY is set up and running an interrupt arrives to say there's some data TTY interrupt here then pulls the byte out of the read buffer and Pushes it towards the TTY device Oh This TTY device and sticks in his buffer and then delivers it to the process When needed So the actual primitives are This one detect this one polls to see whether it's ready to a write Set up Something to do with modem Don't know about this one And I don't know about this one So let's take a look at the MSP430 version Which I'm basing this on So here you can see that the put C is very straightforward We we spin waiting for the buffer to be empty and then we write the byte Sleeping is null TTY white write ready just polls the transmit buffer status and Returns one of these enumerations Setup is no up carrier is no up data consumers are no up. Yeah, very straight forward And the only issue we've got is actually implementing it anyway So I've got the Rom this is simply here. So if I go to ETS put C See what it does this just calls You are TX one char Which actually does the work and There's a comment So this is actually pretty lightweight. It's not calling any additional functions and Here is Rx one char. Oh, there's an interrupt handler Very interesting. I hope it's not buffered. So we've got TX one char Rx one char blocking Rx one char presumably polling So what is this? doing These are some constants This loads a byte multiplies a to buy a for a to is this you also Don't see much in the way of hardware registers Okay, let's find where I put this documentation is a UART mentioned or is this in the Technical docs. I think this is in the other document So if the ROM routines are buffering then we may need to Do some additional work? Okay, I'm apparently I can't find the That reference be nice if this had hyperlinks as well as being you know More complete better written Etc. There we go. You are so we have one read write UART and we've got one write only UART Time for debugging. We are using the The read write UART the ROMs already set it up, which is nice. So we don't have to worry about board rates or anything Okay, this is useful. This tells us how to access the The two hardware five foes This will tell us whether we're ready to read or ready to write the I was actually expecting a one byte buffer, which is what the code here is expecting so Tty ready can be ready now ready soon or or ready later so Given that we have a buffer If the buffer is not full We are ready soon if it is so if it's not full We are ready now if it is full We are either ready soon or ready later probably ready soon for our system. So The FIFO length is not necessarily the one we want Figure interrupt on the screenshot of the interrupt handler, which is actually quite useful. Well, and that's about all there is to it Okay Does it say which How the interrupt is delivered Wow 128 byte buffer, that's quite big So what we are looking for is we want the interrupt to happen whenever The received buffer is not empty. That is there is buffer waiting. So we've got Receive buffer full don't care about Receive buffer overflow These are very similar Receive buffer full will happen When you've got flow control turned on and the UART will take care of turning of telling the sender to stop sending Receive overflows if there isn't any flow control and we don't have flow control when configure threshold value of tout Enable interrupts and UART begin to receive data. It will triggered tout interrupt Once stop transmission time exceeds the set threshold. I think what this is doing is Yeah, you get an interrupt a short time after data shows up So this is the one we want so we need to set up an interrupt handler and Use this particular interrupt Now the fact that the ROMs got this It's own interrupt handler Suggests that the ROMs already set up its buffer so that Incoming data will get sent somewhere I think See we can very easily just override this and set our own interrupt handler So that the interrupts will now be coming to us rather than the ROM I'm just wondering if this is going to upset the Transmit code and this is the init code that sets up the clock speed Which we have overridden all these mem w's and memory synchronization Instructions and they'll indicate that something is fiddling with the registers. I Believe a five is the register base Maybe Right, well, I think that what we're going to have to do is to change Kput char so that instead of Calling ETS put see We talk directly to the hardware So that should be Documented or of course, I could just go look at the Arduino code. It's probably much easier Copy what they're doing. I don't see any reference to the actual data register. I hate that documentation Okay, so Somewhere in here, there should be a reference to you art Like here perhaps this is more complicated than it ought to be because There's some stuff in place for Or Gdb You can use gdb to debug on you Arduino programs which is Rather nice really so it's I actually don't see Here we go. Here is You are doing things. This is interrupt enable. Yeah, this is configuring the ISR So we actually going to want to use some much the same sort of code But I don't want to go there yet. I just want to This is what we want this code. In fact these three functions okay, so So what we're gonna do is You you are TX5 for Full so it's full if there's more than seven F bytes available. That doesn't seem right to me now of course we get the choice of whether we're using the Arduino registers or the SDK registers, I'd rather use the Arduino registers because they seem to be simpler So this is going to be USS is one C U1s so so this should be the number. This is the TX5o count new art status Okay, let the actual register documentation in the SDK stuff is less bad than the rest of it So let me try and find that that should be at the bottom somewhere UART and we're using one C so this is UART status the level of the UART TXD pin eight bits Is that the? No, that's the default value Okay, so the one we're actually looking for is this amount of data in the UART TX5o So what this is doing is saying we're going to consider the UART full if there is If it is more than half full, which is reasonable so For TX5o available. We're just going to go U1 F See I might should add the reason why I'd rather use the Arduino definitions than the SDK definitions is Because eventually I would like to make this code completely independent of the SDK Which right now you have to refer to in the make file to get headers and that's a pain in order to build with so I would much rather replace that dependency with The Arduino stuff that we can just cut and paste into our code. Okay, so this should now be using our own code to write with so let's Build and it doesn't work because we haven't concluded the registers Okay, so that doesn't work Because I am using UART 1 rather than UART 0. There you go So no longer using the ROM routines. Let me just Yep, we've declaring them But we're not using them Okay, so write ready is very much the same code So we're going to say I will actually put this into its own function So this is just going to be TX buffer fill It's greater than equal to 7f then We're actually ready now, but If it's less than that then because say we're ready now Okay, so That's told us how to Write I think the next thing we want to do is I mean, this is all setup codes that we don't care about is We want to register our our ISR We are not using TTY in it for this Is TTY in it actually called anywhere? Yes, it is We could use TTY in it for this you see normally we would attach our interrupt handler down here Yeah, let's just use Okay TTY Let's put this at the bottom So whenever whenever we get an interrupt we print a queue and we probably Okay, just making sure I understood how it worked. We probably want to I Think for an interrupt you get you get This prototype now. It's not ETS compare zero I num. This is a SDK function. So Eagle sock Okay, where is that coming from? It's not say Is this an Arduino? Oh, it's not to find anywhere. We had to do that ourselves and very luckily There is one so that is you are I num Okay, we haven't set anything up yet. So we have to do that This will be in the ESP stuff U0 U0 ie. Yeah, so We actually want to configure some of these so let's take another look at the you are stuff and look for US ie. So this is where It's configuring Yep, that's This is just what we're looking for. So let's just cut and paste all this code Down to here Intrigue Intrigue that 16 When the RX 5.0 full interrupt triggers the value of one triggers a lot Value of 127 will not give much time for the ISR to clear the five for the next byte is dropped Okay, so this is the This is the the RX fill level that we want to actually Make a We want an interrupt to happen at so you see Tot Also, I've just realized remembered rather the buffer is Seven bits wide. So this actually means full So Yep, that's correct. That's not half full. That is full full UC tot is hmm Do we need level and this this will generate an interrupt if I understood it correctly this will generate an interrupt whenever the Whenever data shows up So I don't actually I think we can do without the RX 5.0 level interrupt Because we're not as sophisticated as the Arduino code is so Okay You know interrupt here We want to do this with interrupts turned off. So we get a atomic change So that clears all the interrupts This is enabling Rx 5.0 full interrupt. No, we want Rx 5.0 time out. So I think that's everything So I believe That may you'll be all the code we need so it boots my press a key I Fantastic, it's working We get lots of cues because we haven't actually read anything or cleared the interrupt So what we want to do here is we want to keep Reading bite and delivering it until We have run out of Until the the FIFO buffer is full Let me just go look up where TTY in proc lives It is of course in TTY See, I don't know what happens if the If physics says TTY fills up. I don't actually see any code in here Do we really want to call this from inside an interrupt handler? Right if the key was full it drops the the byte and beeps at the user Okay, so I think this is the right one. So what we want to do is keep looking Yeah, this is the code you want so we want a similar function Rx buffer full. I'm gonna bet that this is Rxc so while Rx buffer fill Is not zero that is while there is some data read a byte Send it to the TTY And we will also need to clear the interrupt. I Hope I've got that right Well, it builds Okay, here we go fantastic It works look LS works We have a completely running system Control C works. It's a little drastic, but it works Okay, I don't know how the this F disk works Okay, so it's listed all our partitions here is our SD card here is The flash Where does geometry come from? I want to partition the flash you see. Oh, right. We haven't implemented this Get Geo. I Don't think this is implemented It should be implemented here, but it's not Anyway, okay, what else have we got? You've got time which I think is not going to Produce anything useful. Yes, zero time taken for that command. Oh PS. You're all our processors PS minus a Init should be on that list. I was the thought Who am I root of course? Oh, yes So this is our boot script. Remember every time we run it We get an error saying that it can't create the utemp file. So we should just be able to Make dear run Why can't we make run? I'm sure I have right permission Yeah That's not good. What was it doing that address? Oh interest. No, I'm going to the wrong address Yes, this is the this is inside the ROM 101 DB No, it's inside the user program Mount crashed for some reason Okay. Well, let's hit the reset button Cannot create There's no M tab. I don't think the file system is rewrite So that's because I actually commented out to the this line Okay, so now it should be rewrite So we should be able to put root prints the the current root file system in a m tab Compatible Format Okay, that's working and give our run Okay, do we have the editor? Yes tab doesn't work Elvis File, I'm not sure we do you've got said Yeah, I don't see anything Okay. Well Yes, now one issue is that the delete key doesn't do anything I have to type control H instead That's actually configurable somewhere And we just need to Edit the TTY somehow edit the TTY configuration Somewhere we can reduce this which will Limit the size because we only have one working TTY the other one is right only Okay, there is our C I'll edit this on the PC. I'm going to have to build some more stuff anyway Does DF work now? What do you mean you can't open m tab it's right there No, it's not m to bar bar No move Right the reason why The reason why that file name was wrong was me mistyping and then trying to use delete Okay, let's remove this Cannot remove Interesting well Right DF now works We've used 62% of our file system do we have mukfs we do Okay So let's try Mukfs dev hdh just use the whole thing 83 2048 and see what happens Confirm yes So now there's be a long pause while it does stuff to the man flash Probably a very long pause. I wasn't aware it was going to do this. I thought it was just going to write the file system structure Anyway, well, that's going Let's check this in and let's go and look for some more applications now We do want oh there we go it's finished, okay, so we should now have We should now have a file system on hdh so dev hdh Again mount dev hdh month There you go There is our flash file system mounted so touch F Through Do we have copy? We've got copy So I can copy in F disk to here Works fine unmount it Interesting has that actually unmounted it. I think it hasn't so I don't know what error that's producing We're missing some stuff. We don't have them We don't have move which is odd so Very odd It might be another command probably cp hardlinked to move the reason for this is If you move files if you move a directory from One file system to another it has to do a recursive copy and then delete So MV is going to have to contain nearly all the code of cp anyway So you see there it's fetching the program name. What does it do with prog name? Yeah, is it is it the cp personality or the move personality? so To do that if you want to copy you want to link cp to move But we can't because there's no ln Okay, let's go find ln Um This is also ln Okay, so we've got copy. So you want to copy copy to ln right Then we link copy to move Now we remove You still need ln to we link copy to ln one Then we move ln one to ln Right, we now have Ln cp and nv Are all linked to the same file on disk. This is the inode count So this is similar to symbolic linking except it works the file system structure level Unix file systems are garbage collected. You can have as many directory entries as you like pointing at underlying files And normally you have one directory entry and one file Which is indicated here there like who am I is the only thing pointing at the who am I binary? But Now we have three different directory entries pointing at mv the underlying data will only get freed up when the last Directory entry disappears and the reference count goes to zero Okay, um No, I can't remember what I was doing now. I Would still like to be able to unmount that file system. Let's Yes, sync works the list looks like it's working So anyway, we want to ln cp to mv cp to ln This these aren't commands that are run. They are Directives to the ucp program. So that will work Here we've got the v7 stuff So we've got programs like tty retails use your current tty Rev reverses a file like so I'm not sure pipes will work. So let's just try this Right, they don't have to come you control see that Apparently we can't That's because we're running in single-tasking mode What other useful stuff is there? It's actually quite a lot of programs. Oh, of course, we've done util Ues micro emacs things like the 6a to 9 assembler or the small c compiler, which doesn't know how to talk to Which only knows how to generate code for a few architectures of which this isn't one won't help Levee is a Vi like editor Cursors games are games What's in DW Drive wire that only makes sense if you're on a device that's got drive wire cp ends not much use because This Isn't a z80. What's this? Oh This looks like more old unix utilities Okay, let's hit the reset button to reboot that Yeah, mounting dirty file system. I think we've actually got the bulk of the useful stuff We could build the games, but the games will probably want cursors Well, there's of course they want curses. These are the curses games So you can build command line games, let's do those so applications games make file Okay, now, how did we do this so we don't need any of that? I think the rest will just work So we need turn cap is that library so Think that will work good not good this is a Host compiler interesting and so that should be this is presumably Building a utility that's being used to build other things. There we go So we've got lots of these missed things. It's an adventure game of some description. Okay, this is This is a manifest listing the um Contents of this directory So we should be able to use this to update our Script to generate file system This will have been processed. This might be my late unlamented build system We can do this easily enough We want to be in So this now wants to be that was all wrong. These all want to be be gets Let's get them all actually Okay Duplicate these Trek stuff wants to be separate applications games like so These want to be the CH mods, which are all those 755 But from a few others Fortune dot that is a data file. So that's going to be 644 Okay, so This isn't a very nice way of building a file system there isn't a standard applications games Star Trek Yep, okay, so Unplug the card Plug it into my PC Is it SDG it is so we should just be able to now do update flash Okay, it ran out of space because the file systems Too big. I wonder if we can make the file system bigger It's 32 meg Okay, so let's me just try something a bit Shifty create a new primary partition to make it the whole whole thing Like so 1.8 gigabytes and Write it. I don't know what the physics maximum limit for a file system is why I need to increase That okay, that's better And why doesn't it why isn't there a tailor made? That's because it didn't build. That's why Okay, it didn't run out of disk space it ran out of file inodes But I am honestly a bit fuzzy about what that number actually means 17 is exist. We already have a user lib. Okay Right unplug out the serial terminal again Plug and hit the reset button and I forgot to update the I forgot to update the RC file. Well, anyway, we're now read write And I'll copy this so that we Get a m-tab Games So here are our games. We should be able to run. Let's try a fortune Thus speak the master programmer without the wind the grass does not move without software hardless Hardware is useless. Well That's Very true. Let's try one of the Missed things assuming I mentioned type the file name correctly Okay, those are error messages Amurabai Try your hand at governing ancient Sumeria. I don't want to govern ancient Sumeria and I can't control see it So, oh and I just managed to kill my serial terminal. No, I managed to background my serial terminal No, I did kill it So who's using TTY USB 0 I created a sub shell Okay, I don't know why controls he's not working But we're gonna have to hit the reset button again. It is not resetting How the cycle? Okay, that's the serial terminal has The serial terminal has not crashed. What happened was I hit controls s which meant that it stopped working Okay, it's now we have the physics prompt again Right I Think probably the next thing to do we have some games that more or less work is to fix the boot script Actually, I mean you want to get full sick physics from somewhere. It's in util Why we should be building util? Okay, it's obviously not in our script Yeah, well the good news is that we seem to be coping with a Four gigabyte four megabyte file system Oh that second parameter of the file system size. Oh, I'm an idiot. I thought it had to do with the I Thought it was way more complicated than that. I thought it's something to do with one of the i-node structures Okay, I don't see any specific you mount Does the Yeah, I think the BCPL compiler Will only Amit Z80 code. Oh, no, it isn't it is interrupt driven. Oh we can Wait, what do you mean? There's no f4th? No, and I didn't I didn't include that either Interesting and some of these files are in here twice. So let me just sort these Yeah, okay, that's better. I think that Oh Can we do TCL we can probably do TCL? It's a very small TCL But we could do TCL, but I can't actually remember any TCL Pilot is another programming language It's good old colossal cave That's worth doing as basic It's a It's a very small basic, but it is at least a basic Though I noticed there is no make file in there Which makes me think that maybe it doesn't work. I am slightly resisting porting stuff like Leve in UE in the cursors games because that would mean needing to set up cursors And I'd have to figure out what terminal type the serial terminal was But I think we actually need to so anyway, let's Let's edit that RC File let's Port colossal cave So we don't want any of that. We want to do root equals That include implications rules.esb8266 and it builds and There is a handy package file be get applications cave Advent Lib, okay, so that is colossal cave. What else? Let's try Let's try Leve that Just to see what how it works 266 Three sets of objects coexist Don't really like the look of that. I do not want to build the Linux version Let's just build the VC 52 version to be honest because we don't care about Cross compilation Multiple compilation in this specific make file So let's see what this does It's okay This is a different type of make file than for the other Programs. Yes, we just want Simplified I don't think we want one of these at all, right? I know No, I think don't think we do. I think that's provided by the oh, yes, we do want that Why doesn't it like health to physics? Because I never actually added the prefix so what that was actually doing was Doing a native doing a host build, so let's try this Fantastic, and is there a package file? There is You can get a man page Okay so be get applications Levee Levee 755 levee I do wonder if you've got a user Can I just do user? man User man man one second work One All right, stick the card back into the PC. Oh Yes, and I did want to look for Okay, we did put lib error into User live let's just make sure it's readable. I don't think that makes a difference and Done so reinserted the card into the board. We hit the reset button. No, we don't we don't I Need to tell the I need to tell screen that we're a vt-52 I think it's that Now we hit the reset button. That's weird The date and time is more or less correct. Okay, so Right the file system is read write, which is a good thing Fussock Did fussock work? Okay fussock. Let me say slash Fussock physics Fussock physics HD a2 Okay, well that's not working for some reason. Well, it's we don't appear not to have any kind of reboots, but We can at least just hit the reset button because we are unmounted Okay, let's edit RC shall we? Mmm, that doesn't work. I can see that it's trying to display stuff, but it hasn't worked control colon Q does at least exit So I think this is So I think that this has at least worked it is trying to display vt-52 But screen is not set up for it. So let's just have a quick title screen Actually, it may not do Vt-52 Okay, let's change this. Let's go to do the easier thing just changes to be antsy That should work. So yes, we do still have to swap cards So it is basically now finished well code complete. I mean there are bugs to fix We did see one crash that crashed horribly it would be nice to be able to catch those and deliver them as signals but We do now have a Functioning sorry, I'm rapidly adjusting stuff behind the scenes. We do now have a functioning Unix on a ESP 8266 with Not a lot of RAM Yes, there is one useful thing that we can do just CRC Gah, I forgot to rebuild Leve after I Swap the card out Well, so now we swap everything back in again, which is why I want to get the thing running in multitasking mode and see if I can make pipes work because that works on the msp430 So it should work on this as well. Okay That's built If you want to know what I think this is useful for the answer is very little I mean, it's a toy. It doesn't have any real-time abilities. It does big chunks of work with interrupts turned off Such as swapping stuff out so if you wanted to Do anything like run a network stack you would have to You'd probably end up needing to use the interrupt priority system So you eventually you basically run the network stack as a kernel task not as a process And then the kernel sits on top of that So that even when the kernels got interrupts turned off then the network stack still runs etc. Etc There you go, so I don't want to run set date anymore These work so yes, that was that was a vi clone just working fine Big as it 27k we don't have a size That's that's mostly most of that will be code Actually, I can figure that out Yeah 25k of code Two and a half k of data But because on this system, we've got 96k of memory 95 and a half the code Doesn't occupy data space So you still get 60 odd k available for your document. Oh Yes, and I also wanted to I'm pretty sure I remembered to add cave to the games list. Oh It's called advent User games is not on the path. No, I don't want to restore a saved game and it doesn't work Yeah, there's something going on here where it's failing to find error messages probably that is This So libero.tex should contain we've got less got more we've got more This contains all the error messages, so they don't have to be loaded into memory given how infrequently they're used but It looks like the binaries are not finding them Maybe I put them in the wrong place C Libs go Error.c no not that one Error.c So path Lib error is where it's supposed to be User Lib Lib Error.txt. Well, here we are in user Lib well Okay, so let's Take a look at that kernel config and Let's try turning this off and see what happens Now assuming it doesn't crash it crashes. Where is it crashing now? This is in Kernel code 2882 Yeah, I should add to that all those programs were working fine in single tasking mode Where you can't actually swap between you can't task between programs at all other than fork and exit So it's interesting just how well it all worked Okay, two one two eight eight two Okay right this is the Same corruption issue. I was seeing before the thing that I spent so much time Fighting that's Extremely interesting So that bug has not actually gone away. It's just hidden It just doesn't manifest in single tasking mode. I wonder if we are running out of Processors what we now have much bigger swap partitioned. So that apparently doesn't help We just figure out what that is so it's this is Kilobytes When I actually I want blocks Okay, well, it's 97 K So we have I've got a two megabyte swap partition. I believe So this was where we had it working for the first time Here we go Sector count. Yes, two megabyte swap partition. That will gives us 20 21 possible swaps, which is lots Somewhere there should be the total number of processors Think is 16 actually This is the total number of file system buffers so Once everything is finished we can do some rearranging and try to save some memory and Then we look to see how much is left and then increase that number until There is no more free These are actually binaries this is Here we go. Keep start is at B938. We've got up to C7 So we actually have a room for a couple more buffers Okay, so So where does the process Table live? So this is the single tasking scheduler This is the multi-tasking scheduler what's probably happening is something along the lines of a Task being incorrectly swapped back in after it gets swapped out Because in the single tasking mode tasks never get swapped in unless they wake up from a fork then maybe It's not provoking Whatever is going on P tab K data P tab size is Not in here right if not defined you get 16 That's fine. So I'm still Not at all sure why it is crashing at least now it doesn't take so long to start up, which is nice So here you can see it do all the swaps in and out so in it This will be SH physics Hmm back to a foot was to cry the back to SH the next binary Back to In it Etc etc etc until eventually we get to this one Where we're trying to swap in process 3 Which here has been swapped out and then it falls over at a ROM address 3b 5 5 is Here you are tx1 char. Why is it? Even going there that's a null pointer D reference No, I don't really follow what's going on there. This doesn't look like this bit of code it's possible that this is Well, you can't move any of the memory objects around so and that's wrong So that must be wrong so it can't be around cache thing and then it bails a slightly different address Here oh, I know what's happening Something's going wrong It's trying the ROM is trying to dump a message and It's potentially going wrong because we're using the you are Okay, well, there is one thing we could do about this which is here in Devices dot see we can do So this wants to be a we then want to Halt okay, these are all dummies so we just want to Spin with interrupts off. Okay. We haven't read any of the special registers and that was a warning going past Okay, apparently I haven't to find Any of these these need to go in This header file Dev SD in it needs to be is actually defined in That which is actually a one of those Okay, fewer warnings. So we're like this won't double fold Yep, and we get a much more sensible error message the next thing to do is to dump the registers and the virtual address but 2128 AE 2128 Is not actually at an address So I think that's happening in here somewhere. So let's just print the the registers So that's a zero SP A3 We can't use a loop here because they're not necessarily Contiguous these should eventually be delivered to either the process as an exception as a signal or Or if they happen in Kernel space, which this one is I'm not really sure what we do kill the process panic probably panic With no memory protection There's actually not a awful lot you can do to recover from something like that It's usually best just to halt and fail rather than to Have try and run with a corrupted system, okay, so I Know why that address didn't match anything. I forgot to rebuild the disassembly So 28 fe is this address. Yep. It's the one after Unix syscall A14 is garbage So a 14 is corrupted Signing these up So yes something in the fork is Not preserving registers under some circumstances Some very repeatable circumstances So it doesn't seem to be an exception An interrupt because it always happens exactly the same time and besides we didn't have any interrupts for a long time read special register, I think it was called the adder into Address register into the adder the comma there remember to include Print f okay, it's not called the adder Would I put ocular here? What was the exception registers called? EXC EXC viadra Okay. Yeah So it's trying to dereference this using this okay that is Sensible enough The question is why and the answer is I have no idea all the same reasoning I had before applies It should never manage to return that far with mangled registers is probably whatever it is it'll be something incredibly simple and hard to find so I think what I'm actually going to do is to Put it back into single tasking mode the only reason you would ever actually want to run multitasking mode here is for Pipes been really nice stuff pipes working But I think I am going to declare this code complete because it essentially is oh, yeah, let's just turn this Tracing off So this particular project I think is now finished. I mean they're still debugging to do but That is a different phase. We knew have physics working on this ridiculously tiny system quite well it may forms a perfectly comfortable if rather small system to use not the most stable but I It's not like I've put any efforts into de-wogging this There's levy. Oh, we've got a fourth now Cannot execute Really that does look like a binary It's the right size Seven cave code nine cave data Why can't it execute it because it's not executable? There you go fourth This is mine. I'm very proud of this Yeah, I'll warrant that most of the stuff You've seen today has never been done in one of these before because frankly no one would really want to So let's try and sum up I spent way too much time trying to make the SD card work and I still don't know why it works. I Hate working with SD cards. They are just awful things Even with a logic analyzer, they're impossible to debug I Mean I have just cut and pasted the Arduino algorithm for figuring out the clock and The numbers it comes up with do not make sense, but they seem to work so Maybe the documentation is wrong Maybe I'm just not understanding how it's all supposed to work But I mean their code for calculating the clock frequency is coming up with a solid zero for all the results And yet it works. So who knows? It's a bit of a nasty mess of Arduino stuff just these and ESP SDK stuff, which is these That could be cleaned up. So I'll do before trying to Upstream this it looks like Sector receiving Sectors being passed to the Block device driver are always aligned which isn't nice because that saves us some annoying code Um So the since the last to my touch physics It has changed and there has been some bit rot So I have had to fix a few things on the way which is a bit of a shame It's a hobby project AT is by the I should add not mine. I should said this several times. It's based on some very old code by Well, it's in the banner here The original Uzi is 1988 onwards and then got abandoned about 2001 that worked on Z80s and then these two picked it up and Improved it dramatically and made it cross-platform Despite being so tiny we have a 48k kernel Approximately 50k yeah It's certainly creeps up over time, but despite having a 50k code kernel it works pretty well and Even on the system this small gives you a pretty comfortable environment It's pretty easy to port the abstractions are fairly thin but present where it's useful This is the second Major port I've done. I've also done a Z80 port to the NC 200 and The hardest bit is in all well, I didn't have to do the Z80 Tricks to S but on this and the MSP 430 Switch in switch out stuff was so much work The MSP 430. I think does have preemption I can't imagine why I thought that was a good idea Preemption is even worse because you have to do all this from inside an interrupt handler as well I think what it actually does there is it fakes a it fiddles the Call stack so that when the interrupt handler returns it actually returns to a trampoline function That calls switch out So that happens in Outside interrupt context But you have to allow for switch outs to happen anywhere in the kernel So I've been a bit fast and loose about Interrupt safety with this because we don't have to worry about that kind of thing. I Hope that's not causing us our problems with multitasking mode The FDL stuff I did was a complete red herring it wasn't too much work wasted and it did Mean that I understood how it all worked rather better the this Dara library is an absolute find it's small and simple and Does exactly what I wanted to do Although learning about its quirks was a bit of an issue. I should have realized that it wanted Lots of free space so that can add lots of free pages But stat works, let me just try and mount my file system again. Yep, absolutely no trouble Just works Not understanding how Mukafes works was stupid and I wonder if it's worth trying to adapt the Mukafes program to understand Linux hard drive geometries or at least seek to the end of the device to see how big it is There's that whole get GOI octal, which is intriguing Yeah, I keep forgetting that you have to use the block device name No, you don't Why is that not working? Yeah, there's a bug there that needs investigating There should be error messages But yeah, I think that's worked out quite well. This is the This we're up to 15th Episode I believe Switch is I Thought it was only going to take maybe a week to a week and a half but we spent a lot of time on the FDL stuff and a lot of time on the SD card so that yeah You know Hofstatus law, which is that Everything takes longer than you expect even when you take into account Hofstatus law So I think that's come out about right Hmm Well, and I'm going to go and do some cleanup and that's going to be dead boring And I'm not going to put it on video. So this is going to be the last one I Am curious to know if anyone has actually like sat down and watched or is listened to all these videos my Programming videos seem to be more popular than my bench videos But as I prefer making the bench ones. I'm going to do them I'm going to do programming ones as well, but Yeah, I suppose I Hope you all enjoyed watching this video and all the other ones if you have watched the other ones and Please let me know what you think in the comments