sparkfun / PSoC_Arduino_Support

Support projects for PSoC processor support within the Arduino IDE
25 stars 11 forks source link

Bootloader project builds, but doesn't work, no USB UART. #12

Closed apullin closed 7 years ago

apullin commented 8 years ago

The 'Bootloader' project does build without error in PSoC Creator 3.3. Doing a "Program" operation after building in release mode, and then plugging USB into the Target port, no USB-to-serial device gets presented to the system. Programming the generated .hex in the release directory produces the same behavior.

Programming the bundled bootloader.hex with PSoC Programmer does cause the board to present a USB-to-serial port, and can be succesfully programmed with the Arudino IDE/avrdude.

mhord commented 8 years ago

Try pressing the reset button twice, in rapid succession, and see what happens.

When you program just the bare bootloader, the bootloader is going to roll over into the non-existent application code. If you double-tap the reset button, that overloads the normal functionality and causes the bootloader to pause for 8 seconds, awaiting the AVRDUDE input. While the target is in the bootloader, you'll see a 1Hz blink on the user LED attached to P6.7.

I'll look into this a bit, though- the default behavior should be to loiter in the bootloader until an application is loaded.

apullin commented 8 years ago

A single press of the target reset button does cause the COM port to be enumerated, and 8 seconds of bootloader with the blinking user LED.

If the reset is timed right, the Arduino upload sequence will actually catch it and try to connect, but ultimately time out, with: Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

I may be programming/using the Bootloader project improperly. I am just doing a Clean & Build in release mode, and then Program. I am not sure where ther FreeSoC2_ST project comes in, if that needs to be injected as a "bootloadable" or something. I was just going down this road to see how it all works, but can't reproduce the precompiled Bootloader.hex that is included.

mhord commented 8 years ago

The best bet is probably to program the Uno_Blocks project. That's essentially an empty project, as well, but it will at least enumerate the serial port and handle the request from avrdude to reboot into bootloader mode.

FreeSoC2_ST is our internal self-test program; it's what they ship with. It's been integrated into this project so the next generation of FreeSoC2 boards can ship with the bootloader already installed.

Try loading Uno_Blocks and see if that gets you where you need to be.

obra-io commented 7 years ago

I believe the issue is a NULL pointer dereference in PSoC_Arduino_Support/Bootloader.cydsn/main.c:93. This is encountered when the bootloader attempts to respond to the host.

mhord commented 7 years ago

Good catch. I added a NULL handler to the CyBtldrCommWrite function (and the Read function too, for that matter).

Fixed.