broncho a1 hack指南-准备硬件

本文介绍如何使用Broncho A1手机进行开发,包括所需硬件准备及Linux系统配置过程。适用于初学者及嵌入式Linux开发者。
AI助手已提取文章相关产品:
<!-- END HEADER --> <!-- LEFTBAR --> <!-- lixianjing added -->

转载时请注明出处和作者联系方式

文章出处:http://www.limodev.cn/blog
作者联系方式:李先静 <xianjimli at hotmail dot com>

很多朋友买Broncho A1就是冲着它的开放性来的,A1不但开放基本内核源代码,提供开发用的数据线,而且开放以前开发的Broncho Linux Platform手机平台。无论是对Just for fun的玩家,还是想学习嵌入式Linux开发的程序员,Broncho A1都是最好的选择之一。我们将写一系列的文章,为新手提供一个hack指南。也希望有兴趣的朋友加入文档的编写和修订工作中来。

1.准备硬件

要hack broncho A1非常容易,只需要一要开发用的数据线和一台Broncho A1手机即可。
broncho-a1
(broncho a1)

dev-lines
(开发用的数据线)

开发用的数据线由两根线组成,一根是USB线,另一根是USB转串口线。还有一个开关:
switch
开关断开时用于生产时自动下载,接通时用于开发时手工下载(上图为断开)。

另外还有一根电源线,如果没有电池时,可以使用外接电源。
power line
对于普通hacker来说,这根线没有什么用处。只要是注意保持正负极处于断开状态,否则是开不了机的。

现在我们把两个USB接头连接到电脑上,另外一端连接到broncho a1上(先取下电池)。电脑上需要安装Linux系统,虚拟机应该也可以(最好是原生的),我的几台电脑安装的是Fedora7/9/12,也推荐大家使用Fedora发行版。

现在我们检查一下串口设备和驱动是否正常:
[lixianjing@localhost ~]$ lsusb
Bus 001 Device 006: ID 054c:033e Sony Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 002 Device 002: ID 1b1a:0000
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

上面的PL2303是USB转串口的设备。

[lixianjing@localhost ~]$ lsmod
Module Size Used by
pl2303 18436 0
bnep 14848 2
rfcomm 34832 4
l2cap 22144 16 bnep,rfcomm
bluetooth 49120 5 bnep,rfcomm,l2cap
vboxnetadp 71472 0
vboxnetflt 76888 0
vboxdrv 107208 1 vboxnetflt
sunrpc 152084 3
iptable_filter 6528 0
ip_tables 13584 1 iptable_filter
ip6table_filter 6400 0
ip6_tables 14480 1 ip6table_filter
x_tables 14980 2 ip_tables,ip6_tables
cp2101 15364 0

这里可以看到pl2303内核模块已经加载。

[lixianjing@localhost ~]$ ll /dev/ttyUSB0
crw-rw—- 1 root uucp 188, 0 12-25 07:41 /dev/ttyUSB0

这里可以看到USB串口设备文件已经存在。

pl2303是很通用的USB转串口驱动,除非你的Linux版本太老,否则上面的步骤不会有任何问题。

到此为止,硬件准备好了。

您可能感兴趣的与本文相关内容

/* * File: gsnap.c * Author: Li XianJing <xianjimli@hotmail.com> * Brief: snap the linux mobile device screen. * * Copyright (c) 2009 Li XianJing <xianjimli@hotmail.com> * * Licensed under the Academic Free License version 2.1 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * History: * ================================================================ * 2009-08-20 Li XianJing <xianjimli@hotmail.com> created * 2011-02-28 Li XianJing <xianjimli@hotmail.com> suppport RGB888 framebuffer. * 2011-04-09 Li XianJing <xianjimli@hotmail.com> merge figofuture's png output. * ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565 * */ #include <png.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <jpeglib.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <linux/fb.h> #include <linux/kd.h> struct _FBInfo; typedef struct _FBInfo FBInfo; typedef int (*UnpackPixel)(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b); struct _FBInfo { int fd; UnpackPixel unpack; unsigned char *bits; struct fb_fix_screeninfo fi; struct fb_var_screeninfo vi; }; #define fb_width(fb) ((fb)->vi.xres) #define fb_height(fb) ((fb)->vi.yres) #define fb_bpp(fb) ((fb)->vi.bits_per_pixel>>3) #define fb_size(fb) ((fb)->vi.xres * (fb)->vi.yres * fb_bpp(fb)) static int fb_unpack_rgb565(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { unsigned short color = *(unsigned short*)pixel; *r = ((color >> 11) & 0xff) << 3; *g = ((color >> 5) & 0xff) << 2; *b = (color & 0xff )<< 3; return 0; } static int fb_unpack_rgb24(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = pixel[fb->vi.red.offset>>3]; *g = pixel[fb->vi.green.offset>>3]; *b = pixel[fb->vi.blue.offset>>3]; return 0; } static int fb_unpack_argb32(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = pixel[fb->vi.red.offset>>3]; *g = pixel[fb->vi.green.offset>>3]; *b = pixel[fb->vi.blue.offset>>3]; return 0; } static int fb_unpack_none(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b) { *r = *g = *b = 0; return 0; } static void set_pixel_unpacker(FBInfo* fb) { if(fb_bpp(fb) == 2) { fb->unpack = fb_unpack_rgb565; } else if(fb_bpp(fb) == 3) { fb->unpack = fb_unpack_rgb24; } else if(fb_bpp(fb) == 4) { fb->unpack = fb_unpack_argb32; } else { fb->unpack = fb_unpack_none; printf("%s: not supported format.\n", __func__); } return; } static int fb_open(FBInfo* fb, const char* fbfilename) { fb->fd = open(fbfilename, O_RDWR); if (fb->fd < 0) { fprintf(stderr, "can't open %s\n", fbfilename); return -1; } if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fb->fi) < 0) goto fail; if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &fb->vi) < 0) goto fail; fb->bits = mmap(0, fb_size(fb), PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0); if (fb->bits == MAP_FAILED) goto fail; printf("---------------framebuffer---------------\n"); printf("%s: \n width : %8d\n height: %8d\n bpp : %8d\n r(%2d, %2d)\n g(%2d, %2d)\n b(%2d, %2d)\n", fbfilename, fb_width(fb), fb_height(fb), fb_bpp(fb), fb->vi.red.offset, fb->vi.red.length, fb->vi.green.offset, fb->vi.green.length, fb->vi.blue.offset, fb->vi.blue.length); printf("-----------------------------------------\n"); set_pixel_unpacker(fb); return 0; fail: printf("%s is not a framebuffer.\n", fbfilename); close(fb->fd); return -1; } static void fb_close(FBInfo* fb) { munmap(fb->bits, fb_size(fb)); close(fb->fd); return; } static int snap2jpg(const char * filename, int quality, FBInfo* fb) { int row_stride = 0; FILE * outfile = NULL; JSAMPROW row_pointer[1] = {0}; struct jpeg_error_mgr jerr; struct jpeg_compress_struct cinfo; memset(&jerr, 0x00, sizeof(jerr)); memset(&cinfo, 0x00, sizeof(cinfo)); cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); if ((outfile = fopen(filename, "wb+")) == NULL) { fprintf(stderr, "can't open %s\n", filename); return -1; } jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = fb_width(fb); cinfo.image_height = fb_height(fb); cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, quality, TRUE); jpeg_start_compress(&cinfo, TRUE); row_stride = fb_width(fb) * 2; JSAMPLE* image_buffer = malloc(3 * fb_width(fb)); while (cinfo.next_scanline < cinfo.image_height) { int i = 0; int offset = 0; unsigned char* line = fb->bits + cinfo.next_scanline * fb_width(fb) * fb_bpp(fb); for(i = 0; i < fb_width(fb); i++, offset += 3, line += fb_bpp(fb)) { fb->unpack(fb, line, image_buffer+offset, image_buffer + offset + 1, image_buffer + offset + 2); } row_pointer[0] = image_buffer; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } jpeg_finish_compress(&cinfo); fclose(outfile); jpeg_destroy_compress(&cinfo); return 0; } //Ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565 static int snap2png(const char * filename, int quality, FBInfo* fb) { FILE *outfile; if ((outfile = fopen(filename, "wb+")) == NULL) { fprintf(stderr, "can't open %s\n", filename); return -1; } /* prepare the standard PNG structures */ png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); png_infop info_ptr = png_create_info_struct(png_ptr); /* setjmp() must be called in every function that calls a PNG-reading libpng function */ if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); fclose(outfile); return -1; } /* initialize the png structure */ png_init_io(png_ptr, outfile); // int width = 0; int height = 0; int bit_depth = 8; int color_type = PNG_COLOR_TYPE_RGB; int interlace = 0; width = fb_width(fb); height = fb_height(fb); png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type, (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* write the file header information */ png_write_info(png_ptr, info_ptr); png_bytep row_pointers[height]; png_byte* image_buffer = malloc(3 * width); int i = 0; int j = 0; unsigned char* line = NULL; for( ; i < height; i++ ) { line = (char*)fb->bits + i * width * fb_bpp(fb); for(j = 0; j < width; j++, line += fb_bpp(fb)) { int offset = j * 3; fb->unpack(fb, line, image_buffer+offset, image_buffer+offset+1, image_buffer+offset+2); } row_pointers[i] = image_buffer; png_write_rows(png_ptr, &row_pointers[i], 1); } png_destroy_write_struct(&png_ptr, &info_ptr); fclose(outfile); return 0; } int main(int argc, char* argv[]) { FBInfo fb; const char* filename = NULL; const char* fbfilename = NULL; if(argc != 3) { printf("\nUsage: %s [jpeg|png file] [framebuffer dev]\n", argv[0]); printf("Example: %s fb.jpg /dev/fb0\n", argv[0]); printf("-----------------------------------------\n"); printf("Powered by broncho(www.broncho.cn)\n\n"); return 0; } filename = argv[1]; fbfilename = argv[2]; memset(&fb, 0x00, sizeof(fb)); if (fb_open(&fb, fbfilename) == 0) { if(strstr(filename, ".png") != NULL) { snap2png(filename, 100, &fb); } else { snap2jpg(filename, 100, &fb); } fb_close(&fb); } return 0; } 以上代码使用/dev/fb0实现截图功能,请重构,使用/dev/dri/card0实现截图功能。
最新发布
11-25
前言: HackRF one是一款全开源的硬件+软件项目,其目的主要是为了提供廉价的SDR(软件定义无线电)方案,它类似于一个几十年前开始流行的基于软件的数字音频技术。正如声卡在计算机数字化的音频波形,软件无线电外设数字化无线电波形。这就像一个非常快的声卡与音箱和麦克风由天线所取代。一个单一的软件无线电平台,可以用来实现几乎任何无线技术(蓝牙,ZigBee,蜂窝技术,FM收音机等)。 PCB图片展示: 什么是软件定义的无线电(SDR) 软件定义的无线电(Software Defined Radio,SDR) 是一种无线电广播通信技术,它基于软件定义的无线通信协议而非通过硬连线实现。频带、空中接口协议和功能可通过软件下载和更新来升级,而不用完全更换硬件。 软件无线电利用现代化软件来操纵、控制传统的"纯硬件电路"的无线通信技术。软件无线电技术的重要价值在于:传统的硬件无线电通信设备只是作为无线通信的基本平台,而许多的通信功能则是由软件来实现,打破了有史以来设备的通信功能的实现仅仅依赖于硬件发展的格局。软件无线电技术的出现是通信领域继固定通信到移动通信,模拟通信到数字通信之后第三次革命。 HackRF One特性介绍: 10 MHz to 6 GHz operating frequency Half-duplex transceiver Up to 20 million samples per second 8-bit quadrature samples (8-bit I and 8-bit Q) Compatible with GNU Radio, SDR#, and more Software-configurable RX and TX gain and baseband filter Software-controlled antenna port power (50 mA at 3.3 V) SMA female antenna connector SMA female clock input and output for synchronization Convenient buttons for programming Internal pin headers for expansion Hi-Speed USB 2.0 USB-powered 附件内容包括: 整个软件定义无线电SDR设计模块原理图和PCB源文件、元器件库文件、材料清单、gerber等; 该HackRF On设计文档介绍; 源代码; host以及固件等; 原文出处:https://www.sparkfun.com/products/13001
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值