Skip to content

Conversation

@aabadie
Copy link
Contributor

@aabadie aabadie commented Feb 28, 2017

This PR adds a partial support for the Arduino MKR1000 board.

This board uses the same MCU as the Arduino Zero : a SAMD21G18A. But apparently, one has to keep the bootloader at the beginning of the flash memory : as a consequence I added a custom linker script.

The debug UART is also not available via the USB port so one needs an FTDI plugged on the RX/TX pins (pins number 13/14) on the board to access it.

Last thing (but not least) : to flash the board via USB, one needs to use Bossa (like for Arduino-due). For the moment, I have to double press the reset button each time I want to flash the board. This is not very convenient and it's not necessary with the Arduino IDE.

Adding an SPI driver for the ATWINC1500 Wifi module will also be required if one wants to add WiFi to this board.

@aabadie aabadie added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Feb 28, 2017
@aabadie aabadie added this to the Release 2017.04 milestone Feb 28, 2017
@aabadie aabadie force-pushed the mkr1000 branch 2 times, most recently from 1149bd0 to f6a3d83 Compare March 10, 2017 17:11
@aabadie
Copy link
Contributor Author

aabadie commented Mar 31, 2017

@haukepetersen, interested in testing this one ?

@aabadie
Copy link
Contributor Author

aabadie commented Apr 14, 2017

I'm planning to add the wifi driver soon using a package from WiFi101 repository. But I prefer adding this in a follow-up PR. Are there people interested in testing this PR so we can merge it fast ?

@aabadie aabadie force-pushed the mkr1000 branch 2 times, most recently from 956807c to 08fe0e2 Compare April 18, 2017 12:12
@aabadie aabadie added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Apr 25, 2017
@kbumsik
Copy link
Contributor

kbumsik commented May 2, 2017

Hi, I came from #6985 . I am currently merging your branch with my work. I have a question before making a PR to you branch, because I have no experience with programming with BOSSA: Why does Linkerscript's flash address start with 0x2000? Can't BOSSA access to system memory, or you want keep arduino bootloader?

@aabadie
Copy link
Contributor Author

aabadie commented May 3, 2017

@kbumsik I merged your PR. Thanks ! I you could give your test result of this PR (flash, ADC, PWM, UART, etc) that would be great and we could merge it fast.
I'm also looking forward your PR with the ATWINC1500 driver :)

@kbumsik
Copy link
Contributor

kbumsik commented May 3, 2017

@aabadie Thanks for a quick feedback :) I will work on ATWINC1500 driver targeting both MKR1000 and WINC1500 XPlained Pro.
For testing, I can confirm that example/default UART terminal example, with pin TX: D14, RX: D13, works perfectly for now. I will update more testing result later.

@kbumsik
Copy link
Contributor

kbumsik commented May 6, 2017

This needs rebase and a fix for ADC after #7009.

@aabadie
Copy link
Contributor Author

aabadie commented May 10, 2017

@kaspar030, I would go for option 3. Seems to be the more reasonable for me: point 1 break "we support latest Ubuntu LTS" as you said and point 2 breaks full cppcheck support (sam0.h is not a vendor file but RIOT code).

include $(RIOTMAKE)/tools/jlink.inc.mk

# set default serial port depending on operating system
PORT_LINUX ?= /dev/ttyUSB0
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be ttyACM0 for independent of the programmer, right? So IMHO these two lines should be taken out of this if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean with independent of the programmer ?
The board USB port is /dev/ttyACM0 but I don't know how it behaves if ones uses the JLINK programmer which I didn't test. If @kbumsik set it to /dev/ttyUSB0 there's probably a good reason.

Copy link
Contributor

@kbumsik kbumsik May 11, 2017

Choose a reason for hiding this comment

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

I copied Makefile from stm32f4 discovery. Just like the case in stm32f4 discovery, /dev/ttyUSB0 is for UART serial converter. So you are right - this is independent to the JLink. I added this when I didn't know how bossac works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, ok, I understand now (sorry, for the delay...!)

# when BOSSA is used, use a different flash map
# refer https://github.com/shumatech/BOSSA for this programmer
export PROGRAMMER = bossa
export CPU_MODEL = samd21g18a_mkr1000
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a different CPU model here? If it is because of the different linkerscript, then it would be the cleaner solution to override the linkerscript variable here directly!

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 was not aware of this variable, I'll change that as you suggest

@@ -0,0 +1,7 @@
source [find interface/cmsis-dap.cfg]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this board support being flashed using openocd through CMSIS-DAP? If so, this option is not usable as there is no option the board's Makefile.include... So I'd say either remove this file or add the needed options to the Makefile.include

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not. We can just remove ir.

*/
#define XTIMER TIMER_0
#define XTIMER_CHAN (0)
/** @} */
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for this block, as these are the default values. Just remove them.

#elif defined(CPU_MODEL_SAMD21G17AU)
#include "vendor/samd21/include/samd21g17au.h"
#elif defined(CPU_MODEL_SAMD21G18A)
#elif defined(CPU_MODEL_SAMD21G18A) || defined(CPU_MODEL_SAMD21G18A_MKR1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

as stated above, there should be no need for this varaible.

@haukepetersen
Copy link
Contributor

About the Murdock issue: sam0.h should be ignored in any case, as this is basically vendor header. My proposed solution: #7038. Does this fix the timeout?

@haukepetersen
Copy link
Contributor

One more question: I was not able to flash the board, as bossac gives me some GLIB errors:

/home/hauke/dev/riot/RIOT/boards/arduino-mkr1000/dist/flash.sh 
/home/hauke/dev/riot/RIOT/boards/arduino-mkr1000/dist/bossac: relocation error: /home/hauke/dev/riot/RIOT/boards/arduino-mkr1000/dist/bossac: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
make: *** [flash] Error 127

Does anyone have a quick solution to this?

@aabadie
Copy link
Contributor Author

aabadie commented May 11, 2017

Does anyone have a quick solution to this?

The bossa binary was built on my Linux using gcc 6.2. I probably have a too recent glibc and this is not compatible with yours. I'll rebuild it using an older Ubuntu (16.04)

@aabadie
Copy link
Contributor Author

aabadie commented May 11, 2017

@haukepetersen, except your bossa issue, your other comments are addressed.

@haukepetersen
Copy link
Contributor

Changes look good. I still can't flash my board (played around with some bossac versions and compiled it myself for a try), but it seems in the end I bricked my board... It doesn't register as /dev/ttyACM0 anymore...

About the bossa issue: I think it would make much sense (as a next step) to include it in form of a Makefile as part of the RIOT tools folder and get rid of the binaries for the arduino sam based boards after all. This way, users of these boards can build their bossac themselves and we get around shipping binaries (which was always sub-optimal). What do you think?

Copy link
Contributor

@haukepetersen haukepetersen left a comment

Choose a reason for hiding this comment

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

Untested ACK (as my board seems bricked)

@kbumsik
Copy link
Contributor

kbumsik commented May 12, 2017

@haukepetersen , I am not sure it is your case, once you flash the MKR1000 using Bossa, it normally won't go back to the bootloader mode so you won't see it as tty device. If you want to flash it again, you may double press the reset button and it will go to the bootloader mode. The board will tell you it is in the bootloader mode by slowly blinking the green LED.

@haukepetersen
Copy link
Contributor

Sounds like a plan :-) Will give it a try...

@aabadie
Copy link
Contributor Author

aabadie commented May 12, 2017

About the bossa issue: I think it would make much sense (as a next step) to include it in form of a Makefile as part of the RIOT tools folder

+1 good idea

@aabadie
Copy link
Contributor Author

aabadie commented May 12, 2017

@haukepetersen, regarding the "bricked" board, as @kbumsik said, just double press the reset button before flashing. I initially added a comment about that in flash script
Thinking of it, the stty line is probably useless (originally copy pasted from arduino-due)

# when BOSSA is used (default), use a different flash map
# refer https://github.com/shumatech/BOSSA for this programmer
export PROGRAMMER = bossa
export LINKER_SCRIPT ?= $(RIOTCPU)/$(CPU)/ldscripts/$(CPU_MODEL)_mkr1000.ld
Copy link
Contributor

@haukepetersen haukepetersen May 12, 2017

Choose a reason for hiding this comment

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

The path to the linkerscript must be $(RIOTCPU)/sam0/ldscripts/$(CPU_MODEL)_mkr1000.ld
EDIT:
$(RIOTCPU)/sam0_common/ldscripts/$(CPU_MODEL)_mkr1000.ld

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, missed that change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@aabadie aabadie force-pushed the mkr1000 branch 2 times, most recently from 6cd8024 to 6158fac Compare May 13, 2017 17:43
@haukepetersen
Copy link
Contributor

Looks good to me now, though the issue with the bossa tool remains. We should simply include a global build script/Makefile in RIOT to build that tool - and then use that for the mkr1000, the due, and udoo. Maybe I find time to look into this... But until then, I am ok with merging this PR -> please squash.

@aabadie
Copy link
Contributor Author

aabadie commented May 16, 2017

squashed and rebased.

@haukepetersen
Copy link
Contributor

Murdock is happy -> let's go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants