開場及OpenWrt介紹 LinkIt Smart 7688 與 Embedded Linux 快速上手 #01 MT7688與WioLink技術沙龍 mokoversity 201512

Good evening, everyone We’ll start now Welcome you all here today and thank you for attending our presentation This topic for tonight is introducing two development boards The first one is LinkIt Smart 7688 It’s very popular among the communities now Our speakers today are all masters The first is a senior engineer from SeeedStudio — Yihui He is involved in projects like 7688, RePhone, and Wio Link, and many others The second is a front end engineer from MediaTek — Blue, Bo-Ju Chen Everyone knows him, so I’ll skip the intro and the third, Sam. The one who is installing a rice cooker Last week he entered 2015 Mobile Hero Contest and got 2nd place His demo will come with a SeeedStudio product, called RePhone. It’s a Smart Rice Cooker and, his partner, (Casear) a master in full stack development Then the team Makee will show you How to write Python and do I/O control in 7688 They made a FPV 4WD remote control car with a 7688 The video is on Youtube and last, this is me (Jollen) For today’s agenda, I’ll start first, with OpenWRT, around half an hour Then Yihui, Blue, Sam, Team Makee I’ll start the first agenda item Before the topic, I’ll show you something within a minute This is a new dev board bring to here by Yihui Wio Link This should be its debut in Taiwan This afternoon, in a coffee shop, with his help, the firmware was replaced with NodeMCU and quickly wrote a program to take photo On the desk over there, it’s a GoPro Here’s a button, It was pressed, you may heard the GoPro taking a picture Just took me half an hour to made a product like this Of course, either Wio Link or 7688 will do It’s simple behind the scenes Because there’s a web server inside GoPro Just hack it, and you’ll know the REST API Then we could use either 7688 or Wio Link, to call the API Configure it into AP mode and connect to it, the web server could be called It’s a lot of fun In the next coming up presentation by Yihui, He’ll mention a new concept called WoT This presentation will introduce OpenWRT and its packages within 7688 A quick rundown of downloading source code, compiling firmware, installing extra kernel module, or say driver and installing extra packages Lots of them are already scattered around the web I’ll organize them and put on GitHub https://github.com/jollen/7688-embedded-linux It should a time saver for you I’ll present 4 important topics of 7688 The first is the embedded Linux distro, OpenWRT Its history, origin, and usage The next coming up by Yihui will have this, too The second topic, installing a USB network interface in 7688 Because with 7688 in AP mode, it needs another network interface to access LAN We could go Guang Hua Computer Market and buy a cheap WiFi USB stick with a Realtek chip, and connect it to 7688 Then you need to install Realtek drivers to make it work It doesn’t come with default config You need to tick the checkbox and compile I’ll go through it The third topic, inside the firmware,

it’s a small footprint filesystem contains packages such as BusyBox, which includes many utilities, and extra applications Today I’ll use a simple topic called ffmpeg Because the firmware of 7688 does not include ffmpeg by default If I want to connect a web cam to it, then use ffmpeg to do straming, HTTP live streaming I’ll show you how to compile it And, inside the root filesystem, There are some important services, like mDNS I’ll make a briefing so that you could study further Basically, it’s a embbed Linux distro, which was derived from Open Embedded project Open Embedded is a “build system” My first experience with it, was its predecessor, long long ago, nearly 10 years, oh, more than 10 years There’s a open source project, OpenMoko I used such a build system from that time Inside OpenWRT, includes many utilities and commands util-linux uClibc, the standard C library, everyone knows it BusyBox, the familiar package It contains lots of utilities If you don’t see a particular command inside, just go to the config menu and tick the checkbox and last, OpenWRT has a buildin web interface, everyone already seen it, so I’ll skip it The first thing, prepare an Ubuntu host, the install necessary packages this, unzip, is a required package, It’s not listed in the 7688 official document on GitHub Then you clone the OpenWRT source code It looks like this after cloning all things are packed as distribution, it’s convenient For checkout, use the 15.05 release branch It’s mentioned in the 7688 official document on GitHub This is the newest master branch, but usually you’ll get into trouble with it. (laugh) Feeds, customized packages That’s the meaning of feeds in OpenWRT MediaTek Labs provides feeds for 7688 You need to add the feeds into this config file That’s the official 7688 packages The last 2 commands are self-describing Then, give the command (make prereq) to check the prerequisite then, go to the config menu (make menuconfig) “make prereq” is needed for first time only The first time you cloned OpenWRT source code After that, you just use menuconfig every time This menu, integrates BusyBox, kernel config, lots of configurations Browse among them, you’ll get an idea of what’s included According to the Internet, more than 2000 packages Versatile According to MediaTek Labs, make correct choices The first one, Target System — Ralink Then MT7688 based boards Next, Profile It goes without saying Next, compile Exit, remember to Save It won’t ask for saving because I didn’t make changes This will give more verbose messages (make V=99)

looks like a mess just remove it (V=99) and you’ll get out of the these My server has 4 cores I’ll enable Amazon instances during compilation of large distros enable 4- or 8-core instance and disable it when done. Because it’s charged by time it has 4 cores, compile with 8 threads -j, followed by the number of CPUs*2. It’s a well-known skill Finally, the finished firmware will be here Just wait for it to finish I used 7688 these weeks, and an idea came into my mind For studying embedded Linux, students are really blissful these days The study days at several years ago was painful I won’t go through the detail of the pain Ignorance is bliss For example, it will took several cups of coffee to just download Linux source code, around 4 cups even more, compilation errors, totally hopeless then went back to compiling again and no such a convenient distro like OpenWRT, sometimes you need to start from source code, run configure, from the basic command I see several friends nodding we are from the same generation It’s really bliss these days Actually, we could consider it as a small Linux PC learning Linux programming Take it to school, it’s a really good choice as a study platform After compiling is finished, like the handout said, You could find it in this place Then perform the firmware update procedure There 2 ways to do so One is by USB, there’s a video on YouTube That’s Macpaul, over there, produced by him Or use the Web UI If both do not work well, just ask Bo-Ju Chen, he’s there I was work with something new this week Connect a web cam to 7688, and do live streaming But my architecture for streaming is slightly different from others the stream will be pushed to another server then the server push the stream the all users instead of pushing by 7688 push by server-class hardware Because the push action will be processed on time and 7688 won’t get overloaded Anyway, I need HLS, HTTP Live Streaming The streaming technology by Apple push the stream to a server The easiest way is to run ffmpeg with just a command but the the firmware doesn’t come with it It doesn’t matter, just went to menuconfig, make a tick check it as M, modularize, that’s easy Because only a new package was compiled, so no need to update the whole firmware download it to the dev board, then opkg install it check it some dependent packages are required, such as ffmpeg library so we need to download 2 package files, the first, libffmpeg the second, ffmpeg to the dev board The most frequently used command during Linux programming, are probably find and grep Copy the package files of ffmpeg and its library to the dev board via network, then install them

scp them to the dev board, then install No need to update the whole firmware A step further, you could make your own feeds Please refer to OpenWRT manual, to add more packages, lots of packages here So actually, 7688 itself is not the most important In embedded Linux, the knowledge of system admin, is rather the point Getting around in Linux before, you need a big PC or a server, somewhat inconvenient Now we have this, a Linux machine that fits in your pocket So 7688 is indeed a nice gadget Also, support our own products Just mentioned, scp package files to the dev board, install them with opkg I’ll skip it Next, kernel module, this is also a common issue Connect a spare USB WiFi adapter to 7688 All of mine have Realtek chip inside, I don’t know why Why they are all Realtek? Maybe they are cheap, in my guess Then you could come to the list of kernel modules and find out relevant options, or devices drivers, 802.11 libraries, and associated stack This is the driver for my spare Realtek 8188 Oh, no EU, another one USB wireless stck with 818x chip The same steps, compile it, then copy the kernel modules to dev board (find ./ -name “*.ko” -print) My lazy way of copying, is to create a tarball and copy it, extract it So I don’t need to copy them individually, How do you know the location of the compiled binaries? Just use the command frequency top 1, find Drivers The above are steps about adding packages, and adding device drivers First one is connecting a USB WiFi dongle to 7688, so it could connect to the Internet Because the on-board WiFi will be used as a Access Point, to connect with my cellphone or computer It needs 2 WiFi connection Another one is USB web cam Use the camera with ffmpeg to do live streaming, As a result, I have a small home surveillance camera After streaming to a server, of course you could watch the video on a web page or mobile app But I’ll skip it Adding kernel modules, how to compile and install Ok! After boot, you’ll find many daemons in the 7688 If today we are in a class in the school, The teacher will introduce them one by one, very detailed It needs a lot of patience, to understand thoroughly So you could buy a book such as… Ubuntu Linux system admin, and study with it or books for LPIC certification, That’s a well-organized material Buy LPIC 101, 102 and study It will told us, the utilities and config files for system admin, Although for some utilities, the config files will have a different path and content compared to OpenWRT But it doesn’t matter, you could adapter yourselves to the new environment But, the first, avahi? Why does it so “high”? (laugh) avahi… what’s that? It also appeared in Ubuntu It’s mDNS service I’ll use it later, so just take a quick introduction We have a limited time frame today,

In coming up sessions, Pay your attention to the speech, don’t practice by yourself It’s dangerous to practice, because you may not be able to catch up Leave the practice after the end I’ll pick up some important diagrams, to save your time There are web server, samba, everybody knows them and time sync, NTP time sync and dropbear, the ssh server and client Those are what everyone familiar with After the 7688 boots, you could find this directory (/etc/avahi) These are config files and these are service groups and… what’s the function of mDNS service? I’ll demo with 7688 mDNS is important for me, because part of my job is giving demo for IoT products I want to be able to do service discovery in LAN To find out what’s on the network So mDNS, aka zero config, is important for me 7688 could be discovered via mDNS, then connect a temperature sensor to 7688 Duo An inspiring idea Later Yihui will have an introduction for you My 7688 should now connected to the same AP… right My computer is a Mac, There’s a command (dns-sd) Let’s go to the manual page, man page One of the arguments is like this (dns-sd -B _http._tcp) This is service name (LinkIt Smart7688…) This is service type (_http._tcp) So I find the type which provides the service (cd /etc/avahi/services) (cat http.service) It has lots of fun, really I never thought it before, a Linux PC, a complete Linux command line environment, Come with a small board which fits into the pocket Dev boards are used to be very large before When I was studying, I made it like a briefcase Somewhat exaggerated Now it’s evolved into such a small size It’s very good for us This is one of the config files On a Mac with mDNS, I could find this service After the service was found, I could do this (dns-sd -R …) Consult the document for these arguments What I want to emphasize, during this phase, It has nothing to do with 7688, embedded Linux, etc A more important background knowledge, is Linux administration This is what just mentioned (service group) a demo (service discover) I’ll commit the slides to GitHub the name on GitHub is … 7688-embedded-linux These are my slides, called index.html You can search for my name on GitHub first, My name is Jollen Go to GitHub and search for “jollen” You’ll find the slides, 7688-embedded-linux It’s not there now, I haven’t commit it Just after the of the presentation Lastly, I’d like to share something,

not mentioned in the slides It will appear in Yihui’s slides Recently I want to use Wio Link, an ESP8266 dev board This afternoon I spent sometime with it, it’s really a good dev board, I think I won’t use NodeMCU anymore, This afternoon, I replaced the Wio Link firmware with NodeMCU firmware Because it’s more convenient to use sensors, no need to connect daughterboards I want to make it a temperature-sensing device, put them everywhere in my home the temperature data could be pushed via some protocol, to a proxy, a “proxy” is what we called “gateway” before 7688 is a good choice as a gateway the job of a gateway, is to collect various sensor data, and push them to the cloud It has such a small size, just what I need Because I want to do something, put it in to a socket The wall socket in the home If possible, my friends in Shenzen who is doing hardware manufacturing business, could help me make it just like ordinary wall socket just like “Smart Sockets” in the marketplace which have build-in WiFi make it “embedded” inside the socket so the dev board won’t be exposed in the beautiful home decoration Recently an idea came into my mind, dev boards now could be treated as end products Dev boards were considered semi-finished products, After the development finished, laying out a new circuit board from the ground up, then mechanism design, ID design, we could only buy them in the store after such a long procedure So I feel that maker age is really lots of fun Recently there is a group buying, I bought lots of boards, with my spare time such as New Year, Christmas to play around with them, turing my home into an IoT demo room Pull out the pin, and connect with a electrical relay, put into the wall, pretty good So first, I like the small form factor And second, I’m familiar with Linux, so the development work is not difficult Besides programming with the familiar NodeJS, of course it could be done with native C, and Python could be used, too Team Makee will introduce how to use Python with 7688, and Bo-Ju Chen is here, he’ll introduce the NodeJS development environment After the session, you could have a talk with Yihui, they just ported Lua to RePhone, a LinkIt ONE platform Lua is another good choice, my Wio Link was turned into a GoPro remote this afternoon, just developed with Lua This is the program I wrote this afternoon It was developed with Lua Turning Wio Link into a WiFi GoPro remote push the button to take a photo This part is connecting to the GoPro, and this is GPIO, interrupt triggering, After triggered, calling the REST API of GoPro, There’s a web server inside GoPro, it has lots of commands, Hackers hacked it and put documents on the Internet But I felt that it must be a intentionally leaked by GoPro company, or, it could not have such details I just gave a speech in another Makerspace yesterday, also stated that GoPro is my favorite IoT product until now, or say WoT product We could use boards like Wio Link, 7688, make peripherals for it in just a few steps Hereafter, there will be such a product, with a build-in server Google have an idea, called “physical web”, just like this We could work surround such a product, consider it as a server, and make peripherals for it this is somewhat outside the topic of my presentation, just share with you Recently, in the MakerPro community,

Chang-You Guo organized a 7688 study road map, I felt it’s a good material For example, in my projects, used only 7688, not Duo, because I used Wio Link or ESP8266 to connect to sensors the communication between them, is not via physical connection such as UART It used protocol implemented with callback (function) so in my way of implementation, I just need 7688 So 7688, 7688 Duo, or Arduino, their areas of application, and how to study with them, Chang-You’s article is very good So I invited him to go here, have an introduction for everyone, and what he has learned If you have any idea, we could discuss further Welcome Chang-You, My session ends here, thank you Subtitles by the Amara.org community