Installed Bootloader but no USB-Device is shown up

Oli
Wed Apr 27, 2016 12:51 am
Hi,

I bought an Olimexino and now I’m trying to use it with your bootloader, but no usb device shows up. This is my setup:

Mac OSX 10.9 Mavericks
Arduino IDE 1.6.5
Olimexino with STM32F103RBT6 on board
FTDI-device

First i tried to upload some sketch using my FTDI, but only got some error messages like: dyld: Library not loaded: /usr/local/lib/libusb-1.0.0.dylib


RogerClark
Wed Apr 27, 2016 1:46 am
This sort of issue turns up at least once a week on the site

Firstly. Serial USB is provided by the sketch not the bootloader.

You need to upload a sketch containing Serial.begin using the correct upload setting from the menu ( All boards that have the bootloader upload menu option enable serial USB in the sketch)

You also need to check that your Olimex board is compatible with the bootloader you have uploaded, i.e the one you chose has an LED on PA1, and will try to reset the board by changing the USB lines to GPIO and back to USB to force a USB reset.
This method was developed for boards that don’t have any USB reset circuit on them.

Your Olimex board may have a USB reset circuit (normally 1 or 2 transistors), which need to be be triggered via a specific GPIO pin.

You will need to get the schematic for the board and see how the USB reset is handled.

If there isn’t a dedicated USB reset circuit, the board needs about a 1.5k pullup on one of the USB lines (I can’t remember which one, but you can look it up in the bootloader code)


Oli
Wed Apr 27, 2016 2:47 am
Thank you very much RogerClark for your really fast reply!

I looked into the schematic of the board https://www.olimex.com/Products/Duino/S … latest.pdf
and it seems to have this USB reset circuit attached to PC12.
Can you tell me which bootloader I should use or if there is none give me a hint what I have to change in the code?

UPDATE:
If I understand the instructions at https://github.com/rogerclarkmelbourne/ … bootloader right, the configuration should look something like this:

#if defined TARGET_OLIMEXINO

#define HAS_MAPLE_HARDWARE 1

#define LED_BANK GPIOA
#define LED_PIN 1
#define LED_ON_STATE 1

/* USB Disc Pin Setup. USB DISC is PC12 */
#define USB_DISC_BANK GPIOC
#define USB_DISC_PIN 12


RogerClark
Wed Apr 27, 2016 3:18 am
I checked and there isnt a pre-made bootloader with the USB “DISC” (Disconnect) pin on PC12

If you look in https://github.com/rogerclarkmelbourne/ … 1/config.h

You can see the various boards that have already been defined.

You would need to add a new “target” , by copying the MAPLE MINI code

#define HAS_MAPLE_HARDWARE 1

#define LED_BANK GPIOB
#define LED_PIN 1
#define LED_ON_STATE 1

/* On the Mini, BUT is PB8 */
#define BUTTON_BANK GPIOB
#define BUTTON_PIN 8
#define BUTTON_PRESSED_STATE 1

/* USB Disc Pin Setup. USB DISC is PB9 */
#define USB_DISC_BANK GPIOB
#define USB_DISC_PIN 9


Oli
Wed Apr 27, 2016 4:38 am
Thanks for the information! I changed the maple-mini target to fit the boards schematics as follows: (if it’s finally working I will create a own target and do a pull request)

#if defined TARGET_MAPLE_MINI

#define HAS_MAPLE_HARDWARE 1

#define LED_BANK GPIOA
#define LED_PIN 5
#define LED_ON_STATE 1

/* On the Mini, BUT is PB8 */
#define BUTTON_BANK GPIOC
#define BUTTON_PIN 9
#define BUTTON_PRESSED_STATE 1

/* USB Disc Pin Setup. USB DISC is PB9 */
#define USB_DISC_BANK GPIOC
#define USB_DISC_PIN 12


RogerClark
Wed Apr 27, 2016 6:16 am
The bootloader stays in DFU upload mode for about 1 second after the board has been reset.

During this time it flashes the LED

If your board continues to flash the LED after about 1 sec, its telling you there is no valid code sketch code in the flash, i.e you don’t appear to have uploaded a valid sketch

I think its tricky on the Mac, as DFU util is picky about timing, but the trick is normally to press upload in the IDE and then just at the point when its finished compiling and is about to upload, then you need to manually reset the board.

Ah.

I also just realised, you will need to modify the core and add a new board, because the code won’t have valid code to reset the USB when it switches back to the bootloader.
i.e what happens is, that the USB serial checks for a magic sequence of chars and DTR line, and if the IDE sends this, via the maple_upload binary, the core toggles the USB disconnect pin and then reboots the processor, so that the bootloader runs.

If you look in board.h for the Maple mini,

https://github.com/rogerclarkmelbourne/ … rd/board.h

it defines

#define BOARD_USB_DISC_DEV GPIOB
#define BOARD_USB_DISC_BIT 9


Oli
Wed Apr 27, 2016 10:37 pm
Ok thanks for pointing that out, but my problem is that with none of the new bootloaders a serial device is created.
I just found out, that the Olimexino is based on the Maple Rev 3 and indeed the schematics are quite similar.

Maple Rev 3: https://github.com/leaflabs/maple/blob/ … ematic.pdf
Olimexino: https://www.olimex.com/Products/Duino/S … latest.pdf

Using the bootloader from the olimex-site: https://www.olimex.com/Products/Duino/S … naries.zip the board shows up with an serial port and I can upload sketches if I select the maple rev 3 as board in the IDE. This is actually quite nice, but of course I would like to use your optimized bootloader. So I flashed the maple_rev3_boot20.bin but with this bootloader no Serial Port is created, even no information in system profiler shows up.
That’s strange since both have the USB reset connected to PC12, BUT at PC9 and the LED at PA5. But looking into config.h the setting don’t fit to the schematics, I’m quite confused:

#elif defined TARGET_MAPLE_REV3

#warning "Target MAPLE_REV3"

// Flag that this type of board has the custom maple disconnect hardware
#define HAS_MAPLE_HARDWARE 1

#define LED_BANK GPIOB
#define LED_PIN 1
#define LED_ON_STATE 1

#define BUTTON_BANK GPIOB
#define BUTTON_PIN 8
#define BUTTON_PRESSED_STATE 1

/* USB Disc Pin Setup. USB DISC is PB9 */
#define USB_DISC_BANK GPIOB
#define USB_DISC_PIN 9


RogerClark
Wed Apr 27, 2016 11:28 pm
The Serial device is not part of the bootloader, its embedded into the sketch

The bootloader purely provides DFU for upload, then the bootloader resets the USB and jumps to the start address of the sketch.

The sketch then runs as the serial device (assuming the serial usb code has been compiled into the sketch – this depends mainly on the upload method selected)

So until you get a sketch into the board, you won’t have USB serial.


Oli
Thu Apr 28, 2016 12:03 am
Ah ok, thanks for clarification, now I get it.
But how do you get an sketch on the device without a serial communication? My workaround now was to start a virtual windows install the maple drivers and load a sketch with the maple ide. But that’s quite complicated. What do you think of including a demo sketch in the bootloader? Wouldn’t that solve the problem?

RogerClark
Thu Apr 28, 2016 12:22 am
The trick is to reboot the board manually at the right time, and upload at that time.

This is tricky on mac.

What I do is press and hold the reset button on the board

Press upload in the IDE

then just before it looks like its finished compiling, release the reset button.

Then hopefully the bootloader will be running as the DFU device at the moment the IDE wants to upload.

If you have another button on your board, the bootloader has a feature called “perpetual bootloader mode”
Basically it holds it in DFU mode.

So what you normally do with a blank Maple Mini board, is press reset the press and hold the user button. The bootloader then goes into perpetual bootloader mode, and you can upload at your leisure

If you don’t have a button on the board, you could simulate the button, by pulling whichever GPIO line is the Maple mini button to Vcc

(I can’t remember which pin the button is on, you could look in the bootloader config)


Oli
Thu Apr 28, 2016 12:33 am
Hm ok, I’m not sure if I got that right. What do you set in tools -> port in the Arduino IDE for that?

RogerClark
Thu Apr 28, 2016 12:54 am
Yes

Once the sketch in running and you have a serial device, you must select that device in the IDE, otherwise the IDE can’t reset the board ready for upload

The IDE sends a magic sequence to the board via serial to do this

However as you don’t have a sketch installed you won’t have a serial device to select

I recommend you try to simulate having the button attached which puts the board into permanent DFU upload mode

Just google for “Maple mini perpetual bootloader” there are vids showing how to do it.


Oli
Thu Apr 28, 2016 1:05 am
Thank you very much for all the detailed information.
The board has a second button, and indeed it worked as you described and I could upload a sketch even without selecting a serial device.

Unfortunately, I still have no serial device after uploading :(
Really strange, will continue investigation tomorrow.


RogerClark
Thu Apr 28, 2016 1:35 am
Add some code into the sketch to send some serial

I think its what we call “Blink & Count” ;-)


Leave a Reply

Your email address will not be published. Required fields are marked *