{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/8501","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/8501/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/8501/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/8501/events","html_url":"https://github.com/ARMmbed/mbed-os/issues/8501","id":372911706,"node_id":"MDU6SXNzdWUzNzI5MTE3MDY=","number":8501,"title":"Setting the MAC address before connection on atmel radio is not possible.","user":{"login":"javier-moreno-tridonic-com","id":14233019,"node_id":"MDQ6VXNlcjE0MjMzMDE5","avatar_url":"https://avatars2.githubusercontent.com/u/14233019?v=4","gravatar_id":"","url":"https://api.github.com/users/javier-moreno-tridonic-com","html_url":"https://github.com/javier-moreno-tridonic-com","followers_url":"https://api.github.com/users/javier-moreno-tridonic-com/followers","following_url":"https://api.github.com/users/javier-moreno-tridonic-com/following{/other_user}","gists_url":"https://api.github.com/users/javier-moreno-tridonic-com/gists{/gist_id}","starred_url":"https://api.github.com/users/javier-moreno-tridonic-com/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javier-moreno-tridonic-com/subscriptions","organizations_url":"https://api.github.com/users/javier-moreno-tridonic-com/orgs","repos_url":"https://api.github.com/users/javier-moreno-tridonic-com/repos","events_url":"https://api.github.com/users/javier-moreno-tridonic-com/events{/privacy}","received_events_url":"https://api.github.com/users/javier-moreno-tridonic-com/received_events","type":"User","site_admin":false},"labels":[{"id":1076979756,"node_id":"MDU6TGFiZWwxMDc2OTc5NzU2","url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/HEADER%20NEEDS%20ACTION","name":"HEADER NEEDS ACTION","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-10-23T09:54:01Z","updated_at":"2018-10-24T11:43:17Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Description\r\n\r\nWe are trying to migrate our codebase from mbedOS 5.7 to 5.10. We have a range of MAC addresses available for our device. The MAC address is pre-flashed in section of our rom after the device is produced. So we do not use any MAC chip. We provide the MAC address ourselves.\r\n\r\nOn mbed 5.7 we could achieve this by calling the virtual method **NanostackPhy::set_mac_address** that was implemented in **NanostackRfPhyAtmel::set_mac_address**.\r\n\r\nThe problem comes because on 5.7 **platform_critical_init()** was called when **ThreadInterface::initialize(NanostackRfPhy \\*phy)** was called. \r\n\r\n![image](https://user-images.githubusercontent.com/14233019/47351536-78929900-d6b8-11e8-9108-6cd7c7bd13c2.png)\r\n\r\nThis allowed the Mutex used by **rf_if_lock();** to be initiliazed. So we could do the following\r\n\r\n- Initialize our interface with **ThreadInterface::initialize(NanostackRfPhy \\*phy)**\r\n- Set the mac address with **NanostackPhy::set_mac_address**\r\n- And finally do a **ThreadInterface::connect()**\r\n\r\nWith the current structure in place the call to **mesh_system_init();** (which will eventualy lead to the call of **platform_critical_init()**) was moved to the constructor of  [Nanostack::Interface::Interface](https://github.com/ARMmbed/mbed-os/blob/8054060bf289624be6d39c6e96d709f976168d91/features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp#L74) \r\n\r\nAs far as I could trace, with the current code, the constructor will only get called when we do **ThreadInterface::connect()**\r\n\r\n![image](https://user-images.githubusercontent.com/14233019/47351235-d672b100-d6b7-11e8-8d93-333e4001d683.png)\r\n\r\nThis means that we can't provide our MAC the way we used to, as doing so will trigger the following error because the Mutex is uninitialized.\r\n\r\n```\r\n++ MbedOS Error Info ++<\\n>\r\nError Status: 0x80010133 Code: 307 Module: 1<\\n>\r\nError Message: Mutex: 0x0, Parameter error<\\n>\r\nLocation: 0x8038DD7<\\n>\r\nError Value: 0x0<\\n>\r\nCurrent Thread: Id: 0x20014BFC Entry: 0x8038AFD StackSize: 0x1800 StackMem: 0x200133A8 SP: 0x2003FF58 <\\n>\r\n-- MbedOS Error Info --\r\n```\r\n\r\nIMHO there should be the possibility to set the mac externally without needing to rely in the specific implementation of the atmel-rf-driver (which I presume right now it just adapted to the arduino shields that come with a MAC chip integrated)\r\n\r\nIs there anything I'm missing that would allow me to do what we intend?\r\n\r\n<!--\r\n    Required\r\n    Add detailed description of what you are reporting.\r\n    Good example: https://os.mbed.com/docs/latest/reference/workflow.html\r\n    Things to consider sharing:\r\n    - What target does this relate to?\r\n    - What toolchain (name + version) are you using?\r\n    - What tools (name + version - is it mbed-cli, online compiler or IDE) are you using?\r\n    - What is the SHA of Mbed OS (git log -n1 --oneline)?\r\n    - Steps to reproduce. (Did you publish code or a test case that exhibits the problem?)\r\n-->\r\n\r\n\r\n### Issue request type\r\n\r\n<!--\r\n    Required\r\n    Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.)\r\n    Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front\r\n    of them would change the meaning incorrectly. The only changes to be made are to add a description text under the\r\n    description heading and to add a 'x' to the correct box.\r\n-->\r\n    [ ] Question\r\n    [X] Enhancement\r\n    [ ] Bug\r\n\r\n\r\nCC @MarceloSalazar \r\n"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/432622390","html_url":"https://github.com/ARMmbed/mbed-os/issues/8501#issuecomment-432622390","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/8501","id":432622390,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjYyMjM5MA==","user":{"login":"javier-moreno-tridonic-com","id":14233019,"node_id":"MDQ6VXNlcjE0MjMzMDE5","avatar_url":"https://avatars2.githubusercontent.com/u/14233019?v=4","gravatar_id":"","url":"https://api.github.com/users/javier-moreno-tridonic-com","html_url":"https://github.com/javier-moreno-tridonic-com","followers_url":"https://api.github.com/users/javier-moreno-tridonic-com/followers","following_url":"https://api.github.com/users/javier-moreno-tridonic-com/following{/other_user}","gists_url":"https://api.github.com/users/javier-moreno-tridonic-com/gists{/gist_id}","starred_url":"https://api.github.com/users/javier-moreno-tridonic-com/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javier-moreno-tridonic-com/subscriptions","organizations_url":"https://api.github.com/users/javier-moreno-tridonic-com/orgs","repos_url":"https://api.github.com/users/javier-moreno-tridonic-com/repos","events_url":"https://api.github.com/users/javier-moreno-tridonic-com/events{/privacy}","received_events_url":"https://api.github.com/users/javier-moreno-tridonic-com/received_events","type":"User","site_admin":false},"created_at":"2018-10-24T11:43:17Z","updated_at":"2018-10-24T11:43:17Z","author_association":"CONTRIBUTOR","body":"@kjbracey-arm I see. I misunderstood/misread your suggestion. Then it should truly be a one-liner :)\r\n\r\nI'll try that on my codebase (just to be sure and open a the PR if it works)"}}
{"actor":{"display_login":"javier-moreno-tridonic-com"}}