r/PSoC • u/darthponeh • Sep 29 '21
How to program a psoc 5LP using Linux (Rasp Pi 4)
Been struggling with this aspect and willing to pay for a solution . I have a CY8CKIT-059 (PSoC 5LP ) kit,
and have it plugged into a Pi via the USB on the PSoC. I am looking to be able to program a PSoC 5LP but there is no Linux supported programmer cli for the PSoC 5.
At the moment I have leveraged a solution to program from my windows PC using www.virtualhere.com, but it is $50 for every host and non transferable. So if you blow a pi, your out the mula.
Any how any collaboration, ideas or solutions greatly appreciated. I love the PSoC 5, but am a little disappointed at the lack of Linux support.
2
u/38andstillgoing Oct 21 '21 edited Oct 21 '21
A little late here, but you can load the HID bootloader to the PSOC 5LP once with windows and then re-flash it with the python HID bootloader host. https://github.com/cyrozap/Cypress-HID-Bootloader-Host
You'll lose some flash space and you'll probably want to add some ability to your code to reboot into bootloader mode on command. (Bootloadable_Load() )
You could probably do similar using the other end with the serial emulation the on-board programmer has and the bootloader in a serial flavor.
1
u/darthponeh Oct 22 '21
Never too late. That looks interesting to me however might be above my current abilities/understanding. Part of my struggle is understanding how the current Kitprog programs the PSoC. So your saying I would load a new HID bootloader onto the Kitprog or the main PSoC (I should clarify I am using the cy8ckit-059 stick)?
2
u/38andstillgoing Oct 22 '21
Sorry, yes, you use the Kitprog to program the Bootloader onto the main PSoC, Luckily you only need the Windows/KitProg once to flash a bootloader. Then you do bootloading via the Micro USB against the main CPU with your actual code.
In my case I'm using a program that uses the Micro USB so on every reset the bootloader wakes up, waits for 5 seconds to see if it's needed then if not it loads the main program from flash. If the main program uses that reset command then the bootloader becomes active until the device is reset or it receives bootloader communications.
The Cypress app note isn't all that great, but it does cover most of the basics. The big difference is that you can actually communicate to the bootloader rather simply rather than the impossible to use under Linux KitProg.
https://www.cypress.com/documentation/application-notes/an73503-psoc-usb-hid-bootloader
Here's the app I'm working on making bootloadable: https://github.com/wormley/fluxengine/tree/psoc_bootloader There's a bootloader project and then the main app, the main app has a single component added so it loads into the proper memory location so it can be bootloaded. The main app once compiled the .HEX actually has the bootloader added so if you flash that then you get both. After the initial flash you use a program like the one I mentioned or the one in that repository under tools/ to load the 'cyacd' file that PSoC Creator creates in the same directory as the .HEX. It's a format the bootloader specifically understands. Additionally the main app I've added a 'reset' command to go into the bootloader.
→ More replies (3)
2
u/kirankanchi Sep 29 '21
Have u tried openOCD on Linux ?
2
u/kirankanchi Sep 29 '21
I agree PSOC programmer is not supported on Linux but I have programmed many parts through openOCD on windows but it should work fine on Linux too. I'll try to program a 5LP on my Linux and let u know how it goes.
1
u/darthponeh Sep 29 '21 edited Sep 30 '21
I tried to use the Open-OCD (CyProgrammer), but it is not compiled for the armv7 and therefore will not run.
0
2
u/anthroid Sep 29 '21
Since there are much more practical solutions to this, I have to ask. Why do you need to program a PSoC 5LP from a Raspberry Pi?
For instance:
You mentioned you have a Windows PC. Why don’t you just connect the board there and use PSoC Creator?
What do you need to do with the PSoC 5LP that can’t be done with a PSoC 6 and ModusToolbox, or any other microcontroller for that matter (STM32, NXP Kinetis, etc)? The configurable mixed signal array is great for prototyping, but once you’ve got a design worked out, you can easily port the design to almost anything with fixed peripherals. Anything “special” (e.g. using custom UDBs) should still be possible with the PSoC 6.
You could program the mixed signal array once (or as needed) with Windows + PSoC Creator, and then move to Linux and program and debug the ARM core using standard tools (J-Link, etc).
You could use Linux as your host and run PSoC Creator in a VM (though probably not on a Raspberry Pi).
You could potentially use the Arduino toolchain that was developed for the FreeSoC
So again, why? Once you hit a wall like this, you should step back and reevaluate your approach. Is it even necessary? Is there a more practical solution?