Skip to content

Update SAML21J18A target to Mbed OS 5.12 #8658

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

Conversation

janjongboom
Copy link
Contributor

@janjongboom janjongboom commented Nov 6, 2018

Description

Co-authored by @martinichka, follow up from #7276.

This PR adds Mbed OS 5.10 (incl. RTOS) support for the SAML21J18A target. It also updates to the latest available device pack from MDK (to Keil.SAM-L_DFP.1.2.1). There are a few issues left to figure out, mostly timer related (see #8656). Tested on: SAML21 XPLAINED PRO development board (already landed in ARMmbed/mbed-ls#390) with GCC ARM 6.

Note that you need the latest interface firmware from the XPLAINED PRO board (automatically pops up when connecting in Atmel Studio).

There are issues with flashing binaries in succession via the USB drag-n-drop interface, which makes the automated testing process very painful (running into SYNC_FAILED often, restarting board solves this). Are there any ways to cut power to a board between GT tests?

Todo

Test results

mbed-os-features-frameworks-utest-tests-unit_tests-basic_test                               OK
mbed-os-features-frameworks-utest-tests-unit_tests-basic_test_default                       OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_control_async                       OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_control_repeat                      OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_selection                           OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_setup_failure                       OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_teardown_failure                    OK
mbed-os-features-frameworks-utest-tests-unit_tests-minimal_async_scheduler                  OK
mbed-os-features-frameworks-utest-tests-unit_tests-minimal_scheduler                        OK
mbed-os-features-frameworks-utest-tests-unit_tests-test_assertion_failure_test_setup        OK
mbed-os-features-frameworks-utest-tests-unit_tests-test_setup_case_selection_failure        OK
mbed-os-features-frameworks-utest-tests-unit_tests-test_setup_failure                       OK
mbed-os-features-frameworks-utest-tests-unit_tests-test_skip                                OK
mbed-os-features-frameworks-utest-tests-unit_tests-control_type                             OK
mbed-os-features-frameworks-utest-tests-unit_tests-case_async_validate                      FAIL (https://github.com/ARMmbed/mbed-os/issues/8656)
mbed-os-features-storage-tests-blockdevice-buffered_block_device                            OK
mbed-os-features-storage-tests-blockdevice-flashsim_block_device                            OK
mbed-os-features-storage-tests-blockdevice-heap_block_device                                OK
mbed-os-features-storage-tests-blockdevice-mbr_block_device                                 OK
mbed-os-features-storage-tests-blockdevice-util_block_device                                OK
mbed-os-tests-integration-basic                                                             OK
mbed-os-tests-mbed_drivers-c_strings                                                        OK
mbed-os-tests-mbed_drivers-crc                                                              FAIL (Test thread safety)
mbed-os-tests-mbed_drivers-dev_null                                                         OK
mbed-os-tests-mbed_drivers-echo                                                             OK
mbed-os-tests-mbed_drivers-generic_tests                                                    OK
mbed-os-tests-mbed_drivers-sleep_lock                                                       OK
mbed-os-tests-mbed_drivers-stl_features                                                     OK
mbed-os-tests-mbed_functional-callback                                                      OK
mbed-os-tests-mbed_functional-callback_big                                                  OK
mbed-os-tests-mbed_functional-callback_small                                                OK
mbed-os-tests-mbed_functional-functionpointer                                               OK
mbed-os-tests-mbed_hal-critical_section                                                     OK
mbed-os-tests-mbed_hal-rtc                                                                  FAIL (RTC - persist)
mbed-os-tests-mbed_hal-rtc_reset                                                            FAIL
mbed-os-tests-mbed_hal-rtc_time                                                             OK
mbed-os-tests-mbed_hal-rtc_time_conv                                                        OK
mbed-os-tests-mbed_hal-sleep                                                                FAIL (sleep - source of wake-up - us ticker)
mbed-os-tests-mbed_hal-sleep_manager                                                        OK
mbed-os-tests-mbed_hal-ticker                                                               FAIL (test_frequencies_and_masks)
mbed-os-tests-mbed_platform-circularbuffer                                                  OK
mbed-os-tests-mbed_platform-critical_section                                                FAIL (Test critical section C API)
mbed-os-tests-mbed_platform-error_handling                                                  OK
mbed-os-tests-mbed_platform-filehandle                                                      OK
mbed-os-tests-mbed_platform-sharedptr                                                       OK
mbed-os-tests-mbed_platform-singletonptr                                                    OK
mbed-os-tests-mbed_platform-stats_heap                                                      OK
mbed-os-tests-mbed_platform-system_reset                                                    OK
mbed-os-tests-mbed_platform-transaction                                                     OK
mbed-os-tests-mbedmicro-mbed-attributes                                                     OK
mbed-os-tests-mbedmicro-mbed-call_before_main                                               OK
mbed-os-tests-mbedmicro-mbed-cpp                                                            OK
mbed-os-tests-mbedmicro-mbed-div                                                            OK
mbed-os-tests-mbedmicro-mbed-static_assert                                                  OK
mbed-os-tests-mbedmicro-rtos-mbed-kernel_tick_count                                         OK
mbed-os-tests-mbedmicro-rtos-mbed-memorypool                                                OK
mbed-os-tests-mbedtls-multi                                                                 OK
mbed-os-tests-mbedtls-selftest                                                              FAIL (mbedtls_sha512_self_test)

Full test log

Pull request type

[ ] Fix
[ ] Refactor
[X] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@cmonr cmonr requested review from a team November 7, 2018 03:24
Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

No tools changes. Targets.json seems fine to me.

@cmonr cmonr requested review from ashok-rao, MarceloSalazar and a team November 8, 2018 01:27
@MarceloSalazar MarceloSalazar requested review from maclobdell and removed request for MarceloSalazar November 8, 2018 09:12
@MarceloSalazar
Copy link

@maclobdell please have a look. I understand you're involved in conversations about SAMx devices.

@cmonr
Copy link
Contributor

cmonr commented Nov 9, 2018

Are there any ways to cut power to a board between GT tests?

Not that I'm aware of. @ARMmbed/mbed-os-test-team , thoughts?

@bridadan
Copy link
Contributor

@cmonr Not at the moment no

@cmonr
Copy link
Contributor

cmonr commented Nov 29, 2018

@janjongboom This'll need a rebase to pull the targets.json updates.

@ARMmbed/mbed-os-hal @ashok-rao @ARMmbed/mbed-os-maintainers @maclobdell Please review when able.

@cmonr
Copy link
Contributor

cmonr commented Dec 21, 2018

@janjongboom Mind rebasing any time soon?

@mbed-os-hal @ashok-rao @ARMmbed/mbed-os-maintainers @maclobdell Would anyone else like to review?

@janjongboom
Copy link
Contributor Author

@cmonr Yes, will do soon.

@janjongboom janjongboom force-pushed the feature-saml21-mbed5-rebased branch 3 times, most recently from f21c170 to 0a1eed4 Compare January 2, 2019 16:46
@janjongboom
Copy link
Contributor Author

@0xc0170 There is a startup script in the IAR folder (although it doesn't seem to do much), but no linker script. I have no idea how to write this either, and I don't have IAR. But if I remove '5' from the target version list then I cannot compile any programs anymore (Could not compile for SAML21J18A: Target does not support mbed OS 5). Could we find a solution for this on short notice?

@janjongboom
Copy link
Contributor Author

@cmonr @0xc0170 Can we land this in a feature branch until the IAR linker script is written? We do an announcement about this next week and I don't want to send people to my GitHub page.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 28, 2019

@cmonr @0xc0170 Can we land this in a feature branch until the IAR linker script is written? We do an announcement about this next week and I don't want to send people to my GitHub page.

We can create a feature branch, but it still should pass tests (in this case without IAR support, it would fail?).

Here's some good example for the icf (I checked one Sam device and adjusted sections):

if (!isdefinedsymbol(MBED_APP_START)) { define symbol MBED_APP_START = 0x00000000; }
if (!isdefinedsymbol(MBED_APP_SIZE)) { define symbol MBED_APP_SIZE = 0x80000; }
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = MBED_APP_START;
define symbol __ICFEDIT_region_ROM_end__     = MBED_APP_START + MBED_APP_SIZE - 1;
define symbol __ICFEDIT_region_NVIC_start__   = 0x20000000;
define symbol __ICFEDIT_region_NVIC_end__   = 0x200000B8;
define symbol __ICFEDIT_region_RAM_start__   = 0x200000B8;
define symbol __ICFEDIT_region_RAM_end__     = 0x20008000;

/*-Sizes-*/
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
    define symbol MBED_BOOT_STACK_SIZE = 0x400;
}

define symbol __ICFEDIT_size_cstack__   = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_heap__     = 0x400;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };


initialize by copy { readwrite };
do not initialize  { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block HEAP, block CSTACK };

Just set RAM, NVIC regions and heap size, this should help you. I assumed there's only one RAM region at address 0x20000000.

@janjongboom
Copy link
Contributor Author

@0xc0170 I assume this still requires a startup script right? It seems empty for this target right now.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 13, 2019

@0xc0170 I assume this still requires a startup script right? It seems empty for this target right now.

Yes, what about feature branch? Or is this targeting master (needs IAR support still) ?

@janjongboom
Copy link
Contributor Author

@0xc0170 If we need IAR anyway for master I'll go for master straight away.

Copy link
Contributor

@c1728p9 c1728p9 left a comment

Choose a reason for hiding this comment

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

A few minor comments, but otherwise looks good to me.

@@ -50,7 +50,7 @@
* Initial system clock frequency. The System RC Oscillator (RCSYS) provides
* the source for the main clock at chip startup.
*/
#define __SYSTEM_CLOCK (4000000)
#define __SYSTEM_CLOCK (4000000 * 12)
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment indicates that this is the "System RC Oscillator" which is typically internal to the chip. Why is the being multiplied by 12? If a clock needs to be updated shouldn't it be for an external or PLL clock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, the previous version ran on 4 MHz. In this PR we're upping the clock frequency to 48 MHz (normal speed of the device). However, if this define is not in sync with the actual clock speed all timers are off in Mbed OS. But I cannot update this value after boot (I've tried but it doesn't do anything), so I think it should be the value after boot here, not the one during boot. Have to update the comment though.

@@ -948,9 +948,9 @@ static inline void system_main_clock_set_failure_detect(
const bool enable)
{
if (enable) {
MCLK->CTRLA.reg |= MCLK_CTRLA_CFDEN;
MCLK->CTRLA.reg |= 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a define that can be used here rather than 4?

"base-address": "0x30000",
"size": "0x10000",
"num-blocks": 3,
"max-test-size": "64 * 1024"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the size need to be reduced for this target? Not enough storage space?

Copy link
Contributor Author

@janjongboom janjongboom Feb 21, 2019

Choose a reason for hiding this comment

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

Yes. Only 256K flash and half is already taken by the binary, so too little to use bigger FlashIAP file system.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 21, 2019

Besides the review ongoing, how are tests for this target? Are all green or still some to be fixed?

My assumption is that this target will be added in 5.12.x rather than 5.12.0

@janjongboom
Copy link
Contributor Author

@0xc0170 Some issues with sleep. We'll have a hackathon next week to resolve those. Other than that still blocked on the IAR scripts.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 27, 2019

Note, #9571 - might have implications for new targets. Please review (there's design document, and targets updated, if any questions, let us know). In any case, please reply to this comment if this change is already done or when completed.

We switched to IAR8 for 5.12 , so will need IAR8 update .

@0xc0170 0xc0170 changed the title Update SAML21J18A target to Mbed OS 5.10 Update SAML21J18A target to Mbed OS 5.12 Feb 27, 2019
@janjongboom
Copy link
Contributor Author

0xc0170 Yep, rebasing now and will make sure the patch is in there.

Hasnain Virk and others added 3 commits March 4, 2019 11:26
Looking at the board layout (SAML21 Xplained Pro) we can see that out of
three EXT pinouts only two (EXT1 and EXT3) have a set of four pins
available on a single SERCOM. For example (PB16, PB17, PB22, PB23) on
EXT3 are mapped to SERCOM5. So if we wish to add a peripheral that uses
4 pin SPI like a SX1276 Wing radio, we can only choose EXt3 or EXT1.

However, we found out that we can't use radio shield on EXT3 as the pin
PB10 used as dio2 interrupt line is also mapped to the LED.
For both SPI and I2C peripherlas, HAL chooses Default PAD. This would
result in picking up SERCOM0 for I2C pins (PA08 and PA09) which will not
work for us as we have attached the secure element to EXT3 and we need
to map these pins to SERCOM2.

One way of solving the issue is to mark PA08 and PA09 as NC on SERCOM0
by default. Another is to swap the SERCOMx mapping for the PA08 and PA09
between the Default PAD and Extended PAD.

A proper fix would probably be to physically cut PB10 and LED
connection. This would mean that we don't need to hack the pin map.
@janjongboom janjongboom force-pushed the feature-saml21-mbed5-rebased branch from f639faa to a2c9a43 Compare March 4, 2019 12:21
@janjongboom
Copy link
Contributor Author

Rebased. Some issues with RTC:

OK   mbed-os-features-frameworks-utest-tests-unit_tests-basic_test
OK   mbed-os-features-frameworks-utest-tests-unit_tests-basic_test_default
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_async_validate
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_control_async
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_control_repeat
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_selection
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_setup_failure
OK   mbed-os-features-frameworks-utest-tests-unit_tests-case_teardown_failure
OK   mbed-os-features-frameworks-utest-tests-unit_tests-control_type
OK   mbed-os-features-frameworks-utest-tests-unit_tests-minimal_async_scheduler
OK   mbed-os-features-frameworks-utest-tests-unit_tests-minimal_scheduler
OK   mbed-os-features-frameworks-utest-tests-unit_tests-test_assertion_failure_test_setup
OK   mbed-os-features-frameworks-utest-tests-unit_tests-test_setup_case_selection_failure
OK   mbed-os-features-frameworks-utest-tests-unit_tests-test_setup_failure
OK   mbed-os-features-frameworks-utest-tests-unit_tests-test_skip
OK   mbed-os-features-storage-tests-blockdevice-buffered_block_device
OK   mbed-os-features-storage-tests-blockdevice-flashsim_block_device
TIMEOUT mbed-os-features-storage-tests-blockdevice-general_block_device
OK   mbed-os-features-storage-tests-blockdevice-heap_block_device
OK   mbed-os-features-storage-tests-blockdevice-mbr_block_device
OK   mbed-os-features-storage-tests-blockdevice-util_block_device
???  mbed-os-features-storage-tests-filesystem-general_filesystem
OK   mbed-os-features-storage-tests-kvstore-tdbstore_whitebox
OK   mbed-os-tests-events-queue (Values Not Within Delta 5 Expected 100 Was 74)
OK   mbed-os-tests-events-timing (Testing accuracy of equeue semaphore)
OK   mbed-os-tests-integration-basic
OK   mbed-os-tests-mbed_drivers-c_strings
OK   mbed-os-tests-mbed_drivers-crc
OK   mbed-os-tests-mbed_drivers-dev_null
OK   mbed-os-tests-mbed_drivers-echo
OK   mbed-os-tests-mbed_drivers-generic_tests
OK   mbed-os-tests-mbed_drivers-race_test
FAIL mbed-os-tests-mbed_drivers-rtc (attach stub RTC functions.)
OK   mbed-os-tests-mbed_drivers-sleep_lock
OK   mbed-os-tests-mbed_drivers-stl_features
OK   mbed-os-tests-mbed_drivers-ticker
FAIL mbed-os-tests-mbed_drivers-timeout (Multiple timeouts running in parallel (attach))
OK   mbed-os-tests-mbed_drivers-timer
FAIL mbed-os-tests-mbed_drivers-timerevent (Test insert_absolute zero)
OK   mbed-os-tests-mbed_functional-callback
OK   mbed-os-tests-mbed_functional-callback_big
OK   mbed-os-tests-mbed_functional-callback_small
OK   mbed-os-tests-mbed_functional-functionpointer
FAIL mbed-os-tests-mbed_hal-common_tickers (Microsecond ticker init is safe to call repeatedly)
OK   mbed-os-tests-mbed_hal-common_tickers_freq
OK   mbed-os-tests-mbed_hal-critical_section
OK   mbed-os-tests-mbed_hal-minimum_requirements
OK   mbed-os-tests-mbed_hal-pinmap
FAIL mbed-os-tests-mbed_hal-rtc (RTC - persist)
FAIL mbed-os-tests-mbed_hal-rtc_reset (mbed-os-tests-mbed_hal-rtc_reset)
FAIL mbed-os-tests-mbed_hal-rtc_time (test set_time twice)
OK   mbed-os-tests-mbed_hal-rtc_time_conv
OK   mbed-os-tests-mbed_hal-sleep
OK   mbed-os-tests-mbed_hal-sleep_manager
OK   mbed-os-tests-mbed_hal-sleep_manager_racecondition
OK   mbed-os-tests-mbed_hal-stack_size_unification
OK   mbed-os-tests-mbed_hal-ticker
OK   mbed-os-tests-mbed_hal-us_ticker
OK   mbed-os-tests-mbed_platform-circularbuffer
FAIL mbed-os-tests-mbed_platform-critical_section (Test critical section C API)
OK   mbed-os-tests-mbed_platform-error_handling
OK   mbed-os-tests-mbed_platform-filehandle
OK   mbed-os-tests-mbed_platform-sharedptr
OK   mbed-os-tests-mbed_platform-singletonptr
FAIL mbed-os-tests-mbed_platform-stats_heap (allocation failure)
OK   mbed-os-tests-mbed_platform-stream
FAIL mbed-os-tests-mbed_platform-system_reset (mbed-os-tests-mbed_platform-system_reset)
OK   mbed-os-tests-mbed_platform-transaction
OK   mbed-os-tests-mbed_platform-wait_ns
OK   mbed-os-tests-mbedmicro-mbed-attributes
OK   mbed-os-tests-mbedmicro-mbed-call_before_main
OK   mbed-os-tests-mbedmicro-mbed-cpp
OK   mbed-os-tests-mbedmicro-mbed-div
OK   mbed-os-tests-mbedmicro-mbed-static_assert
OK   mbed-os-tests-mbedmicro-rtos-mbed-basic
OK   mbed-os-tests-mbedmicro-rtos-mbed-condition_variable
OK   mbed-os-tests-mbedmicro-rtos-mbed-event_flags
OK   mbed-os-tests-mbedmicro-rtos-mbed-heap_and_stack
OK   mbed-os-tests-mbedmicro-rtos-mbed-kernel_tick_count
OK   mbed-os-tests-mbedmicro-rtos-mbed-mail
OK   mbed-os-tests-mbedmicro-rtos-mbed-malloc
OK   mbed-os-tests-mbedmicro-rtos-mbed-memorypool
OK   mbed-os-tests-mbedmicro-rtos-mbed-mutex
OK   mbed-os-tests-mbedmicro-rtos-mbed-queue
OK   mbed-os-tests-mbedmicro-rtos-mbed-rtostimer
OK   mbed-os-tests-mbedmicro-rtos-mbed-semaphore
OK   mbed-os-tests-mbedmicro-rtos-mbed-signals
OK   mbed-os-tests-mbedmicro-rtos-mbed-threads
OK   mbed-os-tests-mbedtls-multi
OK   mbed-os-tests-mbedtls-selftest
OK   mbed-os-tests-network-l3ip

janjongboom referenced this pull request Mar 7, 2019
Add the function analogout_pinmap to all targets.
@cmonr
Copy link
Contributor

cmonr commented Mar 19, 2019

@janjongboom I take it work on this PR is still ongoing, correct?

@janjongboom
Copy link
Contributor Author

@cmonr Yes, still need to do IAR linker script.

@mbed-ci
Copy link

mbed-ci commented Apr 17, 2019

Test run: FAILED

Summary: 2 of 7 test jobs failed
Build number : 4
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-GCC_ARM
  • jenkins-ci/mbed-os-ci_mbed2-build-GCC_ARM

@adbridge
Copy link
Contributor

adbridge commented May 1, 2019

@janjongboom any update on this ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 3, 2019

We can close this and reopen when there is an update.

@0xc0170 0xc0170 closed this Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SAML21 ticker only fires when set to 1ms. or higher