Re: bugfix: _barebox_image_size wrong if enable

2019-06-26 Thread
>>>
>>> AFAIR this only happened for linker variables that point to absolute
>>> addresses. Differences between addresses also worked with the older
>>> compilers, and I think this is what your patch does:
>>
>> No. my patch just for new toolchain. with old toolchain it has no effect,
>> Because all of the size is zero.
>>
>> By using the newer toolchain:
>>  arm-poky-eabi-gcc (GCC) 8.2.0
>>  GNU ld (GNU Binutils) 2.31.1.20180818
>>
>> In barebox config file:
>> CONFIG_TEXT_BASE=0x23e0
>> CONFIG_RELOCATABLE=y
> 
> With CONFIG_RELOCATABLE enabled TEXT_BASE should be 0x0 and this should
> be enforced by Kconfig dependencies. Which barebox version are you on
> and which SoC are you compiling for?

I'm using v2016.10.0 and my custom board based on friendlyarm-tiny2
-- 
Best Regards,
zzs


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: bugfix: _barebox_image_size wrong if enable

2019-06-23 Thread
How about this? Am wrong?

-- 
Best Regards,
zzs


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: bugfix: _barebox_image_size wrong if enable

2019-06-18 Thread
> No, it is corrected during runtime in relocate_to_current_adr(). It
> seems older compilers need a runtime relocation fixup for this.

Yes, in relocate_to_current_adr() the address all be fixed up.

But if _barebox_image_size, __bss_start and __bss_stop all zero. the
barebox_base calculated by arm_mem_barebox_image() would wrong. but because it
align the base to 1M. So mostly it works fine. If the barebox size larger than
1M. It should fail.

>
> AFAIR this only happened for linker variables that point to absolute
> addresses. Differences between addresses also worked with the older
> compilers, and I think this is what your patch does:

No. my patch just for new toolchain. with old toolchain it has no effect,
Because all of the size is zero.

By using the newer toolchain:
arm-poky-eabi-gcc (GCC) 8.2.0
GNU ld (GNU Binutils) 2.31.1.20180818

In barebox config file:
CONFIG_TEXT_BASE=0x23e0
CONFIG_RELOCATABLE=y

Without my patch, in barebox.map

0x0001ff40__bss_start = .

0x00021bec__bss_stop = .
0x00021bec_end = .
0xdc21ff40_barebox_image_size = 
(__bss_start - 0x23e0)

In code, printout barebox_base calculated by arm_mem_barebox_image():

barebox_image_size : 0xdc21ff40
__bss_stop : 0x00021bec
__bss_start : 0x0001ff40
membase : 0x2000
endmem  : 0x6000
barebox_base: 0x83d0

barebox_base outof memory region!

After using my patch, the outpus is:

barebox_image_size : 0x0001ff40
__bss_stop : 0x00021bec
__bss_start : 0x0001ff40
membase : 0x2000
endmem  : 0x6000
barebox_base: 0x5ff0


-- 
Best Regards,
zzs


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


bugfix: _barebox_image_size wrong if enable

2019-06-17 Thread
When a pbl image uncompress and call the normal barebox, In
barebox_non_pbl_start() it should call relocate_to_adr() to relocate barebox
to barebox_base. Ofcouse CONFIG_RELOCATABLE enabled.

And barebox_base calculated by:

#define barebox_image_size  (unsigned int)&_barebox_image_size

unsigned long barebox_size = barebox_image_size +
((unsigned long)&__bss_stop - (unsigned long)&__bss_start);

_barebox_image_size, __bss_stop, __bss_start all defined in linkscript
"arch/arm/lib32/barebox.lds.S"

But when I print there value in function barebox_non_pbl_start() with the
flowwing code:

putc_ll('X');
putc_ll('\r');
putc_ll('\n');
PUTHEX_LL(barebox_size);
putc_ll('\r');
putc_ll('\n');
PUTHEX_LL((unsigned long)&__bss_start);
putc_ll('\r');
putc_ll('\n');
PUTHEX_LL((unsigned long)&__bss_stop);
putc_ll('\r');
putc_ll('\n');

The result as floww:

X




It's so strange, SO objdump it:

00017424 :
   17424:   e59f61a0ldr r6, [pc, #416]  ; 175cc 

   17428:   e080a001add sl, r0, r1
   1742c:   e59f919cldr r9, [pc, #412]  ; 175d0 

   17430:   e1a08000mov r8, r0
   17434:   e92d4890push{r4, r7, fp, lr}
   17438:   e0895006add r5, r9, r6
   1743c:   e59fb190ldr fp, [pc, #400]  ; 175d4 

   17440:   e3a00058mov r0, #88 ; 0x58
   17444:   e1a07002mov r7, r2
   17448:   ebfffca7bl  166ec 
   1744c:   e06b5005rsb r5, fp, r5
   17450:   e3admov r0, #13
   17454:   ebfffca4bl  166ec 
   17458:   e3aamov r0, #10
   1745c:   ebfffca2bl  166ec 
   17460:   e1a5mov r0, r5
   17464:   ebe0bl  173ec 
   17468:   e3admov r0, #13
   1746c:   ebfffc9ebl  166ec 
   17470:   e3aamov r0, #10
   17474:   ebfffc9cbl  166ec 
   17478:   e1abmov r0, fp
   1747c:   ebdabl  173ec 
   17480:   e3admov r0, #13
   17484:   ebfffc98bl  166ec 
   17488:   e3aamov r0, #10
   1748c:   ebfffc96bl  166ec 
   17490:   e1a6mov r0, r6
   17494:   e24a6906sub r6, sl, #98304  ; 0x18000
   17498:   ebd3bl  173ec 
   1749c:   e3c66dffbic r6, r6, #16320  ; 0x3fc0
   174a0:   e3admov r0, #13
   ..
   175c4:   ebffa2c5bl  e0 
   175c8:   ebffa5a5bl  c64 
   175cc:   andeq   r0, r0, r0
   175d0:   andeq   r0, r0, r0
   175d4:   andeq   r0, r0, r0
   175d8:   00022448andeq   r2, r2, r8, asr #8
   175dc:   d00dfeedandle   pc, sp, sp, ror #29


We can see it save __bss_start and __bss_stop in local literal pool located at
175cc and 175d0, The value is zero.  But in barebox.map it's

0x000207b0. = ALIGN (0x4)
0x000207b0__bss_start = .
..
0x00022458__bss_stop = .
0x00022458_end = .
0x000207b0_barebox_image_size = 
__bss_start


Why?? It's so strange! Is it a bug of toolchain?

My toolchain is:

arm-poky-linux-gnueabi-gcc (GCC) 5.3.0
GNU ld (GNU Binutils) 2.26.0.20160214


I test this situation with a newer toolchain:

arm-poky-eabi-gcc (GCC) 8.2.0
GNU ld (GNU Binutils) 2.31.1.20180818

With this toolchain the printhex_ll output value for __bss_start and
__bss_stop same as them in barebox.map. This cofused me more!!

And with new toolchain there is a new thing: As barebox_non_pbl_start()
running address is not it's link address. So if use PUTS_LL(const char *str)
It should crash. but it sure works. I check the dis-asm code. Found the
linker/gcc add some code to using the string ptr pc relatived. Does this the
new toolchain's benifit? And who ? gcc or linker ?


The flowwing patch let _barebox_image_size has right value

---8<- 
From 29420237496b23c97de03c189529b223902653aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= 
Date: Mon, 17 Jun 2019 17:43:44 +0800
Subject: [PATCH] bugfix: _barebox_image_size wrong if enable
 CONFIG_RELOCATABLE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Sig

Why sbrk clear the increased memory region

2019-04-21 Thread
Recently, I'm using barebox in a deep embedded project, and need some funtctions
in libc/libm, So I linked barebox with newlib

But whenever newlib call sbrk with negtive `increment`, barebox crash.

The reason is sbrk clean memory region using `increment`.

Why sbrk must clear the increased memory region? 

8<- 
From dbaa658b60fe413e1d1818afad13a53e7ad000ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= 
Date: Mon, 22 Apr 2019 11:01:33 +0800
Subject: [PATCH] only clear memory when increasing head size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: 张忠山 
---
 common/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/memory.c b/common/memory.c
index 8f0b59891..0a8700d28 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -122,7 +122,7 @@ void *sbrk(ptrdiff_t increment)
void *old = sbrk_no_zero(increment);
 
/* Only clear increment, if valid address was returned */
-   if (old != NULL)
+   if ((old != NULL) && (increment > 0))
memset(old, 0, increment);
 
return old;
-- 
2.21.0

-- 
Best Regards,
zzs


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


maybe bug in common/ddr_spd.c

2019-04-09 Thread
Maybe this is a bug, I'm not sure

---8<- 
From 55509f359abbb1f5c24e9f0c2b9cff167f62ae4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= 
Date: Mon, 8 Apr 2019 14:34:00 +0800
Subject: [PATCH] bugfix: check ddr mod_ranks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: 张忠山 
---
 common/ddr_spd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/ddr_spd.c b/common/ddr_spd.c
index ec343ef5a..277d418e9 100644
--- a/common/ddr_spd.c
+++ b/common/ddr_spd.c
@@ -253,7 +253,7 @@ void ddr_spd_print(uint8_t *record)
printf("Error module type\n");
 
printf("%-48s ", "DRAM Package ");
-   if ((s->mod_ranks & 0x10) == 1)
+   if ((s->mod_ranks & 0x10) != 0)
printf("Stack\n");
else
printf("Planar\n");
-- 
2.21.0
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fix zbarebox linking with new ld

2019-03-06 Thread
Signed-off-by: 张忠山 
---
 arch/arm/pbl/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile
index 347df6424..f897166e5 100644
--- a/arch/arm/pbl/Makefile
+++ b/arch/arm/pbl/Makefile
@@ -31,7 +31,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE
$(call if_changed,disasm)
 
 PBL_CPPFLAGS   += -fdata-sections -ffunction-sections
-LDFLAGS_zbarebox   := -Map $(obj)/zbarebox.map --gc-sections
+LDFLAGS_zbarebox   := -Map $(obj)/zbarebox.map --gc-sections 
--no-dynamic-linker
 ifdef CONFIG_PBL_RELOCATABLE
 LDFLAGS_zbarebox += -pie
 else
-- 
2.20.1


-- 
Best Regards,
zzs
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


unalignment access on cortex-a8 caues exception

2019-01-07 Thread

My board based friendlyarm-tiny210, cpu is s5pv210. It integrates the
ARM Cortex-A8 core.

I want to perform unalignment access, but barebox crash.

The flowwing code used to test unalignment access:

static int do_ldr(int argc, char *argv[])
{
unsigned int sctlr;
unsigned int xx;

asm volatile("mrc p15, 0, %[result], c1, c0, 0": 
[result]"=r"(sctlr));
printf("sctlr = 0x%08x\n", sctlr);

asm volatile(
"ldr r0, =0x3001\n\t"
"ldr %[result], [r0], #4": [result]"=r"(xx));  // this 
cause `data fault` exception

return 0;
}
BAREBOX_CMD_START(ldr)
.cmd = do_ldr,
BAREBOX_CMD_DESC("This command test ldr")
BAREBOX_CMD_GROUP(CMD_GRP_CUSTOM)
BAREBOX_CMD_END

The corresponding asm code is:
000547b0 :
   547b0:   e92d4010push{r4, lr}
   547b4:   ee111f10mrc 15, 0, r1, cr1, cr0, {0}
   547b8:   e59f0010ldr r0, [pc, #16]   ; 547d0 

   547bc:   ebfeb133bl  c90 
   547c0:   e3a00213mov r0, #805306369  ; 0x3001
   547c4:   e4903004ldr r3, [r0], #4
   547c8:   e3a0mov r0, #0
   547cc:   e8bd8010pop {r4, pc}
   547d0:   0007b65aandeq   fp, r7, sl, asr r6


When run this function under barebox prompt, barebox output flowwing
message:

sctlr = 0x00c51078
unable to handle paging request at address 0x3001
pc : [<5ff547cc>]lr : [<5ff547c0>]
sp : 5ffefe00  ip : 0030  fp : 5ffeff38
r10:   r9 : 3ffb25a0  r8 : 3ffb0308
r7 : 3ffb2730  r6 : 0001  r5 : 5ff943fc  r4 : 3ffb2730
r3 : 5ff8f724  r2 : 0002  r1 : 000a  r0 : 3001
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
[<5ff547cc>] (do_ldr+0x1c/0x24) from [<5ff0373c>] 
(execute_command+0x38/0x78)
[<5ff0373c>] (execute_command+0x38/0x78) from [<5ff09d2c>] 
(run_list_real+0x840/0x970)
[<5ff09d2c>] (run_list_real+0x840/0x970) from [<5ff09328>] 
(parse_stream_outer+0x144/0x208)
[<5ff09328>] (parse_stream_outer+0x144/0x208) from [<5ff0a050>] 
(run_shell+0x4c/0x8c)
[<5ff0a050>] (run_shell+0x4c/0x8c) from [<5ff010e8>] 
(start_barebox+0xbc/0xe8)
[<5ff010e8>] (start_barebox+0xbc/0xe8) from [<5ff6448c>] 
(barebox_non_pbl_start+0x138/0x15c)
[<5ff6448c>] (barebox_non_pbl_start+0x138/0x15c) from [<5ff4>] 
(__bare_init_start+0x0/0x10)

[<5ff65c54>] (unwind_backtrace+0x0/0x90) from [<5ff01448>] (panic+0x28/0x44)
[<5ff01448>] (panic+0x28/0x44) from [<5ff64200>] (do_exception+0x10/0x14)
[<5ff64200>] (do_exception+0x10/0x14) from [<5ff64284>] 
(do_data_abort+0x2c/0x38)
[<5ff64284>] (do_data_abort+0x2c/0x38) from [<5ff63f14>] 
(do_abort_6+0x48/0x54)

It shows that `A` bit in SCTLR was cleared. But whenever access
0x3001, `data fault` exception raised.

According arm cortex-a8 technical reference manual:

A, bit[1]
Alignment check enable. This is the enable bit for Alignment
fault checking. The possible values of this bit are:

* 0 Alignment fault checking disabled.
* 1 Alignment fault checking enabled.

**Why unalignment access cause `data fault` even the `A` bit cleared**

CONFIG_MMU **not enabled** in my config file. Does this cause the
strange behaviour?

Anybody help me please!!


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Howto set var from command output

2017-04-19 Thread

Hush does not support command  substitution
In barebox is there some to set var from a command output?
Or is there a command to do it?


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: How to change filesystem size of root

2017-04-14 Thread

在 2017年04月14日 11:48, 张忠山 写道:

When transfer a large file to root through tftp. "Out of memory" error
like this:

# tftp /xy7520/output_file.rbf a.rbf
T [###write: Out of memory  ]

My board has 1G ddr but the file jus 23M. So the memory large enough to
hold the file.

I think it should have a method to adjust the filesystem's size of root.
But I can't find it.
Help me please.


Juct change the size of "MALLOC_SIZE"



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


How to change filesystem size of root

2017-04-13 Thread
When transfer a large file to root through tftp. "Out of memory" error 
like this:


# tftp /xy7520/output_file.rbf a.rbf
T [###write: Out of memory  ]

My board has 1G ddr but the file jus 23M. So the memory large enough to 
hold the file.


I think it should have a method to adjust the filesystem's size of root. 
But I can't find it.

Help me please.


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


How to change filesystem size of root

2017-04-13 Thread
When transfer a large file to root through tftp. "Out of memory" error 
like this:


# tftp /xy7520/output_file.rbf a.rbf
T   [###write: Out of memory  ]

My board has 1G ddr but the file jus 23M. So the memory large enough to 
hold the file.


I think it should have a method to adjust the filesystem's size of root. 
But I can't find it.

Help me please.


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] Do not rm the path from pbl-y target

2016-06-28 Thread


I had to revert this one. The regular expression seems to be wrong. It
breaks omap3530_beagle_defconfig with:

make[2]: *** No rule to make target 'arch/arm/mach-omap/opbl-map3_clock.o', 
needed by 'arch/arm/mach-omap/built-in-pbl.o'.  Stop.
make[2]: *** Waiting for unfinished jobs

Instead of pbl-omap3_clock.o it tries to generate opbl-map3_clock.o.

Sascha



Yes, the regular expression wrong, The flowwing patch should work.


---8<-
From 3b1fd574b0e847ceb9e0961ec454f975e1ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= 
Date: Fri, 24 Jun 2016 19:33:56 +0800
Subject: [PATCH] Do not rm the path from pbl-y target
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Whan add some obj in a subdir to lwl-y or pbl-y, like this:

lwl-y += subdir/test.o other.o

the make process failed:

make[2]: *** No rule to make target 
'arch/arm/boards/boardname/test.o', \

needed by 'arch/arm/boards/boardname/built-in-pbl.o'.  Stop.

Note, there are not the part "subdir" in the path of the test.o.

this patch fix this

Signed-off-by: 张忠山 
---
 scripts/Makefile.lib | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 27365d8..e55bc27 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -39,10 +39,9 @@ endif
 obj-y  += $(obj-pbl-y)
 pbl-y  += $(obj-pbl-y)

-# for non dirs add pbl- prefix to the target
-# so we recompile the source with custom flags and custom quiet
-__pbl-y:= $(notdir $(pbl-y))
-pbl-y  := $(patsubst %.o,pbl-%.o,$(__pbl-y))
+# add pbl- prefix to the target
+pbl-y		:= $(shell echo $(pbl-y) | sed -e 's%\(\([^ \t]\+/\)*\)\([^ 
\t]*\.o\)%\2pbl-\3%g')

+
 # add subdir from $(obj-y) too so we do not need to have the dir define in
 # both $(obj-y) and $(pbl-y)
 __pbl-y:= $(filter-out $(pbl-y), $(filter %/, $(obj-y)))
--
1.9.1



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] fix IORESOURCE_MEM_xxx usage in dm9k driver

2016-06-27 Thread


> This seems to fix platform data based probe but breaks device tree
> support. The culprit is in:
>
> d818f02 net: dm9k: add device tree support
>
> I believe this should be like the attached patch. Could you confirm this
> works for you?
>
> Sascha
>
Yes, It works for me


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] fix IORESOURCE_MEM_xxx usage in dm9k driver

2016-06-27 Thread



This seems to fix platform data based probe but breaks device tree
support. The culprit is in:

d818f02 net: dm9k: add device tree support

I believe this should be like the attached patch. Could you confirm this
works for you?

Sascha


Yes, It works for me



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] fix IORESOURCE_MEM_xxx usage in dm9k driver

2016-06-27 Thread

This seems to fix platform data based probe but breaks device tree
support. The culprit is in:

d818f02 net: dm9k: add device tree support

I believe this should be like the attached patch. Could you confirm this
works for you?

Sascha



Yes. it works for me.


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


how much contents can put to root dir

2016-06-26 Thread

I wan't to copy some large files to `/` through tftp.

But how can I determine whether the root dir large
enough or not?


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] bugfix: don't rely on lr in arm_cpu_lowlevel_init

2014-02-27 Thread
From: 张忠山 

Signed-off-by: 张忠山 
---
 arch/arm/cpu/lowlevel.S |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/lowlevel.S b/arch/arm/cpu/lowlevel.S
index 307b447..c615d5b 100644
--- a/arch/arm/cpu/lowlevel.S
+++ b/arch/arm/cpu/lowlevel.S
@@ -4,6 +4,7 @@
 
 .section ".text_bare_init_","ax"
 ENTRY(arm_cpu_lowlevel_init)
+   mov r2, lr
/* set the cpu to SVC32 mode */
mrs r12, cpsr
bic r12, r12, #0x1f
@@ -35,5 +36,5 @@ ENTRY(arm_cpu_lowlevel_init)
 
mcr p15, 0, r12, c1, c0, 0
 
-   mov pc, lr
+   mov pc, r2
 ENDPROC(arm_cpu_lowlevel_init)
-- 
1.7.9.5



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] rm vim swap file in genenv

2013-11-06 Thread
From: 张忠山 

Signed-off-by: 张忠山 
---
 scripts/genenv |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/genenv b/scripts/genenv
index c14cd87..bd4948e 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -24,7 +24,7 @@ for i in $*; do
 done
 )
 
-find $tempdir -name '.svn' -o -name '*~' -delete
+find $tempdir -name '.svn' -o -name '*~' -o -name '*.swp' -delete
 
 $objtree/scripts/bareboxenv -s $tempdir $target
 
-- 
1.7.9.5



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] don't scan bbt if CONFIG_NAND_BBT not set

2013-11-03 Thread
From: 张忠山 

when CONFIG_NAND_BBT not set, chip->scan_bbt is NULL and
NAND_SKIP_BBTSCAN not set. So barebox crashed, this is the message

..

nand: ONFI param page 0 valid
nand: ONFI flash detected
nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xda (Micron 
MT29F2G08AAD), 256MiB, page size: 2048, OOB size: 64
prefetch abort
pc : [<0004>]lr : [<23f0b8d0>]
sp : 2308  ip : 7fff  fp : 
r10: 0400  r9 :   r8 : 0001
r7 : 23b637f8  r6 :   r5 : 23b63ad4  r4 : 23b638b4
r3 :   r2 : f200  r1 : 000a  r0 : 23b63ad4
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32

may be the best solution is set NAND_SKIP_BBTSCAN somewhere when
CONFIG_NAND_BBT not selected, but I don't known where is the best
position.

Signed-off-by: 张忠山 
---
 drivers/mtd/nand/nand_base.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d249565..1dbd5bf 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3597,8 +3597,12 @@ int nand_scan_tail(struct mtd_info *mtd)
if (chip->options & NAND_SKIP_BBTSCAN)
return 0;
 
+#ifdef CONFIG_NAND_BBT
/* Build bad block table */
return chip->scan_bbt(mtd);
+#else
+   return 0;
+#endif
 }
 EXPORT_SYMBOL(nand_scan_tail);
 
-- 
1.7.9.5



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] fix GENERIC_PHY match nothing

2012-12-09 Thread
In message <20121208123830.gm24...@pengutronix.de> Sascha Hauer wrote:
> On Sat, Dec 08, 2012 at 12:15:03PM +0100, Sascha Hauer wrote:
> > On Sat, Dec 08, 2012 at 09:58:52AM +0800, 张忠山 wrote:
> > > According the match logic in function mdio_bus_match
> > > generic phy driver matchs nothing.
> >
> > This is done on purpose. The generic phy driver is probed manually
> > when no other phy matches, see:
> >
> > > static int phy_register_device(struct phy_device* dev)
> > > {
> > >int ret;
> > >
> > >ret = register_device(&dev->dev);
> > >if (ret)
> > >return ret;
> >
> > register device...
> >
> > >
> > >if (dev->dev.driver)
> > >return 0;
> >
> > ... we have a driver specific to this phy, -> return
> >
> > >
> > >dev->dev.driver = &genphy_driver.drv;
> > >return device_probe(&dev->dev);
> >
> > No driver, use generic phy driver.
> >
> > >}
> >
> > The problem this solves (and that you reintroduce with this patch) is
> > that if the phy driver matches every device, a more specific phy driver
> > will not be used if the generic driver is registered first.
>
> Now I understand what you mean.
>

Sorry for not mention the source code version

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fix GENERIC_PHY match nothing

2012-12-07 Thread
According the match logic in function mdio_bus_match
generic phy driver matchs nothing.

If we want it match anything, We must let it's phy_id_mask
be all zeros

Signed-off-by: 张忠山 
---
 drivers/net/phy/generic.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/phy/generic.c b/drivers/net/phy/generic.c
index 3f5f127..c3743b9 100644
--- a/drivers/net/phy/generic.c
+++ b/drivers/net/phy/generic.c
@@ -25,7 +25,7 @@
 static struct phy_driver generic_phy = {
.drv.name = "Generic PHY",
.phy_id = PHY_ANY_UID,
-   .phy_id_mask = PHY_ANY_UID,
+   .phy_id_mask = 0,
.features = 0,
 };
 
-- 
1.7.4.4



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] let kbuild build foo/bar.o correctly

2012-12-07 Thread
How about this patch.

Why nobody say anything?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


mdio_bus_match() bug

2012-12-07 Thread
In drivers/net/phy/mdio_bus.c: mdio_bus_match(), It compare
phy_id between driver and device.

In drivers/net/phy/generic.c set generic phy driver's phy_id
to PHY_ANY_UID

My phy is DM9161E, it's id is 0x181b881.

Of course they won't match! But the generic phy driver indeed
can works with DM9161E

Maybe the match logic should be fixed

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Howto known uncompressed length when uncompress_fd_to_buf

2012-12-04 Thread
> Why don't you uncompress to a regular file (i.e. /tmp/foo) rather than
> to the device file?
>
My fireware will be a huge file: about 12M bytes. I don't known How much
a regular file's size.

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


what meaning of command function return val

2012-12-03 Thread
When write a command function do_xxx.

When all right it should return zero.

But when error, It should return a negtive value or a positive value?
And what difference between neg-val and pos-val?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Howto known uncompressed length when uncompress_fd_to_buf

2012-12-03 Thread
In message <20121203095534.gl10...@pengutronix.de> Sascha Hauer wrote:
> On Fri, Nov 30, 2012 at 07:03:36PM +0800, 张忠山 wrote:
> > the function uncompress_fd_to_buf has no parameter to return
> > the uncompressed length, How to get the uncompressed content
> > length?
>
> AFAIK the uncompressed size is not contained in the compressed data
> You would have to uncompress to a file and use this afterwards.
> If I understand correctly you want to load a FPGA firmware which you
> have in compressed form. What I would do is:
>
> - uncompress the firmware in a script rather than uncompress it from
>   C code.
> - write a command to flash the firmware.
>
But if uncompress it to a device file, like /dev/tmpmem. the file size
is the device size, not the uncompressed size.

So now I uncompressed it to a file in C code using uncompress_fd_to_fd,
then use lseek to get the current position of target file. That is the
uncompressed size.

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] let kbuild build foo/bar.o correctly

2012-12-03 Thread
When obj-y has foo/bar.o, kbuild can't generate
foo/bar.o according foo/bar.c. Fix this

this patch based on linux kernel
commit 521cb40b0c44418a4fd36dc633f575813d59a43d

Signed-off-by: 张忠山 
---
 scripts/Makefile.lib |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cb46db2..14e471d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -55,10 +55,10 @@ multi-objs-y := $(foreach m, $(multi-used-y), 
$($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs   := $(multi-objs-y) $(multi-objs-m)
 
-# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
-# in the local directory
-__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir 
$(o))),$(o)))
-subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir 
$(o))),$(o)))
+# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
+# tell kbuild to descend
+__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y))
+subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 subdir-obj-y += $(__subdir-obj-y)
 
 # $(obj-dirs) is a list of directories that contain object files
-- 
1.7.4.4



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


kbuild can't build foo/xxx.o

2012-12-03 Thread
kbuild in barebox can't built when

obj-y += foo/xxx.o

But in kernel, It's OK

Maybe it should:

--
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cb46db2..14e471d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -55,10 +55,10 @@ multi-objs-y := $(foreach m, $(multi-used-y), 
$($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs   := $(multi-objs-y) $(multi-objs-m)

-# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
-# in the local directory
-__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir 
$(o))),$(o)))
-subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir 
$(o))),$(o)))
+# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
+# tell kbuild to descend
+__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y))
+subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 subdir-obj-y += $(__subdir-obj-y)

 # $(obj-dirs) is a list of directories that contain object files
--


-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: gunzip error when uncompress to buf

2012-11-30 Thread
In message <20121130113809.gc8...@game.jcrosoft.org> Jean-Christophe 
PLAGNIOL-VILLARD wrote:
> On 19:00 Fri 30 Nov , 张忠山 wrote:
> > On host use the flowwing cmd build a gziped file
> >
> > 
> > $ gzip -c9 zbarebox.bin > xxx
> this is a binary with a decompressor insode you just need to flash it
>

I known zbarebox.bin is a compressed image. I just use this file to
test uncompress_fd_to_buf.

I will compress my fpga firmware and flash it, So I need to uncompress
this image to a buf, then use it to config fpga

But uncompress_fd_to_buf works wrong!

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Howto known uncompressed length when uncompress_fd_to_buf

2012-11-30 Thread
the function uncompress_fd_to_buf has no parameter to return
the uncompressed length, How to get the uncompressed content
length?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


gunzip error when uncompress to buf

2012-11-30 Thread
On host use the flowwing cmd build a gziped file


$ gzip -c9 zbarebox.bin > xxx

$ ls zbarebox.bin xxx -l
-rw-rw-r-- 1 zzs zzs 127605 2012-11-30 17:46 xxx
-rwxrwxr-x 1 zzs zzs 136769 2012-11-30 18:44 zbarebox.bin*


Then on barebox write it to /dev/nor0.kernel


[barebox@SSR600]:/
# tftp xxx /dev/nor0.kernel



And add a barebox cmd to uncompress it:


char ptr[SZ_512K];
static int do_tx(int argc, char *argv[])
{
int ret = 0, size = 0, fd, fd1;

fd = open("/dev/tempmem", O_RDWR);
if(fd < 0)
printf("error open tempmem\n");
fd1 = open("/dev/nor0.kernel", O_RDONLY);
if(fd1 < 0)
printf("error open kernel\n");
ret = uncompress_fd_to_fd (fd1, fd, uncompress_err_stdout);
printf("ret is %d\n", ret);

close(fd1);
fd1 = open("/dev/nor0.kernel", O_RDONLY);
if(fd1 < 0)
printf("error open kernel\n");
ret = uncompress_fd_to_buf(fd1, ptr, uncompress_err_stdout);
printf("ret is %d\n", ret);

return 0;
}

BAREBOX_CMD_START(tx)
.cmd= do_tx,
BAREBOX_CMD_END


Compile barebox, download to board and run this command


[barebox@SSR600]:/
# tx
ret is 0
uncompression error
ret is -1


The result is:

uncompress_fd_to_fd is OK
uncompress_fd_to_buf fail and lib/decompress_inflate.c:gunzip()
output a message "uncompression error"

Anybody help me!

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


what's the meaning of 'dyn'

2012-11-25 Thread
There is a line in defaultenv-2/base/bin/boot:

global -r linux.bootargs.dyn.

What's then meaning of the word 'dyn'? Does it mean dynamic?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer functions"

2012-11-25 Thread
In message <20121125193208.gz8...@game.jcrosoft.org> Jean-Christophe 
PLAGNIOL-VILLARD wrote:
> On 16:11 Sun 25 Nov , 张忠山 wrote:
> > > >
> > > > This patch resolves my problem
> > > I'm expecting to see your patches
> > >
> >
> > My first patch very simple:
> your board patch
>
The flowing is my board patch, sorry for some chinese comments.
But my board patch had nothing about drivers!


diff --git a/Makefile b/Makefile
index 05b8be5..eedad07 100644
--- a/Makefile
+++ b/Makefile
@@ -681,10 +681,29 @@ endef
 quiet_cmd_objcopy = OBJCOPY $@
   cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@

+ifeq ($(CONFIG_GREATFIRST),y)
+MD5SUM_VARNAME=__md5sum__
+quiet_cmd_md5sum = MD5SUM $@
+  cmd_md5sum = (addr=$$($(NM) $(basename $@) | grep $(MD5SUM_VARNAME) | 
sed -e 's%\([0-9a-fA-F]\+\) \+.*%0x\1%'); \
+if [ "$$addr" = "" ]; then echo Can\'t find 
$(MD5SUM_VARNAME); exit 1; fi; \
+addr=$$(($$addr - $(TEXT_BASE))); \
+sum=$$(md5sum -b $@ | sed -e 's%\(.*\) \+\*$@%\1%') && \
+dd ibs=1 count=$$addr status=noxfer < $@ > $@.md5; \
+   echo -n $$sum >> $@.md5; \
+   addr=$$(($$addr + 32)); \
+   dd ibs=1 skip=$$addr status=noxfer < $@ >> $@.md5; \
+   mv $@.md5 $@; \
+echo -n $$sum > $@.md5 )
+else
+cmd_md5sum =
+endif
+
 OBJCOPYFLAGS_barebox.bin = -O binary

 barebox.bin: barebox FORCE
$(call if_changed,objcopy)
+   $(call cmd,md5sum)
+
 ifndef CONFIG_PBL_IMAGE
$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
 endif
diff --git a/arch/arm/boards/greatfirst/com9200/Makefile 
b/arch/arm/boards/greatfirst/com9200/Makefile
new file mode 100644
index 000..eafb716
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/Makefile
@@ -0,0 +1,4 @@
+# EXTRA_CFLAGS += -DPROJECT_NAME="$(PROJECT_NAME)" 
-DPROJECT_VERSION="$(PROJECT_VERSION)"
+
+obj-$(CONFIG_MACH_SSR600T) += basic_init.o tiny_init.o
+obj-$(CONFIG_MACH_SSR600)  += basic_init.o init.o
diff --git a/arch/arm/boards/greatfirst/com9200/basic_init.c 
b/arch/arm/boards/greatfirst/com9200/basic_init.c
new file mode 100644
index 000..3b21b5f
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/basic_init.c
@@ -0,0 +1,55 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+static int mem_init(void)
+{
+   at91_add_device_sdram(64 * 1024 * 1024);
+
+   return 0;
+}
+mem_initcall(mem_init);
+
+static int console_init(void)
+{
+   at91_register_uart(0, 0);
+   return 0;
+}
+console_initcall(console_init);
+
+static struct at91_ether_platform_data ether_pdata = {
+   .flags = AT91SAM_ETHER_RMII,
+   .phy_addr = 0,
+};
+
+void init_eth_device(void)
+{
+   at91_add_device_eth(0, ðer_pdata);
+}
+
+/* 此数组名至少要被引用一次,nm 才能在文件 barebox 找到它 */
+const char __md5sum__[33] = {0};
+
+void init_ip(void)
+{
+   setenv("eth0.ipaddr", "192.168.0.13");
+   setenv("eth0.serverip", "192.168.0.12");
+
+   /* 保证引用 __md5sum__ */
+   printf("md5sum=%s\n", __md5sum__);
+}
+
diff --git a/arch/arm/boards/greatfirst/com9200/basic_init.h 
b/arch/arm/boards/greatfirst/com9200/basic_init.h
new file mode 100644
index 000..087f376
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/basic_init.h
@@ -0,0 +1,17 @@
+/*  HEADER GUARD 
 */
+#ifndef __BASIC_INIT__H__
+#define __BASIC_INIT__H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*  HEADER GUARD 
 */
+
+void init_eth_device(void);
+void init_ip(void);
+
+/*  HEADER GUARD 
 */
+#ifdef __cplusplus
+}
+#endif
+#endif
+/*  HEADER GUARD 
 */
diff --git a/arch/arm/boards/greatfirst/com9200/config.h 
b/arch/arm/boards/greatfirst/com9200/config.h
new file mode 100644
index 000..bb66654
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/config.h
@@ -0,0 +1,71 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define AT91_MAIN_CLOCK18432000/* 18.432 MHz crystal */
+
+#define MASTER_PLL_MUL 39
+#define MASTER_PLL_DIV 4
+
+/* clocks */
+#define CONFIG_SYS_MOR_VAL \
+   (AT91_PMC_MOSCEN |  \
+(255 << 8))/*

Re: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer functions"

2012-11-25 Thread
> >
> > This patch resolves my problem
> I'm expecting to see your patches
>

My first patch very simple:

--
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0477178..a111463 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -155,23 +155,6 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
 }

 /*
- * Minimal-overhead PIO for data access.
- */
-static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
-{
-   struct nand_chip *chip = mtd->priv;
-
-   memcpy_fromio(buf, chip->IO_ADDR_R, len);
-}
-
-static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
-{
-   struct nand_chip *chip = mtd->priv;
-
-   memcpy_toio(chip->IO_ADDR_W, buf, len);
-}
-
-/*
  * Return number of ecc bytes per sector according to sector size and
  * correction capability
  *
@@ -1115,8 +1098,9 @@ static int __init atmel_nand_probe(struct device_d *dev)
if (host->board->bus_width_16)  /* 16-bit bus width */
nand_chip->options |= NAND_BUSWIDTH_16;

-   nand_chip->read_buf = atmel_read_buf;
-   nand_chip->write_buf = atmel_write_buf;
+   /* use default */
+   nand_chip->read_buf = NULL;
+   nand_chip->write_buf = NULL;

atmel_nand_enable(host);
--

After seeing your patch, I suppose the flowing patch may be works.
The idea is use optimized read/write function when 2**ale >= pagesize
and 2**cle >= pagesize.

I can't test it because the ale = a7, cle = a6 on my board, but
pagesize is 2048

--
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0477178..66cf5db 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1115,8 +1115,8 @@ static int __init atmel_nand_probe(struct device_d *dev)
if (host->board->bus_width_16)  /* 16-bit bus width */
nand_chip->options |= NAND_BUSWIDTH_16;

-   nand_chip->read_buf = atmel_read_buf;
-   nand_chip->write_buf = atmel_write_buf;
+   nand_chip->read_buf = NULL;
+   nand_chip->write_buf = NULL;

atmel_nand_enable(host);

@@ -1151,6 +1151,11 @@ static int __init atmel_nand_probe(struct device_d *dev)
goto err_hw_ecc;
}

+   if((1 << pdata->ale) >= mtd->writesize && (1 << pdata->cle) >= 
mtd->writesize) {
+   nand_chip->read_buf = atmel_read_buf;
+   nand_chip->write_buf = atmel_write_buf;
+   }
+
/* second phase scan */
if (nand_scan_tail(mtd)) {
res = -ENXIO;
--

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer functions"

2012-11-23 Thread
In message <1353686104-31295-4-git-send-email-plagn...@jcrosoft.com> 
Jean-Christophe PLAGNIOL-VILLARD wrote:
> As in the kernel we revert as this was supposed to work but does not yet
> this may need more work on the smc to be able to use it
> So for now revert it
>
> This reverts commit 809f0f6327241504b5071622a8d573255f91a875.
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---
>  drivers/mtd/nand/atmel_nand.c |   33 +
>  1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0477178..69e8171 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -159,16 +159,30 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
>   */
>  static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
>  {
> - struct nand_chip *chip = mtd->priv;
> + struct nand_chip*nand_chip = mtd->priv;
>
> - memcpy_fromio(buf, chip->IO_ADDR_R, len);
> + readsb(nand_chip->IO_ADDR_R, buf, len);
> +}
> +
> +static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
> +{
> + struct nand_chip*nand_chip = mtd->priv;
> +
> + readsw(nand_chip->IO_ADDR_R, buf, len / 2);
>  }
>
>  static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
>  {
> - struct nand_chip *chip = mtd->priv;
> + struct nand_chip*nand_chip = mtd->priv;
>
> - memcpy_toio(chip->IO_ADDR_W, buf, len);
> + writesb(nand_chip->IO_ADDR_W, buf, len);
> +}
> +
> +static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
> +{
> + struct nand_chip*nand_chip = mtd->priv;
> +
> + writesw(nand_chip->IO_ADDR_W, buf, len / 2);
>  }
>
>  /*
> @@ -1112,11 +1126,14 @@ static int __init atmel_nand_probe(struct device_d 
> *dev)
>
>   nand_chip->chip_delay = 20; /* 20us command delay time */
>
> - if (host->board->bus_width_16)  /* 16-bit bus width */
> + if (host->board->bus_width_16) {/* 16-bit bus width */
>   nand_chip->options |= NAND_BUSWIDTH_16;
> -
> - nand_chip->read_buf = atmel_read_buf;
> - nand_chip->write_buf = atmel_write_buf;
> + nand_chip->read_buf = atmel_read_buf16;
> + nand_chip->write_buf = atmel_write_buf16;
> + } else {
> + nand_chip->read_buf = atmel_read_buf;
> + nand_chip->write_buf = atmel_write_buf;
> + }
>
>   atmel_nand_enable(host);
>
> --
> 1.7.10.4
>

This patch resolves my problem

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


NAND_ATMEL strange behavior on at91rm9200 board

2012-11-23 Thread
when NAND_ATMEL used on at91rm9200, it's behavior very strange

write to nand have no effect, Read out of nand, the contents
very strange.

So I write some date to nand using u-boot and then start barebox

--
# md -s/dev/nand0 0+0x400
: ea0a eafe eafe eafe
0010: eafe 016c eafe eafel...
0020: 65726162 00786f62 23b0 00020ea9barebox#
0030: e10f3000 e3c3301f e38330d3 e129f003.0...0...0).
0040:    0400
0050:    
0060:    
0070:    
0080:    
0090:    
00a0:    
00b0:    
00c0:    
00d0:    
00e0:    
00f0:    
0100: e1a04000 e50c306f e1a01002 e1a03002.@..o0...0..
0110: e28ee001 e35e0008 e5843000 1afb..^..0..
0120: e3e02000 e3a03003 e502306f e3a03e2e. ...0..o0...>..
0130: e5841000 e502306b e5841000 e502106fk0..o...
0140:    
0150:    
0160:    
0170:    
0180:    0004
0190:    


But the datas should be:
: ea0a eafe eafe eafe
0010: eafe 016c eafe eafel...
0020: 65726162 00786f62 23b0 000200fabarebox#
0030: e10f3000 e3c3301f e38330d3 e129f003.0...0...0).
0040: ee113f10 e3c33d8e e3c33005 e3833a01.?...=...0...:..
0050: e3833002 ee013f10 e3e02000 e51233cf.0...?... ...3..
0060: e3130003 1a39 e59f30e4 e1a0100290..
0070: e50233df e5113397 e3130001 0afc.3...3..
0080: e3a03000 e501309b e59f30c8 e3e02000.0...0...0... ..
0090: e501308f e59f30c0 e50133d7 e5123397.0...0...3...3..
00a0: e3130002 0afc e3a03c01 e50233cf.<...3..
00b0: e59f30a8 e3e0c000 e50233cf e51c3397.0...3...3..
00c0: e3130008 0afc e59f3094 e3a02000.0... ..
00d0: e50c378f e50c278b e50c37fb e59f3084.7...'...7...0..
00e0: e3a01002 e50c109f e3a00202 e50c3067g0..
00f0: e3a03004 e50c106f e1a0e002 e5802000.0..o ..
..

It looks like there are 64bytes correct data in every 256 bytes. It's so
strange!!

After study barebox source codes. I found atmel_read_buf use
memcpy_fromio to read. I can't understand it. May be on at91samxxx cpu
it's right.

So I let "nand_chip->read_buf = NULL" to let it use the default read
function.

After this , It's OK

I has no at91sam board, So anybody tell me is this behavior specific to
at91rm9200?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] read cfi device id according the bus width

2012-11-22 Thread
> I said factorize not duplicate
>
> and you need to handle all the with not only 8 and 16
>
I check the kernel code, th id defined in cfi_private is "int",
but in barebox is a ushort.

When width is 32, How to save the id?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] read cfi device id according the bus width

2012-11-21 Thread
Signed-off-by: 张忠山 
---
 drivers/nor/cfi_flash_amd.c   |7 +--
 drivers/nor/cfi_flash_intel.c |7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
udelay(1000); /* some flash are slow to respond */
 
info->manufacturer_id = jedec_read_mfr(info);
-   info->device_id = flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID);
+   if(info->chipwidth == FLASH_CFI_BY16)
+   info->device_id = flash_read16(flash_make_addr(info, 0, 
FLASH_OFFSET_DEVICE_ID));
+   else
+   info->device_id = flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID);
if (info->device_id == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar (info,
diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
index 32e581a..75dc5a8 100644
--- a/drivers/nor/cfi_flash_intel.c
+++ b/drivers/nor/cfi_flash_intel.c
@@ -19,8 +19,11 @@ static void intel_read_jedec_ids (struct flash_info *info)
udelay(1000); /* some flash are slow to respond */
 
info->manufacturer_id = jedec_read_mfr(info);
-   info->device_id = flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID);
+   if(info->chipwidth == FLASH_CFI_BY16)
+   info->device_id = flash_read16(flash_make_addr(info, 0, 
FLASH_OFFSET_DEVICE_ID));
+   else
+   info->device_id = flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID);
flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
 
-- 
1.7.4.4



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] read cfi device id according the bus width

2012-11-21 Thread
In message <20121122061438.gr8...@game.jcrosoft.org> Jean-Christophe 
PLAGNIOL-VILLARD wrote:
> On 14:01 Thu 22 Nov , 张忠山 wrote:
> > Signed-off-by: 张忠山 
> > ---
> >  drivers/nor/cfi_flash_amd.c |7 +--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> > index 45c59b9..3ab4be0 100644
> > --- a/drivers/nor/cfi_flash_amd.c
> > +++ b/drivers/nor/cfi_flash_amd.c
> > @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
> > udelay(1000); /* some flash are slow to respond */
> >
> > info->manufacturer_id = jedec_read_mfr(info);
> > -   info->device_id = flash_read_uchar (info,
> > -   FLASH_OFFSET_DEVICE_ID);
> > +   if(info->chipwidth == FLASH_CFI_BY16)
> > +   info->device_id = flash_read16(flash_make_addr(info, 0, 
> > FLASH_OFFSET_DEVICE_ID));
> > +   else
> > +   info->device_id = flash_read_uchar (info,
> > +   FLASH_OFFSET_DEVICE_ID);
>
> make this global with all with support
> as don in linux
>
> as this is valid for amd and intel and st
>
Does this mean cp this code to the function
drivers/nor/cfi_flash_intel.c:intel_read_jedec_ids() ?
-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] read cfi device id according the bus width

2012-11-21 Thread
Signed-off-by: 张忠山 
---
 drivers/nor/cfi_flash_amd.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
udelay(1000); /* some flash are slow to respond */
 
info->manufacturer_id = jedec_read_mfr(info);
-   info->device_id = flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID);
+   if(info->chipwidth == FLASH_CFI_BY16)
+   info->device_id = flash_read16(flash_make_addr(info, 0, 
FLASH_OFFSET_DEVICE_ID));
+   else
+   info->device_id = flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID);
if (info->device_id == 0x7E) {
/* AMD 3-byte (expanded) device ids */
info->device_id2 = flash_read_uchar (info,
-- 
1.7.4.4



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Can I use NAND_ATMEL on at91rm9200 board

2012-11-21 Thread
config menu says that NAND_ATMEL is for AT91SAM9xxx
Can I use it on at91rm9200 boards?

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] read cfi device id according the bus width

2012-11-21 Thread
Signed-off-by: 张忠山 
---
 drivers/nor/cfi_flash_amd.c |   22 +-
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..8384f46 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,15 +62,19 @@ static void amd_read_jedec_ids (struct flash_info *info)
udelay(1000); /* some flash are slow to respond */
 
info->manufacturer_id = jedec_read_mfr(info);
-   info->device_id = flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID);
-   if (info->device_id == 0x7E) {
-   /* AMD 3-byte (expanded) device ids */
-   info->device_id2 = flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID2);
-   info->device_id2 <<= 8;
-   info->device_id2 |= flash_read_uchar (info,
-   FLASH_OFFSET_DEVICE_ID3);
+   if(info->chipwidth == FLASH_CFI_BY16) {
+   info->device_id = flash_read16(flash_make_addr(info, 0, 
FLASH_OFFSET_DEVICE_ID));
+   } else {
+   info->device_id = flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID);
+   if (info->device_id == 0x7E) {
+   /* AMD 3-byte (expanded) device ids */
+   info->device_id2 = flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID2);
+   info->device_id2 <<= 8;
+   info->device_id2 |= flash_read_uchar (info,
+   FLASH_OFFSET_DEVICE_ID3);
+   }
}
flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
-- 
1.7.4.4



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


test

2012-11-21 Thread
test

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: wrong cfi flash device id

2012-11-20 Thread
> > I think it should use read8 or read16 according the portwidth like
> > u-boot does.
> I check the kernel we need to read the id according the bus width
>
> btw please use a real name zzs is either an english name or a chinese name
>
This is my chinese name

-- 
Best Regards,
zzs



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox