KitProg

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
niprc_3742601
Level 4
Level 4
5 likes given First like received First like given

Hello,

my understanding is that KitProg is firmware that runs on PSoC5 and is used to program a PSoC4 processor on the same board.  At least, this is how it appears to be set up on my PSoC 4 L-Series Pioneer Kit (CYCKIT-046).

Is it possible to configure/modify KitProg such that it can program more than one PSoC4 chips on our custom board?  I am thinking about configuring/adding some sort of a switch that I could point to a selected chip that I want to program.  Or some sort of "broadcast" option, maybe, where I can program all PSoC4 chips at once.

Please help!

Thanks,

Nikolay

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san and David-san,

For others, following test is my private experiment and is not guaranteed nor recommended!

(You Are Warned)

Anyway, we have kept trying our method, too.

And finally today we could confirm that my method,

which is multiplexing only SWDCLK

and share SWDIO among 4 + 1 CY8CKIT-042s

worked the way I expected.

So "practically" SWDIO seems to be robust enough to be shared among 5 boards (= 5 PSoCs).

IMG_3329.JPG

Although it required to disconnect nRESET from the master board,

I could select a board from 4 connected boards and load different programs in each boards.

As the total power is about 1A, we needed an external power supply.

moto

View solution in original post

0 Likes
23 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

Hi Nikolay,

Presently, Kitrprog supports SWD mode of Programming and it can't program multiple PSoCs at  a given time.

0 Likes

Hello,

and thank you for your reply!

As you mentioned, I haven't being able to find any reference on how to program multiple PSoC chips.  I wonder if there is absolutely anything in my power that I can do to make it work.  The only thing that I can think of right now is, somehow, modify KitProg so it switches to different SWD pins to program different PSoC processors.  Is this possible to do?

Also, I found this document, PSoC4 Programming Using an External Microcontroller (HSSP) (AN84858) that talks about how to program a PSoC.  It references the code from 001-84858_AN84858.zip file that handles PSoC programming.  My understanding is that this is the KitProg code.  My problem is that I am new to PSoC programming as well as microcontroller programming in general, I don't even have much of embedded programming experience either.  I would really appreciate any tips or general guidelines that would help me to accomplish this task OR, maybe, find somebody who could do this.

Thanks again,

Nikolay

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

Following is my "idea" and unfortunately I have not been able to test it.

So please read with a grain of salt.

Skimming some web pages for SWD,

I suppose that SWCLK is output from KitProg

and SWDIO is in/out from KitProg.

So I'd think controlling SWDIO might be difficult

and probably controlling only SWCLK (I hope) should work.

So if you go with jumper(s) or switch(es) the schematic could be like

(Pin Numbers may be incorrect, only refer to the signal names)

000-Jumper-Idea.JPG

Or if you have enough courage, you could implement a circuit in one of the PSoC 4 or

add another PSoC (or FPGA) for this task.

001-UDB-Idea.JPG

But probably the earlier (jumper/switch) method is cheaper and safer.

moto

0 Likes

Hello, and thanks again for your help!

I like your ideas.  My understanding, that in your first proposal, we would have to physically control the switches to change between the processors to program.  If so then, it may not work since we may not always have physical access to our board.

Your second proposal is somewhat what I had in mind, but with a few missing details.  I will talk to my hardware engineer team to see if it would be possible to add a PSoC5 connected to my master PSoC with signal control logic.  You implied that this approach is less safer.  My I ask you why do you think so?

Thank you very much!

Nikolay

0 Likes

Nikolay,

Maybe instead of 4 of PSOC4 processors you can use one PSoC5? What limitations are forcing to use array of 4?

/odissey1

0 Likes

Hello,

it is a better question for my hardware engineer team.  However my understanding is that a large number of pins that that we try to control and redundancy of the overall design are major drivers to use multiple PSoC processors.

Thanks!

Nikolay

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

First of all, I like the idea of /odissey1-san, if you can afford to use PSoC 5,

it has JTAG and multiple devices can be programmed through a single debug connection.

Having written above, I've been thinking/hoping that a PSoC can forward SWDCLK to other PSoC,

then we may be able to program multiple devices via single SWD connection.

Note: As I wanted to test this physically, after a round trip to Akihabara I asked my hardware colleague to make a prototype joint board, but it won't be done today, so currently following is only a desk theory.

Currently I'm considering a couple of plans

(1) Plan_01

Dedicate a PSoC4 to control which device to be programmed and select the device via UART.

For both plans I'll use hello_devicex for each child PSoC 4

and for Plan_01 I'll use swd_test project for PSoC 4 No.0 to select the destination.

Plan_01

plan_01.JPG

(2) Plan_02

Use a PSoC 4 directly connected to SWD (let's call this a parent device) as a controller and download fixed SWDCLK - SWDCLK_OUTx circuit for each PSoC 4 connected after the first one (let's call them children devices).

Note: This method was what I thought may be not safe, as after writing all children device,

we also can write application to this parent device,

but without careful plan/design, this may cause the board bricked.

For Plan_02 I'll down load prog_devx for each child PSoC 4 then

indirectly program each of them.

Plan_02

plan_02.JPG

Although I'm going to test them as soon as the joint board will be made,

in case the SWDCLK forwarding does not work, all of my plan will be a fantasy.

Let's keep our fingers crossed 😉

Best Regards,

10-Jan-2019

Motoo Tanaka

0 Likes

Dear Motoo-san,

thank you for your help!  I shared your ideas with my hardware engineer and here is what he said:

1.

First of all, I like the idea of /odissey1-san, if you can afford to use PSoC 5,

it has JTAG and multiple devices can be programmed through a single debug connection.

I was told that PSoC5 doesn't have GPIO pins (or, maybe, not enough of them).  So it cannot suit our requirements.

2.  Routing SWDCLK line through a PSoC may introduce some lag for this signal and this lag may corrupt the bus.  So it would be better to route all of the SWD signals through a parent PSoC.  Here is how we altered your plan 2:

Slide2.JPG

The plan is to use MiniProg3 to generate the PSoC programming instructions that are going to be rerouted to a specified child by the parent PSoC the same way you reroute SWDCLK signal in your scenarios.  To select the child to be programmed, I send a USB command from the workstation with the child's PSoC ID.  Mode Control is for putting the parent PSoC in the programming mode for the parent programming.  What do you think about our current design?  Do you see any problems with it?

Thank you so much for your help!

Nikolay

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

> 1.

> First of all, I like the idea of /odissey1-san, if you can afford to use PSoC 5,

> it has JTAG and multiple devices can be programmed through a single debug connection.

>

> I was told that PSoC5 doesn't have GPIO pins (or, maybe, not enough of them).  So it cannot suit our requirements.

I was assuming usage of multiple PSoC5s, as JTAG allows us to chain control of multiple devices.

(I'm afraid that the BOM cost will be very high though)

2. If you can synchronize SWDCLK and SWDIO, that will be ideal!

   And I also agree with the idea of using an external MiniProg3.

   I have been too lazy to really attack that trick, and gave up at the first glance of knowing that the signal is bidirectional.

   But I wonder if we can manage to handle both SWDCLK and SWDIO through two stages, Adapter and 5LP.

   In case you succeed to do this, would you please teach me(us) how you managed it?

Anyway, I'm going to play with my plan, too.

And let you know if it works or not when I know it.

Best Regards,

11-Jan-2019

Motoo Tanaka

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

Today, our prototype did not behave as I expected.

Although we have not done enough testing and measuring

I suspect that SWDIO could not hold multi-drop connection.

So, yes, probably your engineer's idea will be better.

Best Regards,

11-Jan-2019

Motoo Tanaka

0 Likes

Dear Motoo-san,

thank you so much for your help!

Once we have our board ready for testing, I'll post here if it worked or not.

And again, thank you for your help!

Nikolay

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

Today, we had some success with my method.

My problems were

(1) USB was connected to the EVBs to use UART,

     but it caused SWD conflict with MiniProg3 and on-board kitProg

(2) For the Device0 (which is supposed to forward clock),

     once clock forwarding program is written, nRESET from MiniProg3 must have been disconnected

     otherwise MiniProg3 will write program to Device0 again.

So after programming Device0 for clock forwarding the circuit looks like

Select_Debug_Target_190115.JPG

With this and providing Vdd from external power supply we could program Device1 with clock forwarded via Device0.

Note: At this point we had only Device0 and Device1 connected to MinProg3.

IMG_3306.JPG

Then we added another target board, so from the top to the bottom

CY8CKIT-042 (only for providing power to other boards)

CY8CKIT-042 as Device02

CY8CKIT-042 as Device01

CY8CKIT-042 ad Device00 (works as SWD_CLOCK_MUX)

The board right side is only for FTDI (USB-UART) to communicate with Device00

swd_mux.JPG

So what we did was

(1) Program Device00 with swd_test_190110

(2) connect MiniProg3, Device00, Device01, Device02 using a handmade cable.

(3) clock_out_0 is connected to the SWD of Device01

(4) clock_out_1 is connected to the SWD of Device02

(5) The nRESET from MiniProg3 to Device00 is removed.

(6) Using Device00 selected device01 (Ctrl = 0x01) and programmed Hello_Device1,

     which brinks Green_LED

(7) Using Device00 selected device02 (Ctrl = 0x01) and programmed Hello_Device2,

     which brinks Red_LED

(8) Both Device01 and Device02 were programmed OK.

One of remaining issues is how to manage connect/disconnect of nRESET to Device00.

Best Regards,

15-Jan-2019

Motoo Tanaka

lock attach
Attachments are accessible only for community members.

Dear Motoo-san,

thank you so much for your help!

I created a little signal routing test program that routes only one signal, however it doesn't work quite as expected.  (I attached the workspace's zip file; the project's name is signal_router).  I am using my PSoC4 L-Series Pioneer kit board.  I create a signal (writing 1 to SIGNAL_OUT) and route it to either the ROUTE_1 or ROUTE_2 pin the same way you do in your sample project.  The TEST_SIGNAL_1 pin is wired to the ROUTE_1 and the TEST_SIGNAL_2 pin is wired to the ROUTE_2  pin.  SIGNAL_OUT is wired to SIGNAL_IN.  However the result is not always what I expect.  Sometimes, it works for a few iterations and then both ROUTE_1 and ROUTE_2 read 1.

Could you take a look at what is wrong in my setup?

Thanks you so much for all the help!

Nikolay

img.jpg

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

First of all, you don't have to paste "Whole workspace",

you can select a project in the "Workspace Explorer" and with the right-button click of the mouse,

you can select "Archive Workspace/Project...", which will generate a zip file of only the selected project

and should be much smaller than the whole workspace.

Last night, as all (well most of all) of projects in my workspace were necessary to form the trick,

I archived my whole workspace and attached it. And I was worrying about the big size of the archive

which was around 4.4MB, but today you made me feel much less guilty 😜

Returning to your question,

I suspect that following two lines in the for(;;) loop seems to be the problem

   uint8 mask = 0x01 ;

   mask = mask << (route - 1) ;

The initialization of mask is done only once then mask will be shifted each iterations

so after a few iterations mask will be larger than 2 and CTRL_REG_Write( mask ) never enables any output.

So I would suggest you to change

  mask = mask << (route - 1) ;

to

  mask = 0x01 << (route - 1) ;

Best Regards,

16-Jan-2019

Motoo Tanaka

0 Likes

Dear Motoo-san,

I think that mask is getting set correctly: it gets initialized to 1 with every iteration of the loop.  Also, I checked the output of CTL_REG and it seems to be as what I would expect.  I added the AND gates instead of the "Output Enable" for the ROUTE_1 and ROUTE_2 and it seems like it fixed the issue.  Now I am just wondering

why it didn't work with the "Output Enable" option

Thank you so much again!

Nikolay

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san,

You were correct!

The mask was working the way you expected.

Then I found the problem.

Which was the input type of TEST_SIGNAL_1/2.

You specified them as High impedance digital.

Meantime the output ROUTE_1/2 has output enable,

so they will be also High impedance when disabled.

As the result when ROUTE_1/2 is disabled, the connection between the corresponding input are both High impedance.

Therefore the value is logically "undefined" and physically "floating"

To avoid this, I would set the input type of TEST_SIGNAL_1/2 as Resistive pull down,

so that when ROUTE_1/2 is disabled the input value of TEST_SIGNAL_1/2 will be 0.

TEST_SIGNAL_1_pulldown.JPG

Since I'm out of my office today and the rest of this week, I tried this with CY8CKIT-044 which I have personally.

And I could reproduce your problem (LED is always RED) and could confirm that with the modification LED lights Blue and Green.

(Supererogatory memo)

The reason I thought mask won't work is that the assignment was done with the variable definition, which usually takes place only once.

May be it's only me to misunderstand it, but I would suggest you define mask at the beginning of main and assign 1 at the beginning of the loop, so that you can avoid misunderstanding of (at least one) person 😉

(original)

int main(void)

{

     uint8 route = 1;

     for(;;)

     {

          route = route == 1 ? 2 : 1 ;

          uint8 mask = 0x01 ; // I thought this assignment will done only once at the beginning

          mask = mask << ( route - 1 ) ;

          ....

      }

}

(my suggestion)

main()

{

     uint8 route = 1 ;

     uint8 mask = 0x01 ;

     for(;;)

     {

          route = route == 1 ? 2 : 1 ;

          mask = 0x01 ;

          mask = mask << ( route - 1 ) ;  // or you can write mask = 0x01 << ( route - 1 ) ;

          ...

       }

}

Best Regards,

16-Jan-2019

Motoo Tanaka

0 Likes

Dear Motoo-san,

as you mentioned, the pins weren't configured correctly.  Everything seems to work now (kind of, until we test it with our board when it's ready ).

Thank you very much!

Nikolay

MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Nikolay-san and David-san,

For others, following test is my private experiment and is not guaranteed nor recommended!

(You Are Warned)

Anyway, we have kept trying our method, too.

And finally today we could confirm that my method,

which is multiplexing only SWDCLK

and share SWDIO among 4 + 1 CY8CKIT-042s

worked the way I expected.

So "practically" SWDIO seems to be robust enough to be shared among 5 boards (= 5 PSoCs).

IMG_3329.JPG

Although it required to disconnect nRESET from the master board,

I could select a board from 4 connected boards and load different programs in each boards.

As the total power is about 1A, we needed an external power supply.

moto

0 Likes

Dear Motoo-san,

thanks for your help!

Nikolay

0 Likes

Dear Motoo-san,

I am the hardware engineer designing the board Nikolay is figuring out how to program.  I agree that a JTAG-enabled PSoC would be ideal, but due to the number of GPIOs we need, it would double the number of devices and we barely have enough board space for the PSoC4s...

The problem of switching the nRESET signal between the parent and child is not too difficult. I am happy to see that the clock MUX works, but I would really like to have MUXes for nRESET and SWDIO to minimize the need for external drivers, etc.

Thanks for all of your assistance!

Best Regards,

David Miller

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear David-san,

Thank you very much for your message!

Yes, I agree that longing for JTAG is somewhat useless complaint in this scenario.

And it's a kind fun to challenge the limitation of SWD, too.

As you could have imagined, I estimated the delay of SWDCLK from input pin to output pin of PSoC as nsec order,

if they are connected without core involvement, so I bet the delay of SWDCLK compared to the SWDIO should be acceptable.

I must confess that I was not paying enough attention with the fan-out delay of SWDIO when it is connected to multiple destinations.

So, yes, if you can manage to route SWDIO similar to SWDCLK, it should be more preferable.

I really love to learn how you will manage it.

Meantime, last night I could not imagine how we can disconnect and connect nRESET to the parent device.

(So we just physically disconnected the connection to the parent device.)

If nRESET of parent device is intact, the SWDCLK (and SWDIO) which is supposed to be routed

are returned to their basic function when MiniProg3 asserts nRESET,

then parent device loses it's routing functionality  and ready to be programmed.

So, yes, I'd love to learn how you will control it here, too.

Best Regards,

16-Jan-2019

Motoo Tanaka

0 Likes

Kitprog's firmware is confidential, it's not available in any ANs presently.

0 Likes

Thanks again!

Do you know the difference in functionality between PSoC4 Programming Using an External Microcontroller (HSSP) (AN84858) and KitProg?  To me, they appear to do the same thing.  AN84858 (page13) talks about loading their HSSP project (B_Hssp_Pioneer.cyacd) on a PSoC 5LP to program a PSoC4 processor.  This is what KitProg does in my understanding.

Thank you for your help!

Nikolay

0 Likes