Bootloader’s role?

turboscrew
Mon Jun 25, 2018 9:12 pm
What’s the role of the boot loader? Does the image require it to get booted right?

I’m about to try a little program with FR22-library to see whether I’m doing something wrong in my code or if my radio module is broken.
I have the .bin and I have ST-LINK V2 mini (that I’ve been using with Eclipse + OpenOCD).
I’m using Linux (so ST-LINK program is not an option).

Can I upload the bin-file without the boot loader using Arduino IDE? Or is the image somehow different from the “standard” image? (Something that needs to be skipped in the beginning or something.)

I tried to google about those things and about the tools in the Arduino_STM32 “tools”-folder, but couldn’t find anything.


Slammer
Mon Jun 25, 2018 9:25 pm
If you are using ST-Link there is no reason to use bootloader, you can select the upload method from the menu (bootloader and stlink among others).
Keep in mind that binaries for bootloader and stlink upload methods are different. Normally the interrupt vectors are located in the beginning of flash memory at 0x08000000 but when bootloader is used this memory is allocated by bootloader itself and the interrupt vectors are moved at 0x08002000.
Bootloader is an easy way to reprogram the MCU by USB without any other tool.

mrburnette
Mon Jun 25, 2018 11:55 pm
STM32 bootloader
Is a good read.

In general, most Arduino board implementations use some form of bootloader although it is not a unique Arduino feature. Long ago, in the microcomputer world, bootloader were often called bootstrap routines… a small program installed to enable loading the main program… often by using a peripheral device like a paper tape reader or a program card reader or magnetic tape. After the main program is loaded, the bootloader is no longer needed until the next program load… Bootloader is not to be confused with BIOS.

Ray


turboscrew
Tue Jun 26, 2018 4:05 am
Yes, I’m using bluepills, and they have serial boot loader in the system memory, but I’ve been using ST-LINK.
I’m wondering, how do I get an Arduino (binary) image uploaded right using ST-LINK.
Do I need to generate a different image for uploading with ST-LINK and without bootloader?
And is it enough if I use “Upload Using Programmer” instead of “Upload”?
And where, in the memory, does the bootloader go, if used?

turboscrew
Tue Jun 26, 2018 4:58 am
[mrburnette – Mon Jun 25, 2018 11:55 pm] –
STM32 bootloader
Is a good read.

In general, most Arduino board implementations use some form of bootloader although it is not a unique Arduino feature. Long ago, in the microcomputer world, bootloader were often called bootstrap routines… a small program installed to enable loading the main program… often by using a peripheral device like a paper tape reader or a program card reader or magnetic tape. After the main program is loaded, the bootloader is no longer needed until the next program load… Bootloader is not to be confused with BIOS.

Ray

I know. In the university we wrote a bare metal program for PDP11/34. :lol:


stevestrong
Tue Jun 26, 2018 6:49 am
If you read the information pointed by Ray you got already answers to some of your questions, right?

turboscrew
Tue Jun 26, 2018 4:21 pm
Well, the bootloader seems to load at 0x08000000, but the size is unknown. So is the address where that bootloader loads the application.
I would guess the loaded image starts from the beginning of the next flash page?
Also, it’s not clear how the vectors are handled. Does Arduino always relocate the vectors or does it handle the vectors differently if bootloader is not used.
And is that “Upload” vs. “Upload Using Programmer” the difference or does “Upload Using Programmer” expect a boot loader being present?

At least it looks like if “Upload” is used after “Upload Using Programmer” or vice versa, Arduino seems to recompile the stuff.
I take it that the image from “Verify/Compile” and “Export Compiled Binary” makes an image with vectors relocated?

[edit] In the bootloader code I found: USER_CODE_FLASH0X8005000 and USER_CODE_FLASH0X8002000. I guess these are the load addresses. It’s just unclear which is used for what.
“I would guess the loaded image starts from the beginning of the next flash page?”
Or then not – 1kB pages…

turboscrew
Tue Jun 26, 2018 7:38 pm
Tried the “Upload Using Programmer”…

dmesg says:
[ 160.348038] usb 6-2: new full-speed USB device number 3 using uhci_hcd
[ 160.515122] usb 6-2: New USB device found, idVendor=0483, idProduct=3748
[ 160.515128] usb 6-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 160.515132] usb 6-2: Product: STM32 STLink
[ 160.515135] usb 6-2: Manufacturer: STMicroelectronics
[ 160.515137] usb 6-2: SerialNumber: S\xffffffc3\xffffffbf\xffffffbfq\x06P\xffffffc2\xffffff88\xffffff88SQ"\x19\x13\xffffffc2\xffffff87\xffffff87


turboscrew
Tue Jun 26, 2018 8:20 pm
Aha. bare “Upload” seems to work…
Sketch uses 17412 bytes (26%) of program storage space. Maximum is 65536 bytes.
Global variables use 2376 bytes (11%) of dynamic memory, leaving 18104 bytes for local variables. Maximum is 20480 bytes.
2018-06-26T23:06:06 INFO src/stlink-usb.c: -- exit_dfu_mode
2018-06-26T23:06:06 INFO src/stlink-common.c: Loading device parameters....
2018-06-26T23:06:06 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2018-06-26T23:06:06 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
2018-06-26T23:06:06 INFO src/stlink-common.c: Attempting to write 17412 (0x4404) bytes to stm32 address: 134217728 (0x8000000)

Flash page at addr: 0x08000000 erased
Flash page at addr: 0x08000400 erased
Flash page at addr: 0x08000800 erased
Flash page at addr: 0x08000c00 erased
Flash page at addr: 0x08001000 erased
Flash page at addr: 0x08001400 erased
Flash page at addr: 0x08001800 erased
Flash page at addr: 0x08001c00 erased
Flash page at addr: 0x08002000 erased
Flash page at addr: 0x08002400 erased
Flash page at addr: 0x08002800 erased
Flash page at addr: 0x08002c00 erased
Flash page at addr: 0x08003000 erased
Flash page at addr: 0x08003400 erased
Flash page at addr: 0x08003800 erased
Flash page at addr: 0x08003c00 erased2018-06-26T23:06:07 INFO src/stlink-common.c: Finished erasing 18 pages of 1024 (0x400) bytes
2018-06-26T23:06:07 INFO src/stlink-common.c: Starting Flash write for VL/F0/F3 core id

Flash page at addr: 0x08004000 erased
Flash page at addr: 0x08004400 erased
2018-06-26T23:06:07 INFO src/stlink-common.c: Successfully loaded flash loader in sram

0/17 pages written
1/17 pages written
2/17 pages written
3/17 pages written
4/17 pages written
5/17 pages written
6/17 pages written
7/17 pages written
8/17 pages written
9/17 pages written
10/17 pages written
11/17 pages written
12/17 pages written
13/17 pages written
14/17 pages written
15/17 pages written2018-06-26T23:06:08 INFO src/stlink-common.c: Starting verification of write complete

16/17 pages written
17/17 pages written2018-06-26T23:06:09 INFO src/stlink-common.c: Flash written and verified! jolly good!


Slammer
Tue Jun 26, 2018 8:52 pm
If you select upload using stlink, the image is “standard”, starts at 0x08000000

turboscrew
Wed Jun 27, 2018 4:42 am
Ah, that’s the magic,,, (Tools/Upload method?)

BTW, what is the “Upload Using Programmer” for?


Leave a Reply

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