[Openocd-development] [PATCH] mips: fixing big endian host issues...

2011-08-12 Thread Mahr, Stefan
nag :-) BR, Stefan -Ursprüngliche Nachricht- Von: openocd-development-boun...@lists.berlios.de [mailto:openocd-development-boun...@lists.berlios.de] Im Auftrag von Mahr, Stefan Gesendet: Donnerstag, 11. August 2011 00:42 An: Drasko DRASKOVIC Cc: Openocd-Dev Betreff: Re: [Openocd

Re: [Openocd-development] [OpenOCD][PULL Request][MIPS32] Fixed single byte memory write

2011-08-10 Thread Mahr, Stefan
Hi Drasko > Solution is more common, but the commit history is not clearer. You > are fixing several bugs in one patch... Serveral? Just one and a half :-) However, I stripped the alignment fix to a seperate patch file. Please find the three new patches attached. > Besides, I have an impressi

Re: [Openocd-development] [OpenOCD][PULL Request][MIPS32] Fixed single byte memory write

2011-07-30 Thread Mahr, Stefan
Andreas Fritiofson wrote: >> +void target_buffer_get_u32_array(struct target *target, const uint8_t >> *buffer, uint32_t count, uint32_t *dstbuf); >> +void target_buffer_get_u16_array(struct target *target, const uint8_t >> *buffer, uint32_t count, uint16_t *dstbuf); >> +void target_buffer_set_u3

Re: [Openocd-development] [OpenOCD][PULL Request][MIPS32] Fixed single byte memory write

2011-07-29 Thread Mahr, Stefan
Hi Drasko. > Drasko DRASKOVIC (1): > mips32 : Fixed memory byte access Your patch fixes the broken byte access, but not the big endian host issue. Since both problems are tied together, I would prefer a more common solution. Attached patch hopefully fixes both issues. It should also fix al

Re: [Openocd-development] MIPS target, big endian host

2011-07-11 Thread Mahr, Stefan
>>> Yes, if BE target shifts out an 32 bit value from address 0, it will >>> begin with bit0:7, that is byte address 0x03 at targets memory. >> >> And host will do the same. When it shifts out 32-bit value , it will >> put contents of it's address 0x3 to output buffer[0] and send this >> first. > I

Re: [Openocd-development] MIPS target, big endian host

2011-07-11 Thread Mahr, Stefan
> When you start shifting out LSB (bit) from the BE host, will you start > shifting out contents of address 0x3, or the address 0x0 ? In my > opinion, it will be content of the addr 0x3 that will be shifted out > first (as it holds bits 0:7 for on the BE host). Yes, if BE target shifts out an 32 b

Re: [Openocd-development] MIPS target, big endian host

2011-07-11 Thread Mahr, Stefan
Øyvind Harboe wrote: > Really OpenOCD could have stored the bits as a series of > words larger than bytes in the host representation to be more > efficient. This would probably be a source of much more confusion :-) ___ Openocd-development mailing list

Re: [Openocd-development] MIPS target, big endian host

2011-07-11 Thread Mahr, Stefan
Sorry, little mistake: wrong: >> LE host:  result = (uint32_t)buffer[0];    // result = 0x78563412  (memory >> 0x12 0x34 0x56 0x78) >> BE host:  result = (uint32_t)buffer[0];    // result = 0x12345678  (memory >> 0x12 0x34 0x56 0x78) corrected: LE host: result = *(uint32_t*)&buffer[0];//

Re: [Openocd-development] MIPS target, big endian host

2011-07-11 Thread Mahr, Stefan
>> buf_get_u32: >>                return (((uint32_t)buffer[3]) << 24) | >>                        (((uint32_t)buffer[2]) << 16) | >>                        (((uint32_t)buffer[1]) << 8) | >>                        (((uint32_t)buffer[0]) << 0); >> > > I do not get this function at all... What I see

Re: [Openocd-development] MIPS target, big endian host

2011-07-09 Thread Mahr, Stefan
> How do they convert then, when they do not know from which endianes to > convert from ? Conversion is done from byte array of jtag chain. >>> How ? >> >> buf_get_u32 does conversion from uint8* array >> >> example: >> mips_ejtag_get_impcode (mips_ejtag.c) >> >>  field.in_value i

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
>>> How do they convert then, when they do not know from which endianes to >>> convert from ? >> >> Conversion is done from byte array of jtag chain. > How ? buf_get_u32 does conversion from uint8* array example: mips_ejtag_get_impcode (mips_ejtag.c) field.in_value is filled by jtag_add_dr_sca

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
> How do they convert then, when they do not know from which endianes to > convert from ? Conversion is done from byte array of jtag chain. The endianness of MIPS EJTAG tap seems to have always the same endianness, no matter of MIPS CPU memory endianness. __

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
> Is this swap to host endianess done by buf_get_u32() in > mips_ejtag_drscan_32() after the queue has been executed ? Yes, buf_get_u32() and buf_set_u32() make sure uint32 is in host endianness. ___ Openocd-development mailing list Openocd-development@

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
>> - buf_set_u32 and buf_get_u32 make sure that data is in host endianness > Why ? Don't we want the data to be in target endianess ? >> You need swapping when reading and comparing debug registers or send code to >> MIPS CPU. > Can you give the example of some of these comparisons in the source

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
> Where are those functions defined and how do they know what the target > endianness is? They doesn't know the target endianness, but host endianness. > It sounds a little strange to do the swapping at this low level. You need swapping when reading and comparing debug registers or send code t

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
> Problem is not in the mips32_pracc.c, thought, but when you come back > to mips_m4k_read_memory(), in which buf is uint8_t*. That's why the solution could be to add swapping to _mem16, _mem32 etc. and alway return uint8*. ___ Openocd-development mail

Re: [Openocd-development] MIPS target, big endian host

2011-07-08 Thread Mahr, Stefan
> are you sure about this ? > > It seems to me that buffer[i] is directly filled by target, and I see > no reason that it is in the host endianess... Hi Drasko, Yes I'm sure. I tested it on my big endian host platform. I do not understand the code completely, but I think it's caused by the mips

Re: [Openocd-development] MIPS target, big endian host

2011-07-07 Thread Mahr, Stefan
>> Probably the best way would be to remove endianness swapping from >> mips_m4k_read_memory >> and put it to mips32_pracc/dma_read_mem32/16. Same for write. >> >> pro: mips32_pracc_read_mem32, ... will return a byte array in target >> endianness, so no cast necessary. >> con: Add swapping to at

Re: [Openocd-development] MIPS target, big endian host

2011-07-07 Thread Mahr, Stefan
If alignment is not guaranteed, casting from uint32 to void would cause problems too, wouldn't it? >>> Why? >> >> Sorry for confusion. I meant the casting within "mips32_pracc_read_mem". This >> is also a cast from void* to uint32_t*. If there will be an alignment error, >> it will >> o

Re: [Openocd-development] MIPS target, big endian host

2011-07-07 Thread Mahr, Stefan
>> If alignment is not guaranteed, casting from uint32 to void would cause >> problems too, wouldn't it? > Why? Sorry for confusion. I meant the casting within "mips32_pracc_read_mem". This is also a cast from void* to uint32_t*. If there will be an alignment error, it will occur here too. ___

Re: [Openocd-development] MIPS target, big endian host

2011-07-07 Thread Mahr, Stefan
Øyvind Harboe wrote: > It is not obvious at all from the context that there is an alignment > guarantee. If alignment is not guaranteed, casting from uint32 to void would cause problems too, wouldn't it? http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd;a=blob;f=src/target/mips3

Re: [Openocd-development] MIPS target, big endian host

2011-07-06 Thread Mahr, Stefan
> Trust the compiler NO ! :-) $ gcc -O3 -S test.c $ cat test.s .file "test.c" .text .p2align 4,,15 .globl uint32_read_unaligned .type uint32_read_unaligned, @function uint32_read_unaligned:

Re: [Openocd-development] MIPS target, big endian host

2011-07-06 Thread Mahr, Stefan
>>> "mips32_pracc_read_mem" casts uint32 to void, so we need to cast it >>> back to uint32. I found no suitable macro in actual sources. >> >> Hmm then I think we ought to define one to get this put to >> bed once and for all... > > static inline uint32_t uint32_read_unaligned(const void *dat

Re: [Openocd-development] MIPS target, big endian host

2011-07-06 Thread Mahr, Stefan
o we need to cast it back to uint32. I found no suitable macro in actual sources. -Ursprüngliche Nachricht- Von: Øyvind Harboe [mailto:oyvind.har...@zylin.com] Gesendet: Mittwoch, 6. Juli 2011 15:02 An: Mahr, Stefan Cc: openocd-development@lists.berlios.de Betreff: Re:

[Openocd-development] MIPS target, big endian host

2011-07-06 Thread Mahr, Stefan
Hi Øyvind, Did you see problems with host endianness or why did you commit this patch: http://openocd.git.sourceforge.net/git/gitweb.cgi?p=openocd/openocd;a=commit;h=2482244b0788c007dd789c21a4416379c229ea5c This patch brokes endianness on big endian host. "mips32_pracc_read_mem" and "mips32_prac

Re: [Openocd-development] [PATCH] mips: add nor flash write from memory block

2011-06-04 Thread Mahr, Stefan
> Ref. your "todo:" shouldn't that be sorted out before we merge it? > > How does this affect the arm target? The actual code in HEAD tries to load arm code to mips target. Bad idea. :-) My patch checks for mips target and branches if needed. All other targets are not affected. This is the reas

[Openocd-development] [PATCH] mips: add nor flash write from memory block

2011-06-03 Thread Mahr, Stefan
Hi, Attached patch adds support for writing flash memory from a memory block. (Only 16bit buswidth, only spansion compatible.) Best Regards, Stefan 0002-mips-add-nor-flash-write-from-memory-block.patch Description: 0002-mips-add-nor-flash-write-from-memory-block.patch _

Re: [Openocd-development] [PATCH] mips target

2011-06-01 Thread Mahr, Stefan
Hi Drasko > Just for the curiosity, n patch 1 : > + /* mips32_pracc_fastdata_xfer requires uint32_t in host endianness, */ > + /* but byte array represents target endianness */ > > Where does this comment comes from ? Pure experience ? Can you back it up ? "mips32_pr

Re: [Openocd-development] [PATCH] mips target

2011-05-31 Thread Mahr, Stefan
> Perhaps some cleanup of ancient history is called for? 0002-...(hopefully) fixes the error in mips_ejtag_fastdata_scan. 0001-...endiannes fixes (it was already sent yesterday) 0001-mips-fix-some-more-endian-madness.patch Description: 0001-mips-fix-some-more-endian-madness.patch 0002

Re: [Openocd-development] [PATCH] mips target

2011-05-31 Thread Mahr, Stefan
Any recommendation where to put the "mips_le_to_h_u32" callback function? mips_ejtag.h or binarybuffer.h ? Why arm_le_to_h_u32 is defined in arm_jtag.h? A function in helper/binarybuffer.h called "buf_le_to_h_u32" could be used by both targets. BR, Stefan _

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
> I bet that they have been deliberatly avoided in these functions > because of performance penalities... So it should go like this? --- a/src/target/mips_ejtag.c +++ b/src/target/mips_ejtag.c @@ -339,10 +339,15 @@ int mips_ejtag_init(struct mips_ejtag *ejtag_info) return ERROR_OK; } +

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
> lead to the NULL pointer dereference in the time of jtag data scan > execution (r is a automatic variable, local to the > mips_ejtag_fastdata_scan() function) ? Correction, not NULL pointer, but some trash value pointer from the no longer valid stack. >>> >>> No, buf_get_u3

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
> I did not saw changes to the mips_m4k_write_memory() and > mips_m4k_read_memory() (where my byte-flip code lives) in the patches > you presented. Maybe I did not follow carefully... I talk about the patch I sent a couple of minutes ago. >> I am not very happy with my crappy patch code, but if

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
>>> fast_load does not work for me. But it also did not work before, so I is >>> maybe a different issue. >> Did you tried it with my patches applied, or before ? Because these >> patches fix fastdata transfer. > I work with HEAD of git repository. Sorry, typo in work area configuration. Now fast

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
>> fast_load does not work for me. But it also did not work before, so I is >> maybe a different issue. > Did you tried it with my patches applied, or before ? Because these > patches fix fastdata transfer. I work with HEAD of git repository. > If you inversed byte order before it comes to the c

Re: [Openocd-development] [PATCH] mips target

2011-05-30 Thread Mahr, Stefan
The target endian issue still worries me. How the target memory is represented in host memory? Is it in physical byte order? When using a uint8 array, buf[0] is same value on target and host memory, isn't it? If so, mips32_pracc_read_u32 mips32_pracc_read_mem32 mips32_pracc_read_mem16 etc. return

Re: [Openocd-development] [PATCH] mips target

2011-05-29 Thread Mahr, Stefan
> The impact is that the code will behave the *same* on big and small > endian hosts. Attached patch fixes some more big endian HOST issues. 0001-mips-fix-swapping-if-running-on-big-endian-host.patch Description: 0001-mips-fix-swapping-if-running-on-big-endian-host.patch __

Re: [Openocd-development] [PATCH] mips target

2011-05-27 Thread Mahr, Stefan
>> I removed swapping in mips_m4k, because for commands like mdw the swapping >> was already done in target.c. If a target was selected as big endian, >> swapping was done twice. So setting endianness had no effect. I did not >> realized that dump_image works different. > What do you concern under

Re: [Openocd-development] [PATCH] mips target

2011-05-27 Thread Mahr, Stefan
argets too. BR, Stefan -Ursprüngliche Nachricht- Von: Drasko DRASKOVIC [mailto:drasko.drasko...@gmail.com] Gesendet: Freitag, 27. Mai 2011 12:58 An: Øyvind Harboe Cc: Mahr, Stefan; openocd-development@lists.berlios.de Betreff: Re: [Openocd-development] [PATCH] mips target On Thu, May 26, 20

Re: [Openocd-development] [PATCH] mips target

2011-05-26 Thread Mahr, Stefan
det: Donnerstag, 26. Mai 2011 12:12 An: Mahr, Stefan Cc: openocd-development@lists.berlios.de Betreff: Re: [PATCH] mips target On Wed, May 25, 2011 at 4:28 PM, Mahr, Stefan wrote: > Hi, > > attached patch fixes the endianess so mips/ejtag can be used on a big endian > host. > > >

[Openocd-development] [PATCH] mips target

2011-05-25 Thread Mahr, Stefan
Hi, attached patch fixes the endianess so mips/ejtag can be used on a big endian host. Btw.: There is still an endianness issue with mips target. Drasko adds endianness swapping (that I removed two years ago) to mips_m4k.c (commit b1256894598296b54a1827e7ac797ad1c60a0b18). But some swapping i

[Openocd-development] [PATCH] support for non cfi spansion flash

2011-05-25 Thread Mahr, Stefan
Hi, attached patch adds support for Spansion AM29LV040B that I found on an Mindspeed evalboard. BR, Stefan 0001-add-support-for-spansion-flash-on-mindspeed-c300-eva.patch Description: 0001-add-support-for-spansion-flash-on-mindspeed-c300-eva.patch _

[Openocd-development] [PATCH] MIPS M4k endianness

2009-09-04 Thread Mahr, Stefan
Hi, the attached patch removes the endianness swapping in mips_m4k.c Swapping is already done in target.c grx Stefan mips_m4k_endianness.patch Description: mips_m4k_endianness.patch ___ Openocd-development mailing list Openocd-development@lists.berli