Opening Keynote

0 0

[Music] welcome to the first Lone Star elixir you had a warm-up now right okay it's really exciting to be here back at the Norris conference center in beautiful Austin Texas if you don't know this already Texas is the only place big enough to hold this much elixir Texas is also the only place big enough to hold the entire earth it's a fact however the only thing that Texas is not big enough to hold is this audience all eight billion of you the coast goes for miles and now that I'm here I'm actually here to be able to talk about building devices I do a little project called nerves and since I'm building devices I am the only man who dare give you the Raspberry Pi at Lone Star I've really tried hard to make that one work well Before we jump into some device making stuff I'd like to talk about some of the great accomplishments and the reasons why everybody's actually here the number of packages available in hex as we can see here over the course of the year growing from 2014 to 2015 to 2016 I have a tiny little sliver of it in 2017 it's not that impressive it's just started so I kept that one out we can also see here a number of package downloads that we have in hex and this is a really tall graph if you can see that little sliver there in 2014 it just scales upwards massively so the community is growing so much so that the nerves project which actually just started getting a lot of great leverage the package when I asked for those statistics from Eric from hex I said hey let me know how many downloads the nerves project had last year this time he goes there wasn't a nerves package last year at this time so uh this is one of my fun little statistic brag slides here I'm really excited with this I hear we've crossed over the 10,000 downloads mark for the package in less than a year and one of my favorite parts about that is that puts us at the 310th package for downloads in the top eight percent all right yes but really the reason that we're all here is because we decided to rally around great tools to build some great software we all decided that we want to be able to use elixir for creating amazing new experiences like customer facing websites some elastic middleware that can really perform and also devices using the nurse project so when working through these I I looked at all the other stuff I looked at I took inspiration from as many places as I could most of which in case were from Phoenix for this talk because when developing devices using nerves it should be really comfortable and up until now there's been some sort of disconnects that's been happening the hardware wasn't really always accessible and in the case of programming on a literature you feel comfortable and confident on your host environment on your laptop because you can just hammer away code and try it out and if it doesn't work everything's fine so that's why I decided that it's about time that we tried to address this and I put together a talk today that I'm gonna be talking about called king of the hill most appropriately displayed right here and for those of you who aren't familiar I dropped an L off of there cuz in the hardware world Hill is I mean it's hardware in the loop and so what we're trying to do is we're trying to be able to bring the hardware closer to your host machine to be able to make it so that you can have that faster iteration that faster debugging and not have to wait you know the tragedy of seconds to be able to get to your it adds up after a while it does we're not in this for those of you don't who don't know me my name is Justin Schneck I develop hardware and hardware accessories I work for a company called lotto and I we're hiring actually we're always looking for people to join us in the beautiful area of San Francisco it's not far from here probably gonna plane oh yeah but with litotes I really need to thank these this company I've had the pleasure of working with some of the smartest funniest not as good-looking as me kind of people but it's been a wonderful experience and without them we wouldn't have been able to get nerves to even to where it is now so with where we're at we're at a point for release right now and that includes some great additions from the last time I spoke about this I believe last time I spoke was an elixir Kumpf in Orlando and we talked about what was going to be shipping well then is now we have a new feature that we're in right now it's called the docker provider and the doctor provider basically allows you to on your Mac or Windows machine may be untested see me afterwards if you can't get working I need one of you you can actually use docker to be able to produce the Linux user land pieces the the actual Linux machine that's going to wrap your code and distribute it out onto the devices up until now this was sort of something that you could only do on a linux host and so instead of only being able to do it on your Linux host now at this point you can actually run it on your Mac in addition to that we have release global artifacts that's four hex packages and this was a fun one and an important one I felt because when it came to running nerves projects for every single project that you had you have to download a system and a tool chain the system can sometimes weigh upwards of you know a hundred to 120 megabytes and the tool chain could be 80 to 150 and that was not only her project that was per environment so you run in dev then you run in tests then you run in prod now you're up to half a gigabyte worth of stuff to be able to produce a system that can run on this tiny little SD card for some reason so all of those things add up after a while and well we decided that for stuff that we trust that we can compute compute the actual hashes for we're going to globalize that and we're gonna make it so that it downloads it to a shared location in your home directory that you can actually go back and clean out later and then the reason that we could do that is because we were able to synchronize everything up we had several packages that have been become deprecated now the nerves system package and the nerves tool chain package they both contain their own compilers and as it turned out those compilers were basically the same so we've sort of made everything now moved upwards into the nerves package there's a lot of them when you look at their the they main top one has this package compiler now so we can we can have everything sort of point to all the same versions everything's in sync everything's nice and compact and everything moves quickly also because we were able to dump xrm and move to distillery it's really fast all right so what do we need to do to be able to do hardware in the loop so this is sort of what we're going to be talking about today what does it mean for nerves to have hardware in the loop we're also going to talk about the changes that were required in nerves to be able to get to accomplish this task and then in addition I'll show you a cool demo I'm excited for the demo it's really cool so as I said before we took a lot of inspiration from different places and one of the places we looked at was Phoenix reload and in the case of Phoenix reload you have a pretty easy mekin you have a browser and then you're on the back end you have your terminal window and and what you do is you you press reload on your webpage and then that sends a request to the to the to the running beam and if they're running the running beam what it does is it it checks to see if there's any code changes on the files and and if it if there are then it recompiles the the modules and then if everything's cool then it sends the request back to the browser and the browser was like hey here's your new stuff and you're like this is awesome where has this been my whole life so Phenix reload also the code reloaded features in phoenix also has this ability of handling errors pretty well because of its ability to to keep the VM running and in a state where it tries to compile it if you same way try to be able to reload a site and it says it fails well then it just gives you this pretty looking error page it says stuff went wrong and then you go on your way and you're like I fixed it yeah and you don't have to do any more work and it's great now the issues here that we can't just be like oh let's just take what Phoenix did and like you know just apply it right - what nerves needs to do there was a little bit more work that needed to be done here's an example of which well we have disconnected pieces you have your host computer let's say that's this terminal window on the on the left here and then you have some device raspberry pi you come on black whatever over here on that on the right side and that device it it it might have some connections that is being made to some accessories you probably are doing something interesting with it and it's not just sitting there computing stuff because we have much more powerful computers to be able to just sit and do computation it's probably connected to some sensors or some displays or other devices and so in this situation when we would want to be able to reload code we would actually be synchronizing the state of two different virtual machines and inevitably then the code that's being used to run on the target typically in the case of nerves devices has pit it has a processes that are running port drivers or interfacing with some low-level C code and that that port driver that C code needs to be reinitialized so that it can utilize the new code paths that are present so what we need to do is on the remote machine we basically need to tell it to reinitialize the application stack and if everything's cool then you know we'll just send a message back to the terminal it's no big deal we'll just synchronize two VMs the problem in this case though is that if everything is not good then we're left in a situation where when re starting the application stack you are sort of restarting the initialization procedure and if the initialization procedure fails then the VM fails then the network fails and you're basically left with this equaling des it's not a good state to be in we want to try to eliminate the need for SD card swapping and in this case you're going to have to go get the SD card out of the box and then plug it in your computer and reborn' it and that's fine for somebody like yourselves but maybe not for an engineer in the field or a customer so we decided that there's three different areas that we need to be able to focus on to be able to make this robust enough to work we have a section of host tools that are required that need to run locally on your host development machine we need stability in the network because we thought about this one for a while we thought you know what's the way that we can connect these devices the easiest well airline is beautiful for Erlang distribution protocol we can just strap together these nodes and then everything is going to be great we can make RPC calls everybody's got the network not everybody has these like spyboss or or you arts and they're slow so make just have a really solid Network and then a set of target tools that needs to be on the target to allow us to do some air handling so that way we don't you know turn into the brick state so this journey sort of unfurled into this magical web of mystery and let me take you down that chaotic path and let's start with some of the target tools because some of the things that I discovered while building this we're pretty interesting so the target requires us to be able to do a couple things we need to be able to always boot all right now what this means is like with nerves when you build a relief when you build firmware on your machine you're building an OTP release and when the when you plug that SD card into your nervs device into like your Raspberry Pi and it starts up basically it starts Linux and then Linux starts a little shim program called Earl in it that knows how to be able to start early and then Erlang goes through its initialization procedure and then you're applications running the mantra of nerves is that we want you to spend as most of your time inside of the VM as possible because there's no better place on these machines to run then in that VM I mean we get a lot of help from Linux on the outside world but for the most part you will be more comfortable by staying inside the virtual machine so in addition always being able to boot that initialization procedure that happens you'll know that if you try to fire up a machine on your on your you try to fire up code on your local machine that fails the initialization it crashes the VM and then that's the brick state if we crash the VM on the target we've basically crashed to the OS and if we have no OS that's running and we're not rebooting then we're just sitting there with nothing and no ability to talk to it in addition it's important that in bypassing the initialization that that if we were to restart services that we that we make sure that critical services stay alive like networking so that way we can always continue to communicate with it and then the last thing that we on the target is some helpers and some abilities for us to be able to sync code and proof files now we went to had a couple different paths with this that were cool one of which Francesco mentions inside of his new book that talks about using a code server and there's actually airline has the ability of saying like oh I've got these two VMs I'm gonna make this one us a code server and then there's these other VMs that are going to connect to it they're gonna get all their code from it and and it was a really promising looking thing for being able to use for debugging unfortunately it doesn't handle proof files so when you comes time for you to try to load a port or an if or some sort of file that lives in the peripheral there of your of your application it would be looking in a path that doesn't exist because the path would be that of the one on the actual code server so we had to decide of going a different way here we needed to be able to sort of scaffold something from the ground up so in this case I look for more inspiration well what does the regular system boot sequence look like when you turn your laptop on or when you turn a Raspberry Pi on a boot into Linux so you've got this tiny little shim program that's called a boot loader the boot loader lays down just enough train-track in front of yourself to be able to know how to be able to boot into the Linux kernel and then that knows how to be able to lay just enough more track down to be able to get to the point where it can start booting your applications and doing something interesting this pretty much how most of our computer systems all work today so that's the interesting part well I knew it there I needed a boot loader we got to shim the VM so that we have control over bypassing the default behaviors of the airline initialization sequence so this led down a path of trying to be able to break apart and understand how releases work this is where things got a little bit more interesting so some of you may or may not be familiar with how an actual OTP release gets put together or what the pieces and components of it actually are but essentially what happens is when you start Erlang on the other side you pass it a boot file and that boot file is a series of instructions that tells the VM where to find ass and what to start what for what applications to start as part of the initialization sequence so to make a boot file you need to do a couple things you need to start with a rail file so this is a sample rail file this is something that you can pretty much easily put together all it is is it's a it's actually a four for temple yeah the first part being the atom release and this is an airline syntax because all the real files are just the Erlang terms it starts with the release atom and then you tell it what the application is which is its own to top with the version you tell it what version of the Erlang runtime you're going to be using for it and it should look for and then you pass it as the last parameter a list of applications and their start types so when building bootloader what we knew we needed to do was during the process that would create an OTP release in addition to creating the rel file that distillery will make for you that knows how to automatically bring up your application in a default state we're gonna make another one called the bootloader rel file that in this case this continues by the way a trunk this off a little because it's quite long in this case our rel file it's a it it knows just enough it loads just enough applications to be able to get a usable system running and itself and then all of the rest of the applications and the third parameter here this is the start type it just says don't start this application but what that does is it automatically wires all the code paths for us so that it's available for us to start so we trick the route the the release system into being able to produce this bootloader rail file and then using this you can you can then pass it to the sis FS tools and say take this rel file make me a start script and then that produces this massive amount of output I mean this is like super truncated right here it's just this never-ending file of instruction after instruction after instruction that basically one at a time gets fed into the into the init system and then just brings up the machine during that sequence and the reason for all of this insanity is because we need to ensure that the initialization sequence always passes and then once we know that it always passes and we boot to the bootloader then the boot loaders responsibility is to triage any errors that we get from then on but as long as that initialization passes we're good so we want to make sure that we have the mo the minimal amount of code in place that is pristine and working so here's some information on how to make those files as part of distillery you can actually use the mix release utils right term we put a couple PRS out to be able to open up some of the stuff and distillery so that we can start leveraging it as well and then the deeper level call once you have a rel file which is that first one then you can just pass it to sis tools tell it to make a script and then that script basically gives you both the scripts and the binary version of it which is the one that you pass to the initialization command so we shim this easily with using a plugin you can see down here for distillery this is a configuration file for distillery all we do is we just say hey when you're running your release I want you to execute the bootloader plug-in and then what bootloader does is it generates those files so that you can use it you can use this with or without nerves it doesn't matter this isn't a nerve specific thing it's a supposed to be a little bit broader and then now we're left with this we have a VM that's that boots to the bootloader and then we use the bootloader to boot our applications so the second part of boot loader is that it handles code updating for us we put some helper files and functions in to be able to do the stuff where we're talking about synchronizing the important pieces modules applications and proof files and so how we do this is we have some functions we we have an application controller and that loads all the applications that it knows about and you just say hey application controller give me a hash and the hash is essentially it's it's a a hash of all the hashes of all of the important files and so that way we know with just one little cache line did anything change if something changed since well since in nerves were on a read-only file system we want to be able to do something that we call in applying an overlay so instead of just loading these new modules what we want you to do is we want you to execute a strategy where you write the files over to this readwrite partition because the ones that you have are read-only and then we want you to update the code paths so that when you apply the overlay that's gonna just go and lay on top of it so then we prepend the code paths so that when it goes looking for the modules and the proof files it'll find them there first and if it doesn't find them because we're only putting in a partial fragment of an overlay it falls through to the old ones that way we can then reversion our stuff over and over again we can reload the applications and then everything's back to where we were so the second component of this now we have the target in place we can update it we can keep it running the second component of this a steady network well when I got to this step I thought to myself how hard could this be it's networking and then I remembered oh there's a package called interim Wi-Fi yeah now not interim Wi-Fi as a matter of fact it just so happens that the interim part of the interim Wi-Fi package meant that it's still being worked on not the matter of that on the Raspberry Pi 3 that you see here it only works an interim amount of times like I had two boards from two different manufacturers both raspberry pi 3 and one of the two of them would would when booting bring up the Wi-Fi properly load the the Wi-Fi stack properly one out of five times the other one zero out of five times yeah I caught wind that in the channels we have for support that people were saying that they just did essentially tell their customers to keep plugging it back in until it works I mean even Windows you only have to reboot three times to get it to work right all right so here's a yak here's a Raspberry Pi 3 here is me fixing Wi-Fi so there's this term I learned recently called yak shaving you're probably familiar with it if you're not basically the idea of yak shaving can be summarized in this statement I said this now here I am recompiling GCC on my Mac just so I can burn an SD card so I can test out the new Linux kernel so I can see if Wi-Fi might work better yeah it's a series of tasks essentially they lead you to the point where you're like I just wanted to do this thing over here and now all of a sudden I'm shaving a yak I don't understand how I got here so as a nice response Lance says to me the irony of this fact is that I'm probably the person that he'd vote vote most likely to shave yak at any time and of any size that was pretty funny until I had the sad realization that working and hardware is kind of like that so I'm putting my entry in for the elixir yearbook most likely to shave a yak so what did this problem turn out to be well I we investigated it for a while we tried to update the Linux kernel essentially what happens is the Broadcom module we were compiling into the Linux kernel there's two ways that you can run module Linux modules you can compile them into the kernel or you can compile them as a module and then you can just load them in at runtime apparently the Broadcom module doesn't like to be compiled into the kernel and that our tests showed that when running against raspbian even raspbian doesn't have a compiled into the kernel probably for you know portability sake but in their case they're just doing a mod probe on start and mod probing and on start seems to yield the results that it always works so problem solved we're gonna pull the Broadcom module out of there and this whole experiment because I was looking for like toys to play with you know how you do development right you're like oh I need a little pet project I can build so that it'll drive me to building this feature got me one step closer to ice cold beer in my room in my kegerator so that I could monitor the sure and have a beer I needed it after this the path was getting deep I figured ah one yaks not enough let's shave more on top of that we decided that interim Wi-Fi was to interim e and it needed to have some things go here's a PR that we just merged recently to rip Jenna vent out and replace it with registry so another thing next version of nerves one for Plus on elixir yeah cutting-edge how we like it registry was needed because we we wanted a consumable way to be able to monitor event changes in interfaces like when an interface running DHCP gets a new IP address in that case we wanted the ability for the IP address change to affect the name of the VM so the strategy is that you register for notifications on the network interface you'll receive DHCP events as they come in when that DHCP event says that the interface address changed you bring net Colonel down you bring it back up with the new name and now all of a sudden you have an addressable node again so now we fixed the network things are getting better we're finally getting towards the end of this path and the last piece left that I wanted to show you here on this case was some of the the work that we've done on the host tools so the host is a tricky place the laptop that you're running on and at this point in the equation I started to see the light at the end of the tunnel I had working tests that I could actually code make code changes on the on the remote device with with bootloader and I had a network that could get me there to do it now at this point it was ready I was like alright now I can start pulling pieces of inspiration and from Phoenix and I can take a look at what they're doing with the monitoring systems and so I brought in FS and the idea here was that we need to know we need to look at all the source files that are on your machine for the different applications that you're running including some of the dependencies that are packed because if you're an umbrella we want to monitor those two so we brought in FS into a project that we're calling the nerves reactor and FS has just told to monitor all these files including the privet erector II files and then whenever it receives a change then it just says hey try to compile it much like how Phoenix works and in theory this all works fine in reality you're running underneath a host environment that is always being compiled for the target so here I am I'm ready to be able to test this out I'm ready to see the fruit of my labor and and all of a sudden then it says FS kicks me back an error that says what native interface for Mac are you talking about I'm running on Linux nope doesn't work so what's the reason for this well I've said this in the past nerve space projects will always compile for the target and the reason that that decision was laid down that way is because it's very important that the environments don't get mixed up throughout the mix life cycle because nerves does so much to be able to patch the life cycle so that it can find the right cross compilers so that your machine can produce code for what it thinks is a Linux machine or a target that's of a different architecture and this is passed just in saying this so now I'm saying it'll sometimes compile it for the target this is a change that we had to make a realization that I've come to and to do this we're sort of taking the step into the next level of adding a second layer an additional layer of mix-ins for configurations in addition to mix ends which we're going to we're we're hiding hooking onto called mixed target here's a pull request it's still open making this change isn't a slight ease actually making this change will actually impact a lot of documentation and a lot of functionality primarily what does this look like from the outside in well our new project generator mix nerves new it always took a target at the end because we always needed to know what you're most interested in compiling for because host wasn't an option so you'd say oh on my default target for this application is going to be a Raspberry Pi 3 and then it would structure your application so that you could you'll always by default be be compiling for a raspberry pi 3 so all your mix commands would just always be in that environment now the change this is before this is after well you no longer in the new project generator coming out need to be able to specify the target because we're going host first in this case a complete 180 and now all of the default mix commands that you run just like you would with any other application and any other project will compile for your host machine first and then if you want to be able to produce firmware or produce an output for a different target like a Raspberry Pi 3 you'd pass in mixed target and let the system know that you're interested in moving the component to the different environment so in the the main component of this the most interesting part of this switch actually is this section right here this is inside of the mix file that gets generated this is where we define our aliases and in the case of mix there's nothing magical about it all of the aliases are declared inside of the file so that things are explicit these are what we do in the case of compiling for a any target this says but now in the new project in the case of the host we're saying don't invoke the mecca the nerves environment as part of the the mix lifecycle we want to actually compile for the host now this introduces a couple different interesting pieces though in the case of nerves projects since there's a lot of times that you're including applications like let's say elixir ale for example which is a an application library written by unless that knows how to be able to interface with GPIO pins like twiddling pins for that are on like a Raspberry Pi or a piece of hardware that aren't necessarily available on your Mac that application on your Mac will not compile unless it's compiling underneath the nerves environment through the target well if you were to let's say design your applications so that as part of the start sequence of your application you wanted to also start elixir ale and start twiddling some sort of pins well then if you tried to run that in IE and an IX session on your host it would crash so another change we're making is we're defining multiple pathways to be able to start the application in the case of starting on a target you'll be able to define a starting point for the application and then that way that'll be able to bring up all the target specific stuff and if you're starting on the host inside that project you'll be able to define either nothing or an additional pathway let's say if you want to be able to stub out some things and mimic some of the functionality that elixir ale might provide because you want to execute some unit tests another thing that we didn't have before hey so here we are the path is getting longer and I'm getting weary because up until now on my path to being able to do hot code reloading I've been doing SD card swapping now we have something in place that allows us to be able to do full remote for more updates it's nerves under firmware under HTTP it'll let's even push firmware updates over the HTTP but up until now the only way to be able to do it would be to bailed like hack together some sort of curl command on your machine or others in the community would write some lightweight mixed tasks that would in themselves pack together a curl command on your machine but the beautiful part is now everything just unfurled we see that we have the ability I can run any utility I want on my machine as part of a nurse project now that can complement the actual target so now at this point when bringing in nervs firmware over HTTP we introduced a new step called firmware push and running on your local machine you'll be able to say fix firmware push to this device this this target and what it does in the background is it compiles a firmware package which is an OTP release and the entire Linux operating system changes and it gives you nice beautiful progress bars inside of the window that you're in and then applies the change and reboots the device on the other end so here's a yak here's mix for more push yak shaved this is what that command looks like by the way you have a couple different options you can see that you can say whether or not you wanted to reboot on the other end when it's finished where the actual target is and you can actually point it to the firmware you have to pass either target or firmware you can if you pass target then it'll discover where the firmware is based off of the the mix file itself if you pass firmware then you can just arbitrarily send it to whatever FW file you have on your machine doesn't even have to be for that device you'll find out later so that's what that command looks like when you go to run it you just point it at a place on the internet and when land whatever it'll just try it's best to be able to get there best part about this is it's a grudgingly written using HTTP see so there's no additional dependencies on your machine it uses all the built-in stuff that's inside of your Lang VM on your on your host computer so here we are now back to the point where we can execute code I'm happy again I can push firmware I don't have to I sneak card swap anymore let's get this done so the next step well from learning my lessons with HTTP for what firmware push I found that there's a little trickery that's involved in starting in one mix environment that's probably not the right term to use there I should say bringing up the mix application with one set of configuration parameters like mix environment is dev and mixed target is post and then tricking it so that you can say bring yourself back up again but I want you to be mix environment as dev and mix target is Raspberry Pi 3 and doing that in a way that's proper we needed some hygiene here so what we're doing is there's some there's some funny business happening behind the scenes and instead of doing it inside of the pristine session that you're running in we wrap it all in a transient VM and we say hey you decorate yourself like this and we're going to tell you when we need stuff from you so here we are we're back to the point where we've got a running reactor we've got a stable Network and we've got a working bootloader and a big pile of yak hair let's see how this works so up here I have I have a Raspberry Pi 0 connected with just a USB cable giving it power and it's it's running bootloader right now so it's waiting for some instructions and I have this example application that I'm going to mirror my displays with now so that you can see it cuz it would be a really bad demo if I can see it but you can't all right let's do a little fun window treatment here you're a little big everybody can make fun of me later for not having a window manager if you find one that works nicely let me know I know you have opinions on this Chris all right so let me tell you what we have going on here the top right here I'm sorry the top left is just my console window I'm sitting inside of a regular project that's this project here I'm calling the PI reactor all right and on the bottom left here I have a serial console of the i-x session that's actually running on this device so on this device I can do things like hey PI reactor do you have a hello function oh it's undefined now you don't okay so first let me show you some of the new setup pieces and we'll look at the mix file first that I talked about this is part of the change that we made we can see here now that we're going host first as our default for mix target we're adding in some additional pathways like I said we're changing aliases on target now which down here decides whether or not we want to invoke the nerves environment and then we're also splitting our dependencies when we get to depths we have these are the shared dependencies that will be existing on both my hosts and any target I run on plus the dependencies of any target in the case of raspberry pi zero I'm including the raspberry pi zero system and NURBS networking because I don't need to use nervous networking to bring up the network on my local computer and then any other target we're gonna this is just some magic here where we're saying if you pass something other than raspberry pi zero just go fetch the system for it and whatever we'll try our best so the other additional changes like I said this is where we split the code paths so that way if I try to open up an IX session I can actually boot into a working VM and it didn't try to be able to bring up some specific stuff like what's happening in this application here just take a peek at that it's trying to fire up the initialize Network worker which would actually try to start configuring DNS masks on it to be able to start a DNS server probably is not going to work too well on my Mac at least in this configuration so and then some additional stuff that I'm doing this stuff is all in the documentation you can pass in your own or an ER linic commands so that we can change the serial ports and we're doing some other configuration stuff like we're telling bootloader where which application were interested in running and where we should store overlays on the target in this case the nerves devices the default place for readwrite partition the app data partition is that is mounted at forward route so we're saying make a directory called oral overlays and put the stuff there and then we're just configuring some static networking and we're telling when we when we build firmware to include our own FS additions so that we have this custom boot command okay so let's take a look at how some of this fun stuff works so here I am in an IX session I'm gonna start the reactor and tell it that it should interface with this remote node and now here we are as I said in a new session with some you know don't mind that that's the man behind the curtain right now we've got a connection to that session and now this is fully fired up and wired and ready to go so if I if I call this command we can see oh it doesn't exist but you know now that we're live programming let's go and check it out let's go into the PI reactor module here and let's say def hello do world and and well hits well hit save it'll synchronize an overlay and all of a sudden now we've got hello world as I said the nice part about this is the portability aspect that it's it's really small fragments that get sent over all that actually happened in this overlay is that it ended up transferring this modified module that it needed to be able to apply on the other end and if we take a look here we'll see at the root yeah there's a directories worth of different overlays that have been applied during the lifecycle of this application and some might cancel out others so in our case we can say okay I don't want hello world I want to go back to the to the old way of doing things I just don't want anything at all and when I hit save it'll synchronize a new overlay now that doesn't work anymore things were really fast it's great it's almost as if it's right there on your machine it's the speed of your network and the beautiful part about this is that even though this Raspberry Pi 0 just so happens to be connected physically to my laptop doesn't mean that it actually has to be physically connected to my laptop since this runs over the network this Raspberry Pi I could be remote debugging it and it could be in the closet in the next room over the only thing that you're not gonna get right now is this serial console output that I'm getting unless you're also REM Sheldon which you can do because you're not bringing down the VM on the other side you're only interacting with the boot layer bootloader shim so let's take a look at the other piece the interim piece now that we're doing our remote debugging is over and we have our thing in production we can see here we have no we have nothing to find let's kill the reactor and let's define a new thing here def bar reactors not running code did not get synchronized but let's say we're in more of a production state we want to start pushing stuff out so what I'm going to do here is I'm going to set my mixed target and compile some firmware it's a little faster than SD card swapping huh still not as fast as the reactor once it's done creating our entire Linux image and firmware now that we have the firmware file we're gonna in the host from the host environment not setting next target we're gonna tell it that we want to execute a firmware push because we need that code to be able that to run on our host we needed to be compiled for our host and we're gonna pass it the some of the default parameters here and we'll say we'll say reading - now what this just did is something that you would there's a combination of events here that you're gonna be using see the nerves reactor is good when you want to be able to do code changes in elixir and like I said we would like it if you could spend as much of your time as possible inside of the VM because it's a nice place to be but let's say that there's a situation where you need to be able to add some sort of Linux land user process that you didn't have on the machine before so you'd end up changing some configurations you'd use the docker provider to be able to produce a new Linux image take a while and then once you're done building your new living exit Linux image that has all your other user land functions in it you'll marry that to your elixir applique all right to your elixir code and then you'll need to push that firmware to your devices something new now you can do that by putting the SD card in your computer and reburning the entire SD card but you'll lose all the contents of your app data partition unless you run an upgrade task but you know by default you'll lose the it'll just flash at all so as I said there's you're gonna use complementing pieces of these tools to be able to to work for debugging in this case the reactor won't be able to synchronize user land programs and applications because it's outside the VM to do that you would need to push a new user space to it a new Linux kernel or any other Linux land applications and with firmware push we can do that what it's doing is actually it's it's loading the firmware onto the device and it's streaming the firmware into the B slot and then it boots into the beast slot and so your old firmware is actually still left in the a slot and if you were to fail in the B slot while you can you can inside of your application take the necessary precautions to prevent yourself from getting into that dredge brick state and then just boot back to the last version it's good for production not necessarily the best for this situation so let's see if we've succeeded so there we go all right I really like to thank Tim meklin Michael Tim works for gaslight Tim is the one that did all the work necessary to be able to take the Raspberry Pi 3 system image that we provided and what he did was he got this is running what's known as gadget mode so it's running as a USB gadget and that's how over this USB interface I'm getting both serial an additional serial port and a network interface to be able to vary in a great compact way do the work necessary to show you this today Tim also got the what's known as the IOT P hat or as the kids are saying that the fad working which is a it is a hat for Raspberry Pi zero that adds Wi-Fi and Bluetooth to it to be able to make it act and more like a PI 3 as I put it it really gives it a purpose I mean what are you gonna do with these tiny little devices if they don't have a network connection so thank you Tim for building that system if you want to check it out there is a link down here you can go to his site we're going to be building a more official repository to hold all of these community editions that we have in addition to Tim's work I'd like to be able to say hooray we hit 900 people on slack Channel yay lots of people are starting discussions it's a little tough to keep up with that times it's a lot smaller than the Phoenix channel but I'm really proud of the fact that we have so many people in the community who are interested and understanding that the same tools that that they use in their everyday lives that they're interested in that you guys are here to learn more about can directly apply to being able to build and tinker with hardware and and then it's not that frightening anymore once you have the tool set under your belt it's just a matter of plugging systems and some stuff in and playing around with it and seeing if it works there's a lot of great tutorials out there as well that you can be able to get up to speed with and if you also always have questions you can just join our nerves channel there's a bunch of great people out there that are putting together stuff commercial products ATLA tote we're using nerves Phoenix and elixir to be able to build an incredible stack to be able to automate a lot of the workflows and processes inside of our organization now what's next for the future well we're gonna finalize the work on mixed target I'm hoping to make that more of a household term and we're gonna change our documentation because we're doing that complete about-face 180 makes sense we're gonna finalize the work on boot loader and get some more test coverage on that writing the test for boot loader to prove that the most early starting replacement to the Erlang initialization system was probably the hardest piece of code that I almost had to work on to date it's very odd it spins up a whole bunch of different VMs and they all kind of talk to each other and shut each other down and it's it's like that chaos monkey I guess like that kind of like that a big thing for me I want to finish on interim networking it's a shame that we have that in the name of our package but you know for just cause networking is hard and Wi-Fi is a lot harder and we're looking to be able to ship more as we're calling it batteries included systems the the goal for nerves was always to be able to provide and build extremely lightweight to strip Abell Linux VM Linux systems that had the Erlang VM and your code inside of it and so you know with with the minimalistic approach that we have today we tout the ability of producing systems that are in the megabytes tens of like a ten ten to twenty megabytes with all your code in a full Linux system the batteries included systems are going to be the complete opposite of those they're gonna contain almost everything that we can turn on that you're interested in and keep an eye out for those because we have a lot of people that are working right now on releasing these systems to use for Raspberry Pi WebKit kiosks so there's a lot of projects out there that that that are starting to show using the 7-inch PI foundation touchscreen displays with the Raspberry Pi on the back to be able to build a kiosk that can leverage Phoenix for its user interfaces then you can use em you can use whatever web languages you want in addition on those battery included systems we're just gonna be able to turn on a whole bunch of drivers we're really hoping at that point that we're gonna say hey if you're the minimalistic image didn't work for you because your Wi-Fi chip that was built by Joe's computer shop down the street doesn't work you know try the batteries included one and and it's gonna weigh like 200 mega but you can at least see if it's gonna solve your problem and then we're and then turn on and off whatever options you need later to save space so with that I'm really happy that everybody is here today because this conference proves that we can continue to grow and rally around such awesome tools and that we're all so interested in learning more about what elixir can provide for us and our businesses thank you [Applause] all right we have time for a few questions any questions hey I know that you I think address us on slack a little bit but part of the firm work push the security aspect of that locking that down making sure that hey I'm the right person that can yeah so Garth is currently working on adding in the ability to secure that better with some certificates the work there is not done yet but the firmware push mechanism is sort of a primary step in the way of adding a level of of I trust the network I'm on level of convenience but yeah we you know we are we are looking to be able to add a higher level of security to that aspect and I believe we're still at the stage where any level of input from the community would be appreciated and and you know we can all open some conversations and talk about what the best way to be able to add that level is that would work for everyone you know the questions all right let's give Justin the begin you [Applause]