I noticed the boatloader currently expects a 32MHz clock. My plan is to see if the timer setup can be refactored to make the 32MHz clock setup optional (though it seems I will also need to look at the reset routines).
This way, I can potentially make bootloaders derived on the Arduino Zero, but having the 32MHz timer become optional.
I want to do this to make it easier for makers to develop with the Atmel SAM D21 and R21 line of chips - not just the larger ATSAMD21G18A.
If anyone has any suggestions (or you are already working on this), I would love to hear back.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
...the 32MHz crystal isn't required to build an basic microcontroller circuit with the SAM D21/R21 line of chips. However, I noticed the Arduino Zero bootloader has timer set up routines that enable it 100% of the time (because it is for the Arduino Zero board, which has such a crystal attached).
I am talking about ArduinoCore-samd/bootloader/zero/board_init.c, line 54
...I was thinking surrounding some of the routines in this file w/ #ifdef/#else#endif blocks would allow us to use the Arduino Zero bootloader code, and supply different bits of code to support the same SAM D21/R21 chips without a 32MHz crystal. This is a preliminary thought, of course.
I would additionally add variants specific to each SAM D21/R21 variant (G, E, etc).
Currently, attempting to use the Arduino Zero bootloader on a board w/o a 32MHz crystal will simply not begin program execution, as the first clock tick doesn't seem to occur.
Hahaha...you are correct. 32kHz, ...my apologies.
I have some Atmel examples working with the internal 8MHz oscillator (prescale set to 0) for the SAM R21 (ATSAMR21E18A). https://github.com/femtoio/samr21-xplained-pro
...but if I am not working with the correct bootloader source code, does anyone know where the correct one is at?
If I succeed, I want to be certain I am contributing correctly.
Thanks in advance.
- Alex
Hi,
I have provided some patches on the bootloader which are in mainline but integrated after the generation of samd package v1.6.2.
Next release will come with what you see in mainline.
The use of 32k external oscillator in bootloader bring a better stability of usb during sketch binary transfer.
If you don't intend to use bossa/usb, you can keep the setup clock configuration which is 1MHz on internal RC.
Otherwise, you may meet broken USB transfers.
Besides that, if you don't intend to have an external 32kHz oscillator on your board, be careful on how you expect using it: an internal RC isn't as precise (ie has some jitter) as a real external one and may bring you issues while using some peripherals like usart, i2c and spi, depending on the components plugged to them. Obviously, these peripherals are less sensitive than USB.
Cheers,
T.
Thanks Thibaut.
As I understood it, there should not be a problem with the SAM D21 USB while the main oscillator is 48MHz. The Atmel data sheet warns of USB problems, but it appears to apply when the main oscillator is below 48MHZ.
I am able to operate a bare SAM D21 board with only a 48MHz clock source and the recommended caps/resistors etc. Note, however, I have not tested extensively.
Updates via the BOSSA tool work without error.
Would you mind providing a link to your repository? I'd love to collaborate where possible.
Blink example (C source) for SAM D21
https://github.com/femtoio/femto-usb-blink-example/blob/master/README.md
EAGLE PCB files, OpenOCD config: https://github.com/femtoio/femto-usb
Thank you Thibaut,
For now, I am simply going to copy the Arduino Zero variant, and adjust the pins to work with the ATSAMD21E18A. The SAM-BA bootloader from Atmel works fine (I can upload sketches to the SAM D21 E chip just fine), so I can probably get a working barebones board w/ SAM-BA + the new ATSAMD21E18A board variant that I'm piecing together.
I'll report back with progress. Stay tuned. :-)
Need help with layout I can help. Just decide what you want similar to pi zero?
@all I have made my current progress available on my git fork ("atsamd21e18a_variant" branch)
...I've copied the Arduino Zero variant, and modified the pin description map, along with the header file. The debug and linker scripts have been left as-is.
https://github.com/femtoio/ArduinoCore-samd/tree/atsamd21e18a_variant
I'll test it out later today. Coincidentally, if anyone knows where I can find info on packaging/loading into my Arduino IDE, I would appreciate the info.
Thanks
Status update: I am able to load sketches using the new "atsamd21e18a" variant.
I am currently attempting to figure if/how I can configure the Serial object to work w/ SerialUSB ...currently, it just makes my board unavailable over USB, so I'm obviously missing something. :-)
Fwiw, I am also making a simple node.js based server to serve a package JSON and tar.bz2 achive so I can have the Arduino IDE load my package archive from localhost:8080
Stay tuned!
- Alex Albino
...meh... The benefits outweigh the costs. For future note, SAM D21/R21 designs that wish to use the Arduino Zero bootloader (or a portion thereof) should simply add a 32.768kHZ external clock.
I've updated my FemtoUSB design to r1.0.1 and will test my derivative work (Arduino Zero core, but with a different pin config in variant.h and variant.c)
...I'll report back w/ progress and updates. Stay tuned.
SUCCESS!!!
I have a modified Arduino Zero core that works with the Atmel SAM D21 E variant.
See https://github.com/femtoio/ArduinoCore-samd/tree/atsamd21e18a_variant?files=1
I am able to create my own package JSON file, along w/ corresponding SHA-256 checksum, and host it locally using my femtoio/Arduino-LocalTestRepo node server.
...The femtoio/femto-usb (femto-usb-r1.0.1 branch) repo has an arduino example named "Serial_Hello".
A simple "Hello" is output every second to the Serial Window using SerialUSB.
See https://github.com/femtoio/femto-usb/tree/femto-usb-r1.0.1?files=1
...I am now waiting on PCBs to test USB Host mode w/ Arduino.
...I wanted to express my sincere thanks to the Arduino developer community for their solid work on the Arduino Zero core.
I am especially grateful for the SerialUSB feature.
Is there a preferred way to contribute back to the Arduino developer community? Is code OK? (Should I send someone a six-pack of beer?)
- Alex
Hi David!
Yes, I have a customized board package based on the Arduino Zero core (bootloader is left as-is).
..I just don't have anywhere to deploy/host the generated package with an HTTPS connection yet. Working on it.
See https://github.com/femtoio/ArduinoCore-samd/tree/atsamd21e18a_variant?files=1
- Alex
David - Ah OK cool. I'll try digging around to see how I can configure my package accordingly and only the necessary files.
I am going to try hosting my package archive and JSON via github pages, thanks for the suggestion. :-)
- Alex
Massimo - Ah ok cool. I'll give that a try too then. :-)
- Alex
Hi Alex,
At the moment, i serve my packages using github releases service and it works fine.
I didn't know about rawgit and will take a look at it. Thanks Massimo for the hint.
It may not be an option if the package files have to be in the git repo, contrary to github release which leaves the repo free of build results.
Cheers,
Thibaut
Well, I now have hourly releases of the Atmel ATSAMD21E18A core work available. See the hourly build instructions at: https://github.com/femtoio/ArduinoCore-atsamd21e18a/tree/atsamd21e18a_variant
...ended up just hosting on one of my own servers. Should be OK for development.
- Alex
Alex, are you really sure r21e doesn't have any pin for osc32?
I don't have the datasheet in front of me but i feel weird about this point as this is the basis of the device functionality
T.
@Thibaut
From what I read, PA00 and PA01 (available only on the G variant) are used as the pins to a 32.768KHz clock source.
The E variant does not appear to have PA00 and PA01, nor does the datasheet mention any other pins for a 32KHz clock source on the E variant.
Perhaps I missed something in the data sheet?
- Alex
SAM R21 oscillator (not available in SAMR21E) is optimized for very low power consumption, hence close attention
should be made when selecting crystals, see Table 44-6 for maximum ESR recommendations on 9pF and 12.5pF
crystals .
@Peter
...I suspect the discrepancy regarding data sheet section numbers is due to me using a slightly older data sheet PDF. Sorry about that.
Ok, I guess the next logical step is to have the Arduino Zero core for SAM R21 E variant use the internal 32.768KHz clock source instead. I'll give it a go.
- Alex
Hi,
This is where i would suggest to move the startup file to the variant folder instead of keeping it in the core api.
It came naturally to me while experimenting here: https://github.com/aethaniel/ExperimentalCore-sam
@Thibaut Thanks for the heads up.
I'll report back w/ progress over the next few days. Stay tuned!
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c: In function 'init':
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:82:41: error: 'PM_APBCMASK_DAC' undeclared (first use in this function)
PM->APBCMASK.reg |= PM_APBCMASK_ADC | PM_APBCMASK_DAC ;
^
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:82:41: note: each undeclared identifier is reported only once for each function it appears in
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:122:11: error: 'DAC' undeclared (first use in this function)
while ( DAC->STATUS.bit.SYNCBUSY == 1 ); // Wait for synchronization of registers between the clock domains
^
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:123:20: error: 'DAC_CTRLB_REFSEL_AVCC' undeclared (first use in this function)
DAC->CTRLB.reg = DAC_CTRLB_REFSEL_AVCC | // Using the 3.3V reference
^
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:124:20: error: 'DAC_CTRLB_EOEN' undeclared (first use in this function)
DAC_CTRLB_EOEN ; // External Output Enable (Vout)
^
exit status 1
Error compiling.
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c: In function 'init':
/home/aalbino/.arduino15/packages/arduino/hardware/samd/1.6.3/cores/arduino/wiring.c:82:41: error: 'PM_APBCMASK_DAC' undeclared (first use in this function)
PM->APBCMASK.reg |= PM_APBCMASK_ADC | PM_APBCMASK_DAC ;
Creating build folder
mkdir build
make: *** No rule to make target 'build/board_driver_led.o', needed by 'samd21_sam_ba.elf'. Stop.
Hi Alex,
I didn't have time yet to finish and publish the samr21 variant. That's why you met some issues.
I'm in business trip at the moment and unable to fix quickly.
Sorry for inconvenience.
T.
@Thibaut - Ah ok, no worries. I modified a copy of the arduino core locally. I added #ifdef and #ifndef blocks appropriately to make DAC setup optional.
I made my own SAMR21 USB header (based on the SAMD21 USB header file) to compensate for differences in structures between SAM D21 and SAM R21.
I've also modified the startup file to use the internal 32.768KHz source for clock 1. It compiles, but doesn't seem to start up - so I'll keep messing with it until it works :-)
- Alex
It seems I will need to step through start up and see why my modified copy of the zero bootloader is halting w/ segfaults...
Uploading a plain samd21e18a sam-ba bootloader from Atmel works fine.
Guess I can comment out everything but the most essential parts and start un-commenting stuff a little at a time to see what is causing segfaults.
On a related note, the segfaults are what appears to lock up the chip, preventing subsequent bootloader burns until the SAM ICE debugger + chip is powered off and on again.
- Alex
I've (mostly) gotten the SAM R21 E working... Except for a minor issue with DLLFP48 closed loop configuration. ...I'll swap out crystals to assert I'm using 48MHz crystals on the XIN/XOUT pins and try again in the AM. I may have to try open loop mode. I'm not particularly happy about using the internal 32KHz clock source instead of an external one, but if it works, it works.
I've heavily modified my variant's usb related setup (never mind my previous comments on the .vec property, I was wrong)
Thankfully, I'm able to step through execution and see where the code is hanging (Eclipse + GNU ARM Eclipse tools)
Stay tuned.
- Alex
...ok, I've figured out clock startup settings. It turns out (after reading the SAM R21 datasheet once more) that the XOSC inputs go from 0.4 to 32MHz, not 48MHz as I had erroneously thought. DFLL and FDLL clock setup can still happen, generating 48MHz and 96MHz clocks internally. The internal OSC32K clock can be enabled to generate 32.768KHz.
I referenced the SAM R21 XPlained Pro schematic and noticed a 12MHz crystal. I have ordered a small quantity of replacement crystals and will retry USB CDC operations in a few days.
Sincerely,
Alex Albino
I DID IT!!!
Arduino bootloader for SAM R21E (the chip on my open-source FemtoBeacon)
Code is available here:
https://github.com/femtoio/ArduinoCore-atsamd21e18a/tree/atsamd21e18a_variant?files=1
Sincerely,
Alex Albino
It is. See the femtoIO github repo for ArduinoCore-atsamd21e18 ...I've simply included the SAM R21E18A variant along with the SAM D21E18A variant.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.
Thank you Cristian! I appreciate your help. :-)
Cristian - will there be a version bump that includes the latest BOSSA updates? (Currently, BOSSA is "1.6.1-arduino")
I tried downloading the latest Arduino IDE, Arduino Zero core/bootloader, ...but it seems I ended up w/ an older version of BOSSA.
Thank you for your help, I greatly appreciate it.
- Alex