Bootloader - a pin for the usb d+ disconnect

Bootloader for boards that don't have the addition hardware found on the Maple mini, which resets the USB
User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sat Aug 13, 2016 11:36 am

There is a 120ns long blip 500ns after the DISC goes first time low after the reset.
disc PB12 2.JPG
disc PB12 2.JPG (46.91 KiB) Viewed 300 times


And a broader view on the situation after DISC goes low after the reset. The 120ns blip is there but you cannot see it here.
disc PB12.JPG
disc PB12.JPG (58.7 KiB) Viewed 299 times


And the first byte on the usb (differential nrz signaling). The shortest width L=H=~85ns.
PICTURE DELETED
Last edited by Pito on Fri Aug 19, 2016 7:30 am, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sat Aug 13, 2016 12:40 pm

And the overall picture (the usb data are not fully visible with this sampling rate).
disc PB12 4.JPG
disc PB12 4.JPG (52.28 KiB) Viewed 298 times
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sat Aug 13, 2016 3:42 pm

I took the bootloader binary from fredbox (dec2016) - he configured DISC at PB9.
http://www.stm32duino.com/viewtopic.php?t=780
So I flashed his binary in and solder DISC to PB9. Using the PMOS as above. Also edited the board.h.
The led blinks only couple of seconds before it goes to userland, so there is a difference between his and mine source/binary.
No go.
I've edited the generics core files where applicable - to remove the PA12 gpio disconnect stuff (hopefully).
No go.

So finally I set MapleMini in the IDE as the board of choice and it works PERFECTLY now. No issues with upload from IDE. :twisted:
It seems to me in the current generics -
1. the bootloader source has been changed since December, and
2. also the generics BP core files still include incompabilities with the external disconnect hardware..

Now, how to consolidate all the stuff such we can build a bootloader for BPill (DISC pin as the option) and have working core files for Generic_BP_EXDISC??
:)
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sun Aug 14, 2016 10:39 am

I took the bootloader source again, and compiled for PB2/boot1 (mind there is 100k in series with the DISC signal), with pmos (and 1Meg from g to Vcc) - it does not enumerate. The RC of the large resistor's values and Cin capacitance of the Q1 (45pf) is too large for short pulsing obviously. So you may try with PB2 when you replace the 100k resistor on the BP's pcb.

I compiled the bootloader again for PB12 DISC (pmos, 68k from g to Vcc), it enumerates. I set MapleMini profile in IDE (and set PB12 in maple's /board/board.h).
First attempts it did not find the DFU.
After few plug out/ins during the upload the DFU was found and it uploaded the sketch (maple com appeared).
Afterwards it finds the DFu each time and it uploads the sketch fine.

The only issue I see it keeps the DISC active for 8secs (see the LA traces) so after upload it takes several seconds it ends up (you cannot open serial monitor till the final bell).
The old fredbox version ends immediately after upload - we probably missing to set DISC high somewhere at the end in the latest source.. Or I am not able to compile the bootloader properly..
This is the schematics which works here:
PMOS DISC.JPG
PMOS DISC.JPG (19.31 KiB) Viewed 280 times
Last edited by Pito on Sun Aug 14, 2016 12:42 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sun Aug 14, 2016 11:28 am

Ok, I went back to generic BP's profile - I edited the board/board.h for PB12 DISC and, in /wirish/boards_setup.cpp I commented out the lines 86-91 ).
Now it uploads fine. There is still the 8secs issue (the LED indicates for 6secs after the upload finishes it is in bootloader, then bells and goes to userland). MapleMini goes immediately after upload finishes.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Sun Aug 14, 2016 8:27 pm

Grrh, I've found the issue with 8seconds long waiting in bootloader - the BUTTON_BANK must be defined in order to get BOOTLOADER_WAIT "6", otherwise the BOOTLOADER_WAIT is "30".. :evil:

So the generic target for BluePill with DISC pin at PB2 may look like this in config.h:

Code: Select all

..
#elif defined TARGET_GENERIC_F103_DISC_PB12  // BluePill

   #define HAS_MAPLE_HARDWARE 1
   
   #define LED_BANK         GPIOC
   #define LED_PIN          13
   #define LED_ON_STATE      0
   
   #define BUTTON_BANK 1

   // DISCONNECT PIN (drives an highside PMOS/PNP)
   // mind the DISC pin is configured Open Drain
   #define USB_DISC_BANK       GPIOB
   #define USB_DISC_PIN         2
   ..


So - in order to get ie. BluePill working with an external USB disconnect switch (PMOS/PNP) at Pin_XY:
Bootloader:
1. in config.h - add the definition as above
2. in Makefile - add the recepies for the above target
3. compile new bootloader

HW:
4. flash the new bootloader
5. wire the external disconnect switch (pmos/pnp and 2-3 resistors)

Arduino_STM32/STM32F1/variants/generic_stm32f103c/
6. in /board/board.h edit the disconnect pin BOARD_USB_DISC_DEV/BIT
7. in /wirish/boards_setup.cpp comment out lines 86-91.

Easy :)
Last edited by Pito on Mon Aug 15, 2016 6:51 pm, edited 2 times in total.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Mon Aug 15, 2016 10:34 am

And my BluePill disconnect via PB2 (Boot1) mod - the Boot0/1 header removed and the pads used for soldering the SMD pmosfet (BSS223), and gate-Vcc resistor (here 47k). On the bottom pcb side, the original R10=10k disconnect resistor removed, R4=100k removed and replaced with the 10k, R3=100k removed, R3 pads used for the new disconnect resistor 1k5 (here 2k2 from my junk box and it works, will be replaced with 1k5) and 2 short wires soldered in at the right places :)
After the mod the USB DISC pin is PB2, Boot0 = 0, the config files mods as above, IDE board generic BPill.
DISC mod 1.JPG
DISC mod 1.JPG (44.52 KiB) Viewed 224 times

DISC mod 2.JPG
DISC mod 2.JPG (81.53 KiB) Viewed 224 times
Last edited by Pito on Fri Aug 19, 2016 2:58 pm, edited 4 times in total.
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 5564
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Bootloader - a pin for the usb d+ disconnect

Postby RogerClark » Mon Aug 15, 2016 9:22 pm

Did you use a FET in your latest modification?
I could not see a FET in the photos.

Can you draw a schematic of these latest changes ( e.g. just draw it on paper and take a photo)

User avatar
Pito
Posts: 986
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Bootloader - a pin for the usb d+ disconnect

Postby Pito » Tue Aug 16, 2016 10:06 am

Yes the pmosfet is there - on the first picture 2mm right from the 47k resistor :)
I have got problem with my attachment quota - I deleted almost all pictures from the past and still off the quota:(.
==========================
The schematics is the same as the above PMOS DISC.JPG:
disconnect pin PB2
sch.R3 1k..10k (a good engineering practice is to have one there)
sch.R2 1k5 (must be)
sch.R1 10k..100k (must be)
Q1 - pmosfet with low Vgs trigger voltage (around 1.5V)
or
Q1 - pnp bipolar, any general purpose type
==========================
The actual implementation is depicted on the shots above - on the BPill PCB you mess with pcb.R3, pcb.R4, pcb.R10 :)
Boot0/1 Header - removed
pcb.R4 = sch.R3
pcb.R3 = removed
pcb.R10 = removed
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 5564
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Bootloader - a pin for the usb d+ disconnect

Postby RogerClark » Tue Aug 16, 2016 11:22 pm

Hi pito

I didnt realise there was a user quota on images.

I will see if I can change it, or perhaps rescale your images ( though I would have to find and download them and upload again)


Return to “Generic bootloader”

Who is online

Users browsing this forum: No registered users and 1 guest