Creating a Bootloader for generic boards

STM32duino bootloader aka Maple bootloader
User avatar
RogerClark
Posts: 7150
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

STM32F103V series

Post by RogerClark » Wed May 13, 2015 11:01 am

Hi Victor,

I've updated the files (mainly boards.txt) and have included them in the repo for the F103V

I've done some basic testing but I've not had chance to test on my V series boards, because I need to solder the headers on and I've not had time to do that yet, because its taken a while to update your new section in boards.txt to match with changes to platform.txt

The other thing I've tried to do, and is to incorporate your USB reset into the Serial USB init code

See f103z/wirish/boards_setup.cpp

Code: Select all

    __weak void board_setup_usb(void) {
#ifdef SERIAL_USB
			
			
			//Attempt to reset the USB interface - developed by Victor PV
			
			gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
			gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);

			
			for(volatile unsigned int i=0;i<5000000;i++)
			{
				asm("nop");
			}
			gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
			


			Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
#endif
        }
I took your code and converted it into more low level stuff that would run at this point in the setup
I could probably have included the files to use pinMode etc but it seemed more sensible just to call the lower level gpio code which pinMode etc is just a wrapper for.

The other thing I did was defined

Code: Select all

#define BOARD_HAVE_SERIALUSB 1

i.e so that you don't need to declare a disconnect pin in order for any board to be able to attempt to use SERIAL_USB

As far as I can tell, this doesn't cause any ill effects

However with STLink uploads it doesn't do as you'd expect

If you plug in the USB after about 1 sec you see the Serial USB appear in the device manager, if I upload via STLink, and runs, it doesnt seem to reset the USB device.

I stil see it in the list but it doesnt re-enumerate like it should. And although the device Maple Serial (COM4) is in the device manager, its not showing up in the Arduino IDE or another terminal program I use.

So what the device manager is reporting is obviously wrong

So the USB reset thing obviously needs more investigation

I'd need to stick a scope on usb D- and see what happens on a Maple mini and also what happens on a generic board, using the different methods to reset

But it does kind of work (however I'm not sure if the extra code is helping really or not).

No doubt Rick will shed some light on this, but I need to call it a day

Cheers

Roger

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: Creating a Bootloader for generic boards

Post by victor_pv » Wed May 13, 2015 3:30 pm

Roger thanks for checking. I will try to download from your repo and do some testing with my board and report back.

I suspect that it working or not may depend on several factors, I am trying to narrow down what else needs to happen. In my board it was working while the USBSerial itself was not, it may depend on the USB peripheral being shutdown or something like that.
I wrote a couple of functions that shutdown and re-enable the port, so I can throw them in and see what happens.

I am more interested in just getting the SerialUSB working first, and then after that see if I can force the re-enumeration.

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Wed May 13, 2015 9:01 pm

Victor

I presume you are using windows ?

I'm not sure if you posted if you were using 32 or 64 bit.

Let me know as I need to pm you some exe files

Edit

While I remember...

I took a look at the Maple bootloader code the other day to see when it uses the Disconnect line, and it seems to be in the code that is called prior to jumping to the start of the sketch code

Anyway, one thing I noticed, is that it is hard coded to use PC12, in hardware.c, ie unlike the LED and "button" pins, there isn't a #define for it, in config.h

This may partially explain why I could not seem to use PC13 on my generic board as the LED even though I changed all the necessary registers in config.h

I will need to look through the bootloader code again, because at the moment I can't see where it's setting up the RCC for Port C nor where it sets up that PC12 is an output.

I suspect wherever its setting PC12 as an output, its possibly setting PC13 as an input, unless its doing a masked OR of the update

Btw here is the reset code.

I.e it can't be holding in reset that long, because the GPIO init still will be clearing the DISC pin in I suspect less than a millisecond after starting execution of the sketch init code

Code: Select all

void jumpToUser(u32 usrAddr) {
    typedef void (*funcPtr)(void);

    u32 jumpAddr = *(vu32 *)(usrAddr + 0x04); /* reset ptr in vector table */
    funcPtr usrMain = (funcPtr) jumpAddr;

    /* tear down all the dfu related setup */
    // disable usb interrupts, clear them, turn off usb, set the disc pin
    // todo pick exactly what we want to do here, now its just a conservative
    flashLock();
    usbDsbISR();
    nvicDisableInterrupts();
    setPin(GPIOC, 12); // disconnect usb from host. todo, macroize pin
    systemReset(); // resets clocks and periphs, not core regs


    __MSR_MSP(*(vu32 *) usrAddr);             /* set the users stack ptr */

    usrMain();                                /* go! */
}


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

Windows USB exe's

Post by RogerClark » Wed May 13, 2015 10:56 pm

Victor,

I've attached the Windows usb reset exe's

There is a 32 bit and a 64 bit version, i.e one with x64 at the end is the 64 bit one

See my other posting, but basically, if you modify your upload script so that you run devcon.exe after its complete, you and tell Windows to restart a USB device.

I'm cheating a bit and just saying restart all leadlab's ID's in the code below, because it was easier and I couldn't quite work out the syntax for resetting an individual device

e.g.

Code: Select all

devconX64.exe restart *1eaf*
e.g. in my Stlink upload script I had

Code: Select all

texane-stlink\st-flash.exe write %str% 0x8000000
sleep 1
devconX64.exe restart *1eaf*
The Sleep 1 is quite important, as it didnt seem to work if you reset straight away, (1 second seemed to be the optimum, Im not sure if 2 secs worked)

BTW. Devcon needs to be run as administrator

So if you add that to your upload script, you'll need to run the IDE as administrator

if you want to just run devcon manually, you need to open up a command prompt as administrator

Docs and examples on devcon are on the microsoft site

https://msdn.microsoft.com/en-us/librar ... 85%29.aspx


Cheers

Roger
Attachments
devcon.zip
(40.02 KiB) Downloaded 23 times

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: Creating a Bootloader for generic boards

Post by victor_pv » Thu May 14, 2015 2:22 pm

Roger, so far the modifications you made in the V code so the Serial does the PA12 actions, also works in my RET board, I haven't had to use the DEVCON tool yet, but thanks for posting it.

Once I get the bootloader to work properly in the RET board, I'll let you know if it re-enumerates when jumping to the sketch.
Regarding the RET bootloader, I think is mostly the same as the Maple Native bootloader, so if I get it work for one, should work for the other.
The main differences are all in the define lines (flash size, page size, LED pin number and port, etc) so I feel we should be able to have them all in a single repo, and just have all the options in the config.h file like you were doing with the maple and maple mini.

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: Creating a Bootloader for generic boards

Post by victor_pv » Fri May 15, 2015 4:22 am

I have the bootloader running fine in a RCT6 generic board. Blinks the led, waits a few seconds to get uploads, uploads fine, runs the code, and re-enumerates fine in Windows.
I have set the wait time in the bootloader a bit longer to give more time to Windows and the DFU tool to detect it.

I started with leaflabs RET6 bootloader, then applied all the updates and optimizations that had been applied up to the code Roger added to have uploads with ID2.

I am pretty sure we can uncomment upload to RAM if needed. In these type of boards that may actually be useful, but before touching more, I am uploading it to a new repo in my github.

Once tested and confirmed all good, I think we should merge with Roger's mini bootloader, because the differences are really small:
-pin numbers for the led
-a bit of code to cause the re-enumeration with PA12
-does not check for a button cause there is no button on this board
-and page size of 2KB which is already set with a DEFINE line, so easy to make it conditional

If anyone wants to use it and have trouble let me know.

EDIT: https://github.com/victorpv/maple-bootl ... nsity-2.0/

dlankvel
Posts: 4
Joined: Thu Jul 09, 2015 2:27 pm

re: Building the bootloader -> link error

Post by dlankvel » Thu Jul 09, 2015 2:45 pm

Dear mr Clark,

Firstr I want to say thank you for all the hard work on the STM32F devices... I have been using your Arduino IDE shortly with STM32F103ZET6 clone but don't like this IDE. So I am using either Eclipse or CoIDE now for development.

I own this clone from G&C supermarket: http://www.ebay.com/itm/1pcs-STM32F103Z ... 1305557264) for which /i would like to build the generic bootloader (LED on PG15)

I am using CoIDE (with arm-none-eabi-gcc-4.9.3) at the moment and getting a link error which I cannot solve, I hope you can give me some pointers on how to solve this link error:

[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib/c_only_startup.s:108: multiple definition of `Default_Handler'


I commented out all the non applicable configurations in the Makefile and did a #define generic-pg15 in config.h

Here is the complete output of CoIDE (link error is @ the end):

GCC HOME: C:\Localdata\Eclipse_C++\GCC_arm_eabi\bin
compile:
[mkdir] Skipping C:\Users\dlankvel\CoIDE\workspace\STM32duino\stm32duino\Debug\bin because it already exists.
[mkdir] Skipping C:\Users\dlankvel\CoIDE\workspace\STM32duino\stm32duino\Debug\obj because it already exists.
[cc] 14 total files to be compiled.
[cc] arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -g2 -Wall -O0 -c -DSTM32F103ZET6 -IC:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master -IC:\Users\dlankvel\CoIDE\workspace -IC:\Users\dlankvel\CoIDE\workspace\STM32duino -IC:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1 -IC:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib -IC:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_core.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_int.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\dfu.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib\c_only_startup_user.s C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_init.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\main.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\hardware.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_callbacks.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.c C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib\c_only_startup.s C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib\cortexm3_macro.s C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_mem.c
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_lib.h:22:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_core.c:17:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_core.c: In function 'SetDeviceAddress':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:380:26: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] _GetENDPOINT(bEpNum) & EPREG_MASK | bAddr)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_core.c:997:5: note: in expansion of macro '_SetEPAddress'
[cc] _SetEPAddress((u8)i, (u8)i);
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_lib.h:22:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:17:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'ToggleDTOG_RX':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:356:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:401:3: note: in expansion of macro '_ToggleDTOG_RX'
[cc] _ToggleDTOG_RX(bEpNum);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'ToggleDTOG_TX':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:358:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:412:3: note: in expansion of macro '_ToggleDTOG_TX'
[cc] _ToggleDTOG_TX(bEpNum);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'ClearDTOG_RX':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:356:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:368:5: note: in expansion of macro '_ToggleDTOG_RX'
[cc] _ToggleDTOG_RX(bEpNum)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:423:3: note: in expansion of macro '_ClearDTOG_RX'
[cc] _ClearDTOG_RX(bEpNum);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'ClearDTOG_TX':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:358:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:370:5: note: in expansion of macro '_ToggleDTOG_TX'
[cc] _ToggleDTOG_TX(bEpNum)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:434:3: note: in expansion of macro '_ClearDTOG_TX'
[cc] _ClearDTOG_TX(bEpNum);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'SetEPAddress':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:380:26: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] _GetENDPOINT(bEpNum) & EPREG_MASK | bAddr)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:446:3: note: in expansion of macro '_SetEPAddress'
[cc] _SetEPAddress(bEpNum, bAddr);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c: In function 'FreeUserBuffer':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:358:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] ^
[cc] EP_DTOG_TX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:711:5: note: in expansion of macro '_ToggleDTOG_TX'
[cc] _ToggleDTOG_TX(bEpNum);
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:356:70: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
[cc] EP_DTOG_RX | _GetENDPOINT(bEpNum) & EPREG_MASK))
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.h:204:10: note: in definition of macro '_SetENDPOINT'
[cc] (u16)wRegValue)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib\usb_regs.c:715:5: note: in expansion of macro '_ToggleDTOG_RX'
[cc] _ToggleDTOG_RX(bEpNum);
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:36:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\hardware.h:30,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\dfu.c:33:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\config.h:86:16: warning: missing whitespace after the macro name
[cc] #define generic-pg15
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\dfu.c: In function 'dfuCopyState':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\dfu.c:374:9: warning: return discards 'volatile' qualifier from pointer target type
[cc] return (&(dfuAppStatus.bState));
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:36:0,
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\config.h:86:16: warning: missing whitespace after the macro name
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\main.c:34:
[cc] #define generic-pg15
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\main.c: In function 'main':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\main.c:51:2: warning: implicit declaration of function 'readButtonState' [-Wimplicit-function-declaration]
[cc] bool no_user_jump = (!checkUserCode(USER_CODE_FLASH0X8005000) && !checkUserCode(USER_CODE_FLASH0X8002000)) || readButtonState() ;
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:36:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb.h:27,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb.c:33:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\config.h:86:16: warning: missing whitespace after the macro name
[cc] #define generic-pg15
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:36:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\hardware.h:30,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\hardware.c:33:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\config.h:86:16: warning: missing whitespace after the macro name
[cc] #define generic-pg15
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:36:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.h:28,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.c:35:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\config.h:86:16: warning: missing whitespace after the macro name
[cc] #define generic-pg15
[cc] ^
[cc] In file included from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib/usb_lib.h:21:0,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb.h:28,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\common.h:40,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.h:28,
[cc] from C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.c:35:
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_lib/usb_type.h:23:14: warning: initialization makes integer from pointer without a cast
[cc] #define NULL ((void *)0)
[cc] ^
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\usb_descriptor.c:201:28: note: in expansion of macro 'NULL'
[cc] u8 u8_usbStringInterface = NULL;
[cc] ^
[cc] 0 total files to be compiled.
[cc] Starting link
[cc] arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -g2 -Wl,-Map=STM32duino.map -O0 -Wl,--gc-sections -LC:\Users\dlankvel\AppData\Roaming\CooCox\CoIDE\configuration\ProgramData\STM32duino -Wl,-TC:\Users\dlankvel\AppData\Roaming\CooCox\CoIDE\configuration\ProgramData\STM32duino/arm-gcc-link.ld -g -o STM32duino.elf ..\obj\usb.o ..\obj\usb_regs.o ..\obj\cortexm3_macro.o ..\obj\c_only_startup_user.o ..\obj\usb_mem.o ..\obj\usb_init.o ..\obj\usb_int.o ..\obj\usb_descriptor.o ..\obj\usb_core.o ..\obj\usb_callbacks.o ..\obj\c_only_startup.o ..\obj\dfu.o ..\obj\hardware.o ..\obj\main.o
[cc] ..\obj\c_only_startup.o:(.isr_vector+0x0): multiple definition of `g_pfnVectors'
[cc] ..\obj\c_only_startup_user.o:(.isr_vector+0x0): first defined here
[cc] ..\obj\c_only_startup.o: In function `USBWakeUp_IRQHandler':
[cc] C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib/c_only_startup.s:108: multiple definition of `Default_Handler'
[cc] ..\obj\c_only_startup_user.o:C:\Users\dlankvel\CoIDE\workspace\STM32duino-bootloader-master\STM32F1\stm32_lib/c_only_startup_user.s:109: first defined here
[cc] ..\obj\c_only_startup_user.o:(.isr_vector+0x0): undefined reference to `_estack'
[cc] ..\obj\c_only_startup_user.o:(.isr_vector+0x8): undefined reference to `_magicRate'
[cc] ..\obj\c_only_startup.o:(.isr_vector+0x0): undefined reference to `_estack'
[cc] collect2.exe: error: ld returned 1 exit status

BUILD FAILED
Total time: 3 seconds


Regards and thanks in advance.

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Thu Jul 09, 2015 9:37 pm

Are you trying to build the bootloader of build a sketch to run on the board.

The Repo contains contains loads of stuff, not just the core for the Stm32f103 but also for the F3 and F4 as well as the bootloader and also sources for all the tools that are used to upload

If you are just trying to build the bootloader, the make file works fine, ( at least on windows).

If you are not trying to build the bootloader, do not add bootloader files to your project.

I think various other people have used Eclipse to build the core and sketches e,g, Rick Kimball, you could try PMing him

However I'm afraid I can't support the Eclipse as an IDE as the whole repo is only designed to work with the Arduino IDE

dlankvel
Posts: 4
Joined: Thu Jul 09, 2015 2:27 pm

Re: Creating a Bootloader for generic boards

Post by dlankvel » Fri Jul 10, 2015 4:58 pm

Thanks for the reply, mr Clark.

I am just trying to build the bootloader. I downloaded the zipfile from github with the sourcecode of the bootloader, created a new project in CoIDE and added all the files and directories from the zip manually. Then started the build and got the error...

I will give it a go in the STM32 Arduino IDE then, see if that works out for me...

Regards,

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: Creating a Bootloader for generic boards

Post by victor_pv » Fri Jul 10, 2015 6:10 pm

dlankvel wrote:Thanks for the reply, mr Clark.

I am just trying to build the bootloader. I downloaded the zipfile from github with the sourcecode of the bootloader, created a new project in CoIDE and added all the files and directories from the zip manually. Then started the build and got the error...

I will give it a go in the STM32 Arduino IDE then, see if that works out for me...

Regards,
We don't build the bootloader with the Arduino IDE, or any other IDE for that matter, but straight with gcc in the command line.
The bootloader does not use any of the files in the stm32duino core, if you try to build it in a project that include those files, there is most likely going to be a lot of conflicts.
I don't know what compiler Eclipse uses, but I guess is most likely gcc, so you should be able to use that install of gcc to build the bootloader.

Post Reply