-
Notifications
You must be signed in to change notification settings - Fork 178
Create custom-target-porting.md #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add and edit content provided about porting Mbed OS to a custom board
@@ -0,0 +1,163 @@ | |||
# Porting Mbed OS to a custom board | |||
|
|||
If you are designing a board similar to an existing Mbed Enabled board, you can use target inheritance to configure your board to meet your needs. In previous versions of Mbed OS (before Mbed OS 5.8), adding a new target required modifying the `mbed-os` directory tree itself, but now you can extend an existing MCU port with a `custom_target.json` file and by adding source files that complete a port outside of `mbed-os`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are my needs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to know what was going on in versions we don't even have docs for anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...needs, such as different clocking, pin connections, peripheral usage, etc.
@@ -0,0 +1,163 @@ | |||
# Porting Mbed OS to a custom board | |||
|
|||
If you are designing a board similar to an existing Mbed Enabled board, you can use target inheritance to configure your board to meet your needs. In previous versions of Mbed OS (before Mbed OS 5.8), adding a new target required modifying the `mbed-os` directory tree itself, but now you can extend an existing MCU port with a `custom_target.json` file and by adding source files that complete a port outside of `mbed-os`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I need to know what was going on in versions we don't even have docs for anymore?
|
||
If you are designing a board similar to an existing Mbed Enabled board, you can use target inheritance to configure your board to meet your needs. In previous versions of Mbed OS (before Mbed OS 5.8), adding a new target required modifying the `mbed-os` directory tree itself, but now you can extend an existing MCU port with a `custom_target.json` file and by adding source files that complete a port outside of `mbed-os`. | ||
|
||
For detailed information about all the ways you can configure targets, go to [adding and configuring targets](../reference/adding-and-configuring-targets.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then what's in this doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this fit into the general porting story?
|
||
For detailed information about all the ways you can configure targets, go to [adding and configuring targets](../reference/adding-and-configuring-targets.html). | ||
|
||
## Extending an existing Mbed Enabled MCU target configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't Mbed Enabled a specific thing, and not just any board that happens to already have a port?
|
||
1. Choose a target in Mbed OS that your board can inherit from. | ||
|
||
If that existing target follows one of the recommended inheritance patterns, such as Family -> MCU -> Board, then it makes it simple to just inherit the MCU target information and add your own board information. In some cases, you may need to inherit a Family or Board and add or replace configurations accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a family?
|
||
1. Choose a target in Mbed OS that your board can inherit from. | ||
|
||
If that existing target follows one of the recommended inheritance patterns, such as Family -> MCU -> Board, then it makes it simple to just inherit the MCU target information and add your own board information. In some cases, you may need to inherit a Family or Board and add or replace configurations accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When? Why? How? Do we have more info somewhere?
|
||
The new board target configuration inherits the MCU target, then follows similar configurations to the development kit, including specifying it should build with Mbed OS 5. Also, it uses `device_name nRF52840_xxAA`, which matches the CMSIS pack for that device. The `detect_code` is a unique ID that identifies the board to the Mbed OS test tools. | ||
|
||
<span class="notes">**Note:** Contact the Arm Mbed team to get a unique ID, especially if you plan to have your board coexist with other Mbed Enabled boards while running automated tests.</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, is that the detect_code? Then maybe break it out of line 72 so that it more clearly goes with a comment.
1. The new ImaginaryBoard board does not use AnalogIn, and it does not have a Quad SPI. Remove those. | ||
|
||
1. AnalogIn is an Mbed OS HAL driver, which the MCU target added using `device_has`. Remove it with `device_has_remove`. | ||
1. Similarly, the MCU target added QSPI using `components_add`. Remove it with `components_remove`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I maybe see a before and after of all this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Can you answer this?
1. (Optional) You can also use `device_has_add` to add additional drivers. | ||
|
||
<span class="notes">**Note:** If you choose to add a driver, you may have to provide the driver implementation if it is not already available for your hardware.</span> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er... that's not a very detailed comment.
|
||
## Configuring the code directory and folders | ||
|
||
The target source code directory should follow a similar structure as the target configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar as?
|
||
## Configuring the code directory and folders | ||
|
||
The target source code directory should follow a similar structure as the target configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't tell me where that directory goes (although I can see in the code block that it goes in mbed-os, it's not obvious that it's mandatory because of how the "For example" sentence is structured)
Standardize formatting for consistency, as requested in comments.
Address some comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Could you please answer these technical questions?
|
||
In this example, there is an MCU target configuration in `mbed-os/targets/targets.json` that the new board can inherit from. It is called MCU_NRF52840. | ||
|
||
Below is a short summary of the MCU target. For simplicity, areas have been omitted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Can you answer this?
|
||
In this example, the new board is similar to the NRF52840 development kit. | ||
|
||
1. Instead of making edits within `mbed-os`, create a `custom_target.json` file, and put it in a directory alongside `mbed-os`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Can you answer this?
} | ||
``` | ||
|
||
The new board target configuration inherits the MCU target, then follows similar configurations to the development kit, including specifying it should build with Mbed OS 5. Also, it uses `device_name nRF52840_xxAA`, which matches the CMSIS pack for that device. The `detect_code` is a unique ID that identifies the board to the Mbed OS test tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Can you answer this?
1. The new ImaginaryBoard board does not use AnalogIn, and it does not have a Quad SPI. Remove those. | ||
|
||
1. AnalogIn is an Mbed OS HAL driver, which the MCU target added using `device_has`. Remove it with `device_has_remove`. | ||
1. Similarly, the MCU target added QSPI using `components_add`. Remove it with `components_remove`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell Can you answer this?
|
||
1. Choose a board in Mbed OS that your board can inherit from. | ||
|
||
If that existing board follows one of the recommended inheritance patterns, such as Family -> MCU -> Board, then it makes it simple to just inherit the MCU target information and add your own board information. In some cases, you may need to inherit a family or board and add or replace configurations accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maclobdell What's a family? Do we have more information about this?
I see we have https://os.mbed.com/docs/mbed-os/v5.13/reference/adding-and-configuring-targets.html, but it only talks about parents and children. Are there other family members?
Closing in favor of PR #1145 |
Add and edit content provided about porting Mbed OS to a custom board.