Re: [Openocd-development] pointers modification within functions
On Thu, Nov 3, 2011 at 1:43 AM, Tomek CEDRO wrote: > Hello Andreas :-) > > On Thu, Nov 3, 2011 at 12:36 AM, Andreas Fritiofson > wrote: > > This won't even compile. You pass a pointer-to-int, but swd_bus_read_ack > > expects a pointer-to-pointer-to-char. > > naah this is only typo in mind-shortcut, code builds well, but i dont > get it why i cannot use single pointer to pass back a memory location > to function caller... this is what pointers exist.. > > Ah, well, but c passes parameters by value, to get out parameters you have to go via a pointer. Consider: void foo(int x) { x++; } int main(void) { int a = 3; foo(a); return 0; } Did you expect the value of a to change after the call to foo? No, didn't think so. You'd have to do this instead: void foo(int *x) { *x++; } int main(void) { int a = 3; foo(&a); return 0; } Here a gets the value 4 after the call to foo. Now change the variable type to a pointer instead of an integer: void foo(int **x) { *x++; } int main(void) { int *a = &bar; foo(&a); return 0; } Here a points to the integer following bar after the call to foo. It's exactly the same concept, just a change of variable type from int to int*. Note that &a is now a double pointer, nothing magic here. Do the same variable type change in the first, non-functional, example and convince yourself that that wont work either. ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] pointers modification within functions
Hello Andreas :-) On Thu, Nov 3, 2011 at 12:36 AM, Andreas Fritiofson wrote: > This won't even compile. You pass a pointer-to-int, but swd_bus_read_ack > expects a pointer-to-pointer-to-char. naah this is only typo in mind-shortcut, code builds well, but i dont get it why i cannot use single pointer to pass back a memory location to function caller... this is what pointers exist.. i have constructed this simple program to test if this can work - it can but i need to pass a address of a variable and write value to that variable, playing with pointers require double pointer :-( ill try this on more complex application :-) #include #include int f2(int *pf21, int *pf22){ int *stuff; stuff=(int*)calloc(1,sizeof(int)); if (!stuff) exit(-1); *stuff=0xDEADBEEF; printf("stuff[@%X]=%X\n", stuff, *stuff); *pf21=stuff; *pf22=*stuff; return 0; } int f1(int *pf11, int *pf12){ return f2(pf11, pf12); } int main(){ int a1=0,a2=0; f1(&a1,&a2); printf("a1[@%X]=%X\na2[@%X]=%X\n", &a1, a1, &a2, a2); return 0; } -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] pointers modification within functions
On Thu, Nov 3, 2011 at 12:41 AM, Tomek CEDRO wrote: > Hey, > > I have some problems with pointers and need some support plz ;-) > I'm not sure I understand what the problem is, but I can give some general hints. int swd_bus_read_ack(swd_ctx_t *swdctx, swd_operation_t operation, char > **ack){ > swd_cmd_enqueue_miso_ack(swdctx, ack); > You discard the return value and one of the parameters, but perhaps this is not the complete function? } > > int swd_cmd_enqueue_miso_ack(swd_ctx_t *swdctx, char **ack){ > if (swdctx==NULL) return SWD_ERROR_NULLCONTEXT; > int res; > swd_cmd_t *cmd; > cmd=(swd_cmd_t *)calloc(1,sizeof(swd_cmd_t)); > As a side note, cmd = calloc(1, sizeof(*cmd)); is preferred, in case the type of cmd changes later. if (cmd==NULL) return SWD_ERROR_OUTOFMEM; > if (ack!=NULL) *ack=&cmd->ack; > You probably want to wait with setting *ack until after checking res below. If swd_cmd_enqueue fails, ack will point to free'd memory, but you discard the return value in swd_bus_read_ack so the caller won't be able to tell. Leave *ack unchanged unless the function succeeds. cmd->bits=SWD_ACK_BITLEN; > cmd->cmdtype=SWD_CMDTYPE_MISO_ACK; > res=swd_cmd_enqueue(swdctx, cmd); //should be 1 on success > if (res<1) free(cmd); > return res; > } > > main(){ > int *ack; swd_bus_read_ack(swdctx, operation, ack); > This won't even compile. You pass a pointer-to-int, but swd_bus_read_ack expects a pointer-to-pointer-to-char. } > > The problem is: > 1. I need to use double pointers to return back the address of the > queue element (*ack=&cmd->ack). > Correct. 2. If I use single pointer *ack the value of the ack is only changed > inside swd_cmd_enqueue_miso_ack() but after its return to > swd_bus_read_ack() the ack value is taken back to the state as it was > before swd_cmd_enqueue_miso_ack() call. > You have already concluded that you need a double pointer in 1, so I don't know why you say this. A single pointer won't work. 3. I have tried to use single pointer *ack and call > swd_bus_read_ack(swdctx, operation, &ack) but is changes nothing. > Ditto. You're reusing the same name (ack) for several things in your description (two function parameters and a variable) so it's hard to understand what you mean. > This makes impossible to give back data on queue_dp_read(). There is > something wrong with these pointers!!! Help! :-) > ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] pointers modification within functions
Hey, I have some problems with pointers and need some support plz ;-) int swd_bus_read_ack(swd_ctx_t *swdctx, swd_operation_t operation, char **ack){ swd_cmd_enqueue_miso_ack(swdctx, ack); } int swd_cmd_enqueue_miso_ack(swd_ctx_t *swdctx, char **ack){ if (swdctx==NULL) return SWD_ERROR_NULLCONTEXT; int res; swd_cmd_t *cmd; cmd=(swd_cmd_t *)calloc(1,sizeof(swd_cmd_t)); if (cmd==NULL) return SWD_ERROR_OUTOFMEM; if (ack!=NULL) *ack=&cmd->ack; cmd->bits=SWD_ACK_BITLEN; cmd->cmdtype=SWD_CMDTYPE_MISO_ACK; res=swd_cmd_enqueue(swdctx, cmd); //should be 1 on success if (res<1) free(cmd); return res; } main(){ int *ack; swd_bus_read_ack(swdctx, operation, ack); } The problem is: 1. I need to use double pointers to return back the address of the queue element (*ack=&cmd->ack). 2. If I use single pointer *ack the value of the ack is only changed inside swd_cmd_enqueue_miso_ack() but after its return to swd_bus_read_ack() the ack value is taken back to the state as it was before swd_cmd_enqueue_miso_ack() call. 3. I have tried to use single pointer *ack and call swd_bus_read_ack(swdctx, operation, &ack) but is changes nothing. This makes impossible to give back data on queue_dp_read(). There is something wrong with these pointers!!! Help! :-) Tomek -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] openocd patch: 96c3cbf cortex_m: add missing error checking
On Tue, Nov 1, 2011 at 11:16 PM, Tomek CEDRO wrote: > Hey does this code is related anyhow to arm_adi_v5 or this is totally > alternative solution? > > Yes, it *uses* arm_adi_v5. /Andreas ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] include linux/scripts in OpenOCD project?
On Wed, Nov 2, 2011 at 8:09 PM, Øyvind Harboe wrote: > On Wed, Nov 2, 2011 at 9:06 PM, Tomek CEDRO wrote: >> On Wed, Nov 2, 2011 at 8:03 PM, Øyvind Harboe >> wrote: >>> Should we? >> >> What does these scripts do? Will they work on FreeBSD? :-P :-) > > They allow you to check patches for coding style, remove whitespace, > automatically indent, etc. Aaah, ok, I finally upgraded my hardware so I can run VM and test stuff on/for other operating systems, this might be good option to have everything in one place :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] include linux/scripts in OpenOCD project?
On Wed, Nov 2, 2011 at 9:06 PM, Tomek CEDRO wrote: > On Wed, Nov 2, 2011 at 8:03 PM, Øyvind Harboe wrote: >> Should we? > > What does these scripts do? Will they work on FreeBSD? :-P :-) They allow you to check patches for coding style, remove whitespace, automatically indent, etc. Don't know about FreeBSD... -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 http://www.zylin.com/ ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] include linux/scripts in OpenOCD project?
On Wed, Nov 2, 2011 at 8:03 PM, Øyvind Harboe wrote: > Should we? What does these scripts do? Will they work on FreeBSD? :-P :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] include linux/scripts in OpenOCD project?
Should we? -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 http://www.zylin.com/ ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] openocd patch: 2fb67e0 tx27stk5: add board init support for KaRo TX27 CPU module
This is an automated email from Gerrit. Mark Vels (mark.v...@team-embedded.nl) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/158 -- gerrit commit 2fb67e0d442b3e00e81df5fadd4eedc930e3bd6d Author: Mark Vels Date: Tue Nov 1 13:29:11 2011 +0100 tx27stk5: add board init support for KaRo TX27 CPU module This patch adds support for a KaRo TX27 CPU module on a StarterkitV base board. The register settings have been extracted from a RedBoot distribution that is distributed along with the hardware by KaRo. This setup has been tested with a JTAGKey. The testing has been focussed on loading a program into memory and start execution. Although the flash seems to be correctly detected, no effort has been put in testing the NAND programming yet. Change-Id: Ib17763f1e3ecacd0eb9b5fdc32f8cba7a5e59be5 Signed-off-by: Mark Vels diff --git a/tcl/board/tx27_stk5.cfg b/tcl/board/tx27_stk5.cfg new file mode 100644 index 000..2a1c8b8 --- /dev/null +++ b/tcl/board/tx27_stk5.cfg @@ -0,0 +1,60 @@ +source [find target/imx27.cfg] + +$_TARGETNAME configure -event gdb-attach { reset init } +$_TARGETNAME configure -event reset-init { tx27_init } + +proc tx27_init { } { + # This setup puts RAM at 0xA000 + # init_aipi (AIPI1.PSR0, AIPI2.PSR0, AIPI1.PSR1 and AIPI2.PSR1) + mww 0x1000 0x20040304 + mww 0x1002 0x + mww 0x1004 0xDFFBFCFB + mww 0x10020004 0x + + sleep 100 + + #init_max ( PORT0.MPR, #PORT0.AMPR, #PORT1.MPR, #PORT1.AMPR, #PORT2.MPR, #PORT2.AMPR) + mww 0x1003F000 0x00302145 + mww 0x1003F004 0x00302145 + mww 0x1003F100 0x00302145 + mww 0x1003F104 0x00302145 + mww 0x1003F200 0x00302145 + mww 0x1003F204 0x00302145 + + #init_drive_strength (#DSCR3, #DSCR5, #DSCR6, #DSCR7, #DSCR8 ) + mww 0x10027828 0x + mww 0x10027830 0x + mww 0x10027834 0x + mww 0x10027838 0x5005 + mww 0x1002783C 0x1555 + + #init_sdram_speed + #mww 0xD8001010 0x0004 + mww 0xD8001010 0x0024 + + mww 0xD8001004 0x00395729 + + mww 0xD8001000 0x9212 + mww 0xA400 0x0 + + mww 0xD8001000 0xA212 + mww 0xA000 0x0 + mww 0xA000 0x0 + + mww 0xD8001000 0xB212 + mdb 0xA000 + mdb 0xA033 + + mww 0xD8001000 0x82126485 + + # = + # Sync mode (AHB Clk = 133MHz ; BCLK = 44.3MHz) + # = + mww 0xD8002000 0x23524E80 + mww 0xD8002004 0x1D03 + mww 0xD8002008 0x00720900 + + nand probe 0 +} + +nand device tx27.nand imx27 $_TARGETNAME hwecc -- ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] openocd patch: aa9bc05 HACKING: all you need is http access
This is an automated email from Gerrit. ?yvind Harboe (oyvindhar...@gmail.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/157 -- gerrit commit aa9bc05890f74e51599e38d5ad195bb7af848261 Author: Ãyvind Harboe Date: Wed Nov 2 10:48:44 2011 +0100 HACKING: all you need is http access Change-Id: I191c1da5126c4c9ea1ff8826576b6b24feaf9881 Signed-off-by: Ãyvind Harboe diff --git a/HACKING b/HACKING index dc06b45..353e72f 100644 --- a/HACKING +++ b/HACKING @@ -1,3 +1,6 @@ +NB! If you're behind a corporate wall with http only access to the +world, you can still use these instructions! + Submitting patches to the OpenOCD Gerrit server: OpenOCD is to some extent a "self service" open source project, so to @@ -10,7 +13,7 @@ The procedure to create a patch is essentially: - create a commit - send the changes to the Gerrit server for review - correct the patch and re-send it according to review feedback - + 0. Create a Gerrit account at: @@ -43,7 +46,7 @@ you should scroll down the page till you get to the section: 'Next: Set Up SSH Keys', and follow the steps described. 1. Clone the git repository, rather than just -download the source. +download the source. git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd @@ -60,24 +63,35 @@ Add a new remote to git using Gerrit username: git remote add review ssh://usern...@openocd.zylin.com:29418/openocd.git git config remote.review.push HEAD:refs/for/master +Or with http only: + +git remote add review http://openocd.zylin.com/p/openocd.git +git config remote.review.push HEAD:refs/for/master + You will need to install this hook, we will look into a better solution: scp -p -P 29418 usern...@openocd.zylin.com:hooks/commit-msg .git/hooks/ +Or with http only: + +wget http://openocd.zylin.com/tools/hooks/commit-msg +mv commit-msg .git/hooks +chmod +x .git/hooks/commit-msg + 3. Set up git with your name and email: git config --global user.name "John Smith" git config --global user.email "j...@smith.org" -4. Work on your patches. Split the work into +4. Work on your patches. Split the work into multiple small patches that can be reviewed and applied seperately and safely to the OpenOCD repository. while(!done) { work - edit files using your favorite editor. - run "git commit -s -a" to commit all changes. + run "git commit -s -a" to commit all changes. } TIP! use "git add ." before commit to add new files. -- ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
Re: [Openocd-development] Gerrit with http only
On 2 November 2011 09:24, Øyvind Harboe wrote: > Setting up the commit-msg hook isn't possible using http only: > > scp -p -P 29418 usern...@openocd.zylin.com:hooks/commit-msg .git/hooks/ > > http://repo.or.cz/w/openocd.git/blame?f=HACKING > > Any suggestions? > http://openocd.zylin.com/tools/hooks/commit-msg Spen ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development
[Openocd-development] Gerrit with http only
Setting up the commit-msg hook isn't possible using http only: scp -p -P 29418 usern...@openocd.zylin.com:hooks/commit-msg .git/hooks/ http://repo.or.cz/w/openocd.git/blame?f=HACKING Any suggestions? -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 http://www.zylin.com/ ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development