Skip to content

Made saml21 target run on mbed5 #7276

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 5 commits into from
Closed

Made saml21 target run on mbed5 #7276

wants to merge 5 commits into from

Conversation

martinichka
Copy link
Contributor

Description

Last bits to make SAM L21 being supported in mbed5 (mbed2 was already working fine).

Open issues:

  • rtos not supported yet, needed to be compiled with the following mbedignore:
mbed-os/rtos/*
mbed-os/features/filesystem/*
mbed-os/features/nvstore/*
mbed-os/features/cellular/*
mbed-os/features/frameworks/*
mbed-os/features/net/*
mbed-os/features/netsocket/*
mbed-os/features/storage/*

Pull request type

[ ] Fix
[ ] Refactor
[x] New target
[ ] Feature
[ ] Breaking change

@martinichka
Copy link
Contributor Author

@0xc0170 and @ashok-rao this PR was requested by @janjongboom

@@ -3366,7 +3366,7 @@
"SAML21J18A": {
"inherits": ["Target"],
"core": "Cortex-M0+",
"macros": ["__SAML21J18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true"],
"macros": ["__SAML21J18A__", "I2C_MASTER_CALLBACK_MODE=true", "EXTINT_CALLBACK_MODE=true", "USART_CALLBACK_MODE=true", "TC_ASYNC=true", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
"extra_labels": ["Atmel", "SAM_CortexM0P", "SAML21"],
Copy link
Contributor

Choose a reason for hiding this comment

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

release_versions is missing if you want to add support for OS 5. Also, why RTOS support is removed via .mbedignore?

Copy link
Contributor Author

@martinichka martinichka Jun 23, 2018

Choose a reason for hiding this comment

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

why RTOS support is removed via .mbedignore?

as we don't use RTOS for our project and it was failing with:

Compile [  0.3%]: main.cpp
[Fatal Error] mbed_rtx_conf.h@25,22: mbed_rtx.h: No such file or directory
[ERROR] In file included from ./mbed-os/rtos/TARGET_CORTEX/rtx5/RTX/Config/RTX_Config.h:31:0,
                 from ./mbed-os/rtos/TARGET_CORTEX/rtx5/RTX/Include/rtx_evr.h:31,
                 from ./mbed-os/rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_lib.h:38,
                 from ./mbed-os/rtos/TARGET_CORTEX/mbed_rtos_storage.h:43,
                 from ./mbed-os/rtos/rtos.h:28,
                 from ./mbed-os/mbed.h:20,
                 from ./main.cpp:1:
./mbed-os/rtos/TARGET_CORTEX/mbed_rtx_conf.h:25:22: fatal error: mbed_rtx.h: No such file or directory
 #include "mbed_rtx.h"
                      ^
compilation terminated.

@bulislaw
Copy link
Member

Once you get the RTOS sorted, could you post results of mbed test -v (depending on your env settings you may need to set the compiler and targets), just the test results not the whole dump.

@janjongboom
Copy link
Contributor

There will be a follow up PR with RTOS support. Do you want to hold off from landing this before it's sorted out?

@cmonr
Copy link
Contributor

cmonr commented Jun 25, 2018

@janjongboom In order for this to pass tests in Mbed 5, RTOS support is needed.

@martinichka
Copy link
Contributor Author

I added mbed_rtx.h for saml21. With stack pointer to end of ram. Base address is 0x20000000 and ram size is 32k I set it to 0x20008000UL. That should be all isn't it? It is still untested. I will test it in the coming days (it is a side project for me).

The only file I needed to put into mbedignore to make it compile is:
mbed-os/features/filesystem/bd/MBRBlockDevice.cpp
otherwise it fails with:

[ERROR] In file included from /opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/c++/6.2.1/algorithm:61:0,
                 from ./mbed-os/features/filesystem/bd/MBRBlockDevice.cpp:18:
/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/c++/6.2.1/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

Any ideas what issue that might be?

@martinichka
Copy link
Contributor Author

Running mbed test -v fails with the same error about min/max

@martinichka
Copy link
Contributor Author

After removing the conflicting math macros I can compile without mbedignores. Now the test tries to connect the device, which obviously does not succeed because it don't have it here with me at the moment. @0xc0170 and @ashok-rao But how it would find the device? How does this work and how can I make it supported?

@cmonr
Copy link
Contributor

cmonr commented Jun 25, 2018

@martinichka The tool that we use to detect targets is called mbed-ls.

You should submit a PR here: https://github.com/ARMmbed/mbed-ls/pulls

@cmonr
Copy link
Contributor

cmonr commented Jul 3, 2018

@martinichka Any updates? Need any help anywhere?

@martinichka
Copy link
Contributor Author

martinichka commented Jul 4, 2018 via email

@cmonr
Copy link
Contributor

cmonr commented Jul 26, 2018

@martinichka You'll need to open a pull request to https://github.com/ARMmbed/mbed-ls and add support for your board. Once it's in and mbed-ls has been released, then we can update CI with the latest version and revisit this PR.

@janjongboom
Copy link
Contributor

@martinichka When running with RTOS on it errors out for me at Mutex 0x20000c94 error -8: Unknown. Have you seen that before?

@janjongboom
Copy link
Contributor

The gpio_api.c gpio_init implementation is not correct. The MBED_ASSERT should be removed, it's fine to declare a NC pin as gpio, it should just call return. This is in line with other HAL implementations.

diff --git a/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/gpio_api.c b/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/gpio_api.c
index 2706e3cfb..256ad2f32 100644
--- a/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/gpio_api.c
+++ b/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/gpio_api.c
@@ -28,14 +28,14 @@ uint32_t gpio_set(PinName pin)

 void gpio_init(gpio_t *obj, PinName pin)
 {
-    MBED_ASSERT(pin != (PinName)NC);
+    if (pin == (PinName)NC)
+        return;
+
     struct port_config pin_conf;
     PortGroup *const port_base = (PortGroup*)port_get_group_from_gpio_pin(pin);

     obj->pin = pin;
-    if (pin == (PinName)NC)
-        return;
-
     obj->mask = gpio_set(pin);
     port_get_config_defaults(&pin_conf);
     obj->powersave = pin_conf.powersave;

@martinichka
Copy link
Contributor Author

martinichka commented Aug 3, 2018 via email

@janjongboom
Copy link
Contributor

@martinichka FYI, ARMmbed/mbed-ls#384 - will take a stab at it next week.

@cmonr
Copy link
Contributor

cmonr commented Aug 24, 2018

@martinichka @janjongboom Any updates?

@janjongboom
Copy link
Contributor

@cmonr No, unfortunately not; and I don't have the target with me right now...

@janjongboom
Copy link
Contributor

janjongboom commented Sep 5, 2018

@cmonr @martinichka mbed-ls PR is now open ARMmbed/mbed-ls#390

Trying to run the tests but nothing seems to run on the fresh board that I got... Will check when back in Netherlands.

@janjongboom
Copy link
Contributor

janjongboom commented Oct 10, 2018

@martinichka RTOS working here: https://github.com/janjongboom/mbed-os/tree/feature-saml21-mbed5-rebased - now about to run the tests.

@cmonr
Copy link
Contributor

cmonr commented Oct 23, 2018

@janjongboom Any update on the tests?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 23, 2018

@martinichka RTOS working here: https://github.com/janjongboom/mbed-os/tree/feature-saml21-mbed5-rebased - now about to run the tests.

As this require further work, please update us (reopen pull request once there is an update we can review). In the meantime, we close this PR due to inactivity.

@0xc0170 0xc0170 closed this Oct 23, 2018
@janjongboom
Copy link
Contributor

@cmonr Yes, some issues with the test runner on the board. Just hangs sometimes, that makes it hard. Will get back to this when back from travelling.

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.

6 participants