Skip to content

Create detailed custom-target-porting.md #1145

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

Closed
wants to merge 13 commits into from

Conversation

maclobdell
Copy link
Contributor

Add tutorial about porting Mbed OS to a custom board.

This replaces #1130.

Due to difficulty rebasing the previous PR, I went ahead and created a new one.

I rewrote the document based on feedback received. My goal was to provide more clarity and helpful details.

There might be formatting issues. Pleases review and let me know what I should fix.

@maclobdell maclobdell force-pushed the add-custom-target-tutorial branch from 852b131 to d3e07c0 Compare August 28, 2019 18:15
@maclobdell
Copy link
Contributor Author

@iriark01 for review

Push up initial copy edits.
@AnotherButler AnotherButler requested a review from iriark01 August 29, 2019 21:55
@iriark01
Copy link
Contributor

@arekzaluski and @sophewilliams I understand you did a lot of work on this topic - would you like to review this?

@AnotherButler
Copy link
Contributor

ping @arekzaluski @sophewilliams

@MarceloSalazar
Copy link
Contributor

This doc is really good - what do we need to merge it for 5.14?

@iriark01
Copy link
Contributor

This is still a work in progress and will not make it to 5.14; code freeze has already happened, OOB has started and the release is in six days.

@MarceloSalazar
Copy link
Contributor

Note this is not based on any new feature and doesn't depend on OOB. It's based on knowledge gaps we have in our docs.
Maybe could be introduced later after 5.14.0 is released?


When designing a custom board based on an existing Mbed Enabled board, you may need to make configuration and software changes to adapt Mbed OS to run on your new board. This is called a software port. The necessary changes may include adaptations for the unique design choices you have made for your new board, such as clocking, pin connections and peripheral usage. This can often be accomplished by adding configuration and source files to an Mbed OS-based application project without the need to modify files within `mbed-os`, itself. If you don't plan to push your changes to the upstream `mbed-os` repository, this simplifies your software configuration management by allowing you to keep your new files separate.

Mbed OS supports target inheritance, which allows you to extend an existing microcontroller (MCU) target and just add software and configurations required for your board. You have the ability to add a file named `custom_target.json` to your project, which can store your custom target configurations without the need to modify `targets.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear on the break and order of information in the first two paragraphs.


When designing a custom board based on an existing Mbed Enabled board, you may need to make configuration and software changes to adapt Mbed OS to run on your new board. This is called a software port. The necessary changes may include adaptations for the unique design choices you have made for your new board, such as clocking, pin connections and peripheral usage. This can often be accomplished by adding configuration and source files to an Mbed OS-based application project without the need to modify files within `mbed-os`, itself. If you don't plan to push your changes to the upstream `mbed-os` repository, this simplifies your software configuration management by allowing you to keep your new files separate.

Mbed OS supports target inheritance, which allows you to extend an existing microcontroller (MCU) target and just add software and configurations required for your board. You have the ability to add a file named `custom_target.json` to your project, which can store your custom target configurations without the need to modify `targets.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Mbed OS supports target inheritance, which allows you to extend an existing microcontroller (MCU) target and just add software and configurations required for your board. You have the ability to add a file named `custom_target.json` to your project, which can store your custom target configurations without the need to modify `targets.json`.
Mbed OS supports target inheritance, which allows you to extend an existing microcontroller (MCU) target and just add software and configurations required for your board. You can add a file named `custom_target.json` to your project, which can store your custom target configurations without the need to modify `targets.json`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this sentence assumes I know what targets.json is; might be nice to link to information about it, or any other information we want people to have before they try this tutorial (the assumption may be correct for our readers - I'm just pointing it out)


## Extending an existing MCU target configuration

As an example, consider a situation in which you are creating a new board based on an existing Mbed Enabled board. For this tutorial, consider a new board called `ImaginaryBoard` that is based on [DISCO-L475VG-IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that an example, or just the premise of this whole document?


1. Create a new file named `custom_targets.json` at the same level as the `mbed-os` directory:

Inspect the contents of `mbed-os/targets/targets.json`. For this example, search for `DISCO_L475VG_IOT01A`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a new step.


You can test this simple example using a `DISCO-L475VG-IOT01A`. If you actually created a `ImaginaryBoard` board, you could use that too.

<span class="notes">**Note:** Unless your board has an Mbed Enabled debug interface, you need a method of flashing the memory on your board. </span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this come earlier?


<span class="notes">**Note:** Unless your board has an Mbed Enabled debug interface, you need a method of flashing the memory on your board. </span>

Since the `DISCO-L475VG-IOT01A` has a Mbed Enabled debug interface (STLink in this case), we can use drag-and-drop programming to flash the board.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Since the `DISCO-L475VG-IOT01A` has a Mbed Enabled debug interface (STLink in this case), we can use drag-and-drop programming to flash the board.
Since the `DISCO-L475VG-IOT01A` has an Mbed Enabled debug interface (STLink in this case), we can use drag-and-drop programming to flash the board.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we flipping a bit between "We" and "You"?


Locate the binary file and drag it onto the disk drive name for the board (for example, `DIS_L4IOT`).

After the file transfer is complete, press the reset button on the board. You should see the LED blinking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After the file transfer is complete, press the reset button on the board. You should see the LED blinking.
When the file transfer is complete, press the reset button on the board. You should see the LED blinking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New step


After the file transfer is complete, press the reset button on the board. You should see the LED blinking.

1. (Optional) Run automated tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe new header?

mbed test -m IMAGINARYBOARD -t <toolchain>
```

The tests should start running.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to some information about testing?

@AnotherButler
Copy link
Contributor

@iriark01 Could you please review again?

@AnotherButler
Copy link
Contributor

@arekzaluski @sophewilliams Would y'all like to review?

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I would just add some more details and considerations around the detect code.

#### Changes

1. The board name changed from `DISCO_L475VG_IOT01A` to `IMAGINARYBOARD`, so the board can be uniquely identified.
1. The `detect_code` changed from `0764` to `1234`. The `detect_code` is a unique number that identifies the board to the Mbed OS test tools. For Mbed Enabled boards, this number is exposed through the debug interface with Mbed CLI by typing `mbedls`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need some information how to set it? When do you need to get it from us and when it's ok to just pick some? How to avoid clashes? Consideration based on public vs private port? I guess it deserves a link to a separate doc.

Copy link
Contributor Author

@maclobdell maclobdell Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through our documentation - I see it mentioned a few times, but never really see it explained well and the terminology is inconsistent.

I like Board ID, but Platform ID or the others seem fine.

For me the key points are:

  1. Board IDs are unique identifiers assigned by the Arm Mbed team.
  2. Board IDs are used by the Mbed tools to identify the connected board.
  3. You really only need your own unique ID if you plan to push your platform to the Mbed community.
  4. You can make Mbed CLI recognize your own custom board even without getting your own Board ID.
  5. Contact a technical account manger or Mbed support if you would like to request a board ID.

@AnotherButler - can you recommend where this information would be best located?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added a new commit for this PR with changes related to the Platform ID. Also, I made pull request #1175 to align the terminology and add more detail. Please let me know if this addresses the comments.

@AnotherButler
Copy link
Contributor

@maclobdell Can you make these changes requested by @bulislaw ?

@AnotherButler
Copy link
Contributor

AnotherButler commented Nov 21, 2019

Thanks for the updates, @maclobdell

This is failing Circle CI because of something unrelated. Could you please rebase, and then I'll merge? If you'd rather, I can close this PR and make these changes directly.

AnotherButler pushed a commit that referenced this pull request Dec 3, 2019
Add content from PR #1145 to fix merge conflict.
@AnotherButler
Copy link
Contributor

Closing in favor of 6be8ae4

@AnotherButler AnotherButler deleted the add-custom-target-tutorial branch December 3, 2019 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants