{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6065","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6065/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6065/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6065/events","html_url":"https://github.com/ARMmbed/mbed-os/issues/6065","id":296337322,"number":6065,"title":"[NRF52] FlashIAP Interface usage without SoftDevice","user":{"login":"drahnr","id":667047,"avatar_url":"https://avatars1.githubusercontent.com/u/667047?v=4","gravatar_id":"","url":"https://api.github.com/users/drahnr","html_url":"https://github.com/drahnr","followers_url":"https://api.github.com/users/drahnr/followers","following_url":"https://api.github.com/users/drahnr/following{/other_user}","gists_url":"https://api.github.com/users/drahnr/gists{/gist_id}","starred_url":"https://api.github.com/users/drahnr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drahnr/subscriptions","organizations_url":"https://api.github.com/users/drahnr/orgs","repos_url":"https://api.github.com/users/drahnr/repos","events_url":"https://api.github.com/users/drahnr/events{/privacy}","received_events_url":"https://api.github.com/users/drahnr/received_events","type":"User","site_admin":false},"labels":[{"id":405492686,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/devices:%20nordic","name":"devices: nordic","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-12T11:08:45Z","updated_at":"2018-02-12T20:45:58Z","closed_at":null,"author_association":"NONE","body":"Note: This is just a template, so feel free to use/remove the unnecessary things\r\n\r\n### Description\r\n- Type: Bug/Question\r\n- Related: https://github.com/ARMmbed/mbed-os/issues/5974\r\n- Priority: Major\r\n\r\n---------------------------------------------------------------\r\n## Bug\r\n\r\n**Target**\r\nNRF52_DK / Custom\r\n\r\n**Toolchain:**\r\nGCC_ARM\r\n\r\n**Toolchain version:**\r\narm-none-eabi-gcc (Fedora 7.1.0-5.fc27) 7.1.0\r\n\r\n\r\n**mbed-cli version:** \r\n1.3.0\r\n\r\n**mbed-os sha:**\r\n4.7.4 / caeaa49d68c67ee00275cece10cd88e0ed0f6ed3 + 2 custom commits enabling C++11 and fixing an SPI ISR bug\r\n\r\n**Expected behavior**\r\nFlashIAP works \r\n\r\n**Actual behavior**\r\nFlasIAP programing fails with ret code -1\r\n\r\n**Steps to reproduce**\r\ncustom_targets.json\r\n```\r\n{\r\n    \"CUSTOM_TARGET\": {\r\n        \"supported_form_factors\": [\"ARDUINO\"],\r\n        \"inherits\": [\"NRF52_DK\"],\r\n        \"macros_remove\": [\"S132\", \"SOFTDEVICE_PRESENT\", \"CONFIG_GPIO_AS_PINRESET\", \"BLE_STACK_SUPPORT_REQD\"],\r\n        \"macros_add\" : [\"CONFIG_NFCT_PINS_AS_GPIOS\",\"MBED_TICKLESS\"],\r\n        \"release_versions\": [\"2\", \"5\"],\r\n        \"device_has_add\": [\"FLASH\"],\r\n        \"device_name\": \"nRF52832_xxAA\",\r\n        \"features_remove\": [\"BLE\"],\r\n        \"MERGE_BOOTLOADER\": false,\r\n        \"MERGE_SOFTDEVICE\": false,\r\n        \"bootloader_supported\": true\r\n    }\r\n}\r\n```\r\n\r\n```\r\n#if 1\r\n    ret = iap.init(); // <<<< good\r\n    if (ret < 0 ) {\r\n        printf(\"Failed to init IAP %i\", ret);\r\n    } else {\r\n        const char x[] = \"TestPatternABC1230xFF\";\r\n        const size_t x_len = sizeof(x);\r\n        char y[x_len] = {'\\0', };\r\n        const uint32_t addr = 0x38000; // somewhere after the firmware\r\n        ret = iap.program(x, addr, x_len); // <<<<<< fails\r\n        if (ret < 0) {\r\n            printf(\"Failed to program IAP %i\", ret);\r\n        } else {\r\n            ret = iap.read(y, addr, x_len);\r\n            if (ret < 0) {\r\n                printf(\"Failed to read IAP %i\", ret);\r\n            } else {\r\n                assert(memcmp(y,x,x_len) == 0);\r\n            }\r\n            printf(\"Read %s\", y);\r\n        }\r\n        ret = iap.deinit();\r\n        if (ret < 0) {\r\n            printf(\"Failed to deinit IAP %i\", ret);\r\n        }\r\n    }\r\n#endif\r\n```\r\n----------------------------------------------------------------\r\n\r\n## Question\r\n\r\n**How to?**\r\n\r\nSo apparently the check of `sd_softdevice` in  \r\n\r\n```\r\nint32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)\r\n{\r\n    uint8_t sd_enabled;\r\n    if ((sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && sd_enabled == 1) {\r\n        return -1;\r\n    }\r\n    /* We will use *_words function to speed up flashing code. Word means 32bit -> 4B\r\n     * or sizeof(uint32_t).\r\n     */\r\n    nrf_nvmc_write_words(address, (const uint32_t *) data, (size / sizeof(uint32_t)));\r\n    return 0;\r\n}\r\n```\r\n\r\nSo it appears that the softdevice is present and enabled which I thought I deliberately disabled with the above settings in `CUSTOM_TARGET`?"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/365056230","html_url":"https://github.com/ARMmbed/mbed-os/issues/6065#issuecomment-365056230","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6065","id":365056230,"user":{"login":"drahnr","id":667047,"avatar_url":"https://avatars1.githubusercontent.com/u/667047?v=4","gravatar_id":"","url":"https://api.github.com/users/drahnr","html_url":"https://github.com/drahnr","followers_url":"https://api.github.com/users/drahnr/followers","following_url":"https://api.github.com/users/drahnr/following{/other_user}","gists_url":"https://api.github.com/users/drahnr/gists{/gist_id}","starred_url":"https://api.github.com/users/drahnr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drahnr/subscriptions","organizations_url":"https://api.github.com/users/drahnr/orgs","repos_url":"https://api.github.com/users/drahnr/repos","events_url":"https://api.github.com/users/drahnr/events{/privacy}","received_events_url":"https://api.github.com/users/drahnr/received_events","type":"User","site_admin":false},"created_at":"2018-02-12T20:45:58Z","updated_at":"2018-02-12T20:45:58Z","author_association":"NONE","body":"Also: If `size` is `4*N+[1..3]` the last `[1..3]` bytes will be lost (given `sizeof(uint32_t) == 4` )"}}
{"actor":{"display_login":"drahnr"}}