MURPHYENGINEERING / STM32F405RGT6-Breakout

Following along with Phil's Lab: https://www.youtube.com/watch?v=t5phi3nT8OU
1 stars 0 forks source link

Support software reset over USB for programming from Arduino IDE without BOOT0 pin #1

Open MURPHYENGINEERING opened 2 years ago

MURPHYENGINEERING commented 2 years ago

Reading about FTDI programming with a bootloader:

RS-232 chips use the DTR pin to reset the chip and enter the bootloader's firmware-receptive window:

The DTR signal is present on pin 20 of the 22-wire RS-232 interface using a DB-25 connector, and on pin 4 of a newer DE-9 serial port. The signal is asserted (logic "1") by raising the voltage of the pin from negative to positive. https://en.wikipedia.org/wiki/Data_Terminal_Ready

That pin is toggled when the IDE starts uploading (or opens the serial monitor) and stays high. The reset pulse is implemented by draining a capacitor on the chip reset pin:

On the hardware side, the DTR pin is connected to one side of a 0.1uf ceramic capacitor. The other side of that 0.1uf ceramic capacitor is connected to the RST pin on the AVR, and pulled up with a 10k resistor to Vcc. (thanks DrAzzy on forum.arduino.cc)

To support that process on the STM32, we need to find how the FTDI chip translates the always-connected USB channel to a toggling DTR signal. Can the host-side driver toggle power on the USB interface? That seems almost too easy.

Briefly looking at the Arduino UNO schematic, it looks like they're using an ATMEGA16 as an ISP connected directly to USB.

Screen Shot 2021-11-19 at 11 08 18 AM

On the datasheet there's a good clue about how this might work:

– Microcontroller reset on USB Bus Reset without detach

The ATMEGA16 appears to be using something like that DTR reset scheme:

Screen Shot 2021-11-19 at 11 11 55 AM

More after class

MURPHYENGINEERING commented 2 years ago

We can use the built-in bootloader to flash it without a programmer, but the user has to boot it with the BOOT0 pin. Asking the user to put it in a special mode every time they want to upload code isn't what I want. We can require this the first time to flash a bootloader that listens for a programmer on USB so they have a more Arduino-like experience.

See the STM docs on the boot capabilities for our chip (c20ec9f2251de8fd79f439a7f0a2a60e13dd4db3). What we're looking for is