Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 3 months ago.
about programming of arm mbed boards
Hi, I was looking through the arm mbed's website, I compiled and built .bin files for two different boards(By choosing different boards from online ide). Programming for all the 100 around boards is same(similar to arduino's programming). But my question is how this ide comes to know that which board is chosen and how and where those specific changes are done that makes two exactly same codes for two different boards. For example what changes can I do or are occured in files and/or at architecture level that the code for teensy board can run on some other board, say lpc176x related some board.
1 Answer
8 years, 3 months ago.
In mbed OS we have targets. Each board represents a target. Depending on the target we have feature lists and includes that we load depending on the target. For example, here's a list of targets that we have, including the flags that they will receive, like: 'do they have a FPU?' and 'which architecture are they'.
Then we also have code that depends on the target, f.e. here's some for Freescale KLxx, which make up the Hardware Abstraction Layer. We also have pinmaps available, which make sure that when you f.e. use D0
as a pin name, it gets mapped to the right pin on the actual board.
To see how a program gets built for different targets, use mbed-cli and build like:
$ mbed compile -m K64F -t GCC_ARM -v
This will show the exact folders that are loaded for the target, the g++ command issued, and the flags added to the compile command.
thank you for the wonderful answer. I almost got it, just a little bit confusion about what comman and hal folder(the one that is outside target folder) are for. I got that these are target independent folders along with the api folder, why we have api folder is quite clear but please give some explanation about these two folders. I read them about here https://developer.mbed.org/handbook/mbed-library-internals#design-overview but still not clear. thanks
posted by 13 Sep 2016/hal/api contains all headers for the HAL. /hal/common contains cross-platform implementations for HAL. For example, I2C::write function is declared in /hal/api/I2C.h, then a common implementation is written in /hal/api/I2C.cpp. However, in I2C.cpp we call i2c_write
function, which is implemented by target-dependent HAL, for example in /hal/targets/hal/TARGET_STM/TARGET_STM32F4/i2c_api.c for STM32F4.