Hacking COMPLETED My dongle project, internal/external SAMD Loader with CR2032 Holder

MatinatorX

Hardware Developer
Developer
Joined
Jul 17, 2018
Messages
366
Trophies
1
Website
www.dragoninjector.com
XP
2,538
Country
Canada
That's a pretty good idea! I figured I'd have to go hacking the uf2 boot loader. My proposal would be to click reset and hold while the boot loader cycled through 1, 2, 3.

Then, gotta pick a common memory location so the firmware can read it out.

Problem is, click and hold is a bit uncomfortable to do, at least in my opinion.

Your plan is better, but it might also be tricky because clicking again too fast would drop into boot loader. Maybe 2 seconds?

Hmm, I hadn't really thought about messing with the bootloader itself. Is it easy to work with? That would get around a lot of the limitations on this.

2 seconds is probably a safe bet. You'd have to find a comfortable window that's not so short that you risk going into the bootloader, but not so long that injecting the payload becomes a waiting game. Maybe between 2 and 4 seconds?

I haven't really worked with the ATSAMD21 much but I've got a number of projects out in the wild using the ATMEGA328P. There's a slick EEPROM library called EEPROMex that makes reading and writing values to EEPROM a breeze. I wonder if it works for the ATSAMD21...

https://playground.arduino.cc/Code/EEPROMex

EDIT: If anyone feels like testing I can provide some example code.
 
Last edited by MatinatorX,

electronrancher

Well-Known Member
OP
Member
Joined
Aug 4, 2018
Messages
208
Trophies
0
XP
371
Country
United States
Hmm, I hadn't really thought about messing with the bootloader itself. Is it easy to work with? That would get around a lot of the limitations on this.

2 seconds is probably a safe bet. You'd have to find a comfortable window that's not so short that you risk going into the bootloader, but not so long that injecting the payload becomes a waiting game. Maybe between 2 and 4 seconds?

I haven't really worked with the ATSAMD21 much but I've got a number of projects out in the wild using the ATMEGA328P. There's a slick EEPROM library called EEPROMex that makes reading and writing values to EEPROM a breeze. I wonder if it works for the ATSAMD21...

https://playground.arduino.cc/Code/EEPROMex

EDIT: If anyone feels like testing I can provide some example code.

I think on the arduino side, it's nearly the same writing for atmel or arm. Maybe not so much for the boot loader, but I have not dug in to it much.

I'll check out that library you mentioned, thanks! I'd need to do a bit more thinking on the bootloader before I can come up with a plan of attack.
 

mattytrog

You don`t want to listen to anything I say.
Member
Joined
Apr 27, 2018
Messages
3,708
Trophies
0
Age
48
XP
4,328
Country
United Kingdom
That's a pretty good idea! I figured I'd have to go hacking the uf2 boot loader. My proposal would be to click reset and hold while the boot loader cycled through 1, 2, 3.

Then, gotta pick a common memory location so the firmware can read it out.

Problem is, click and hold is a bit uncomfortable to do, at least in my opinion.

Your plan is better, but it might also be tricky because clicking again too fast would drop into boot loader. Maybe 2 seconds?

Gents!

Its easy.

Just write last payload to flash on sleep.

On reset, check payload pointer, increase by one.

Rinse/repeat. I`m working on it now. It works.
 

mattytrog

You don`t want to listen to anything I say.
Member
Joined
Apr 27, 2018
Messages
3,708
Trophies
0
Age
48
XP
4,328
Country
United Kingdom
How do you distinguish between a reset where you want to advance the counter, and a normal power up or restart of searching?

The only way of doing it with one button is to...

I'm paraphrasing here obviously...

Power on...

Get last payload stored pointer from flash. If invalid value, = 1...
Findtegra... Found? Yes... Sendpayload {below } Else no... Increase payload pointer... Blink led... Write new pointer to flash... Sleep

Send payload...
Increase pointer..
Write to flash
Sleep

...start again
 

MatinatorX

Hardware Developer
Developer
Joined
Jul 17, 2018
Messages
366
Trophies
1
Website
www.dragoninjector.com
XP
2,538
Country
Canada
The only way of doing it with one button is to...

I'm paraphrasing here obviously...

Power on...

Get last payload stored pointer from flash. If invalid value, = 1...
Findtegra... Found? Yes... Sendpayload {below } Else no... Increase payload pointer... Blink led... Write new pointer to flash... Sleep

Send payload...
Increase pointer..
Write to flash
Sleep

...start again

So every time you turn on the dongle, if it's not connected to a Switch in RCM mode, the payload switches to the next one?

Not trying to discredit the hard work you've done of course, but that sounds like it could get frustrating very quickly. I think if we can modify the bootloader to change the behavior of the reset button, or use a timed window on MCU startup, it could be a little more user friendly.
 

mattytrog

You don`t want to listen to anything I say.
Member
Joined
Apr 27, 2018
Messages
3,708
Trophies
0
Age
48
XP
4,328
Country
United Kingdom
So every time you turn on the dongle, if it's not connected to a Switch in RCM mode, the payload switches to the next one?

Not trying to discredit the hard work you've done of course, but that sounds like it could get frustrating very quickly. I think if we can modify the bootloader to change the behavior of the reset button, or use a timed window on MCU startup, it could be a little more user friendly.

Yep... You could have it so if it's successful, the pointer stays where is it, on fail, increases.

To streamline the process, my unpublished code adds the ability to rapid change with every reset. Using colours rather than flashing.

Best you can do with one button. Or use a different button... Can do what you like then.

It's all simple really...

Pointers and logic. That's all.

Using openocd is beyond most end users, so low level boot modification isn't an option. (I've been playing and it's do-able)
 
Last edited by mattytrog,

MatinatorX

Hardware Developer
Developer
Joined
Jul 17, 2018
Messages
366
Trophies
1
Website
www.dragoninjector.com
XP
2,538
Country
Canada
Yep... You could have it so if it's successful, the pointer stays where is it, on fail, increases.

To streamline the process, my unpublished code adds the ability to rapid change with every reset. Using colours rather than flashing.

Best you can do with one button. Or use a different button... Can do what you like then.

It's all simple really...

Pointers and logic. That's all.

Using openocd is beyond most end users, so low level boot modification isn't an option. (I've been playing and it's do-able)

It might be worth it if you were shipping a dongle to customers though. For mine, I ended up just adding a second button to make it as user friendly as possible.

Might I ask how you're committing the payload pointer to memory? Are you just writing an uint8_t
to EEPROM using a library? I haven't yet had the time to play around with coding for the ATSAMD21 so I'd be curious how different accessing the hardware functions is.
 

electronrancher

Well-Known Member
OP
Member
Joined
Aug 4, 2018
Messages
208
Trophies
0
XP
371
Country
United States
Using openocd is beyond most end users, so low level boot modification isn't an option. (I've been playing and it's do-able)


Note: Openocd may not be needed for boards that already have the UF2 bootloader. When I build the bootloader, it does generate a UF2 for itself. I believe this is to allow you to update the bootloader on a board that already contains UF2.

Never tried it though...
 
Last edited by electronrancher,

mattytrog

You don`t want to listen to anything I say.
Member
Joined
Apr 27, 2018
Messages
3,708
Trophies
0
Age
48
XP
4,328
Country
United Kingdom
Note: Openocd may not be needed for boards that already have the UF2 bootloader. When I build the bootloader, it does generate a UF2 for itself. I believe this is to allow you to update the bootloader on a board that already contains UF2.

Never tried it though...

Hey electron...

Try the latest build of my multipayload launcher in my thread.

Tell me what you think.
 

MatinatorX

Hardware Developer
Developer
Joined
Jul 17, 2018
Messages
366
Trophies
1
Website
www.dragoninjector.com
XP
2,538
Country
Canada
Batch 1 of the SAMD Loader is officially sold out. Next build will be in a few days - just waiting on components!

Great to hear man! Glad to see your efforts are helping people.

(Also, I can't get the notion of a pick and place machine out of my head. I'm now thinking about grabbing a CHMT36VA in the coming months...)
 
D

Deleted User

Guest
Wow, that was fast! Glad it arrived and is working for you
Quick question, can you explain how to update the firmware to support multi payload option?

I'm confused by "ground D0/D1". All I have is a reset switch and on/off toggle.

Thanks in advance!
 
Last edited by ,

electronrancher

Well-Known Member
OP
Member
Joined
Aug 4, 2018
Messages
208
Trophies
0
XP
371
Country
United States
So if you use the multi loader firmware, it starts with one blink - hekate.

To advance, you'd connect the dot called D1 just above the chip to the dot called GND at the top. A wire, tweezers, whatever should be fine to make a momentary connection.

To store your selection, you ground the line called D0 that is just beneath the PWR LED

--------------------- MERGED ---------------------------

So if you use the multi loader firmware, it starts with one blink - hekate.

To advance, you'd connect the dot called D1 just above the chip to the dot called GND at the top. A wire, tweezers, whatever should be fine to make a momentary connection.

To store your selection, you ground the line called D0 that is just beneath the PWR LED
And to update the firmware, plug into USB and double click reset. You'll get a flash drive called FIRMWARE. Open one of the firmware zip files and drag the 3 files inside onto the flash drive. Piece of cake
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: Other games I can have turned up to like 2X and all kinds of enhancements, Motorstorm hmmm nope...