Author Topic: Add one line of code to an existing GitHub project  (Read 3693 times)

0 Members and 1 Guest are viewing this topic.

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 859
  • Country: ca
Add one line of code to an existing GitHub project
« on: December 11, 2021, 07:19:00 pm »
Hi,

I'm an engineer not a programmer so out of my comfort zone beyond simple c type programming.

A while back I designed a custom PCB similar to Arduino MKRZERO, initially I used the same uC, a SAMD21G18. I wrote a fairly extensive program based on a custom board variant and had the whole thing working tickety-boo.

Fast forward to Covid and supply line disruptions and chip shortages I could not get the SAMD21G18 parts so I moved to the SAMD21G17. I built one of my custom boards with the 17 variation and the problem I have is that after successful compile and link when Arduino attempts to load the main program via the bootloader (using the open source bossac uploader), bossac does not recognize the G17 chip ID 0x10010093 and quits with an unrecognized chip ID message.

I know for a fact my code compiles and works because as a work around I compiled a no bootloader version and loaded it using atmel studio and a Segger programmer. The problem is I need to do further development and would like to simply do it using Arduino and do updates using the normal bootloader that uses bossac via the USB port (just like a conventional Arduino board and the way I was doing it when I had the G18A parts.)

A bit of google searching and bossa, and bossac are open source and available here: https://github.com/shumatech/BOSSA

I'm not the first one to have this problem and others have made branches of the original BOSSA and BOSSAC project to support other varieties of the SAMD processors, unfortunately, none with the G17D I'm using. See:

 https://github.com/mattairtech/ArduinoCore-samd
 https://github.com/ElectronicCats/BOSSA/releases/tag/v1.1.1

These branched versions actually supports some varieties of the SAMD21G17, just not the one I'm using. I'm pretty sure if just one line is added to device.cpp for the mattairtech branch, or a new section to the ElectronicCats branch in Devices.h and then compiled for Win7 (64), my problem would be solved.

mattairtech example

  case 0x10010001: // J17A
  case 0x10010006: // G17A
  case 0x10010093: // G17D    128KB FLASH 48TQFP           <--- this is the new line required at about line 456 in devices.cpp   there are 4 instances of G17A, however all have different chip ID's
   case 0x1001000b: // E17A
   case 0x10010010: // G17A WLCSP
            _family = FAMILY_SAMD21;
            flashPtr = new D2xNvmFlash(_samba, "ATSAMD21x17", 2048, 64, 0x20002000, 0x20004000) ;
            break;

---------------------------
ElectronicCats example Devices.h
#define ATSAMD21G17D_NAME                    "ATSAMD21G17D"
#define ATSAMD21G17D_CHIPID                  (0x10010093ul)  // DIE & REV bitfields masked in Samba::chipId()
#define ATSAMD21G17D_FLASH_BASE              (0x00000000ul + ATSAMD_BOOTLOADER_SIZE)
#define ATSAMD21G17D_FLASH_PAGE_SIZE         (64ul)
#define ATSAMD21G17D_FLASH_PAGES             (2048ul)
#define ATSAMD21G17D_FLASH_PLANES            (1ul)
#define ATSAMD21G17D_FLASH_LOCK_REGIONS      (16ul)
#define ATSAMD21G17D_BUFFER_ADDR             (0x20002000ul)
#define ATSAMD21G17D_STACK_ADDR              (0x20004000ul)
#define ATSAMD21G17D_NVMCTRL_BASE            (0x41004000ul)

If you can do that, please let me know and what you would charge.
J
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6389
  • Country: ca
  • Non-expert
Re: Add one line of code to an existing GitHub project
« Reply #1 on: December 13, 2021, 09:42:34 pm »
Isn't it easier to do development and debugging with Segger? Unless its an issue with getting at the SWD pins.
I would recommend VisualGDB or VisualMicro for IDE, so much better than Arduino IDE.

edit:
FlashFactory.cpp
Code: [Select]
case ATSAMD21G17D_CHIPID:
        flash = new NvmFlash( samba, ATSAMD21G17D_NAME, ATSAMD21G17D_FLASH_BASE, ATSAMD21G17D_FLASH_PAGES, ATSAMD21G17D_FLASH_PAGE_SIZE,
                              ATSAMD21G17D_FLASH_PLANES, ATSAMD21G17D_FLASH_LOCK_REGIONS, ATSAMD21G17D_BUFFER_ADDR, ATSAMD21G17D_STACK_ADDR,
                              ATSAMD21G17D_NVMCTRL_BASE, ATSAMD_BOD33_REG, ATSAMD_BOD33_REG_RESET_BIT, BOD33_REG_ENABLE_BIT, ATSAMD_FLASH_ROW_PAGES, /*isD51*/false, /*canBrownout*/true ) ;
        break ;
Samba.cpp
Code: [Select]
case ATSAMD21G17D_CHIPID: //added
Devices.h
Code: [Select]
#define ATSAMD21G17D_NAME                    "ATSAMD21G17D"
#define ATSAMD21G17D_CHIPID                  (0x10010093ul)  // DIE & REV bitfields masked in Samba::chipId()
#define ATSAMD21G17D_FLASH_BASE              (0x00000000ul + ATSAMD_BOOTLOADER_SIZE)
#define ATSAMD21G17D_FLASH_PAGE_SIZE         (64ul)
#define ATSAMD21G17D_FLASH_PAGES             (2048ul)
#define ATSAMD21G17D_FLASH_PLANES            (1ul)
#define ATSAMD21G17D_FLASH_LOCK_REGIONS      (16ul)
#define ATSAMD21G17D_BUFFER_ADDR             (0x20002000ul)
#define ATSAMD21G17D_STACK_ADDR              (0x20004000ul)
#define ATSAMD21G17D_NVMCTRL_BASE            (0x41004000ul)

but I don't see any easy way to compile in MSYS as I need wxwidgets2.8 package which I cannot locate.
« Last Edit: December 14, 2021, 12:10:55 am by thm_w »
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline ve7xen

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: ca
    • VE7XEN Blog
Re: Add one line of code to an existing GitHub project
« Reply #2 on: December 14, 2021, 01:03:53 am »
There already seems to be a pull request to add support for this variant (and a couple others):

https://github.com/shumatech/BOSSA/pull/124/files

You should be able to just grab it with
Code: [Select]
git clone -b atsamd21dl https://github.com/mistoll/BOSSA and build it as normal. Or do you need help with building it?
73 de VE7XEN
He/Him
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6389
  • Country: ca
  • Non-expert
Re: Add one line of code to an existing GitHub project
« Reply #3 on: December 14, 2021, 01:15:25 am »
There already seems to be a pull request to add support for this variant (and a couple others):
https://github.com/shumatech/BOSSA/pull/124/files

You should be able to just grab it with
Code: [Select]
git clone -b atsamd21dl https://github.com/mistoll/BOSSA and build it as normal. Or do you need help with building it?

Building it is the hard part, see above, might be easier in linux but I assume its not possible to build the windows binary in linux.. removing the GUI from the build might make easier?

These were the build instructions, in addition to the readme:
Quote
I use msys2 with mingw32 7.3.0 to build the releases. I configure wxWidgets with:
configure --disable-shared --enable-unicode --with-zlib=builtin --disable-debug
https://github.com/shumatech/BOSSA/issues/71
« Last Edit: December 14, 2021, 01:18:34 am by thm_w »
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline JesterTopic starter

  • Frequent Contributor
  • **
  • Posts: 859
  • Country: ca
Re: Add one line of code to an existing GitHub project
« Reply #4 on: December 14, 2021, 02:51:09 am »
The issue was that I don't run a Linux machine and trying to compile a branch of that project is beyond my programming skills.

Thanks everyone, one of the members here has managed to compile a branch of the original project , so this is resolved. :-+ :)
« Last Edit: December 15, 2021, 08:14:54 pm by Jester »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf