steps:
1. 從 http://sourceforge.net/projects/strace/files/strace/ 下載strace source code
2. 解壓縮 source
3. ./configure --host=arm-linux CC=arm-unknown-linux-uclibcgnueabi-gcc LD=arm-unknown-linux-uclibcgnueabi-ld , 配置makefile
4. make CFLAGS="-static" , 產生靜態可執行檔
5. (可做可不做) arm-linux-strip strace , 縮減strace的size
完成, 之後就可以把strace copy到ARM 的 linux平台上執行了
source:
http://hamersun.blogspot.tw/2010/05/strace-for-arm.html
2014年12月29日 星期一
Linux 解/壓縮指令
source:
http://note.drx.tw/2008/04/command.html
http://note.drx.tw/2008/04/command.html
.tar (僅打包,無壓縮)
- 套件名稱:tar。
- 打包:
[ jonny@linux ~ ]
$ tar cvf FileName.tar DirName - 解包:
[ jonny@linux ~ ]
$ tar xvf FileName.tar
.gz
- 套件名稱:gzip。
- 壓縮
[ jonny@linux ~ ]
$ gzip FileName - 解壓縮1:
[ jonny@linux ~ ]
$ gunzip FileName.gz - 解壓縮2:
[ jonny@linux ~ ]
$ gzip -d FileName.gz
.tar.gz
- 套件名稱:gzip。
- 壓縮:
[ jonny@linux ~ ]
$ tar zcvf FileName.tar.gz DirName - 解壓縮:
[ jonny@linux ~ ]
$ tar zxvf FileName.tar.gz
bz
- 壓縮:unkown。
- 解壓縮1:
[ jonny@linux ~ ]
$ bzip2 -d FileName.bz - 解壓縮2:
[ jonny@linux ~ ]
$ bunzip2 FileName.bz
.tar.bz
- 壓縮:unkown。
- 解壓縮:
[ jonny@linux ~ ]
$ tar jxvf FileName.tar.bz
.bz2
- 套件名稱:bzip2。
- 壓縮:
[ jonny@linux ~ ]
$ bzip2 -z FileName - 解壓縮1:
[ jonny@linux ~ ]
$ bzip2 -d FileName.bz2 - 解壓縮2:
[ jonny@linux ~ ]
$ bunzip2 FileName.bz2
.tar.bz2
- 套件名稱:bzip2。
- 壓縮:
[ jonny@linux ~ ]
$ tar jcvf FileName.tar.bz2 DirName - 解壓縮:
[ jonny@linux ~ ]
$ tar jxvf FileName.tar.bz2
.xz
- 套件名稱:xz-utils。
- 壓縮:
[ jonny@linux ~ ]
$ xz -z FileName - 解壓縮:
[ jonny@linux ~ ]
$ xz -d FileName.xz
.tar.xz
- 套件名稱:xz-utils。
- 壓縮:
[ jonny@linux ~ ]
$ tar Jcvf FileName.tar.xz DirName - 解壓縮:
[ jonny@linux ~ ]
$ tar Jxvf FileName.tar.xz
.Z
- 壓縮:compress FileName
- 解壓縮:
[ jonny@linux ~ ]
$ uncompress FileName.Z
.tar.Z
- 壓縮:
[ jonny@linux ~ ]
$ tar Zcvf FileName.tar.Z DirName - 解壓縮:
[ jonny@linux ~ ]
$ tar Zxvf FileName.tar.Z
.tgz
- 套件名稱:gzip。
- 壓縮:
[ jonny@linux ~ ]
$ tar zcvf FileName.tgz FileName - 解壓縮:
[ jonny@linux ~ ]
$ tar zxvf FileName.tgz
.tar.tgz
- 套件名稱:gzip。
- 壓縮:
[ jonny@linux ~ ]
$ tar zcvf FileName.tar.tgz FileName - 解壓縮:
[ jonny@linux ~ ]
$ tar zxvf FileName.tar.tgz
.7z
- 套件名稱:p7zip-full。
- 壓縮:
[ jonny@linux ~ ]
$ 7z a FileName.7z FileName - 使用密碼 (PASSWORD) 壓縮:
[ jonny@linux ~ ]
$ 7z a FileName.7z FileName -pPASSWORD - 解壓縮:
[ jonny@linux ~ ]
$ 7z x FileName.7z
.zip
- 套件名稱:zip。
- 壓縮:
[ jonny@linux ~ ]
$ zip FileName.zip DirName - 解壓縮:
[ jonny@linux ~ ]
$ unzip FileName.zip
.rar
- 套件名稱:rar, unrar。
- 壓縮:
[ jonny@linux ~ ]
$ rar a FileName.rar DirName - 解壓縮1:
[ jonny@linux ~ ]
$ rar e FileName.rar - 解壓縮2:
[ jonny@linux ~ ]
$ unrar e FileName.rar
.lha
- 套件名稱:lha。
- 壓縮:
[ jonny@linux ~ ]
$ lha -a FileName.lha FileName - 解壓縮:
[ jonny@linux ~ ]
$ lha -e FileName.lha
2014年12月25日 星期四
Android
[安裝環境]
第一支Android app程式教學-
http://readandplay.pixnet.net/blog/post/140001110-%E7%AC%AC%E4%B8%80%E6%94%AFandroid-app%E7%A8%8B%E5%BC%8F%E6%95%99%E5%AD%B8
不管你幾歲,都能開發 Android App 2
http://jpress.tw/android-dev2
不管你幾歲,都能開發 Android App 1
http://jpress.tw/android-dev
[APP範例]
這是 Jacky 版大的「在這提供一個初學 Android APPS 開發的教學網站」主題內
教學網中的一個基礎練習,練習範例的程式名稱為 BMI ( 體質量指數 Body Mass Index )。
http://gphonefans.net/thread-94517-1-1.html
這是近日在找學寫 app 的練習中,個人覺得很值得推薦的一個,因它包含了一個
app 最基本的簡單運作,只要願意花點時間去了解這個範例,便可建立一個簡單的
架構概念,對於學習寫 app 有一定的幫助;特別是當不想買書,只想從網上學點兒
如何寫 app 時 ( 我就是這樣 XD )。
而教學網中,範例是以 Eclipse 3.6 版來展示,但若以較新的 Eclipse 3.7.2 版本
來進行練習,在使用者介面設定上,將出現偏差及些微指令不適用,在此將範例
以 Eclipse 3.7.2 整理了一遍 。
範例的流程及解說,須請移玉步到 Jacky 版大主題內的教學網中參考,謝謝!
網頁:
http://gphonefans.net/thread-132873-1-1.html
第一支Android app程式教學-
http://readandplay.pixnet.net/blog/post/140001110-%E7%AC%AC%E4%B8%80%E6%94%AFandroid-app%E7%A8%8B%E5%BC%8F%E6%95%99%E5%AD%B8
不管你幾歲,都能開發 Android App 2
http://jpress.tw/android-dev2
不管你幾歲,都能開發 Android App 1
http://jpress.tw/android-dev
[APP範例]
這是 Jacky 版大的「在這提供一個初學 Android APPS 開發的教學網站」主題內
教學網中的一個基礎練習,練習範例的程式名稱為 BMI ( 體質量指數 Body Mass Index )。
http://gphonefans.net/thread-94517-1-1.html
這是近日在找學寫 app 的練習中,個人覺得很值得推薦的一個,因它包含了一個
app 最基本的簡單運作,只要願意花點時間去了解這個範例,便可建立一個簡單的
架構概念,對於學習寫 app 有一定的幫助;特別是當不想買書,只想從網上學點兒
如何寫 app 時 ( 我就是這樣 XD )。
而教學網中,範例是以 Eclipse 3.6 版來展示,但若以較新的 Eclipse 3.7.2 版本
來進行練習,在使用者介面設定上,將出現偏差及些微指令不適用,在此將範例
以 Eclipse 3.7.2 整理了一遍 。
範例的流程及解說,須請移玉步到 Jacky 版大主題內的教學網中參考,謝謝!
網頁:
http://gphonefans.net/thread-132873-1-1.html
2014年12月23日 星期二
修改 u-boot (recover mode )
modify=>cmd_bootm.c ( extern do_recover )
modify=>auto_update.c (新增 do_recover)
modify=>gm8139.h (定義 nand or nor flash)
modify=>fw_env.h (修改 config 路徑 "/mnt/mtd/fw_env.config")
modify=>fw_env.config (修改 device offset 路徑")
modify=>fw_env_main.c (修改 lockname = "/var/locks/ ")
[command line]
workspace/uboot#./make_8136 =====>看哪個平台可以切換
workspace/uboot#cp u-boot.bin => 燒錄目錄
workspace/uboot#cat /proc/mtd => 看 parition
** command line 下 make 出可設定 uboot 的 tool
- 在/uboot/tools/env 底下
- fw_env.config
../gm8139.h 下定義
(SPI NOR)
workspace/uboot#export PATH=/usr/src/arm-linux-3.3/toolchain_gnueabi-4.4.0_ARMv5TE/usr/bin:$PATH
workspace/uboot#make HOSTCC=arm-unknown-linux-uclibcgnueabi-gcc HOSTSTRIP=arm-unknown-linux-uclibcgnueabi-strip env
workspace/uboot#cd tools/env
int do_recover(void)
{
char cmd_load_image[128];
unsigned int offset,partsz;
unsigned int *mem_tmp;
int flag = H_HIDE_DOT;
/* get u-boot environment */
ENTRY e, *ep;
flag &= ~H_HIDE_DOT;
e.key = "recover_check";
e.data = NULL;
hsearch_r(e, FIND, &ep, &env_htab, flag);
/* It must need to burn in the empty partition at the end of all */
/* first-time check after burn-in image */
if (ep == NULL)
{
printf("there is no recover_check and insert !! \n");
e.key = "recover_check"; // pattern name in u-boot environment
e.data = "0xaaaaaaaa"; // pattern value in u-boot environment
hsearch_r(e, ENTER, &ep, &env_htab, flag);
if (!ep) {
printf("error inserting for u-boot variable !!\n");
return -1;
}
saveenv();
return 1;
}
//printf("%s=%s\n", ep->key, ep->data);
/* check checksum */
if(strcmp(ep->data,"0xaaaaaaaa")==0)
{
printf("burned-in image: no problem ! \n");
return 1;
}
else
{
printf("burned-in image: error ! \n\n");
printf("start recover mode >>>>> \n");
printf("recover mode: copy image ...... \n");
/* recovered partition */
#ifdef CONFIG_SPI_NAND_GM
offset = nand_sys_hdr->image[4].addr;
partsz = nand_sys_hdr->image[4].size+nand_sys_hdr->image[5].size+nand_sys_hdr->image[6].size;
#else
offset = spi_sys_hdr->image[4].addr;
partsz = spi_sys_hdr->image[4].size+spi_sys_hdr->image[5].size+spi_sys_hdr->image[6].size;
#endif
printf("recover mode: offset = 0x%x size = 0x%x \n",offset , partsz);
/* clear the memory tmp */
mem_tmp = (unsigned int *)malloc(partsz);
memset(mem_tmp, 0x00, partsz);
#ifdef CONFIG_SPI_NAND_GM
sprintf(cmd_load_image, "nand read 0x%x 0x%x 0x%x", (unsigned int)mem_tmp ,offset , partsz);
offset = nand_sys_hdr->image[1].addr;
#else
sprintf(cmd_load_image, "sf probe 0:0;sf read 0x%x 0x%x 0x%x", (unsigned int)mem_tmp ,offset , partsz);
offset = spi_sys_hdr->image[1].addr;
#endif
/* start read from spi flash to memory */
if (run_command(cmd_load_image, 0) != 0) {
printf("copy image fail \n");
return -1;
}
printf("recover mode: recover image ...... \n");
printf("recover mode: offset = 0x%x size = 0x%x \n",offset , partsz);
/* start write from memory to spi flash */
#ifdef CONFIG_SPI_NAND_GM
sprintf(cmd_load_image, "nand erase 0x%x 0x%x", offset, partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("erase partition fail \n");
return -1;
}
/* update partition */
sprintf(cmd_load_image, "nand write 0x%x 0x%x 0x%x", (unsigned int)mem_tmp , offset ,partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("write partition fail \n");
return -1;
}
offset = nand_sys_hdr->image[6].size+nand_sys_hdr->image[6].addr;
#else
sprintf(cmd_load_image, "sf probe 0:0;sf update 0x%x 0x%x 0x%x", (unsigned int)mem_tmp , offset ,partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("update image fail \n");
return -1;
}
offset = spi_sys_hdr->image[6].size+spi_sys_hdr->image[6].addr;
#endif
printf("recover mode: recover finish ...... \n");
/* set checksum after recovering */
e.key = "recover_check";
e.data = "0xaaaaaaaa";
hsearch_r(e, ENTER, &ep, &env_htab, flag);
if (!ep) {
printf("Error inserting for u-boot variable !!\n");
return -1;
}
saveenv();
}
printf("\n");
do_reset(NULL, 0, 0, NULL); // reset the system after recover-mode
return 1;
}
modify=>auto_update.c (新增 do_recover)
modify=>gm8139.h (定義 nand or nor flash)
modify=>fw_env.h (修改 config 路徑 "/mnt/mtd/fw_env.config")
modify=>fw_env.config (修改 device offset 路徑")
modify=>fw_env_main.c (修改 lockname = "/var/locks/ ")
[command line]
workspace/uboot#./make_8136 =====>看哪個平台可以切換
workspace/uboot#cp u-boot.bin => 燒錄目錄
workspace/uboot#cat /proc/mtd => 看 parition
** command line 下 make 出可設定 uboot 的 tool
- 在/uboot/tools/env 底下
- fw_env.config
../gm8139.h 下定義
(SPI NOR)
#define CONFIG_ENV_OFFSET 0x50000
#define CONFIG_ENV_SIZE 0x10000
(SPI NAND)
#define CONFIG_ENV_OFFSET 0x220000
#define CONFIG_ENV_SIZE 0x20000
fw_env.config => SPI NOR
/dev/mtd0 A
0x10000
0x10000
1
如果燒錄的uboot位址是 0x10000
A = 0x50000-0x10000=0x40000
fw_env.h => 修改 config 路徑
#define CONFIG_FILE "/mnt/mtd/fw_env.config"
workspace/uboot#export PATH=/usr/src/arm-linux-3.3/toolchain_gnueabi-4.4.0_ARMv5TE/usr/bin:$PATH
workspace/uboot#make HOSTCC=arm-unknown-linux-uclibcgnueabi-gcc HOSTSTRIP=arm-unknown-linux-uclibcgnueabi-strip env
workspace/uboot#cd tools/env
int do_recover(void)
{
char cmd_load_image[128];
unsigned int offset,partsz;
unsigned int *mem_tmp;
int flag = H_HIDE_DOT;
/* get u-boot environment */
ENTRY e, *ep;
flag &= ~H_HIDE_DOT;
e.key = "recover_check";
e.data = NULL;
hsearch_r(e, FIND, &ep, &env_htab, flag);
/* It must need to burn in the empty partition at the end of all */
/* first-time check after burn-in image */
if (ep == NULL)
{
printf("there is no recover_check and insert !! \n");
e.key = "recover_check"; // pattern name in u-boot environment
e.data = "0xaaaaaaaa"; // pattern value in u-boot environment
hsearch_r(e, ENTER, &ep, &env_htab, flag);
if (!ep) {
printf("error inserting for u-boot variable !!\n");
return -1;
}
saveenv();
return 1;
}
//printf("%s=%s\n", ep->key, ep->data);
/* check checksum */
if(strcmp(ep->data,"0xaaaaaaaa")==0)
{
printf("burned-in image: no problem ! \n");
return 1;
}
else
{
printf("burned-in image: error ! \n\n");
printf("start recover mode >>>>> \n");
printf("recover mode: copy image ...... \n");
/* recovered partition */
#ifdef CONFIG_SPI_NAND_GM
offset = nand_sys_hdr->image[4].addr;
partsz = nand_sys_hdr->image[4].size+nand_sys_hdr->image[5].size+nand_sys_hdr->image[6].size;
#else
offset = spi_sys_hdr->image[4].addr;
partsz = spi_sys_hdr->image[4].size+spi_sys_hdr->image[5].size+spi_sys_hdr->image[6].size;
#endif
printf("recover mode: offset = 0x%x size = 0x%x \n",offset , partsz);
/* clear the memory tmp */
mem_tmp = (unsigned int *)malloc(partsz);
memset(mem_tmp, 0x00, partsz);
#ifdef CONFIG_SPI_NAND_GM
sprintf(cmd_load_image, "nand read 0x%x 0x%x 0x%x", (unsigned int)mem_tmp ,offset , partsz);
offset = nand_sys_hdr->image[1].addr;
#else
sprintf(cmd_load_image, "sf probe 0:0;sf read 0x%x 0x%x 0x%x", (unsigned int)mem_tmp ,offset , partsz);
offset = spi_sys_hdr->image[1].addr;
#endif
/* start read from spi flash to memory */
if (run_command(cmd_load_image, 0) != 0) {
printf("copy image fail \n");
return -1;
}
printf("recover mode: recover image ...... \n");
printf("recover mode: offset = 0x%x size = 0x%x \n",offset , partsz);
/* start write from memory to spi flash */
#ifdef CONFIG_SPI_NAND_GM
sprintf(cmd_load_image, "nand erase 0x%x 0x%x", offset, partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("erase partition fail \n");
return -1;
}
/* update partition */
sprintf(cmd_load_image, "nand write 0x%x 0x%x 0x%x", (unsigned int)mem_tmp , offset ,partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("write partition fail \n");
return -1;
}
offset = nand_sys_hdr->image[6].size+nand_sys_hdr->image[6].addr;
#else
sprintf(cmd_load_image, "sf probe 0:0;sf update 0x%x 0x%x 0x%x", (unsigned int)mem_tmp , offset ,partsz);
if (run_command(cmd_load_image, 0) != 0) {
printf("update image fail \n");
return -1;
}
offset = spi_sys_hdr->image[6].size+spi_sys_hdr->image[6].addr;
#endif
printf("recover mode: recover finish ...... \n");
/* set checksum after recovering */
e.key = "recover_check";
e.data = "0xaaaaaaaa";
hsearch_r(e, ENTER, &ep, &env_htab, flag);
if (!ep) {
printf("Error inserting for u-boot variable !!\n");
return -1;
}
saveenv();
}
printf("\n");
do_reset(NULL, 0, 0, NULL); // reset the system after recover-mode
return 1;
}
2014年11月17日 星期一
make fw_printenv 的方式
1. /uboot/ 下
make HOSTCC=arm-unknown-linux-uclibcgnueabi-gcc HOSTSTRIP=arm-unknown-linux-uclibcgnueabi-strip env
2./uboot/tools/env/ 下
cp fw_printenv => /mnt/mtd
cp fw_printenv => /mnt/mtd/fw_setenv
cp fw_env.config => /mnt/mtd/
fw_env.h 定義
#define CONFIG_FILE "/mnt/mtd/fw_env.config"
3.fw_env.config 內容
#define
CONFIG_ENV_OFFSET
0x220000
#define
CONFIG_ENV_SIZE
0x20000
cat /proc/mtd => erase size = 0x20000
uboot 燒錄 offset 0x140000 size 0x100000
fw_env.config
/dev/mtd0 A
0x20000
0x20000
1
A = 220000-140000
4./mnt/mtd 下
./fw_printenv
./fw_setenv aaa 1
5.開機至 uboot 與 linux user space 下查看 => OK
在Linux里读取UBOOT环境变量
source: http://www.cnblogs.com/pengdonglin137/p/3564508.html
转载:http://falloutmx.blog.163.com/blog/static/39236020201211145010154/
可以通过mtd方式读取,也可以用ioremap方式。不过这些都比较麻烦,简单的方法有两种,一种是mtd_debug,另一种是fw_printenv。前者是一个软件包,需要单独下载安装。后一个就是我目前使用的方式,是Uboot带的一个工具,使用方法如下:
1、编译fw_printenv工具
在你uboot目录下用以下编译指令:
make env成功后在tools/env下会生成fw_printenv,如果提示缺少mtd-user.h文件,从系统中拷贝过来即可:
cp /usr/include/mtd/ ./include/mtd -a
2、修改配置文件
根据mtd分区、UBOOT环境变量的位置、大小等内容修改tools/env下的fw_env.config文件,可参见/tools/env/README文件。这 个工具还需要一个配置文件,以获取uboot的ENV区域的位置信息。默认状态下,请将fw_env.config文件拷贝到目标机的文件系统的/etc 目录下。然后结合uboot配置中定义的ENV区和Linux下mtd分区的情况修改配置文件。具体的修改方法见fw_env.config文件中的说明 及/tools/env/README文件。
3、使用fw_printenv工具
将编译好的fw_printenv拷贝到目标机的文件系统中,并将fw_env.config文件拷贝到目标机的文件系统的/etc 目录下。执行fw_printenv即可打印Uboot环境变量信息,如果没打印出来或者打印乱码,请检查配置文件是否正确
转载:http://labs.isee.biz/index.php/How_to_modify_the_uboot_environment_from_userspace
How to modify the uboot environment from userspace
Overview
This How-To is meant to be a starting point for people to learn how access to the uboot environment from userspace.
This is my first wiki page so please be benevolent with the formatting :-)
Tools needed
In order to modify the uboot environment variables from userspace we will need a program called fw_setenv, we can compile this program ourselves from the u-boot sources, follow the instructions in this wiki page and then proceed to compile with (don't modify the .h file as it says in the tools/env/README file):
make env
This will give us fw_printenv, in order to get fw_setenv we just have to change the name of the file. Magic!!
cp fw_printenv fw_setenv
The next thing we will need is the fw_env.config file with the appropiate settings for our board. Here comes the confusion :-)
In this file you have to specify:
- MTD device name
- Device Offset
- Environment Size
- Flash sector size
- Number of sectors (ignored in NOR)
Finding out the correct values for fw_env.config
Ok, so in order to get all this information the easyest thing is to read it from dmesg or from /proc/mtd
cat /proc/mtd
All my initial confusion comes from using an incorrect kernel, my first tries where with 2.6.28.10 and the driver used to read mtd was NAND, in the kernel configuration file I only had :
CONFIG_MTD_NAND=y
being the output of /proc/mtd:
dev: size erasesize name
mtd0: 00080000 00040000 "X-Loader"
mtd1: 001e0000 00040000 "U-Boot"
mtd2: 00020000 00040000 "U-Boot Env"
mtd3: 00500000 00040000 "Kernel"
mtd4: 1f880000 00040000 "File System"
through "dmesg" I could see this line indicating something was wrong:
[ 1174.517120] Creating 5 MTD partitions on "omap2-onenand":
[ 1174.522552] 0x00000000-0x00080000 : "X-Loader"
[ 1174.528381] 0x00080000-0x00260000 : "U-Boot"
[ 1174.533508] 0x00260000-0x00280000 : "U-Boot Env"
[ 1174.538177] mtd: partition "U-Boot Env" doesn't start on an erase block boundary -- force read-only
[ 1174.548126] 0x00280000-0x00780000 : "Kernel"
[ 1174.553192] 0x00780000-0x20000000 : "File System"
But if we use the aproppiate kernel, in my case 2.6.33.7-0 with the onenand driver instead of the nand driver:
CONFIG_MTD_ONENAND=y
The output of /proc/mtd is different:
dev: size erasesize name
mtd0: 00080000 00040000 "X-Loader"
mtd1: 00180000 00040000 "U-Boot"
mtd2: 00080000 00040000 "Environment"
mtd3: 00300000 00040000 "Kernel"
mtd4: 1fa80000 00040000 "File System"
Now we can fill in all the values we needed (that's what I thought)
- MTD device name ---> /dev/mtd2 ("u-boot environment")
- Device Offset ----> 80.000 + 18.000
- Environment Size ---> 80.000
- Flash sector size ---> 40.000
- Number of sectors (ignored in NOR)----> nothing
Pretty easy right? wrong!!! The right values are:
- MTD device name ----> /dev/mtd2
- Device Offset -----> 0x0000
- Environment Size -----> 0x01000
- Flash sector size ------> 0x020000
- Number of sectors (ignored in NOR) -----> nothing
I figured these out by reading different posts and by trial and error, but I still don't understand the environment size value or the flash sector size, I can imagine the device offset is 0 if you specify /dev/mtd2 but I'd be great if someone could edit this page and point out why are this the correct values.
Giving it a try
In order to give it a try is better to poke with fw_printenv than with fw_setenv, because the first one just tries to read, so go ahead and try it:
fw_printenv
this should output something like:
ethact=smc911x-0
distro=poky
project=poky-image-sato
ipaddr=192.168.254.254
netmask=255.255.255.0
gatewayip=192.168.254.10
serverip=192.168.254.10
addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}::eth0:
mmc-boot=mmc init 0; if fatload mmc 0 80000000 boot.ini; then source; else if fatload mmc 0 80000000 uImage; then run mmc-bootargs; bootm; fi; fi
onenand-bootargs=setenv bootargs ${bootargs-base} root=/dev/mtdblock4 rootfstype=jffs2 ; run addip
onenand-boot=run onenand-bootargs; onenand read 80000000 280000 400000 ; bootm 80000000
nfs-bootargs=setenv bootargs ${bootargs-base} root=/dev/nfs nfsroot=${serverip}:/srv/nfs/${distro}/${project}/${machine} ; run addip
nfs-boot=if ping ${serverip}; then run nfs-bootargs; tftp 0x80000000 ${distro}/${project}/${machine}/uImage; bootm; fi;
machine=igep0020
mmc-bootargs=setenv bootargs ${bootargs-base} root=/dev/mmcblk0p2 rw rootwait dieid=${dieid#}
dieid#=638a00040000000004036abc07016018
mpurate=110
stdin=serial
stdout=serial
stderr=serial
bootargs-base=mem=512M console=ttyS2,115200n8 console=tty0 omapfb.mode=dvi:1024x768MR-16@60 mpurate=110
bootcmd=run onenand-boot; run mmc-boot;
if you get something like:
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200
it means the values in /etc/fw_env.config are not correct, so don't even try fw_setenv
Using fw_setenv
Now that we found out the correct values for /etc/fw_env.config you can just use fw_setenv with the same syntax as if you were in u-boot command line, to assing a value don't use "=" but a space.
./fw_setenv test 1234
then fw_printenv should output
test=1234
notice we didn't need to use saveenv as we would do in u-boot command line.
That's it!!
转载:http://www.denx.de/wiki/DULG/HowCanIAccessUBootEnvironmentVariablesInLinux
- Question:
- I would like to access U-Boot's environment variables from my Linux application. Is this possible?
- Answer:
- Yes, you can. The environment variables must be stored in flash memory, and your Linux kernel must support flash access through the MTD layer. In the U-Boot source tree you can find the environment tools in the directory
tools/env, which can be built with command:
make env
For building against older versions of the MTD headers (meaning before v2.6.8-rc1) it is required to pass the argument "MTD_VERSION=old" to make:
make MTD_VERSION=old env
The resulting binary is called
fw_printenv, but actually includes support for setting environment variables too. To achieve this, the binary behaves according to the name it is invoked as, so you will have to create a link called fw_setenv to fw_printenv.
These tools work exactly like the U-Boot commands
printenv resp. setenv You can either build these tools with a fixed configuration selected at compile time, or you can configure the tools using the /etc/fw_env.config configuration file in your target root filesystem. Here is an example configuration file:# Configuration file for fw_(printenv/setenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
#########################################################################
# For TQM8xxL modules:
#########################################################################
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x8000 0x4000 0x4000
/dev/mtd0 0xC000 0x4000 0x4000
#########################################################################
# For NSCU:
#########################################################################
# MTD device name Device offset Env. size Flash sector size
#/dev/mtd1 0x0000 0x8000 0x20000
#/dev/mtd2 0x0000 0x8000 0x20000
#########################################################################
# For LWMON
#########################################################################
# MTD device name Device offset Env. size Flash sector size
#/dev/mtd1 0x0000 0x2000 0x40000
转载:http://blog.csdn.net/hangbing0203/article/details/4314576
u-boot在线更新 需编译mtd-utils,编译fw_printenv、fw_setenv, 和修改内核 1.编译mtd-utils 将编译的flash_eraseall、flashcp拷贝到/nfsroot/cq8401/sbin中 然后用命令 flash_eraseall /dev/mtd1 刷bootloader分区 用命令 flashcp /bootloader/u-boot.bin.336new /dev/mtd1 将新的u-boot写入u-boot分区 2.编译fw_printenv和fw_setenv 进入u-boot-1.1.3/ vi tools/env/Makefile 加入 CROSS_COMPILE = mipsel-linux- make -C tools/env all cp tools/env/fw_printenv /nfsroot/cq8401/sbin cd /nfsroot/cq8401/sbin ln -sf fw_printenv fw_setenv cp -av u-boot-1.1.3/tools/env/fw_env.config /nfsroot/cq8401/etc 问题汇总: 问题1: fw_env.c:34:27: 错误:linux/mtd/mtd.h:没有那个文件或目录 fw_env.c: 在函数‘fw_printenv’中: fw_env.c:244: 警告:初始化指针时目标与指针符号不一致 fw_env.c:259: 警告:传递‘fputs’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:262: 警告:传递‘puts’的参数 1 给指针时,目标与指针符号不一致 fw_env.c: 在函数‘fw_setenv’中: fw_env.c:293: 警告:对指针赋值时目标与指针符号不一致 fw_env.c:317: 警告:传递‘strcmp’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:318: 警告:传递‘strcmp’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:350: 警告:传递‘strlen’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:364: 警告:初始化指针时目标与指针符号不一致 fw_env.c: 在函数‘flash_io’中: fw_env.c:390: 错误:‘erase_info_t’未声明(在此函数内第一次使用) fw_env.c:390: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其 fw_env.c:390: 错误:所在的函数内也只报告一次。) fw_env.c:390: 错误:expected ‘;’ before ‘erase’ fw_env.c:393: 警告:传递‘open’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:409: 警告:传递‘open’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:421: 错误:‘erase’未声明(在此函数内第一次使用) fw_env.c:423: 错误:‘MEMUNLOCK’未声明(在此函数内第一次使用) fw_env.c:462: 错误:‘MEMERASE’未声明(在此函数内第一次使用) fw_env.c:519: 错误:‘MEMLOCK’未声明(在此函数内第一次使用) fw_env.c: 在函数‘parse_config’中: fw_env.c:719: 警告:传递‘stat’的参数 1 给指针时,目标与指针符号不一致 fw_env.c:726: 警告:传递‘stat’的参数 1 给指针时,目标与指针符号不一致 make: *** [fw_printenv] 错误 1 解决办法: 在tools/env/Makefile 加入CROSS_COMPILE = mipsel-linux- 问题2: Cannot parse config file: No such file or directory 解决办法: 在/etc下创建fw_env.config文件 问题3: Cannot parse config file: Invalid argument 解决办法: 修改文件权限 问题4: Bus error 解决办法: echo "/dev/mtd2 0x0000 0x20000 0x20000" > /etc/fw_env.config 问题5: Warning: Bad CRC, using default environment 问题6: Error: can't write fw_env to flash 5和6解决办法: 将Env. size 和 Flash sector size改为arch/mips/cq8401/com/setup.c中 所设定的值。 fw_env.config文件的内容 # Configuration file for fw_(printenv/saveenv) utility. # Up to two entries are valid, in this case the redundand # environment sector is assumed present. # MTD device name Device offset Env. size Flash sector size /dev/mtd2 0x0000 0x20000 0x20000 3.内核的修改 设置分区: 将arch/mips/cq8401/com/setup.c修改为以下,可以直接刷bootloader分区而不会将u-boot的配置空间擦除掉 static struct mtd_partition cq8401_mtd_parts[] = { { .name = "ROOTFS", .size = 0xC00000, .offset = 0, .mask_flags = 0, }, { .name = "BOOTLOADER", .size = 0x40000, .offset = MTDPART_OFS_APPEND, //.mask_flags = MTD_WRITEABLE, /* force read-only */ .mask_flags = 0, }, { .name = "uboot_env", .size = 0x20000, .offset = MTDPART_OFS_APPEND, .mask_flags = 0, }, { .name = "KERNEL", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_APPEND, .mask_flags = 0, } 进入系统可用 cat /proc/mtd 查看分区设置 根据uboot的配置空间的设备节点设置/etc/fw_env.config中的第一项MTD device name,根据其偏移地址设值Device offset,根据空间大小设置Env. size ,根据闪存扇区大小设置Flash sector size 如果需要保存和恢复uboot的配置空间,用以下命令: dd if=/dev/mtd2 of=env.bin 将配置空间的内容保存为文件env.bin dd if=env.bin of=/dev/mtd2 将配置文件env.bin写回配置空间 如果需要读出配置空间的内容,使用以下命令: fw_printenv 如果需要单独修改uboot的参数,使用以下命令: fw_setenv bootdelay 5 u-boot更新脚本 #! /bin/sh echo "##########################################" echo "Save uboot_env space" dd if=/dev/mtd2 of=env.bin echo "Erasure bootloader" flash_eraseall /dev/mtd1 echo "Erasure uboot_env space" flash_eraseall /dev/mtd2 echo "Ersure kernel " flash_eraseall /dev/mtd3 echo "##########################################" echo "Write new bootloader" flashcp /bootloader/u-boot.bin.336new /dev/mtd1 echo "Update u-boot completed" echo "Write new kernel" flashcp /bootloader/uImage /dev/mtd3 echo "Update kernel completed" echo "Write uboot coonfig" dd if=env.bin of=/dev/mtd2 echo "UPDATE completed" echo "##########################################"
2014年9月11日 星期四
linux 命令與問題解法
sudo passwd
Password: <--- 输入安装时那个用户的密码
Enter new UNIX password: <--- 新的Root用户密码
Retype new UNIX password: <--- 重复新的Root用户密码
Password: <--- 输入安装时那个用户的密码
Enter new UNIX password: <--- 新的Root用户密码
Retype new UNIX password: <--- 重复新的Root用户密码
==
開機後, 自動載入
sudo vi /etc/rc.local 加入下面這行
sudo mount -t vboxsf ShareFolder
/media/sf_ShareFolder/
==
修改locale
把语言环境变量改为英文
将Ubuntu系统语言环境改为英文的en_US.UTF-8
查看当前系统语言环境
locale
编辑配置文件,将zh_US.UTF-8改为en_US.UTF-8,zh改为en
sudo nano /etc/default/locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
==
當桌機的 Linux 硬碟滿了, 下述可以考慮先做清除的動作.
清空 Trash bin
apt-get clean # 清除 local repository 淘汰得 Package (deb)
apt-get autoclean # 清除舊版本的 暫存 Package (deb)
apt-get autoremove # 刪除系統不再使用的 Package
/var/cache/apt/archives # Package (deb) cache
/var/cache/apt/archives/partial # 沒有下載完成的 Package 放在這邊
~/.mozilla/firefox/*.default/Cache # 若已經指定進 Ram Disk, 就不用管這個.
/var/log/*
/tmp/*
==
Linux出現Read-Only,沒辦法寫檔案時,重新mount root目錄(/)或許可以解決
或
開機時若出現,以下訊息
=================================
Give root password for maintenance
(or type Control-D to continue):
=================================
$ mount -o remount,rw /
==
apt-get install vim
apt-get remove vim
==
xxx is not in the sudoers file 解決方法
(注意有- ,这和su是不同的,在用命令"su"的时候只是切换到root,但没有把root的环境变量传过去,还是当前用户的环境变量,用"su -"命令将环境变量也一起带过去,就象和root登录一样),然后
1、移动光标,到最后一行
2、按a,进入append模式
3、输入
your_user_name ALL=(ALL) ALL
4、按Esc
5、输入“:wq”(保存文件并退出)
http://my.oschina.net/scorpius/blog/60903
==
/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory
solution:
1
| su - |
1
| visudo //切记,此处vi和sudo之间没有空格 |
2、按a,进入append模式
3、输入
your_user_name ALL=(ALL) ALL
4、按Esc
5、输入“:wq”(保存文件并退出)
http://my.oschina.net/scorpius/blog/60903
==
/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory
solution:
sudo apt-get install libc6-dev-i386
http://askubuntu.com/questions/368404/make-command-compiling-errors
訂閱:
意見 (Atom)