6 years, 4 months ago.

Feature request : export for a given (supported) MCU variant rather than few demo boards only

i cant understand why this is not possible to select directly a MCU variant instead of the very limited number of support mbed board when we export a library from it webpage or from the online compiler, also i find it hard to figure why some targets are dropped from the target list of mbed compiler but still present in the mbed-dev folder. What is the purpose of limiting the export targets when the y are existing, it makes no sense.

I spent over 8 hours trying to change the target of an SW4STM32 project exported from mbed online compiler from NUCLEO_F303RB to DISCO_F303VC (actual target is F303CC), after a ton of changes (includes path, preproc define, startup, linker files etc) and an overall very painful process i have the SW4STM32 project compiling perfectly, with the right target, files and system config taken into account, unfortunately after programming the target doesnt work, i try with a LED blink example, it can start and switch the LED on but it stucks as soon as the ''wait'' statement arrives, step debugging tells it is related to systick IRQ and it falls into configuration fault.

IS there anywhere some informations on how to properly setup a mbed project for using the right target, without spending hours on it and ending up more frustrated than at the beginning? Why not jsut let us select an arbitrary (supported) MCU model instead of a very imited, constantly changing, list of target boards, i can understand there are commercial reasons for doing this, and even then i dont get the point.

Of course i dont ask we can use online compiler for any target, but at least that we can export a project or a library with any of the supported MCU rather than a very limited set of the very last nucleo demo boards.

In my case a customer want mbed compatibility, i have no choice than using it, i already spend over 8 hours trying to figure out how just configure the project, and it still doesnt work. i find no clear information or instruction anywhere on how to setup mbed library for a particular target, and the online compiler and export options on the library page are totally useless, they make a working project but for the wrong target, and the project configuration is so bloated it seems impossible to reconfigure and get it working again.

If anyone has a clue on how to change project target, or configure a project from scratch with the correct preproc defines that would help a lot, i tried both aproach and both failed. Also If anyone has an idea of what is wrong and want to try the SW4STM32 project it is here

https://github.com/Hoel/mbed/blob/master/mbed-dev%202.zip

here is a screenshot of the project three

/media/uploads/lo/capture_d-e-cran_2017-12-09_a-_15.09.02.png Thanks

Hi,

we have an initial page for porting in our handbook: https://docs.mbed.com/docs/mbed-os-handbook/en/latest/advanced/porting_guide/

We use targets, publicly they are seen as boards. They are based on MCU targets. A board defines pinout (PinNames, Peripheral pins), default clock setup + board setup, and applications for the board (examples). MCU has own target but that is not exposed, as it is a base target (class that you can build your board). You should be able to quickly create a board based on the targets that are already supported. For instance, https://github.com/ARMmbed/mbed-os/blob/master/targets/targets.json#L949, that defines NUCLEO F303RE. If you need 303, but a different pinout (smaller package, bigger), different clocks, etc. Create a new target and set it up according to this (https://github.com/ARMmbed/mbed-os/tree/master/targets/TARGET_STM/TARGET_STM32F3 - this is F3 targets, each of them contains subfolders with detailed pinout, peripheral, linker file, startup file). This is described in the handbook porting guide. Any feedback appreciated to make this process easier.

You can change in the online compiler or offline (using mbed-cli) a target quickly, and your app should work (if pinnames and peripheral pins match, in this case is good to use for instance arduino pins Ax, D0 that would allow this). Please clone https://github.com/ARMmbed/mbed-os-example-blinky, blinky example, do targets change you need, export or compile locally to test your changes.

Some exporters need additional setup, that needs porting. Therefore not all targets support all exporters. For instance, MDK exporter uses cmsis-pack for device, if it is not there, it wont be supported.

posted by Martin Kojtal 15 Dec 2017

Thank you for the links and steps, i'll have a new try this afternoon

Quote:

If you need 303, but a different pinout (smaller package, bigger), different clocks, etc. Create a new target and set it up according to this (https://github.com/ARMmbed/mbed-os/tree/master/targets/TARGET_STM/TARGET_STM32F3 - this is F3 targets, each of them contains subfolders with detailed pinout, peripheral, linker file, startup file). This is described in the handbook porting guide.

Well, this is what i've already done of course https://github.com/Hoel/mbed/tree/master/mbed-dev/targets/TARGET_STM I based the custom target on the existing DISCO STM32F303VC folder. It took a lot of changes and once compiling after a long strike it has been tried with blinky example, unfortunately the STM32F303CC falls in <UsageFault_Handler> when reaching HAL_TIM_SET_COMPARE(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp); function is situated in the file : us_ticker_32b.c

Quote:

Any feedback appreciated to make this process easier.

If there was a tool to make this folders and files set automatically when providing a target MCU as argument that would ease things a lot, doing this by hand is error prone and we dont have all the elements to do it properly (startup and linker files), since mbed uses the STM32 HAL it should tailor to any STM32 target.

posted by BIDAULT Hoel 15 Dec 2017

ST has some specific settings, hal_tick.h in this case plus cmsis_nvic.h (these 2 need to be tailored for your target).

Also look at the startup file, I recall by default they had main jump, not _start as it is required by mbed (true for GCC only) that you are using

posted by Martin Kojtal 18 Dec 2017

Thanks for the hint, indeed i suspected cmsis_nvic.h has specific setting, however i cannot find the appropriate informations for my target. I counted 82 + 15 vectors but i am really unsure of this figure nor if NVIC_RAM_VECTOR_ADDRESS 0x20000000 is actually the right address, same goes for hal_tick.h. For startup file i use the one from AC6 (SW4STM32) and it doesnt seem to have not _start https://github.com/Hoel/mbed/blob/master/STM32F303CC_LED_HAL_MBED/src/targets/TARGET_STM/TARGET_STM32F3/TARGET_STM32F303xC/device/TOOLCHAIN_GCC_ARM/startup_stm32.s

posted by BIDAULT Hoel 18 Dec 2017

1 Answer

6 years, 4 months ago.

Quote:

i find no clear information or instruction anywhere on how to setup mbed library for a particular target, and the online compiler and export options on the library page are totally useless, they make a working project but for the wrong target, and the project configuration is so bloated it seems impossible to reconfigure and get it working again.

I'm not sure what you're trying to do. You don't need to set up the Mbed library for a particular target. The Mbed library is always the same. At build time it'll be determined what gets built and linked in depending on target, config settings, etc.

Quote:

If anyone has a clue on how to change project target, or configure a project from scratch with the correct preproc defines that would help a lot, i tried both aproach and both failed. Also If anyone has an idea of what is wrong and want to try the SW4STM32 project it is here

So if you just want a Makefile to build locally, you can do so quickly via (using Mbed CLI):

$ mbed new some-project
$ cd some-project
$ mbed export -i make_gcc_arm -m YOUR_TARGET_NAME

If you have a new target - as you're using the MCU, not the dev board - you can inherit from the dev board and just change what's different for your platform (e.g. clocks, pinmap). Then either export again, or just build from Mbed CLI.

Side note: you're using mbed-dev, which is Mbed OS 2. For new projects I'd highly suggest switching to Mbed OS 5.

If you've got more questions, feel free to reach out to me directly (email in my profile) and I'll try and get you setup and running :-)

Thanks for the kind help, i'll follow up on your email if i dont manage to get it working this afternoon.

EDIT: after more tries, i can confirm using CLIis the way to go for making a new variant and SW4STM32 project. , all attemps of making a SW4STM32 project from scratch failed but the SW4STM32 project created from CLI with custom variant does work.

posted by BIDAULT Hoel 15 Dec 2017