找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
楼主: qiushui_007

利用 Imagebuilder 可以生成自己所需要的固件, 告别和别人伸手乞讨固件的磨练

  [复制链接]
发表于 2012-12-20 04:50 | 显示全部楼层
泥马,真给力,我要顶!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2012-12-21 21:34 | 显示全部楼层
我要顶!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2012-12-22 00:02 | 显示全部楼层
厉害,顶,顶上呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2012-12-24 13:52 | 显示全部楼层
很难得看到秋水兄发的文章啊!必须顶!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2013-1-18 16:08 | 显示全部楼层
submars 发表于 2012-12-24 13:52
很难得看到秋水兄发的文章啊!必须顶!!!

哎, 代码囧图中, 来论坛的时间少了....
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-1-18 17:26 | 显示全部楼层
感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2013-1-19 16:17 | 显示全部楼层
刷不死的wr703N的u-boot, 是用uip 实现HTTP协议的,  大体看了下代码, 稍微总结如下:


//--- include/config.h, 生成的内容如下
#define CONFIG_AR7240 1
#define CONFIG_MACH_HORNET 1
#define CONFIG_HORNET_1_1_WAR 1
#define NEW_DDR_TAP_CAL 1
#define FLASH_SIZE 4

/* Automatically generated - do not edit */
#include <configs/ap121.h>
#define CONFIG_PID_WR70301  1
#define GPIO_SYS_LED_BIT    27
#define GPIO_SYS_LED_ON 0
#define GPIO_RST_BUTTON_BIT 11

---- include/configs/ap121.h, 相关的配置数据都在此文件!!!!
//#define FLASH_SIZE 4

#if (FLASH_SIZE == 8)
#define CFG_MAX_FLASH_BANKS     1       /* max number of memory banks */
#define CFG_MAX_FLASH_SECT      128     /* max number of sectors on one chip */
#define CFG_FLASH_SECTOR_SIZE   (64*1024)
#define CFG_FLASH_SIZE          0x00800000 /* Total flash size */

#elif (FLASH_SIZE == 4)
#define CFG_MAX_FLASH_BANKS     1       /* max number of memory banks */
#define CFG_MAX_FLASH_SECT      64      /* max number of sectors on one chip */
#define CFG_FLASH_SECTOR_SIZE   (64*1024)
#define CFG_FLASH_SIZE          0x00400000 /* Total flash size */

#else
/* For 2 MB flash */
#   error "not support 2MB flash now"
#define CFG_MAX_FLASH_BANKS     1       /* max number of memory banks */
#define CFG_MAX_FLASH_SECT      32      /* max number of sectors on one chip */
#define CFG_FLASH_SECTOR_SIZE   (64*1024)
#define CFG_FLASH_SIZE          0x00200000 /* Total flash size */
#endif

#define CONFIG_IPADDR   192.168.1.1
#define CONFIG_SERVERIP 192.168.1.2

----- net/uip-0.9/fsdata.c, httpd.c, fsdata.c,
#升级时的提示
Flashing...
The system is now trying to flash. If there is a problem, the LEDs will start to blink.
After a successful update the box will reboot

static const char data_index_html[] =
"HTTP/1.0 200 OKn"
"Server: uIP/0.9 (http://dunkels.com/adam/uip/)n"
"Content-type: text/htmln"
"n"
"<html>n"
"t<head>n"
"tt<title>n"
"tttFailsafe UIn"
"tt</title>n"
"t</head>n"
"t<body>n"
"tt<h1>Failsafe UI</h1>n"
"tt<form method="post" enctype="multipart/form-data">n"
"ttt<input type=file name=firmware>n"
"ttt<input type=submit>n"
"tt</form>n"
"t</body>n"
"</html>n";

const struct fsdata_file file_index_html[] =
{{file_404_html, "/index.html", data_index_html, sizeof(data_index_html)}};

-- httpd.c
void httpd_init(void)
{
    fs_init();
    uip_listen(HTONS(80));
}
upload_data = httpd_upload_data = (unsigned char *)do_http_tmp_address();
printf("received data will be stored at %pn", upload_data);
next = (unsigned char *)strstr((char *)boundary_start, "name="firmware";");

void httpd_appcall(void)
{
    //第一包
    if(hs->state == HTTP_FIRMWARE) {
        next = (unsigned char *)strstr((char *)boundary_start, "name="firmware";");
        if(!next)
        {
            uip_close();
            return;
        }
        next = (unsigned char *)strstr((char *)next, eol2); //rnrn
        if(!next)
        {
            printf("could not find start of datan");
            uip_close();
            return;
        }
        next += 4;  //此为首包的有效数据
        hs->script = 0;
        hs->state = HTTP_FIRMWARE;
        hs->upload = uip_len - (next - start);   //有效数据的长度
        hs->upload_total = len - (int)(next - boundary_start);
        hs->upload_total -= (strlen(boundary) + 6);
        //printf("storing %d bytes at %pn", (int)hs->upload, upload_data);
        for(i = 0; i < hs->upload; i++)
            upload_data = next;   //有效数据赋值
        upload_data += (int)hs->upload;
        printf("%d / %dn", (int)hs->upload, hs->upload_total);
        uip_slen = 0;
        return;
    }

    //后续包
    if(hs->state == HTTP_FIRMWARE) {
        if(uip_newdata()) {
            int i;
            hs->count = 0;
            uip_appdata[uip_len] = '';
            hs->upload += uip_len;
            //printf("storing %d bytes at %pn", uip_len, upload_data);
            printf("%d / %dn", (int)hs->upload, hs->upload_total);
            for(i = 0; i < uip_len; i++)
                upload_data = uip_appdata;
            upload_data += uip_len;
            uip_slen = 0;
            if(hs->upload >= hs->upload_total)
            {
                upload_running = 1;
                NetBootFileXferSize = hs->upload_total;
                fs_open(file_flash_html.name, &fsfile);
                hs->script = 0;
                hs->state = HTTP_FILE;
                hs->dataptr = fsfile.data;
                hs->count = fsfile.len;
            }
        }
    }
}
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-1-20 03:22 | 显示全部楼层
这个教程好..........
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-1-20 04:31 | 显示全部楼层

写的不错,谢谢总结。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2013-1-21 16:15 | 显示全部楼层
有想修改u-boot 代码的大神, 一起学习下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2013-2-17 08:52 | 显示全部楼层
本帖最后由 qiushui_007 于 2013-2-17 08:58 编辑

如果想更快捷的调试代码, 可以利用openwrt的交叉编译

1. shell中如下命令
export STAGING_DIR="~/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir"

2. hello.c, 代码如下:
/*------------------------------------------------------------------------------------------
openwrt之交叉编译
~/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc hello.c -o hello

如果直接在虚拟机上执行, 则错误如下
xxg@xxg-desktop:~/1-wire/helloword$ ./hello
bash: ./hello: cannot execute binary file

路由器上执行
chmod +x hello
./hello
-----------------------------------------------------------------------------------------*/

#include <stdio.h>

int main(int agrc, char *argv)
{
        printf ("oepnmips-openwrt-linux-gcc hello.c -o hello\n");
        return 1;
}


3. Makefile, 内容如下
OPENWRT = 1

ifeq ($(OPENWRT), 1)
CC = ~/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
CFLAGS += -L/home/xxg/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/lib

else
CC = gcc
endif

CFLAGS += -Wall -g

#可执行文件名和相关的obj文件
APP_BINARY = hello
OBJ = hello.o

all: APP_FILE

%.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<

APP_FILE: $(OBJ)
        $(CC) $(CFLAGS) $(OBJ) -o $(APP_BINARY)        $(LFLAGS)

clean:
        @echo "cleanning project"
        $(RM) *.a *.o *~ *.so *.lo $(APP_BINARY)
        @echo "clean completed"

.PHONY: clean

执行make则编译出 hello 可执行文件, 可以用winscp拷贝到路由器上.

4. 假设拷贝到路由器的 xutest目录下,
root@OpenWrt:/xutest# chmod +x hello
root@OpenWrt:/xutest# ./hello
mips-openwrt-linux-gcc hello.c -o hello
root@OpenWrt:/xutest#



我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-2-17 13:44 | 显示全部楼层
make
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-3-26 17:47 | 显示全部楼层
ding .谢谢!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-4-2 22:50 | 显示全部楼层
固件不是一般人能做的把!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2013-6-17 17:17 | 显示全部楼层
标记下,学习。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-20 08:44

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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