Comments (7)
Rick
I've spent some time trying to tidy the boards.txt and platform.txt files up.
Here is the cleanest version of the STM32F103Z series that I've been able to get to compile and upload
##################################################################################################################
genericSTM32F103Z.name=Generic STM32F103Z Series
genericSTM32F103Z.build.error_led_port=GPIOG
genericSTM32F103Z.build.error_led_pin=15
genericSTM32F103Z.build.variant=generic_stm32f103zxx
genericSTM32F103Z.build.common_flags=-mthumb -march=armv7-m -D__STM32F1__
genericSTM32F103Z.build.mcu=cortex-m3
genericSTM32F103Z.build.f_cpu=72000000L
genericSTM32F103Z.build.board=GENERIC_STM32F103Z
genericSTM32F103Z.build.core=maple
genericSTM32F103Z.build.vect=VECT_TAB_ADDR=0x8000000
genericSTM32F103Z.menu.device_variant.STM32F103ZC=STM32F103ZC
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.cpu_flags=-DMCU_STM32F103ZC
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.maximum_size=262144
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.ram.maximum_size=492152
genericSTM32F103Z.menu.device_variant.STM32F103ZC.upload.flash.maximum_size=262144
genericSTM32F103Z.menu.device_variant.STM32F103ZC.build.ldscript=ld/stm32f103zc.ld
genericSTM32F103Z.menu.device_variant.STM32F103ZD=STM32F103ZD
genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.cpu_flags=-DMCU_STM32F103ZD
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.maximum_size=393216
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.ram.maximum_size=65536
genericSTM32F103Z.menu.device_variant.STM32F103ZD.upload.flash.maximum_size=393216
genericSTM32F103Z.menu.device_variant.STM32F103ZD.build.ldscript=ld/stm32f103zd.ld
genericSTM32F103Z.menu.device_variant.STM32F103ZE=STM32F103ZE
genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.cpu_flags=-DMCU_STM32F103ZE
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.maximum_size=524288
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.ram.maximum_size=65536
genericSTM32F103Z.menu.device_variant.STM32F103ZE.upload.flash.maximum_size=524288
genericSTM32F103Z.menu.device_variant.STM32F103ZE.build.ldscript=ld/stm32f103ze.ld
genericSTM32F103Z.menu.upload_method.serialMethod=Serial
genericSTM32F103Z.menu.upload_method.serialMethod.upload.protocol=maple_serial
genericSTM32F103Z.menu.upload_method.serialMethod.upload.tool=serial_upload
genericSTM32F103Z.menu.upload_method.STLinkMethod=STLink
genericSTM32F103Z.menu.upload_method.STLinkMethod.upload.protocol=STLink
genericSTM32F103Z.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
genericSTM32F103Z.menu.upload_method.STLinkMethod.build.debug_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1
I've spotted several mistakes in platform.txt as well, but none of them actually stopped things working ;-)
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=STM32 Boards
version=0.1.0
# compiler variables
# ----------------------
compiler.path={runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -Os -w -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-c -g -Os -w -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O binary
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
# this is overriden in boards.txt
build.cpu_flags=
build.hs_flag=
build.common_flags=
build.debug_flags=
build.extra_flags=
## Dont need to do the line below as all the individual flags are always in the compile line already
#build.extra_flags= {build.cpu_flags} {build.hs_flag} {build.common_flags}
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags="-L{build.variant.path}/ld"
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
compiler.libs.c.flags="-I{build.system.path}/libmaple" "-I{build.system.path}/libmaple/include" "-I{build.system.path}/libmaple/stm32f1/include" "-I{build.system.path}/libmaple/usb/stm32f1" "-I{build.system.path}/libmaple/usb/usb_lib"
# build patterns
# ---------------------
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {build.debug_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {build.debug_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {build.debug_flags} {build.cpu_flags} {build.hs_flag} {build.common_flags} {compiler.libs.c.flags} {includes} "{source_file}" -o "{object_file}"
#recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group {object_files} -Wl,--whole-archive "{build.path}/{archive_file}" -Wl,--no-whole-archive -Wl,--end-group
## Create eeprom
recipe.objcopy.eep.pattern=
## Create hex
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
#recipe.size.regex=\.text\s+([0-9]+).*
recipe.size.regex=^(?:\.text|\.rodata|\.ARM.exidx)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
# Uploader tools
# -------------------
# Upload using Maple bootloader over DFU
tools.maple_upload.cmd=maple_upload
tools.maple_upload.cmd.windows=maple_upload.bat
tools.maple_upload.path.windows={runtime.hardware.path}/tools/win
tools.maple_upload.path.macosx={runtime.hardware.path}/tools/macosx
tools.maple_upload.path.linux={runtime.hardware.path}/tools/linux
tools.maple_upload.upload.params.verbose=-d
tools.maple_upload.upload.params.quiet=
tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
# USB to Serial upload - external adaptor uses STM's serial protocol
tools.serial_upload.cmd=serial_upload
tools.serial_upload.cmd.windows=serial_upload.bat
tools.serial_upload.cmd.macosx=serial_upload
tools.serial_upload.path.windows={runtime.hardware.path}/tools/win
tools.serial_upload.path.macosx={runtime.hardware.path}/tools/macosx
tools.serial_upload.path.linux={runtime.hardware.path}/tools/linux
tools.serial_upload.upload.params.verbose=-d
tools.serial_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
# stlink upload
tools.stlink_upload.cmd=stlink_upload
tools.stlink_upload.cmd.windows=stlink_upload.bat
tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx
tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux
tools.stlink_upload.upload.params.verbose=-d
tools.stlink_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
I really don't think the upload_router is needed at all
The boards.txt can specify the upload tool e,g
genericSTM32F103Z.menu.upload_method.serialMethod.upload.tool=serial_upload
or
genericSTM32F103Z.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
I don't think the protocol line really matters but I think if I remove it the IDE gets upset
If you look in the bottom of the platform.txt I pasted above
what the blocks of code are supposed to do is ...
Sets the script name, i.e stlink_upload is the default and the windows override is stlink_upload.bat
tools.stlink_upload.cmd=stlink_upload
tools.stlink_upload.cmd.windows=stlink_upload.bat
The next bit sets the path to the script on all platforms, as they are in different directories
tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx
tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux
I'm not sure what params.verbose=-d does, but the IDE wants it.
tools.stlink_upload.upload.params.verbose=-d
finally the whole lot of put together to make one big string from the stuff built above
i.e this is the command that the IDE executes for the upload
tools.stlink_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
Note we have redundant items for USB ID etc, which are only applicable to the Maple uploader
This is my fault, I just copied the maple uploader code when I created the other ones, I should have worked out that the USB ID and ALT ID were not needed for serial or STLink
And even the Serial port is redundant on STLink I think
So we could clean it all up, but you'd need to modify the serial_upload and stlink_upload (bash and windows scripts) to get them to match the number of arguements
I didnt want to push my changes, as I've been doing some other things as well, and also I didnt want to break anything, ;-)
Anyway, I hope that helps,... Or I may be telling you stuff you know already ;-)
from arduino_stm32.
I'm all for cleaning it up. However, right now I only have a few smt32f103c8 and a few stm32f0 discovery/nucleo boards. I can't really test any of that out except to do inspection. And to be honest now that my c8 board works .. heh .. well .. i'm happy.
I think stability right now is a good thing. At least as a bunch of new people check it out. But beware you don't have long before making any changes will be bring groans of change.
from arduino_stm32.
Rick
Part of the cleaning is to be able to have the flags for the debug stuff needed for stlink, to be separated from the build_extra_flags
So I definitely need to do that
But perhaps I will limit the change to just adding the new debug_flags parameter
Its a delicate balancing act, as half the time people complain that some things are overly verbose, and the other half would rather I just add something rather than doing a clean up
Anyway. I will sort something out ;-)
from arduino_stm32.
I'm not sure if you had a chance to checkout the commits to the boards.txt I made on my fork. I have it setup to properly compile for stlink and stm32flash. In my fork I can compile and upload using both stlink and stm32flash right from the arduino ide now on linux. Personally I think leaving the debug pins on by default is a useful thing because you can always use it later to debug even if your normal mode is to use a serial loader. When you are used to less than 28 pins of useable pinage .. leaving 2 alone on a board with > 30 isn't that big a deal
from arduino_stm32.
Rick,
Sorry, I didn't get chance to look at your repo.
Re: leaving that define on all time time. I'll need to check if it affects the Maple mini guys, i.e do they loose GPIO pins ?
I didnt remove that option, it was possibly something Bob Cousins did when he did his initial port of libmaple , which I then used for the repo
from arduino_stm32.
I have added the binaries so that Linux can upload via STLink or ST Flash, however I still need to update the Generic boards in boards.txt to facilitate using the binaries
I was waiting for @ahull to let me know if he thinks he needs upload to 0x8005000 even though he's not using the bootloader, as these options IMHO are pointless, and also clutter and confuse the menu structure
I will update the comment when I get the all clear from @ahull
from arduino_stm32.
Seems to be fixed now
from arduino_stm32.
Related Issues (20)
- PIN_MAP and boardPWMpins tables mismatch HOT 1
- Arduino IDE "Access Denied" on Uploading Sketch HOT 3
- Can't connect to target after flashing generic_boot20_pc13.bin using j-flash HOT 1
- Software reset HOT 1
- How to change default 42/72/128 MHz to 8/16Mhz HOT 2
- Add CH32F103 HOT 2
- Compilation error Problem with sketch that used library Arduino_STM32 HOT 1
- dfu upload failed on macOS + PlatformIO because cannot reset upload port HOT 5
- Writing String to EEPROM HOT 3
- EEPROM donot work on STM32F103C6(32k)
- ‘MCU basic current’ increases after PWM operation. help me. HOT 25
- Wire.h and Wire slave.h using in same program not working HOT 2
- Is 'STM32F103C8' 'digitalWrite' and 'digitalRead' possible in FAST mode? HOT 10
- Is any type a persistent storage available for STM32F4 ?
- Solution to use PB3 for things other than JTAG (Proposal for documentation note) HOT 2
- Not able to uploaded the code for NUCLEO-F103R HOT 2
- change clock soure HOT 5
- Unable to upload program when using STM32duino BootLoader HOT 4
- CAN bus stalls USB HOT 1
- Ports missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino_stm32.