找回密码
 马上注册

QQ登录

只需一步,快速开始

查看: 72029|回复: 26

创建一个可启动EV3的SD卡(以便使用Java/lejos)

[复制链接]
发表于 2013-9-20 00:37:52 | 显示全部楼层 |阅读模式
本帖最后由 ntwuhui 于 2013-9-27 00:46 编辑

QQ图片20130920080305.jpg


These tools are designed to help you create a bootable SD card for the Lego EV3. This card can then be used to run Java/leJOS programs on the device. The SD card image is based on the standard Lego firmware but has been enhanced to provide the following:


这个工具用于帮助你创建一个可用于启动EV3的SD卡,通过此卡以便在EV3上使用Java/leJOS程序。这个卡中的镜像的设计是基于原有乐高固件而设计,不过能够增强EV3的功能。(个人翻译能力有限,请见谅)


1. The Lego device access Kernel modules are loaded without having the Lego VM running.
2. The WiFi stack is loaded to allow connection to the EV3 via a supported USB WiFi adaptor. This allows you to connect to the EV3 via Telnet, SSH and NFS and makes program development very simple.
3. Driver modules for Atheros ATH9K and Realtex 8192cu based devices are included and will be loaded automatically based on the detected WiFi chipset. The EV3 has been tested using the NetGear WNA1100 and EDIMAX EW-7811Un adaptors, but others may work if they use the same chipsets.
4. Installs the Oracle Java SE Embedded JVM, JNA and leJOS classes so you are ready to run Java programs on the EV3.
5. Includes shutdown scripts to power off the device when Linux is shutdown


So what do you need?

1. A micro SD card 2Gb or more in size.
2. A WiFi dongle that is supported by the EV3. At the moment the only devices used are the NetGear WNA1100 and EDIMAX EW-7811Un. But hopefully this list will be expanded.
3. A PC running Linux (the tools were created/tested on Ubuntu 12.10) to create the SD card and to use for program development. This can be a Windows system with Linux running under VirtualBox.
4. A WiFi Network and details of the SSID and PSK etc. needed to connect to it.
5. A download of the Oracle Java SE Embedded JVM.
6. A Telnet or ssh program to connect to the EV3
7. Optionally an NFS server to allow you to easily run programs developed on your PC.


为此,你应准备一下:

1.一个不低于2Gb的SD卡;

2.用于EV3的WIFI适配器。目前唯一能够使用的是NetGear WNA1100 和 EDIMAX EW-7811Un。不过希望这个支持清单能够得到扩展。

3. 一台运行Linux的PC机(这个工具在Ubuntu12.10下创建并测试通过)以便创建SD卡以及开发平台。也可以在运行windows的系统下(通过虚拟机软件VirtualBox运行Linux)实现。

4. 一个能了解到SSID以及PSD等详细信息的WIFI网络。(用于连接)

5. 下载Java SE Embedded JVM

6. 一个用于与EV3相连的Telnet或ssh程序

7. 一台NFS服务器用于更简便的运行开发平台(PS:个人觉得可以先忽略这一块)


Getting started.
1. Download the latest leJOS creation tools (file lejosimage.bz2) from:
https://sourceforge.net/projects/lejos/files/lejos-EV3/
2. Unpack them on your Linux system using tar xfj lejosimage.bz2. This will create a directory called lejosimage that contains the tools.
3. Download the Oracle Java SE Embedded JVM from the Oracle download site:
http://www.oracle.com/technetwork/java/embedded/downloads/javase/javaseemeddedev3-1982511.html
copy the downloaded tar file into the lejosimage directory.
4. You now need to set things up to allow access to your WiFi network. To do this you need to edit the wpa_supplicant.conf file to provide the details of your network. The sample file looks like this:


让我们开始:

1.下载leJOS创建工具(file lejosimage.bz2)https://sourceforge.net/projects/lejos/files/lejos-EV3/

2.Linux终端下展开:tar xfj lejosimage.bz2 ,这一步可以得到一个名为lejosimage的文件夹(内含创建工具)

3.下载java虚拟机:http://www.oracle.com/technetwork/java/embedded/downloads/javase/javaseemeddedev3-1982511.html

并将下载到的tar文件复制到lejosimage文件夹中

4.下面该让你的wifi网络起作用了。你需要修改文件wpa_supplicant.conf,示例如下:


ctrl_interface=/var/run/wpa_supplicant# Persnetwork={        ssid="legolan"
        key_mgmt=WPA-PSK
        psk=8e9116c7665b56a95c03e3e23ec707f4cbe18fea82d620d9b85b2f79fe34cfee
        pairwise=CCMP TKIP
        group=CCMP TKIP
        proto=RSN}

Which basically defines a network that has an SSID of “legolan” and uses WPA2 authentication. You can find more details of the various settings and configuration options here:


这里定义了网络SSID为“legolan”并使用wpa2验证,关于此配置文件更多例子见这里:


http://linux.die.net/man/5/wpa_supplicant.conf
http://linux.die.net/man/8/wpa_supplicant
You will probably need to run the wpa_passphrase command:
http://linux.die.net/man/8/wpa_passphrase
to create the shared key required to connect to your network.

Ok now we are ready to create the image. First off we need to format the card. basically we are creating two partitions one DOS, the second Linux. To format the card hook up an SD card reader and use the command:


下面来创建镜像,第一步先格式化这张卡,将该卡分两个区:第一个用于DOS,第二个Linux。运行下面的命令进行格式化


./format_sdcard.sh

This will prompt you for sudo access as required. Take care when specifying the device to format, you could end up formatting your hard disk!


此步骤会提示需要sudo密码。。。

Once you have a formatted card we can create the image. First remove and re-insert the card. On most Linux systems the system will automatically mount the two partitions (called LMS2012 and LMS2012_EXT), if they are not mounted automatically you will need to mount them before continuing. Make a note of the location that that card has been mounted (on Ubuntu this will be /media//), then issue the command:


格式化后我们来创建镜像先移除sd卡再重新插入。linux系统会重新挂载这两个分区(名叫LMS2012以及LMS2012_EXT),如果没有自动挂载这两个分区,可以手工用mount命令挂载后再继续。将挂载点的名字记载下来(Ubuntu在/media/下可以看到),然后输入以下命令

./update_sdcard.sh <mount point> <JVM tar file>

Where <mount point> is the location that the SD card is mounted and <JVM tar file> is name of the file you downloaded previously. On my system the command line would be:


这里<mount point>是SD卡的挂载点名字。<JVM tar file>是先前下载的文件:

./update_sdcard.sh /media/andy ejre-7u21-fcs-b11-linux-arm-sflt-headless-04_apr_2013.tar.gz


The script will then go ahead and create the boot image.


此脚本将会创建一个可启动镜像。

Once complete eject the SD card using the eject option in the Linux file browser and remove it from the reader. Make sure the EV3 is powered off and then insert the card into the EV3 SD card slot. Press the enter button to boot the EV3. As the system boots it will turn on the Red LEDs when these turn off the EV3 will be ready to use. Shortly after the red light turns off the LCD screen will display the leJOS logo. Just below this you should see the IP address assigned to the EV3. If you do not see an IP address displayed then something has gone wrong with the WiFi setup, check that you have correctly configured the wpa_supplicant.conf and that you are using a supported WiFi device. If necessary re-run the update_sdcard.sh command to recreate the image.


当制作完成后正常退出SD卡,确认关闭EV3,再次插入SD卡,按Enter开启SD卡。当系统启动时红色LED会打开直到系统启动结束再自动关闭提示可以开始使用。

然后LCD屏幕上会显示leJOS logo.在此之后可以看到分配给EV3的IP地址。如果不显示这些,仔细检查配置文件wpa_supplicant.conf。必要时重新使用update_sdcard脚本重新创建SD卡镜像。


Once the EV3 has booted you should be able to connect to the displayed IP address using either ssh or telnet. Login as root with no password. Once connected you can now check that it is possible to run leJOS based Java programs. cd to the the /home/root/lejos/samples directory and type:


一切OK后,可以使用ssh或者telnet登陆EV3(telnet ip地址),登陆账户名root,密码为空。连上后就可以cd进入/home/root/lejos/samples并运行


jrun EV3HelloWorld

After a short while the program should play some sounds, light up the EV3 LEDs and display a message on the EV3 display.

。。。。。。

原文地址: http://sourceforge.net/p/lejos/wiki/Creating%20a%20bootable%20SD%20card/



如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
发表于 2016-4-18 22:45:41 | 显示全部楼层
装了lejos启动EV3后,蓝牙怎么总和电脑连接不上呢? 互相都发现了,用EV3找到设备,就是电脑了,连接时候总提示输入电脑的PIN,1234 , 0000 都试过了,提示unsuccessful ,press any key,就退出了。 请教,怎么解决?
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复 1 0

使用道具 举报

 楼主| 发表于 2013-9-21 01:31:50 | 显示全部楼层
本帖最后由 ntwuhui 于 2013-9-21 19:57 编辑

对于创建两个分区的补充:

Partition 1: At least 4 MBytes size, filesystem type 0x0c / W95/FAT32, named "LMS2012" (not sure if this is needed).
Partition 2: The available space, filesystem type 0x83 / Linux ext3 / named "LMS2012_EXT" (not sure if this is needed).

分区1:至少4MB,文件类型为0x0c / W95/FAT32, 名叫 "LMS2012" (不确信是否必须)分区2:可用空间,文件类型为0x83 / Linux ext3 /, 名叫 "LMS2012_EXT" (不确信是否必须)

Put the kernel (uImage) in the first partition and the lms filesystem in the second partition.

将内核(uImage)放入第一分区,lms文件系统放置第二分区。

You can extract the firmware bin files from LEGO:

你可以从固件文件中解压如下文件:

EV3_firmware_1.03H.bin
uBoot: 0x000000 - 0x04ffff
uImage: 0x050000 - 0x24ffff
lms2012cramfs: 0x250000 - 0xcb0000

Throw away uBoot, put uImage in the first partition and extract the cramfs to the second partition.
扔掉uBoot文件,只将uImage核心文件放置在第一分区并将cramfs释放放在第二分区。

如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-9-21 18:26:21 | 显示全部楼层
非常不错,自制EV3 ROM以后会非常流行!这是第一步!
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-9-22 23:50:20 | 显示全部楼层
这样说来,是不是以后EV3就不用像NXT那样刷机了?直接插卡就可以使用java?
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2013-9-23 12:35:11 | 显示全部楼层
是的,系统在卡里边呢;当然有人正研究直接在ev3系统下直接内置java呢
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-9-26 20:14:02 | 显示全部楼层
谢谢分享!同时更正一处翻译错误:
copy the downloaded tar file into the lejosimage directory.
并用tar解压到lejosimage文件夹中

这句话应该是”将下载到的tar文件复制到lejosimage文件夹中“(不要解压)
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2013-9-27 00:44:49 | 显示全部楼层
hyj53 发表于 2013-9-26 20:14
谢谢分享!同时更正一处翻译错误:
copy the downloaded tar file into the lejosimage directory.
并用t ...

已经更正。谢谢反馈!本人水平有限,e文好的请直接看原文!
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-10-16 10:39:30 | 显示全部楼层
收藏了,下次慢慢整
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-10-16 11:14:31 | 显示全部楼层
好帖,支持。慢慢学习。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-10-21 21:43:04 来自手机 | 显示全部楼层
支持加鼓励,俺刚刚入门需要慢慢学习
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-12-10 22:24:30 | 显示全部楼层
EV3用的卡到底是TF呢还是SD卡哟~机器还没收到不敢买卡
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-12-10 23:15:07 | 显示全部楼层
本帖最后由 静候轮回 于 2014-1-11 13:52 编辑
jy00889076 发表于 2013-12-10 22:24
EV3用的卡到底是TF呢还是SD卡哟~机器还没收到不敢买卡
是Micro SD
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2013-12-13 11:26:41 | 显示全部楼层
这个启动卡用在别的功能上也非常好,这样的linux就可以全盘读写了,乐高里面的系统是压缩格式的,所以除项目目录外都是没有改写权限的,很多linux功能都配置不了,比如自启动程序。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2014-1-11 01:04:25 | 显示全部楼层
静候轮回 发表于 2013-12-13 11:26
这个启动卡用在别的功能上也非常好,这样的linux就可以全盘读写了,乐高里面的系统是压缩格式的,所以除项 ...

我目前也走到如何自启动问题的问题上了,能启动dropbear服务就OK了
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2014-7-3 20:52:58 | 显示全部楼层
不错。很好的文章。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

手机版|中文乐高 ( 桂ICP备13001575号-7 )

GMT+8, 2024-11-23 11:23 , Processed in 0.098320 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表