Installed Bootloader but no USB-Device is shown up

Apple Mac OSX
Oli
Posts: 9
Joined: Wed Apr 27, 2016 12:26 am

Installed Bootloader but no USB-Device is shown up

Post by 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:

Code: Select all

dyld: Library not loaded: /usr/local/lib/libusb-1.0.0.dylib
and the dfu-util seemed not to find my FTDI. After changing the Apple FTDI Library as explain here: http://forum.arduino.cc/index.php?topic=198539.0 and installing dfu-util with home-brew as explain here: http://www.stm32duino.com/viewtopic.php ... t=10#p4926 I'm able to upload an Sketch using "Serial"-upload method.

But of course it would be much nicer to use the build in USB-port. So I installed the bootloader

Code: Select all

generic_boot20_pa1.bin
successfully and after restarting my device the led on port PA1 is only flashing quite fast and systemprofiler shows me an Maple 003-USB-Device, but nothing under /dev/

What else can I try?

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

Re: Installed Bootloader but no USB-Device is shown up

Post by 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
Posts: 9
Joined: Wed Apr 27, 2016 12:26 am

Re: Installed Bootloader but no USB-Device is shown up

Post by 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:

Code: Select all

#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
	
But what to choose as bank and pin for BUT? If I got the schematic right it is connected to Boot 0, but what does that mean?

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

Re: Installed Bootloader but no USB-Device is shown up

Post by 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

Code: Select all

	#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
The HAS_MAPLE_HARDWARE means it has a USB reset circuit

If yours has a user button, you can define it, or remove those defines if you don't have a User button.
You DISC Pis PC12 so that Bank GPIOC PIN 12

You will also need to modify the Makefile and add a new build target

If you are just doing this for your own use, I know some people just modify the existing Maple mini stuff in config.h and then "make" the Maple-mini target

But it would be better for the community if you could share your work and add a new section to config.h and update the make file to add a new build target for this board

Then you can post your files and I can update the code on github

Or ideally, you fork the repo on github, make the changes and then generate a Pull Request for your code to be merged back into the repo

Oli
Posts: 9
Joined: Wed Apr 27, 2016 12:26 am

Re: Installed Bootloader but no USB-Device is shown up

Post by 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)

Code: Select all

#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
and compiled the new bootloader with "make maple-mini" (I used https://launchpad.net/gcc-arm-embedded/+download as arm-none-eabi-gcc)
UPADTE: Instead of downloading a new arm-none-eabi-gcc compiler, just use the one which is included in arduino (as RogerClark recommended somewhere in the forum). For mac you have to set your path export like this:

Code: Select all

export PATH=$PATH:/Users/YOURUSERNAME/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin
(thought that might help someone else :)
End of UPDATE

But sadly the led is still flashing (after pressing reset it flashes for 1 sec really fast, after that just fast).

Any idea what else could be the problem?
Last edited by Oli on Thu Apr 28, 2016 1:17 am, edited 1 time in total.

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

Re: Installed Bootloader but no USB-Device is shown up

Post by 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

Code: Select all

#define BOARD_USB_DISC_DEV        GPIOB
#define BOARD_USB_DISC_BIT        9
The easiest thing you can do is temporarily change this in the Maple mini variant.

Oli
Posts: 9
Joined: Wed Apr 27, 2016 12:26 am

Re: Installed Bootloader but no USB-Device is shown up

Post by 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:

Code: Select all

#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
What am I doing wrong?

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

Re: Installed Bootloader but no USB-Device is shown up

Post by 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
Posts: 9
Joined: Wed Apr 27, 2016 12:26 am

Re: Installed Bootloader but no USB-Device is shown up

Post by 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?

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

Re: Installed Bootloader but no USB-Device is shown up

Post by 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)

Post Reply