Integrating Sparkfun SAMD21 mini in Atmel studio 7

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I want to program SAMD21G18 from AS7 that's why I want to integrate Sparkfun SAMD21 mini breakout board in AS7 so that I can directly program it from there via USB(without any external debugger/Programmer).The board uses SAM-BA protocol as it's default upload protocol as I can see from the Arduino 'boards.txt' file.I was able to program AVRs by configuring external tools by configuring Commands & Arguments.Is there anything same to program the SAMD21 from AS7 directly??

Please help...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok,I figured out something but not receiving anything in the output window.I studied the Arduino output window & found that the Arduino is using "Bossac.exe" as the tool to burn the program to the SAMD.But one thing I noticed that looksconfusing.The physical port is COM29 but the port is being used while burning is COM28 in Arduino output window.Please take a look..

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Sharanya\AppData\Local\Arduino15\packages -hardware C:\Users\Sharanya\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Sharanya\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Sharanya\Documents\Arduino\libraries -fqbn=SparkFun:samd:samd21_mini -vid-pid=0X1B4F_0X8D21 -ide-version=10808 -build-path C:\Users\Sharanya\AppData\Local\Temp\arduino_build_614083 -warnings=none -build-cache C:\Users\Sharanya\AppData\Local\Temp\arduino_cache_681658 -prefs=build.warn_data_percentage=75 -verbose C:\Users\Sharanya\AppData\Local\Temp\untitled783495375.tmp\sketch_jun11a\sketch_jun11a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Sharanya\AppData\Local\Arduino15\packages -hardware C:\Users\Sharanya\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Sharanya\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Sharanya\Documents\Arduino\libraries -fqbn=SparkFun:samd:samd21_mini -vid-pid=0X1B4F_0X8D21 -ide-version=10808 -build-path C:\Users\Sharanya\AppData\Local\Temp\arduino_build_614083 -warnings=none -build-cache C:\Users\Sharanya\AppData\Local\Temp\arduino_cache_681658 -prefs=build.warn_data_percentage=75 -verbose C:\Users\Sharanya\AppData\Local\Temp\untitled783495375.tmp\sketch_jun11a\sketch_jun11a.ino
Using board 'samd21_mini' from platform in folder: C:\Users\Sharanya\AppData\Local\Arduino15\packages\SparkFun\hardware\samd\1.5.4
Using core 'arduino' from platform in folder: C:\Users\Sharanya\AppData\Local\Arduino15\packages\SparkFun\hardware\samd\1.5.4
Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
Detecting libraries used...
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSB_VID=0x1B4F -DUSB_PID=0x8D21 -DUSBCON "-DUSB_MANUFACTURER=\"SparkFun\"" "-DUSB_PRODUCT=\"SFE SAMD21\"" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.1.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\variants\\SparkFun_SAMD_Mini" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch\\sketch_jun11a.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSB_VID=0x1B4F -DUSB_PID=0x8D21 -DUSBCON "-DUSB_MANUFACTURER=\"SparkFun\"" "-DUSB_PRODUCT=\"SFE SAMD21\"" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.1.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\variants\\SparkFun_SAMD_Mini" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch\\sketch_jun11a.ino.cpp" -o "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10808 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSB_VID=0x1B4F -DUSB_PID=0x8D21 -DUSBCON "-DUSB_MANUFACTURER=\"SparkFun\"" "-DUSB_PRODUCT=\"SFE SAMD21\"" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.1.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\variants\\SparkFun_SAMD_Mini" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch\\sketch_jun11a.ino.cpp" -o "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch\\sketch_jun11a.ino.cpp.o"
Compiling libraries...
Compiling core...
Using previously compiled file: C:\Users\Sharanya\AppData\Local\Temp\arduino_build_614083\core\variant.cpp.o
Using precompiled core: C:\Users\Sharanya\AppData\Local\Temp\arduino_cache_681658\core\core_SparkFun_samd_samd21_mini_a163b8e84c95bfe270c95759f99a4fb0.a
Linking everything together...
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-gcc" "-LC:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083" -Os -Wl,--gc-sections -save-temps "-TC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\samd\\1.5.4\\variants\\SparkFun_SAMD_Mini/linker_scripts/gcc/flash_with_bootloader.ld" "-Wl,-Map,C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.map" --specs=nano.specs --specs=nosys.specs -mcpu=cortex-m0plus -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -o "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.elf" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch\\sketch_jun11a.ino.cpp.o" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\core\\variant.cpp.o" -Wl,--start-group "-LC:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Lib/GCC/" -larm_cortexM0l_math -lm "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/..\\arduino_cache_681658\\core\\core_SparkFun_samd_samd21_mini_a163b8e84c95bfe270c95759f99a4fb0.a" -Wl,--end-group
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/\\arm-none-eabi-size.exe" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083\\sketch_jun11a.ino.elf"
   text	   data	    bss	    dec	    hex	filename

  10016	    256	   1776	  12048	   2f10	C:\Users\Sharanya\AppData\Local\Temp\arduino_build_614083\sketch_jun11a.ino.elf

"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O binary "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.elf" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.bin"
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.elf" "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.hex"
"C:\\Users\\Sharanya\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-size" -A "C:\\Users\\Sharanya\\AppData\\Local\\Temp\\arduino_build_614083/sketch_jun11a.ino.elf"
Sketch uses 10016 bytes (3%) of program storage space. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port COM29
PORTS {COM29, } / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {COM28, } => {COM28, }
Found upload port: COM28
C:\Users\Sharanya\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0/bossac.exe -i -d --port=COM28 -U true -i -e -w -v C:\Users\Sharanya\AppData\Local\Temp\arduino_build_614083/sketch_jun11a.ino.bin -R 
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Version      : v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.817 seconds

Write 10272 bytes to flash (161 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

[===========                   ] 39% (64/161 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)

[=======================       ] 79% (128/161 pages)write(addr=0x20005000,size=0x840)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x840)

[==============================] 100% (161/161 pages)
done in 0.067 seconds

Verify 10272 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 1430
checksumBuffer(start_addr=0x3000, size=0x1000) = 196d
checksumBuffer(start_addr=0x4000, size=0x820) = ffbf
Verify successful
done in 0.009 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)

Now,I configured an external tool is AS7 like this below:

 

Title: SAMD21 Spakfun Mini

Command: C:\Users\Sharanya\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0\bossac.exe

Arguments: -i -d --port=COM29 -U true -i -e -w -v "$(TargetDir)$(TargetName).bin" -R

 

But the program seems to hang & doing nothing.I also tried with COM28 but that is returning "No device found on COM28".I am unable ti odentify what is getting wrong.Please help....

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hallo,

 

Ive done a similar thing a while ago getting the ADAFruit Feather M0 ATSAMD21 working with Atmel Studio 7, which is also programmed via the USB port with Bossa

 

I am attaching the Atmel Studio project I posted on the ADAFruit forum earlier, where I got the whole project configuration and program download with bossa integrated into atmel studio.

 

Look at the start of main.c for how to:

 

2. Ofsetting the start address of your program

3. Installing the Bossac command line programmer

4. Start.Atmel project creation

 

Hope this helps you

 

Regards

 

Gert van Biljon

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I have done the followings:

 

Offsetting the start address by adding the following lines in the Linker Flasgs.But that is also not helping....

 

 -Wl,--section-start=.text=0x2000

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok,I am able to communicate & read the device signature now.I had to hit the reset button twice & send the board to bootloader mode.But I am unable to program the chip as it is being hanged at 0% write.I am getting message like this below:

 

Set binary mode
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
readWord(addr=0x41004018)=0
readByte(addr=0x804001)=0xc7
readByte(addr=0x804001)=0xc7
readByte(addr=0x804006)=0xff
readByte(addr=0x804007)=0xff
Device       : ATSAMD21x18
Version      : v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Address      : 0x0
Pages        : 4096
Page Size    : 64 bytes
Total Size   : 256KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
BOD          : true
BOR          : true
Erase flash
chipErase(addr=0)

Done in 5.000 seconds
Write 2068 bytes to flash (33 pages)

[                              ] 0% (0/33 pages)

 

Reseting/power cycling the board is resulting the bootloader to stop working(No USB device found after the reset/power cycle).I had to burn the bootloader again using the Atmel ICE.

Also,this below mentioned Arguement is returning "Extra arguement found" message from Bossa.

 

Arguement: -i -d --port=COM28 -U true -i -e -w -v "$(TargetDir)$(TargetName).bin" -R

 

But,when I am omitting -U true,the chip is responding but stuck at 0% write.Please suggest what to do!!

 

Another thing is ,How Arduino IDE resets the board resulting the chip to go into bootloader?? Is this somehow possible without hitting the reset button twice when trying to program from Atmel studio??

 

 

Last Edited: Tue. Jun 11, 2019 - 03:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After some digging in the internet & testing through the whole afternoon & evening,here is the result.....

 

The Arduino IDE sets 1200 baud rate then open & closes the COM port to send the SAMD21 into bootloader mode.By opening & closing the COM port @1200bps,The CPU is "soft erased" & the device is restarted into bootloader mode.

Now,I tried that & got success from a normal Serial Terminal to send the CPU into bootloader mode.

In the next part,in the Arguements i.e -i -e -w -v,the -e stands for erase total device.It is surely erasing the whole flash starting from memory location 0 including the bootloader as you can see from this line in the dump I provided in the last post:

Address      : 0x0

Just compare it with the Arduino dump & you can clearly see that

Address : 8192. (i.e 0x2000)

I think adding this line i.e ' -Wl,--section-start=.text=0x2000 '  in the linker flags is having no effect.Also,i didn,t find any option to start erasing from some particular memory address(i.e 0x2000) in the Bossac.exe.

 

Now I tried two thing,

 

1)I removed the -e arguement in the external tools section using the Bossac.exe (version 1.9) which I downloaded manually.But gave me the same result.

 

2)I removed the -e arguement & changed the path of the Bossac.exe to Arduino's tools Bossac (version 1.7) & tried burning.

 

Now,i was able to enter into the debug mode & programming gets completed starting from location 0x2000.But the CPU is unable to come outside of bootloader mode.Verify is getting failed.

But when tried to burn bootloader with Atmel ICE,the USB port didn't show up in the PC like before.Afte resetting the board several times & burning bootloader,the COM port showed up.

 

Please explain,if there is any straightforward way!!I am getting frustrated with AS7..... 

 

 

 

 

Last Edited: Tue. Jun 11, 2019 - 05:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I almost solved it

But

with only one problem.

 

When I am freshly attaching the SAMD21 board to program with Arduino IDE,the COMPORT is 29.During the reset,it is entering into bootloader & COMPORT is now become 28.After programming done,the COMPORT is then changed back to 29(i can see USB to Serial in device manager also) .

 

I have managed to to modify a batch file as mentioned in this link & automated the whole programming process into a single click.

Now,when programming from Atmel studio,(testing with a blank program in both cases),after the program completes,the COMPORT29 as well as 28 is getting vanished.I have manually checked both output windows line by line but not found any differences(except the program size).But how the CPU backs to normal & COM#29 is showing immediately after programming finishes?????

But I am able to go into bootloader mode by double tap reset button after programming from Atmel studio as well as Arduino.To comeback to normal(attaching to PC & COM port showing up),I have to enter bootloader mode & burn a blank program from Arduino.

Is it somekind of code already working in the background in the Arduino to configure COMPORT#29 in normal condition which I am missing in Atmel studio?

 

Please give some reply why this is happening??

 

I am attaching both outputs from Arduino & Atmel studio output!

 

Arduino output:

Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Version      : v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.820 seconds

Write 10272 bytes to flash (161 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

[===========                   ] 39% (64/161 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)

[=======================       ] 79% (128/161 pages)write(addr=0x20005000,size=0x840)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x840)

[==============================] 100% (161/161 pages)
done in 0.075 seconds

Verify 10272 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 1430
checksumBuffer(start_addr=0x3000, size=0x1000) = 196d
checksumBuffer(start_addr=0x4000, size=0x820) = ffbf
Verify successful
done in 0.010 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)

Now,from manual cmd line output(as i am unable to catch the output when batch file finishes)

C:\Users\Sharanya>"C:\Users\Sharanya\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0/bossac.exe" -i -d --port=COM28 -U true -i -e -w -v "C:\Users\Sharanya\Desktop\SAMD21\SAMD21Test\SAMD21Test\Debug\SAMD21Test.bin" -R
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Version      : v2.0 [Arduino:XYZ] Nov 14 2016 13:12:03
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.821 seconds

Write 2036 bytes to flash (32 pages)
write(addr=0x20005000,size=0x800)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x800)
[==============================] 100% (32/32 pages)
done in 0.023 seconds

Verify 2036 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x7f4) = 6595
Verify successful
done in 0.006 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)

Please take a look & give your opinions....

Last Edited: Tue. Jun 11, 2019 - 08:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it somekind of code already working in the background in the Arduino to configure COMPORT#29 in normal condition which I am missing in Atmel studio?

Yes, you don't get a USB CDC COM port without code. You could look at the Arduino implementation for how to do this (or just make your application with Arduino).

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Ok,I got the USB CDC port working by the zip files gertvb provided earlier.Thanks a ton for this gertvb.I also changed the name from "Communication Device Class ASF example"(Previously appearing in device manager by this name) to "USB Serial Device"(So that my batch file can find by this name for com port # listing for auto reset).Now the device is listed in the device manager like below:

But

now resetting the CPU like the Arduino does i.e opening & closing the port @1200 baud is not working(Obvious,as i had to write some code regarding that I guess).Any suggestions about how to make the reset work & enter into bootloader mode??

 

I am attaching the modified file.Please take a look & reply guys!!

 

 

 

Attachment(s): 

Last Edited: Wed. Jun 12, 2019 - 10:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did someone check the files or have any sample program about how to do?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Arduino core implementation should be an example of how to do it I guess. I you don't know where that is in your installation then check "Show verbose output during compilation" in the Arduino IDE preferences and build something for a Feather M0.

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I already visited that part!.....But Arduino files greatly depends on various other files/middlewares & it is very much hectic to study all the files to reach to the bare metal programming function calls/definitions etc.

What i was wondering if there is any  simple & understanble bare metal programming sample available regarding USB CDC Serial programming!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just had a quick look at the Arduino code. I don’t think you’ll get it much simpler. There’s only three or four files for the code and what middleware are you talking about? It’s pretty easy to see where the hardware is initialised and the interrupts are instantiated. It helps if you have some knowlege of how usb works - there’s various phases in the connection, layers to the protocol and specific terminology.

A read of this might help: http://read.pudn.com/downloads126/ebook/534950/MindShare+Anderson2001+USB+System+Architecture+USB+2.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for the late reply!

I think at this stage,the thing what I intended to do,is pretty much heavy for me.I have to do a lot of study to accomplish that using bare metal programming.For now,I have ordered a Atmel SAMD21 XPRO board.I wish to learn about USB programming of SAMD21 using register level access.I have downloaded the PDF you provided!

Another teo things i would like to ask...

1)If any good book is available for SAMD21 programming.I've already purchased Mazidi's "Atmel Arm Programming for Embedded Systems" but it doesn't cover the USB programming....

2)Should I start programming using C++ or C for SAMD21??Which one will be more beneficial?I will use Atmel studio as my IDE.