2009-07-30 08:50:53     Catching the right offset...

Document created by Aaronwu Employee on Sep 24, 2013
Version 1Show Document
  • View in full screen mode

2009-07-30 08:50:53     Catching the right offset...

Emanuele Italia (ITALY)

Message: 78202   

 

Hello,

 

 

 

i'm tring to get the right offset for "fw_printenv".

 

I  have U-Boot 1.1.5 on Bf533-ezkit(SPI), the config file have these values:

 

ezkit533.h:

 

 

 

#define CFG_ENV_IS_IN_FLASH     1

 

#define CFG_ENV_ADDR            0x20020000

 

#define CFG_ENV_SECT_SIZE       0x10000 /* Total Size of Environment Sector */

 

 

 

/proc/mtd:

 

 

 

dev:    size   erasesize  name

 

mtd0: 01000000 00001000 "ROMfs"

 

mtd1: 00800000 00020000 "linux kernel"

 

mtd2: 0f800000 00020000 "file system"

 

mtd3: 00020000 00010000 "bootloader"

 

mtd4: 000e0000 00010000 "kernel"

 

mtd5: 00700000 00010000 "file system"

 

so i decided to put these values in "fw_env.config"

 

 

# MTD device name       Device offset   Env. size       Flash sector size

 

/dev/mtd3               0x20000         0x1000         0x1000

 

 

 

But it doesn't work... but if i put in "fw_env.config" these values:

 

/dev/mtd3               0x19308         0x1000         0x1000

 

i noticed this...

 

 

 

 

 

root:/www> ./strace -f ./fw_printenv

 

.

 

.

 

.

 

open("/dev/mtd3", O_RDONLY)             = 3

 

ioctl(3, 0x80204d01, 0x3dfe10)          = 0

 

lseek(3, 103176, SEEK_SET)              = 103176

 

read(3, "bootargs=root=/dev/mtdblock5 roo"..., 4096) = 4096

 

close(3)                                = 0

 

write(2, "Warning: Bad CRC, using defau"..., 47quiWarning: Bad CRC, using default environment

 

) = 47

 

write(1, "bootcmd=bootp; setenv bootargs r"..., 150bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatew

 

.

 

.

 

.

 

 

 

it seems i'm reading on the right device and quite near to offset value.

 

Looking the C struct decalred in "fw_env.c":

 

typedef struct environment_s {

 

        ulong crc;                      /* CRC32 over data bytes    */

 

        uchar flags;                    /* active or obsolete */

 

        uchar *data;

 

} env_t;

 

 

 

it seems that i must go back to take the CRC value.

 

Have you any suggestions?

 

Thanks in advance,

 

 

 

Emanuele

TranslateQuoteReplyEditDelete

 

 

2009-07-30 10:54:09     Re: Catching the right offset...

Robin Getz (UNITED STATES)

Message: 78219   

 

Emanuele:

 

Last time I tried - it was just the start of the env.

 

https://docs.blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:env#modifying_variables_from_linux

 

But - you need to make sure you are using the same version of userspace tools as U-Boot... Are you using the same release?

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-30 11:55:02     Re: Catching the right offset...

Emanuele Italia (ITALY)

Message: 78220   

 

i'm using "fw_printenv" from newer version because the old one doesn't compile:

 

 

 

 

 

CC=bfin-linux-uclibc-gcc AR=bfin-linux-uclibc-ar; make env

 

make -C tools/env all || exit 1

 

make[1]: Entering directory `/root/u-boot-1.1.5/tools/env'

 

bfin-uclinux-gcc -Wall -DUSE_HOSTCC crc32.c  fw_env.c  fw_env_main.c -o fw_printenv

 

crc32.c:15:18: error: zlib.h: No such file or directory

 

crc32.c:77: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘crc_table’

 

crc32.c:153: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘crc32’

 

crc32.c:155: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

 

crc32.c:156: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘len’

 

crc32.c:157: error: expected identifier or ‘(’ before ‘{’ token

 

fw_env.c:34:27: error: linux/mtd/mtd.h: No such file or directory

 

fw_env.c: In function ‘fw_printenv’:

 

fw_env.c:244: warning: pointer targets in initialization differ in signedness

 

fw_env.c:259: warning: pointer targets in passing argument 1 of ‘fputs’ differ in signedness

 

fw_env.c:262: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness

 

fw_env.c: In function ‘fw_setenv’:

 

fw_env.c:293: warning: pointer targets in assignment differ in signedness

 

fw_env.c:317: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness

 

fw_env.c:318: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness

 

fw_env.c:350: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness

 

fw_env.c:364: warning: pointer targets in initialization differ in signedness

 

fw_env.c: In function ‘flash_io’:

 

fw_env.c:390: error: ‘erase_info_t’ undeclared (first use in this function)

 

fw_env.c:390: error: (Each undeclared identifier is reported only once

 

fw_env.c:390: error: for each function it appears in.)

 

fw_env.c:390: error: expected ‘;’ before ‘erase’

 

fw_env.c:393: warning: pointer targets in passing argument 1 of ‘open’ differ in signedness

 

fw_env.c:409: warning: pointer targets in passing argument 1 of ‘open’ differ in signedness

 

fw_env.c:421: error: ‘erase’ undeclared (first use in this function)

 

fw_env.c:423: error: ‘MEMUNLOCK’ undeclared (first use in this function)

 

fw_env.c:462: error: ‘MEMERASE’ undeclared (first use in this function)

 

fw_env.c:519: error: ‘MEMLOCK’ undeclared (first use in this function)

 

fw_env.c: In function ‘parse_config’:

 

fw_env.c:717: warning: pointer targets in passing argument 1 of ‘stat’ differ in signedness

 

fw_env.c:724: warning: pointer targets in passing argument 1 of ‘stat’ differ in signedness

 

make[1]: *** [fw_printenv] Error 1

 

make[1]: Leaving directory `/root/u-boot-1.1.5/tools/env'

 

make: *** [env] Error 1

 

 

 

tring in different way to compile....

 

 

 

debian:~/u-boot-1.1.5/tools/env# bfin-uclinux-gcc -Wall -DUSE_HOSTCC -elf2flt -I/root/u-boot-1.1.5/include crc32.c  fw_env.c  fw_env_main.c -o fw_printenv

In file included from /root/u-boot-1.1.5/include/linux/posix_types.h:46,

                 from /root/u-boot-1.1.5/include/linux/types.h:8,

                 from /root/u-boot-1.1.5/include/linux/mtd/mtd.h:11,

                 from fw_env.c:34:

/root/u-boot-1.1.5/include/asm/posix_types.h:43: error: conflicting types for ‘__kernel_ipc_pid_t’

/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/bits/kernel_types.h:16: error: previous declaration of ‘__kernel_ipc_pid_t’ was here

/root/u-boot-1.1.5/include/asm/posix_types.h:44: error: conflicting types for ‘__kernel_uid_t’

/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/bits/kernel_types.h:17: error: previous declaration of ‘__kernel_uid_t’ was here

/root/u-boot-1.1.5/include/asm/posix_types.h:45: error: conflicting types for ‘__kernel_gid_t’

/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/bits/kernel_types.h:18: error: previous declaration of ‘__kernel_gid_t’ was here

/root/u-boot-1.1.5/include/asm/posix_types.h:72: error: conflicting types for ‘__kernel_fsid_t’

/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/bits/kernel_types.h:42: error: previous declaration of ‘__kernel_fsid_t’ was here

In file included from /root/u-boot-1.1.5/include/linux/mtd/mtd.h:12,

                 from fw_env.c:34:

/root/u-boot-1.1.5/include/linux/mtd/mtd-abi.h:11: error: expected specifier-qualifier-list before ‘uint32_t’

/root/u-boot-1.1.5/include/linux/mtd/mtd-abi.h:16: error: expected specifier-qualifier-list before ‘uint32_t’

/root/u-boot-1.1.5/include/linux/mtd/mtd-abi.h:61: error: expected specifier-qualifier-list before ‘uint8_t’

/root/u-boot-1.1.5/include/linux/mtd/mtd-abi.h:72: error: expected specifier-qualifier-list before ‘uint32_t’

/root/u-boot-1.1.5/include/linux/mtd/mtd-abi.h:93: error: expected specifier-qualifier-list before ‘uint32_t’

fw_env.c: In function ‘fw_printenv’:

fw_env.c:244: warning: pointer targets in initialization differ in signedness

fw_env.c:259: warning: pointer targets in passing argument 1 of ‘fputs’ differ in signedness

fw_env.c:262: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness

fw_env.c: In function ‘fw_setenv’:

fw_env.c:293: warning: pointer targets in assignment differ in signedness

fw_env.c:317: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness

fw_env.c:318: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness

fw_env.c:350: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness

fw_env.c:364: warning: pointer targets in initialization differ in signedness

fw_env.c: In function ‘flash_io’:

fw_env.c:390: error: ‘erase_info_t’ undeclared (first use in this function)

fw_env.c:390: error: (Each undeclared identifier is reported only once

fw_env.c:390: error: for each function it appears in.)

fw_env.c:390: error: expected ‘;’ before ‘erase’

fw_env.c:393: warning: pointer targets in passing argument 1 of ‘open’ differ in signedness

fw_env.c:409: warning: pointer targets in passing argument 1 of ‘open’ differ in signedness

fw_env.c:421: error: ‘erase’ undeclared (first use in this function)

fw_env.c: In function ‘parse_config’:

fw_env.c:717: warning: pointer targets in passing argument 1 of ‘stat’ differ in signedness

fw_env.c:724: warning: pointer targets in passing argument 1 of ‘stat’ differ in signedness

 

 

it seems that i must use another version.

 

any ideas to fix this compile issue?

 

Thanks in advance,

 

Emanuele

TranslateQuoteReplyEditDelete

 

 

2009-07-30 15:58:03     Re: Catching the right offset...

Robin Getz (UNITED STATES)

Message: 78226   

 

I used the one that was integrated into the uClinux dist. You should do the same.

 

user/blkfin-apps/u-boot-tools

 

CONFIG_USER_UBOOT_TOOLS

 

-Robin

QuoteReplyEditDelete

 

 

2009-07-31 05:21:08     Re: Catching the right offset...

Emanuele Italia (ITALY)

Message: 78243   

 

i don't find U-boot tools on 2007 uClinux. On 2008 version i found it and it compiles but it doesn't work.

 

My "fw_env.config" is :

 

# MTD device name       Device offset   Env. size       Flash sector size

 

/dev/mtd3               0x0000          0x2000         0x2000

 

TranslateQuoteReplyEditDelete

 

 

2009-07-31 07:49:07     Re: Catching the right offset...

Robin Getz (UNITED STATES)

Message: 78251   

 

Emanuele:

 

I have no idea if it works in the 2007 release in any way - since there were so many fixes between now and then.

 

Can you upgrade?

QuoteReplyEditDelete

 

 

2009-08-03 05:40:30     Re: Catching the right offset...

Emanuele Italia (ITALY)

Message: 78301   

 

Hello,

 

dumping the mtd3 (my bootloader partiton) into file, i noticed with hexdump that bootloader configuration it's compelalty different:

 

 

 

hexdump:

 

 

 

00019300  00 00 00 00 00 00 00 00  62 6f 6f 74 61 72 67 73  |........bootargs|

 

00019310  3d 72 6f 6f 74 3d 2f 64  65 76 2f 6d 74 64 62 6c  |=root=/dev/mtdbl|

 

00019320  6f 63 6b 35 20 72 6f 6f  74 66 73 74 79 70 65 3d  |ock5 rootfstype=|

 

00019330  6a 66 66 73 32 20 72 77  00 62 6f 6f 74 63 6d 64  |jffs2 rw.bootcmd|

 

00019340  3d 72 75 6e 20 73 70 69  62 6f 6f 74 00 62 6f 6f  |=run spiboot.boo|

 

00019350  74 64 65 6c 61 79 3d 33  00 62 61 75 64 72 61 74  |tdelay=3.baudrat|

 

00019360  65 3d 31 31 35 32 30 30  00 6c 6f 61 64 73 5f 65  |e=115200.loads_e|

 

00019370  63 68 6f 3d 31 00 65 74  68 61 64 64 72 3d 30 32  |cho=1.ethaddr=02|

 

00019380  3a 38 30 3a 61 64 3a 32  30 3a 33 31 3a 62 38 00  |:80:ad:20:31:b8.|

 

00019390  65 74 68 31 61 64 64 72  3d 30 32 3a 38 30 3a 61  |eth1addr=02:80:a|

 

000193a0  64 3a 32 30 3a 33 31 3a  62 39 00 69 70 61 64 64  |d:20:31:b9.ipadd|

 

000193b0  72 3d 31 39 32 2e 31 36  38 2e 31 2e 33 30 00 73  |r=192.168.1.30.s|

 

000193c0  65 72 76 65 72 69 70 3d  31 39 32 2e 31 36 38 2e  |erverip=192.168.|

 

000193d0  31 2e 32 00 70 72 65 62  6f 6f 74 3d 65 63 68 6f  |1.2.preboot=echo|

 

 

printenv from u-boot:

 

addnet=ip=10.0.0.100:10.0.0.254:192.168.1.1:255.255.255.0:BF1:eth0:on

filesize=2080eb

fileaddr=1000000

gatewayip=10.0.0.200

netmask=255.255.255.0

ipaddr=10.0.0.100

serverip=10.0.0.200

autostart=yes

nandboot=nboot 0x2000000 0x0

bootcmd=run nandboot

bootargs=ethaddr=00:09:45:56:50:B0 console=ttyBF0,115200 root=/dev/mtdblock2 rw

 

 

it's  strange behaviour, are they maybe the default configuration and not my personal one?

 

Anyway in hexdump i don't find my configuration( i saved it from u-boot).

 

Do you have any ideas?

 

Thanks in advance,

 

Emanuele

TranslateQuoteReplyEditDelete

 

 

2009-08-03 08:37:51     Re: Catching the right offset...

Robin Getz (UNITED STATES)

Message: 78305   

 

Emanuele:

 

If you upgrade your U-Boot - do you get the same thing?

 

-Robin

QuoteReplyEditDelete

 

 

2009-08-04 08:19:30     Re: Catching the right offset...

Emanuele Italia (ITALY)

Message: 78353   

 

i compiled the u-boot  but when i try to testing it,

 

u-boot say :

 

 

 

ip04>tftp 0x1000000 u-boot.bin

 

dm9000 i/o: 0x20100000, id: 0x90000a46

 

MAC: 00:09:45:56:50:b0

 

operating at 100M full duplex mode

 

Using DM9000#0 device

 

TFTP from server 10.0.0.200; our IP address is 10.0.0.100

 

Filename 'u-boot.bin'.

 

Load address: 0x1000000

 

Loading: checksum bad

 

checksum bad

 

checksum bad

 

T ########################

 

done

 

Bytes transferred = 119148 (1d16c hex)

 

Automatic boot of image at addr 0x01000000 ...

 

## Booting image at 01000000 ...

 

Bad Magic Number

 

 

 

 

 

i tried with "ldr" extension with the same result.

 

Do you have any ideas?

 

 

 

Thanks in advance,

 

 

 

Emanuele

TranslateQuoteReplyEditDelete

 

 

2009-08-04 08:28:23     Re: Catching the right offset...

Robin Getz (UNITED STATES)

Message: 78356   

 

Emanuele:

 

The "checksum bad" means the IP header checksum. Something is wrong with your network, your board, or the driver. (most likely the network).

 

.bin files are just that - binaries. So, use "go 0x1000000". rather than bootm.

 

-Robin

QuoteReplyEditDelete

 

 

2009-08-04 08:37:15     Re: Catching the right offset...

Emanuele Italia (ITALY)

Message: 78357   

 

ip04>tftp 0x1000000 u-boot.bin

dm9000 i/o: 0x20100000, id: 0x90000a46

MAC: 00:09:45:56:50:b0

operating at 100M full duplex mode

Using DM9000#0 device

TFTP from server 10.0.0.200; our IP address is 10.0.0.100

Filename 'u-boot.bin'.

Load address: 0x1000000

Loading: checksum bad

checksum bad

T ########################

done

Bytes transferred = 119148 (1d16c hex)

Automatic boot of image at addr 0x01000000 ...

## Booting image at 01000000 ...

Bad Magic Number

ip04>go 0x1000000

## Starting application at 0x01000000 ...

pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp

 

 

I don't think it's network problem because i can "load" kernel by tftp without problem....

TranslateQuoteReplyEditDelete

 

 

2009-09-18 06:42:46     Re: Catching the right offset...

Wang Xiang (CHINA)

Message: 80131   

 

Hi 

 

     I met the same issue. when I  wanted to download uImage via tftp in u-boot, the hint "checksum bad" displayed.

 

whereas the process of tftp can be finished and the file is right.

 

    The hardare platform is bf532 +DM9000AEP; And below is the hint of console. any idea?

 

 

 

 

 

ip04>reset

 

U-Boot 1.1.5 (Sep 17 2009 - 12:02:06)

 

CPU:   ADSP BF532 Rev.: 0.5

Board: IP04 IP-PBX

       http://www.rowetel.com/ucasterisk/ip04.html

Clock: VCO: 400 MHz, Core: 400 MHz, System: 133 MHz

SDRAM: 64 MB

In:    serial

Out:   serial

Err:   serial

nand_init :  drivers/nand.c

256 MiB

DM9000#0

starting from spi flash

Hit any key to stop autoboot:  3     0

ip04>tftp 0x1000000 gw24

 

dm9000 i/o: 0x20100000, id: 0x90000a46

MAC: 02:80:ad:20:31:b8

operating at 100M full duplex mode

Using DM9000#0 device

TFTP from server 192.168.0.222; our IP address is 192.168.0.15

Filename 'gw24'.

Load address: 0x1000000

Loading: * checksum bad

#################################################################

  #################################################################

  ################################checksum bad

#################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  ######

done

Bytes transferred = 5022528 (4ca340 hex)

ip04><INTERRUPT>

ip04>

 

Br

 

Wang Xiang

QuoteReplyEditDelete

 

 

2009-09-18 06:42:46     Re: Catching the right offset...

Wang Xiang (CHINA)

Message: 80132   

 

Hi 

 

     I met the same issue. when I  wanted to download uImage via tftp in u-boot, the hint "checksum bad" displayed.

 

whereas the process of tftp can be finished and the file is right.

 

    The hardare platform is bf532 +DM9000AEP; And below is the hint of console. any idea?

 

 

 

 

 

ip04>reset

 

U-Boot 1.1.5 (Sep 17 2009 - 12:02:06)

 

CPU:   ADSP BF532 Rev.: 0.5

Board: IP04 IP-PBX

       http://www.rowetel.com/ucasterisk/ip04.html

Clock: VCO: 400 MHz, Core: 400 MHz, System: 133 MHz

SDRAM: 64 MB

In:    serial

Out:   serial

Err:   serial

nand_init :  drivers/nand.c

256 MiB

DM9000#0

starting from spi flash

Hit any key to stop autoboot:  3     0

ip04>tftp 0x1000000 gw24

 

dm9000 i/o: 0x20100000, id: 0x90000a46

MAC: 02:80:ad:20:31:b8

operating at 100M full duplex mode

Using DM9000#0 device

TFTP from server 192.168.0.222; our IP address is 192.168.0.15

Filename 'gw24'.

Load address: 0x1000000

Loading: * checksum bad

#################################################################

  #################################################################

  ################################checksum bad

#################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  #################################################################

  ######

done

Bytes transferred = 5022528 (4ca340 hex)

ip04><INTERRUPT>

ip04>

 

Br

 

Wang Xiang

QuoteReplyEditDelete

 

 

2009-10-06 04:23:53     Re: Catching the right offset...

Mike Frysinger (UNITED STATES)

Message: 80888   

 

you didnt create your config file correctly.  look at the erasesize of /proc/mtd and compare it to what you wrote in your fw_env.config file for the flash sector size.

QuoteReplyEditDelete

 

 

2009-10-06 04:25:13     Re: Catching the right offset...

Mike Frysinger (UNITED STATES)

Message: 80889   

 

your issue is unrelated to this thread (updating u-boot env), so you should start your own thread.  really though you should ask your question on the project page of the people who actually make that hardware.  we dont make/know the board.

Attachments

    Outcomes