How to load P2 from Flash after power cycle or reset?
Just dove into the P2 world this evening with my new Dev Kit. Trying to figure out how to load my P2 Edge from Flash when power cycled. I have Flash selected to on, "up arrow" off, and "down arrow" off. I compile and click "Load Flash" and nothing happens when I power cycle or press reset. Perhaps I am being completely naive here, but I was expecting similar behavior to "Load EEPROM" on the P1. Am I supposed to write additional code to load my .spin2 file from Flash? I found a Prop2 Flash loader V1.2 code at some random website page, but it is specifically for loading a .obj file. Do I have to convert my .spin2 file to a .obj file and save them in the same folder? Any help would be greatly appreciated.
Attached is the first .spin2 code I've attempted to write (P2 Test 1.spin). F10 / Load Ram works great but has no use if I can't power cycle my product. I have no intention of adding a micro SD card reader to my design. I also attached the flash loader I found.
Comments
I'm confused about what you're trying to accomplish. F11 will load the current program in the editor to flash and it will run on reboot. The flash loader program you posted expects the new code to be in the flash at the 1M address, and have it's length in bytes as the first long. Are you wanting to switch between programs that are on flash instead of an SD card? You can do that, but you need to know where the are, and all of your programs would need to have a little loader executive attached to them. Brian's code is in PASM. I've done it (as a demo using a program embedded in DAT) with Spin2.
Probably the switch settings are off..
Think need one on to boot from flash…
JonnyMach and Rayman,
Thanks for the response.
"I'm confused about what you're trying to accomplish."
I was hoping to simply load my .spin2 code to Flash using F11 (just like I would load my .spin code to EEPROM on the P1 using F11). I was then expecting my LEDs to resume flashing (see previously attached P2 Test 1.spin2) every time I power cycled the board or pressed Reset. Instead, it's as if my code is only loaded into RAM (F10). When I power cycle the P2 Edge or press Reset, nothing loads and no LEDs flash.
Do I need to write a separate boot loader for the Flash or is it automated as it is with the P1 loading from EEPROM? Is it possible I have a bad FLASH chip?
Here are my DIP switch settings for Boot Mode Selection (see page 6 of attached P2-EC32MB-Edge-Module-Rev-A-Guide-v1.1.pdf)
(1) LEDs - ON
(2) FLASH - ON
(3) up-arrow - OFF
(4) down-arrow - OFF
There is no microSD card loaded in the P2 Edge module.
My P2 Edge is the P2-EC REV D.
Any help would be greatly appreciated.
Switches look right…
Are you using prop tool?
Make sure you are in p2 mode.
Save file with .spin2 file extension to make sure..
Unlike the P1, the P2 does need a user-supplied flash programmer / boot loader. However, this is added automatically by Propeller Tool or PNut when programming to flash, so it should really JustWorkTM.
Make sure the DIPs are really set firmly and that nothing else is connected to the boot pins. Maybe try disconnecting the serial adapter, too.
After trouble shooting for another couple of hours, I finally figured it out. The "Load Flash" button in the Propeller Tool is broken. As a habit, I always F8 before clicking "Load Ram" / "Load EEPROM" with the P1. If you F8 and then click "Load Flash" with the P2, it only loads to Ram, not Flash. Am I really the first person to discover this bug with the Propeller Tool? See attached. I have the latest version of the Propeller Tool which is V2.9.3. This was after wasting another couple of hours last night simply because the micro SD card was loaded in the P2 Edge. One of my engineering interns opened the dev kit last week and I didn't want to misplace the microSD card that came with the dev kit when I moved it over to my desk. I figured simply inserting it into the SD slot would solve the issue of not losing it not knowing I was setting myself up for two hours of frustration with my computer failing to identify the P2. I even tried digging out my older version of the Prop Plug (the one with the USB Mini thinking I might have received a bad prop plug. This was in addition to the frustration of another couple of hours because I wasn't saving my first "hello world" code as a .spin2 file before attempting to download it onto my P2. In short, It has taken me approximately 8 hours just to get "hello world" saved to Flash and working on my P2. I love Parallax and have used the P1 in thousands of my products. However, my P2 experience so far has not been positive. I intentionally waited to start transitioning some of my more advanced products over to the P2 because I wanted to give the P2 ecosystem time to have bugs resolved. I highly recommend the Parallax team perform more testing. I also recommend creating a 5 minute quick guide pdf or video for the P2 Edge (perhaps a project for one of my interns) that shows you how to get "hello world" working, correct DIP switch settings, mentioning not to have a microSD card inserted, to save your file before testing, and any other potential gotchas.
I think that @"Jeff Martin" may be updating Propeller Tool shortly (Chip suggested he would), so there is an opportunity to fix that. The "Save Binary File" button is 'broken' too, in that it doesn't provide a bootable file -- but with the latest version of the PNut compiler, that fix is a possibility, too.
In the meantime, F11 is your friend.
As much as I like Propeller Tool, if you're not using the Alt+Copy & Paste feature (which I really love), consider switching to Spin Tools IDE. It gives you the feel of Propeller Tool in a cross-platform package that has most (and more are coming) of the features that I wish Parallax had put into Propeller Tool. @macca is a Propeller developer like us, and I've found him very open to suggestions. Others have, too. I think it's fair to say that Spin Tools IDE is as nice as it is because Marco brought a nice base to the community and allowed the community to give input to make it better.
You can get Spin Tools here:
-- https://maccasoft.com/en/spin-tools-ide/
In Spin Tools:
Again, if you want your final compilation to be with another tool (e.g. the latest version of PNut), you can use the External Tool feature of Spin Tools.
Stick with it, you'll be happy you did. Parallax resources are slim, but you have the community. Consider it your AI (Actual Intelligence) for the P2.
@"Juliet Oscar Echo" I'm not a fan of the combined flash/uSD for exactly the trouble you had.
The boards I make can only boot from flash, have uSD on separate pins, and don't have this dip switch thing to figure out...
@"Juliet Oscar Echo" Looks like you are correct, the "load flash" button in the info window is broke.
Works from main window though.
Update to Prop Tool would be great.
Spin Tools IDE is probably better, but I'm kinda entrenched in Prop Tool.
Think most people don't actually write to flash until they have something final to deploy.
Probably why that doesn't get exercised that much...
Let's be blunt: that was a stupid idea -- to save ONE pin -- forced onto the design of the P2 by a person who has left the Propeller community.
Now that I have passed through the arduous P2 right of passage known as "hello world", it's time to have some fun...
Has anyone created an ATAN2 trig function? The CORDIC in the P2 is the main reason I'm wanting to make the switch over from the P1. Ideally the ATAN2 trig function would be in .spin2 and require zero additional dedicated cogs. All of my cogs are already assigned to other important tasks. Floating point math is not a requirement since I also enjoy using fixed-point arithmetic. I've seen some incomplete .spin2 binfloat code on the OBEX that was never finished to include the ATAN2 trig function.
Attached is my initial steps into playing with the CORDIC on the P2... effortlessly calculating square root, sine, and cosine. THANK YOU PARALLAX!
It's already built into Spin2,
XYPOL(x,y)
(also returns vector length)