SAMD21J18A compiling error

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

 

Hi all, 

I'm working on an Arduino project using an Arduino Zero based board with a SAMD21J18A. If I create a new project in ATMEL Studio, indicating I'm using an Arduino Zero, I have to choose SAMD21G18A.

I select the tool ( I have a j-link 261000470 ), which in other projects it's able to upload bootloaders and FWs.

If I compile with SAMD21G18A I don't have errors, while if I upload I rightly have an error cause the SAMD version is not correct.

I change device to SAMD21J18A but if I compile again I have the following error: 

If I switch back to the SAMD21G18A the error still exists and I'm not able to compile anymore. What's wrong?

 

 

Last Edited: Wed. Jan 29, 2020 - 11:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

acutone,

 

I'm trying to do the same thing and have the exact same results. I will point out a few other things I have noticed and tried. There are 2 "projects" when you bring an arduino sketch into Atmel studio. The arduino core and then your sketch portion. After changing the chip in both portions the arduino core will compile correctly. The failure happens when building the sketch portion. Also notice when you change the device in the sketch portion Atmel Studio adds a "Device Startup" folder that contain linker scripts that are similar to the ones in the "linker scripts" folder. Building at this point you get the error you mention. Deleting the linker files below will allow it to successfully build. The problem is when you load the program into a real chip it is instantly in a invalid memory location. The layout of the chip memory addresses are different. My hunch is you would need to edit the linker script in in the "linker_scripts" folder to match the layout of the SAMD21J18A. Note that there is one for with and one for without bootloader, but I doubt it does anything with the bootloader one if you're using ICE to program it.

linker files

 

If someone could verify this and explain what needs to be changed, that'd be great. Otherwise, let my know if I'm way off base.

 

Adam

Adam

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

Hope this helps someone, I think I have it figured out:

 

I was incorrect, the SAMD21G18A (Arduino Zero chip) and the SAMD21J18A have the same memory layout. What's going on is when you change the device, atmel studio also changes your linker flags under the toolchain tab. It points at the new .ld files. Copy the flag string before changing the device and then paste it back in after. There is still some work to do after this in the variants.cpp file to map IO pins and such. see https://hackaday.io/project/8007....

 

Adam

Adam