[Openocd-development] PIC32MX flash programming

2009-12-15 Thread Dubreuil, Thomas
Hi, 
 
This issue is due to a bad configuration of flash bank :
 
jtag_nsrst_delay 100
jtag_ntrst_delay 100
#use combined on interfaces or targets that can't set TRST/SRST
separately
reset_config srst_only
#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag newtap $_CHIPNAME cpu -irlen 5  -ircapture 0x1 -irmask 0x1f
-expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME mips_m4k -endian $_ENDIAN -chain-position
$_TARGETNAME
$_TARGETNAME configure -work-area-virt 0xbd00 -work-area-phys
0xa000 -work-area-size 0x4000 -work-area-backup 0
flash bank pic32mx 0x1d00 0x0004 0 0 $_TARGETNAME
flash bank pic32mx 0x1fc0 0x3000 0 0 $_TARGETNAME
init
halt
 
now trying to program with this configuration I have:
 
Debug: 56 2902355 command.c:68 script_debug(): command - write_image
Debug: 57 2902355 command.c:77 script_debug(): write_image -
argv[0]=ocd_flash_write_image
Debug: 58 2902355 command.c:77 script_debug(): write_image -
argv[1]=unlock
Debug: 59 2902355 command.c:77 script_debug(): write_image -
argv[2]=blinky_leds.hex
Debug: 60 2902355 command.c:77 script_debug(): write_image - argv[3]=0
Debug: 61 2902355 command.c:77 script_debug(): write_image -
argv[4]=ihex
User : 62 2902370 command.c:400 command_print(): auto unlock enabled
Debug: 63 2902386 configuration.c:83 find_file(): found blinky_leds.hex
Debug: 64 2902542 target.c:1054 target_alloc_working_area(): MMU
disabled, using physical address for working memory 0xa000
Debug: 65 2902542 target.c:1116 target_alloc_working_area(): allocated
new working area at address 0xa000
Debug: 66 2902542 target.c:1246 target_write_buffer(): writing buffer of
512 byte at 0xa000
Debug: 67 2902542 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xa000, size: 0x0004, count: 0x0080
Debug: 96 2916853 pic32mx.c:500 pic32mx_write_row(): addr: 0x1d00
srcaddr: 0xa000
Debug: 97 2916853 target.c:1560 target_write_u32(): address: 0xbf80f420,
value: 0x9d00
Debug: 98 2916853 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f420, size: 0x0004, count: 0x0001
Debug: 99 2917181 target.c:1560 target_write_u32(): address: 0xbf80f440,
value: 0x
Debug: 100 2917181 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f440, size: 0x0004, count: 0x0001
Debug: 102 2917525 target.c:1560 target_write_u32(): address:
0xbf80f400, value: 0x4003
Debug: 103 2917525 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f400, size: 0x0004, count: 0x0001
Debug: 105 2917853 target.c:1560 target_write_u32(): address:
0xbf80f410, value: 0xaa996655
Debug: 106 2917853 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f410, size: 0x0004, count: 0x0001
Debug: 107 2918181 target.c:1560 target_write_u32(): address:
0xbf80f410, value: 0x556699aa
Debug: 108 2918181 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f410, size: 0x0004, count: 0x0001
Debug: 110 2918509 target.c:1560 target_write_u32(): address:
0xbf80f408, value: 0x8000
Debug: 111 2918509 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f408, size: 0x0004, count: 0x0001
Debug: 113 2918853 mips_m4k.c:853 mips_m4k_read_memory(): address:
0xbf80f400, size: 0x0004, count: 0x0001
Debug: 114 2919118 target.c:1483 target_read_u32(): address: 0xbf80f400,
value: 0x6003
Debug: 115 2919118 target.c:1560 target_write_u32(): address:
0xbf80f404, value: 0x4000
Debug: 116 2919118 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f404, size: 0x0004, count: 0x0001
Error: 118 2919446 pic32mx.c:438 pic32mx_write_block(): Flash write
error NVMERR (status = 0x6003)
Debug: 119 2919446 target.c:1560 target_write_u32(): address:
0xbf80f420, value: 0x9d00
Debug: 120 2919446 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f420, size: 0x0004, count: 0x0001
Debug: 121 2919775 target.c:1560 target_write_u32(): address:
0xbf80f430, value: 0x0f46
Debug: 122 2919775 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f430, size: 0x0004, count: 0x0001
Debug: 124 2920103 target.c:1560 target_write_u32(): address:
0xbf80f400, value: 0x4001
Debug: 125 2920103 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f400, size: 0x0004, count: 0x0001
Debug: 127 2920431 target.c:1560 target_write_u32(): address:
0xbf80f410, value: 0xaa996655
Debug: 128 2920431 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f410, size: 0x0004, count: 0x0001
Debug: 129 2920774 target.c:1560 target_write_u32(): address:
0xbf80f410, value: 0x556699aa
Debug: 130 2920774 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f410, size: 0x0004, count: 0x0001
Debug: 132 2921087 target.c:1560 target_write_u32(): address:
0xbf80f408, value: 0x8000
Debug: 133 2921087 mips_m4k.c:885 mips_m4k_write_memory(): address:
0xbf80f408, size: 0x0004, count: 0x0001
Debug: 135 2921415 mips_m4k.c:853 mips_m4k

Re: [Openocd-development] [PATCH v2] Common target file for lm3s CPU family

2009-12-15 Thread Yegor Yefremov
On Tue, Dec 15, 2009 at 1:23 AM, David Brownell  wrote:
> On Monday 09 November 2009, Yegor Yefremov wrote:
>> Common target file for LM3S CPU family
>
> I'm merging the modified version below ... your version
> still arrived mangled, among other things.  Updates:
>
>  - renamed it "stellaris.cfg" to match the chip brand
>   and docs, not the subsidiary;
>
>  - used the new "-ignore-version" option to avoid skipping
>   IDCODE values (you missed one we now use)
>
>  - used a smaller default work area size, 8K not 16K,
>   since that's big enough and since a there are a fair
>   number of chips that don't *have* 16K of SRAM (and
>   only a dozen or so that don't even have 8K)
>
>  - made the reset method restore the default JTAG speed,
>   since "reset init" code must be able to work without
>   the crystal or PLL kicking in
>
>  - updated to match new flash config syntax
>
> Plus, I've got a followup removing the lm3s3748 config
> file in favor of this.  You might want to provide similar
> patches for stuff you can test.

I've tested your changes with OpenOCD: 0.4.0-dev-00931-g6f929db
(2009-12-15-13:50)
It is working as earlier. For my board lm3s6432 I had to increase
work-area amount to 0x4000 to avoid warnings. But still I have a
problem that sometimes the first erase/write attempt fails with the
following messages:

flash write_image erase image.bin 0x1000 bin
auto erase enabled
Algorithm flash write 2048 words to 0x1000, 16757 remaining
error executing stellaris flash write algorithm
flash writing failed with CRIS: 0x0
error writing to flash at address 0x at offset 0x1000 (-902)
Command handler execution failed
in procedure 'flash' called at file "command.c", line 637
called at file "command.c", line 352

but the second one always succeeds:

flash write_image erase image.bin 0x1000 bin
auto erase enabled
Algorithm flash write 2048 words to 0x1000, 16757 remaining
Algorithm flash write 2048 words to 0x3000, 14709 remaining
Algorithm flash write 2048 words to 0x5000, 12661 remaining
Algorithm flash write 2048 words to 0x7000, 10613 remaining
Algorithm flash write 2048 words to 0x9000, 8565 remaining
Algorithm flash write 2048 words to 0xb000, 6517 remaining
Algorithm flash write 2048 words to 0xd000, 4469 remaining
Algorithm flash write 2048 words to 0xf000, 2421 remaining
Algorithm flash write 2048 words to 0x11000, 373 remaining
Algorithm flash write 373 words to 0x13000, 0 remaining
wrote 75220 byte from file image.bin in 18.802422s (3.907 kb/s)

Under Windows it succeeds at the first attempt. Any idea?

Regards,
Yegor
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] [PATCH 1/2] ecos: crisper implementation of timeval_ms()

2009-12-15 Thread Øyvind Harboe
A crisper implementation makes profiling a tad easier.

Signed-off-by: Øyvind Harboe 
---
 src/helper/time_support.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/helper/time_support.c b/src/helper/time_support.c
index 693528f..4e69c42 100644
--- a/src/helper/time_support.c
+++ b/src/helper/time_support.c
@@ -29,6 +29,9 @@
 
 #include "time_support.h"
 
+#if BUILD_ECOSBOARD == 1
+#include 
+#endif
 
 /* calculate difference between two struct timeval values */
 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval 
*y)
@@ -73,13 +76,26 @@ int timeval_add_time(struct timeval *result, long sec, long 
usec)
return 0;
 }
 
+/* simple and low overhead fetching of ms counter. Use only
+ * the difference between ms counters returned from this fn.
+ */
 int64_t timeval_ms()
 {
+#if BUILD_ECOSBOARD == 0
struct timeval now;
int retval = gettimeofday(&now, NULL);
if (retval < 0)
return retval;
return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;
+#else
+   /* Faster/less noisy implementation of getting ms when
+* profiling
+*/
+   static const int ms_per_tick =
+   (CYGNUM_HAL_RTC_NUMERATOR / CYGNUM_HAL_RTC_DENOMINATOR) 
/ 100;
+   cyg_tick_count_t cur_time = cyg_current_time();
+   return ((int)cur_time) * ms_per_tick;
+#endif
 }
 
 
-- 
1.6.3.3

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] [PATCH 2/2] server: server loop will exhaust data inputs before sleeping

2009-12-15 Thread Øyvind Harboe
By exhausting data on input, the performance will be more
consistent + the code more clearly distinguishes between
polling and processing. A test showed gdb packet load
performance go from ~1550kByte/s to 1650kBytes/s + being
more stable.

Signed-off-by: Øyvind Harboe 
---
 src/server/server.c |   48 +++-
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/server/server.c b/src/server/server.c
index 75a6bed..f762704 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -292,9 +292,10 @@ int server_loop(struct command_context *command_context)
 {
struct service *service;
 
+   bool poll = true;
+
/* used in select() */
fd_set read_fds;
-   struct timeval tv;
int fd_max;
 
/* used in accept() */
@@ -305,10 +306,6 @@ int server_loop(struct command_context *command_context)
LOG_ERROR("couldn't set SIGPIPE to SIG_IGN");
 #endif
 
-   /* do regular tasks after at most 10ms */
-   tv.tv_sec = 0;
-   tv.tv_usec = 1;
-
while (!shutdown_openocd)
{
/* monitor sockets for activity */
@@ -351,12 +348,24 @@ int server_loop(struct command_context *command_context)
 #endif
 #endif
 
-   openocd_sleep_prelude();
-   kept_alive();
-
-   /* Only while we're sleeping we'll let others run */
-   retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv);
-   openocd_sleep_postlude();
+   struct timeval tv;
+   tv.tv_sec = 0;
+   if (poll)
+   {
+   /* we're just polling this iteration, this is faster on 
embedded
+* hosts */
+   tv.tv_usec = 0;
+   retval = socket_select(fd_max + 1, &read_fds, NULL, 
NULL, &tv);
+   } else
+   {
+   /* Every 100ms */
+   tv.tv_usec = 10;
+   /* Only while we're sleeping we'll let others run */
+   openocd_sleep_prelude();
+   kept_alive();
+   retval = socket_select(fd_max + 1, &read_fds, NULL, 
NULL, &tv);
+   openocd_sleep_postlude();
+   }
 
if (retval == -1)
{
@@ -385,15 +394,20 @@ int server_loop(struct command_context *command_context)
 #endif
}
 
-   target_call_timer_callbacks();
-   process_jim_events(command_context);
-
if (retval == 0)
{
-   /* do regular tasks after at most 100ms */
-   tv.tv_sec = 0;
-   tv.tv_usec = 1;
+   /* We only execute these callbacks when there was 
nothing to do or we timed out */
+   target_call_timer_callbacks();
+   process_jim_events(command_context);
+
FD_ZERO(&read_fds); /* eCos leaves read_fds unchanged 
in this case!  */
+
+   /* We timed out/there was nothing to do, timeout rather 
than poll next time */
+   poll = false;
+   } else
+   {
+   /* There was something to do, next time we'll just poll 
*/
+   poll = true;
}
 
for (service = services; service; service = service->next)
-- 
1.6.3.3

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Cross Platform Debugger

2009-12-15 Thread Alain Mouette
Can anyone help me with this?

To make single-step work better with IRQs and FreeRTOS in Eclipse, it 
seems that I need to send this do GDB:

define hook-step
mon cortex_m3 maskisr on
end
define hookpost-step
mon cortex_m3 maskisr off
end

The big question is: how/where do I put that? I supose that it should be 
in my config file for OpenOCD, I tried many things without success :(

There is very little about that in Google or in GDB or even in OpenOCD 
manual...

Please help !!! Bellow is my previous question a an answer from David 
that did help me in understanding what is happening :)

I am using OpennOCD 0.3.1 now :)

Thanks,
Alain

Alain Mouette escreveu:
> David Brownell escreveu:
>> On Monday 14 December 2009, Alain Mouette wrote:
>>> I tried debugging with Eclipde+Gdb+OpenOCD on a Cortex-M3, and it works 
>>> just fine for the start-up code, but as soon as FreeRTOS (preemptive) 
>>> and Interrupts are running, it is not much usefull anymore... Is there 
>>> any way to single-step in a multi-thread environment?
>> When you say "not useful" ... why, specifically?
> 
> It is not usefull because when I single-step it goes to a ISR or to 
> another thread, and eventualy goes to some invalid address. I gess that 
> you partially undestood what I meant :)
> 
>> Didn't you say, earlier, that using the
>>  cortex_m3 maskisr enable
>> command while stepping solved the problem for you?
> 
> Sorry, that was not me...
> 
> I read the manual, googled and did not find how to use it. I added it to 
> my config file, just before "init" but it made no difference.
> 
> The only explanation that makes some sense to me is 
> 
>  
> from this list. It looks like I should define a hook for GDB, is that it?
> 
> If so, it sshould probably be in some function in my configuration 
> script (like I did for flash writing) and call it from command line with 
> "-c"? Could you give me an example? ... :)
> 
> BTW, I am using OpenOCD 0.2.0 in Linux, would I have to upgrade to test 
> that? (I will be doing it today anyway)
> 
> Sorry it I look dumb sometimes, I am a programmer, but I came from an 
> environment too different and I am having a hard time with too many 
> different tools at once :(
> 
> Thanks
> Alain
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] ohloh.net statistics

2009-12-15 Thread Yegor Yefremov
Hi all,

since the project moved to git, the ohloh.net
(http://www.ohloh.net/p/openocd) can only see the legacy svn
repository. I found a discussion about how to add new repository:
https://www.ohloh.net/forums/10/topics/3840. Can someone change the
repo?

Regards,
Yegor
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Cross Platform Debugger

2009-12-15 Thread Mathias K.
Hello,

you can pass it to gdb with the -x start option. Put your stuff into e.g. 
gdb.cfg and start gdb with

gdb -x gdb.cfg



Regards,

Mathias


Am 15.12.2009 16:51, schrieb Alain Mouette:
> Can anyone help me with this?
> 
> To make single-step work better with IRQs and FreeRTOS in Eclipse, it 
> seems that I need to send this do GDB:
> 
> define hook-step
> mon cortex_m3 maskisr on
> end
> define hookpost-step
> mon cortex_m3 maskisr off
> end
> 
> The big question is: how/where do I put that? I supose that it should be 
> in my config file for OpenOCD, I tried many things without success :(
> 
> There is very little about that in Google or in GDB or even in OpenOCD 
> manual...
> 
> Please help !!! Bellow is my previous question a an answer from David 
> that did help me in understanding what is happening :)
> 
> I am using OpennOCD 0.3.1 now :)
> 
> Thanks,
> Alain
> 
> Alain Mouette escreveu:
>> David Brownell escreveu:
>>> On Monday 14 December 2009, Alain Mouette wrote:
 I tried debugging with Eclipde+Gdb+OpenOCD on a Cortex-M3, and it works 
 just fine for the start-up code, but as soon as FreeRTOS (preemptive) 
 and Interrupts are running, it is not much usefull anymore... Is there 
 any way to single-step in a multi-thread environment?
>>> When you say "not useful" ... why, specifically?
>>
>> It is not usefull because when I single-step it goes to a ISR or to 
>> another thread, and eventualy goes to some invalid address. I gess that 
>> you partially undestood what I meant :)
>>
>>> Didn't you say, earlier, that using the
>>> cortex_m3 maskisr enable
>>> command while stepping solved the problem for you?
>>
>> Sorry, that was not me...
>>
>> I read the manual, googled and did not find how to use it. I added it to 
>> my config file, just before "init" but it made no difference.
>>
>> The only explanation that makes some sense to me is 
>> 
>>  
>> from this list. It looks like I should define a hook for GDB, is that it?
>>
>> If so, it sshould probably be in some function in my configuration 
>> script (like I did for flash writing) and call it from command line with 
>> "-c"? Could you give me an example? ... :)
>>
>> BTW, I am using OpenOCD 0.2.0 in Linux, would I have to upgrade to test 
>> that? (I will be doing it today anyway)
>>
>> Sorry it I look dumb sometimes, I am a programmer, but I came from an 
>> environment too different and I am having a hard time with too many 
>> different tools at once :(
>>
>> Thanks
>> Alain
> ___
> Openocd-development mailing list
> Openocd-development@lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/openocd-development
> 

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] Disabling svn server on berlios

2009-12-15 Thread Øyvind Harboe
The last couple of days we've run into a few situations where
there is confusion since the old svn server is still up and
running.

Please scream NOW if you can think of any good reason why
the old svn server should keep running.

I would like to bring it offline before the 0.4 merge window closes.

-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] dsp563xx support

2009-12-15 Thread Øyvind Harboe
I've pushed the work done by Mathias so far. This is
mostly to coordinate development at this point.

I have not added anything to NEWS, because I believe it will
take a release cycle until we have a feel for the status
of the code and what major outstanding issues are.

Chances of regressions are *very* slight for other targets.

-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Disabling svn server on berlios

2009-12-15 Thread Thomas Kindler
Øyvind Harboe wrote:
> The last couple of days we've run into a few situations where
> there is confusion since the old svn server is still up and
> running.
> 

Please remember to update the website at berlios, too!

The latest news still says "OpenOCD 0.3.0-rc", the "Getting
OpenOCD"-Topic still mentions SVN (and seems to be redundant, as there's
also a "Repository" topic).

Perhaps, it would be best to put the website in git, too?! It's getting
outdated so easily!

best regards,
-- 
Thomas Kindler 

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Disabling svn server on berlios

2009-12-15 Thread Øyvind Harboe
On Tue, Dec 15, 2009 at 8:16 PM, Thomas Kindler  wrote:
> Øyvind Harboe wrote:
>> The last couple of days we've run into a few situations where
>> there is confusion since the old svn server is still up and
>> running.
>>
>
> Please remember to update the website at berlios, too!
>
> The latest news still says "OpenOCD 0.3.0-rc", the "Getting
> OpenOCD"-Topic still mentions SVN (and seems to be redundant, as there's
> also a "Repository" topic).

OK.

> Perhaps, it would be best to put the website in git, too?! It's getting
> outdated so easily!

We have daily builds of Doxygen available on the net. I was thinking
about pushing more stuff into Doxygen...



-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] Disabling svn server on berlios

2009-12-15 Thread Øyvind Harboe
I've announced on the web page that we're going git only, svn
server will be disabled shortly.

http://openocd.berlios.de/web/

-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH 1/2] ecos: crisper implementation of timeval_ms()

2009-12-15 Thread Zach Welch
I would almost prefer that you use a Makefile trick here.  We should
avoid adding new #if's in the code when it's possible to avoid them.

At the very least, provide two _complete_ versions of the function.
Your new comment is misleading, as it only applies to one branch.

On Tue, 2009-12-15 at 15:46 +0100, Øyvind Harboe wrote:
> A crisper implementation makes profiling a tad easier.
> 
> Signed-off-by: Øyvind Harboe 
> ---
>  src/helper/time_support.c |   16 
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/src/helper/time_support.c b/src/helper/time_support.c
> index 693528f..4e69c42 100644
> --- a/src/helper/time_support.c
> +++ b/src/helper/time_support.c
> @@ -29,6 +29,9 @@
>  
>  #include "time_support.h"
>  
> +#if BUILD_ECOSBOARD == 1
> +#include 
> +#endif
>  
>  /* calculate difference between two struct timeval values */
>  int timeval_subtract(struct timeval *result, struct timeval *x, struct 
> timeval *y)
> @@ -73,13 +76,26 @@ int timeval_add_time(struct timeval *result, long sec, 
> long usec)
>   return 0;
>  }
>  
> +/* simple and low overhead fetching of ms counter. Use only
> + * the difference between ms counters returned from this fn.
> + */
>  int64_t timeval_ms()
>  {
> +#if BUILD_ECOSBOARD == 0
>   struct timeval now;
>   int retval = gettimeofday(&now, NULL);
>   if (retval < 0)
>   return retval;
>   return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;
> +#else
> + /* Faster/less noisy implementation of getting ms when
> +  * profiling
> +  */
> + static const int ms_per_tick =
> + (CYGNUM_HAL_RTC_NUMERATOR / CYGNUM_HAL_RTC_DENOMINATOR) 
> / 100;
> + cyg_tick_count_t cur_time = cyg_current_time();
> + return ((int)cur_time) * ms_per_tick;
> +#endif
>  }
>  
> 


___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] Have the NAND erase function use the nand page command

2009-12-15 Thread Dean Glazeski
I noticed the NAND erase function was doing page command stuff, so I pulled
the redundant code out.  Patch is attached

// Dean Glazeski
From 2bb284a568f936f47e2a638e80c1554f94f5e860 Mon Sep 17 00:00:00 2001
From: Dean Glazeski 
Date: Tue, 15 Dec 2009 23:57:18 -0600
Subject: [PATCH 1/4] Use NAND page command in erase.

Updated the NAND erase function to use the NAND page command function.  This
also updates the command function to support the erase command and uses the NAND
poll function when the NAND ready function doesn't exist for the controller.
---
 src/flash/nand/core.c |   50 +++-
 1 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c
index d52cf5d..044f4e2 100644
--- a/src/flash/nand/core.c
+++ b/src/flash/nand/core.c
@@ -537,48 +537,16 @@ int nand_erase(struct nand_device *nand, int first_block, int last_block)
 	for (i = first_block; i <= last_block; i++)
 	{
 		/* Send erase setup command */
-		nand->controller->command(nand, NAND_CMD_ERASE1);
-
 		page = i * (nand->erase_size / nand->page_size);
+		retval = nand_page_command(nand, page, NAND_CMD_ERASE1, false);
 
-		/* Send page address */
-		if (nand->page_size <= 512)
-		{
-			/* row */
-			nand->controller->address(nand, page & 0xff);
-			nand->controller->address(nand, (page >> 8) & 0xff);
-
-			/* 3rd cycle only on devices with more than 32 MiB */
-			if (nand->address_cycles >= 4)
-nand->controller->address(nand, (page >> 16) & 0xff);
-
-			/* 4th cycle only on devices with more than 8 GiB */
-			if (nand->address_cycles >= 5)
-nand->controller->address(nand, (page >> 24) & 0xff);
-		}
-		else
-		{
-			/* row */
-			nand->controller->address(nand, page & 0xff);
-			nand->controller->address(nand, (page >> 8) & 0xff);
-
-			/* 3rd cycle only on devices with more than 128 MiB */
-			if (nand->address_cycles >= 5)
-nand->controller->address(nand, (page >> 16) & 0xff);
-		}
-
-		/* Send erase confirm command */
-		nand->controller->command(nand, NAND_CMD_ERASE2);
-
-		retval = nand->controller->nand_ready ?
-nand->controller->nand_ready(nand, 1000) :
-nand_poll_ready(nand, 1000);
-		if (!retval) {
+		if (ERROR_OK != retval) {
 			LOG_ERROR("timeout waiting for NAND flash block erase to complete");
 			return ERROR_NAND_OPERATION_TIMEOUT;
 		}
 
-		if ((retval = nand_read_status(nand, &status)) != ERROR_OK)
+		retval = nand_read_status(nand, &status);
+		if (retval != ERROR_OK)
 		{
 			LOG_ERROR("couldn't read status");
 			return ERROR_NAND_OPERATION_FAILED;
@@ -758,11 +726,17 @@ int nand_page_command(struct nand_device *nand, uint32_t page,
 			nand->controller->command(nand, NAND_CMD_READSTART);
 	}
 
+	if (NAND_CMD_ERASE1 == cmd) {
+		/* verify erase commands. */
+		nand->controller->command(nand, NAND_CMD_ERASE2);
+	}
+
 	if (nand->controller->nand_ready) {
-		if (!nand->controller->nand_ready(nand, 100))
+		if (!nand->controller->nand_ready(nand, 1000))
 			return ERROR_NAND_OPERATION_TIMEOUT;
 	} else {
-		alive_sleep(1);
+		if (!nand_poll_ready(nand, 1000))
+			return ERROR_NAND_OPERATION_TIMEOUT;
 	}
 
 	return ERROR_OK;
-- 
1.6.5.2

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] AT91SAM9 NAND Driver

2009-12-15 Thread Dean Glazeski
Hey all,

I have the AT91SAM9 branch, at91sam9-nand, updated against the current
OpenOCD head at http://repo.or.cz/w/openocd/dnglaze.git, but it needs all
the patches from the nand-refactor branch from the same repository.  I did
some updates to the nand-refactor branch based on some things David
suggested.  I'd like to see the at91sam9-nand pieces make it into the
version 0.4.0 release, if it's still possible.

Let me know if there's anything I need to do to get it in.  I can post a
giant patch for the AT91SAM9 NAND driver once the NAND refactor changes are
approved.

// Dean Glazeski
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH 1/2] ecos: crisper implementation of timeval_ms()

2009-12-15 Thread Øyvind Harboe
I believe this patch addresses the issues you raised.



-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
From c8b8a34bb5e98660c4ce3683fb64af31b494d55c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?=C3=98yvind=20Harboe?= 
Date: Tue, 15 Dec 2009 14:57:38 +0100
Subject: [PATCH] ecos: crisper implementation of timeval_ms()
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

A crisper/faster implementation under eCos that makes profiling a
tad easier.

Signed-off-by: Øyvind Harboe 
---
 src/helper/Makefile.am   |4 +-
 src/helper/time_support.c|   11 -
 src/helper/time_support_common.c |   42 +
 src/helper/time_support_ecos.c   |   43 ++
 4 files changed, 87 insertions(+), 13 deletions(-)
 create mode 100644 src/helper/time_support_common.c
 create mode 100644 src/helper/time_support_ecos.c

diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am
index 244ada7..3ec4f31 100644
--- a/src/helper/Makefile.am
+++ b/src/helper/Makefile.am
@@ -7,9 +7,9 @@ METASOURCES = AUTO
 noinst_LTLIBRARIES = libhelper.la
 
 if ECOSBOARD
-CONFIGFILES =
+CONFIGFILES = time_support_ecos.c
 else
-CONFIGFILES = options.c jim.c jim-eventloop.c
+CONFIGFILES = options.c jim.c jim-eventloop.c time_support_common.c
 endif
 
 
diff --git a/src/helper/time_support.c b/src/helper/time_support.c
index 693528f..1934315 100644
--- a/src/helper/time_support.c
+++ b/src/helper/time_support.c
@@ -29,7 +29,6 @@
 
 #include "time_support.h"
 
-
 /* calculate difference between two struct timeval values */
 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
 {
@@ -73,16 +72,6 @@ int timeval_add_time(struct timeval *result, long sec, long usec)
 	return 0;
 }
 
-int64_t timeval_ms()
-{
-	struct timeval now;
-	int retval = gettimeofday(&now, NULL);
-	if (retval < 0)
-		return retval;
-	return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;
-}
-
-
 int duration_start(struct duration *duration)
 {
 	return gettimeofday(&duration->start, NULL);
diff --git a/src/helper/time_support_common.c b/src/helper/time_support_common.c
new file mode 100644
index 000..1ad3676
--- /dev/null
+++ b/src/helper/time_support_common.c
@@ -0,0 +1,42 @@
+/***
+ *   Copyright (C) 2006 by Dominic Rath*
+ *   dominic.r...@gmx.de   *
+ * *
+ *   Copyright (C) 2007,2008 Øyvind Harboe *
+ *   oyvind.har...@zylin.com   *
+ * *
+ *   Copyright (C) 2008 by Spencer Oliver  *
+ *   s...@spen-soft.co.uk  *
+ * *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or *
+ *   (at your option) any later version.   *
+ * *
+ *   This program is distributed in the hope that it will be useful,   *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of*
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *
+ *   GNU General Public License for more details.  *
+ * *
+ *   You should have received a copy of the GNU General Public License *
+ *   along with this program; if not, write to the *
+ *   Free Software Foundation, Inc.,   *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
+ ***/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "time_support.h"
+
+/* simple and low overhead fetching of ms counter. Use only
+ * the difference between ms counters returned from this fn.
+ */
+int64_t timeval_ms()
+{
+	struct timeval now;
+	int retval = gettimeofday(&now, NULL);
+	if (retval < 0)
+		return retval;
+	return (int64_t)now.tv_sec * 1000 + now.tv_usec / 1000;
+}
diff --git a/src/helper/time_support_ecos.c b/src/helper/time_support_ecos.c
new file mode 100644
index 000..b0911fc
--- /dev/null
+++ b/src/helper/time_support_ecos.c
@@ -0,0 +1,43 @@
+/*