Arduboy Hat Idea

From what I can tell, they track the rising and falling edges of the pins using interrupts, so it’s possible they would be more processor intensive.

It might be an issue for the speaker,
though I doub’t it would be as much of an issue for the LED given how infrequently it’s used.

Barring the issue with USB usually being 5V,
would normal PEX pins not suffice if there was a suitable system for acting as a host?

Is the protocol not the same even if you use unadorned pins instead of a standard port?

I found a few mbed classes for controlling USB, but none listed the Pokitto’s MCU as being supported unfortunately.
Though that isn’t to say it’s not possible that one does work for the Pokitto or that there aren’t alternatives.


If there’s evidence to suggest that there will definitely be an official ESP32 hat or there will definately be an ESP32 chip added to the Pokitto, or if there’s evidence to suggest it would be cheaper than the 32u4 approach then it’s worth consideration.

Even with those taken into account, I think a full scale emulator that would be compilable for ESP32 might be a bit difficult to find/create.

USB power is 5V but the signals are 3.3V

The USB pins on the 32u4 are dedicated to USB only. They’re not usable as general purpose I/O. You need a USB host to talk to it. Since the standard Caterina bootloader used in the Arduboy expects to talk over the USB pins using USB protocol, that’s what you need to provide.

A custom bootloader could be made to use any pins and any protocol.

If I were tasked with writing a custom bootloader for an Arduboy hat, I’d probably use the 32u4 RX and TX UART pins (0 and 1). I’d use asynchronous serial protocol and ether the standard AVR programming commands or something more suitable for control by the Pokitto.

I was going by Wikipedia, there was no mention of 3.3V.
In that case it’s probably even easier.


So essentially if it were possible to make the Pokitto act as a USB host then the USB connection could be done over plain pins, without an actual USB port, yes?

By “plain pins” do you mean ones that swing from GND to 3.3V? If so yes.

Or, do you mean over general purpose I/O pins? If so, I don’t think so. You would need dedicated USB hardware. I’ve never heard of anyone “bit banging” a USB host controller.

EDIT: After some research, it looks like bit banging USB may be possible. However, I don’t see what the problem would be with making a custom bootloader. You have to burn some kind of bootloader into the 32u4 on the hat anyway, and the hat is dedicated to connecting to the Pokitto. You could probably hack the one used on the Arduino UNO, that uses a serial interface, pretty quickly. You could then wire the 32u4’s USB port to a microUSB connector, so you could use it with Arduboy sketches that emulate a mouse, keyboard, etc.

Aparently it has been done:

And oddly enough a Cortex M0+ is involved.

Unfortunately the link in the article appears to be a dead end.

There’s a surprising number of results for “bit banging usb”.

There’s even a Dr Dobb’s article about it, which is especially relevant

There’s even a line saying:

What I mean is using software in a microprocessor to convert a few general-purpose I/O pins into a USB port.

Caterina is a LUFA CDC derivative using an AVR serial protocol. Just drop the virtual USB port part of the bootloader and recompile to read directly from uart (shouldn’t be too hard, and has been done with 8-bit Caterina versions)

If you’re sure it’ll be easier than getting the Pokitto doing USB over the PEX then I guess I’ll drop that idea.


If we do end up going down that route though,
it might be best to wait for a bit.

Someone on the Arduboy forums called Mr.Blinky (who I assume is the same one with an account here) has been working on an improved version of the caterina bootloader (which can be found here on his github), and it might be worth asking him if we could use that as a base.

It’s mostly done but he recently mentioned a few more things he had in mind for it.

No need for custom bootloaders and bit-banging USB though, right?

Why not just write the hex files to the 32u4 over SPI (in-circuit serial programming)?

Details start on page 368 of the datasheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf

(PS. this is the first time I am realising that Microchip now own all of Atmel’s products?!)

Oh, nice find.

I had just assumed SPI wouldn’t work for some reason, but if it’s possible then I think that’s the best option - minimal fuss.

(Yeah, microchip bought up Atmel late 2015 early 2016 aparently. It just took them some time to get all the documentation shifted over.)

I can design a PCB for this project if anyone wants or no one started before me to design a PCB :smile:

1 Like

Arduboy owners. Help please!
I started working on PCB. I found a schematic of arduboy (page says it’s production schematic). But…
It’s working completely on battery voltage and crystal is 16MHz. There are no boost circuit. Running atmega32u4 with battery is not a good idea (lipo batteries can go below 3v and below 4.5v running at 16MHz is not safe).
Pokitto is 3.3v device. We need boost converter, logic level shifters etc. for this.
Is any arduboy owner faced any problem due overclocking? I want to stay in safe side but for lower production cost we can do overclocking.

This was discussed back in the design stages (literally years ago now :astonished: - time flies!!) and Kevin acknowledged this, and said running it outside of the specifications would be no big deal:

1 Like

This 32u4 hat is quite an amazing project! Any estimate about the hw costs (just the electronics, excluding any 3d printed cover etc.)?

Btw. I might be good to divide this thread to separate “Porting Arduboy games” and “Arduboy Hat” threads.

1 Like

Thanks for information :slight_smile:
We can try running at 3.3v and 16MHz for a while and see what happens. If we see any problem I can add other circuits.
@Hanski production cost is not too much. When I draw a schematic I can say what is the production cost. Also you’re right. We need to split this discussion to another post.

1 Like

Good point. I think I’ll wave my magic wand and migrate all the posts into an ‘Arduboy Hat’ thread.

Edit:
Abracadabra, thread migrated.

2 Likes

Here is schematic. If there is a problem please report me back. I will fix. I appreciate any suggestion :slight_smile:
Schematic:


ArduboyHat.pdf (133.4 KB)
PCB Top:

PCB Bottom:

Edit: XC6201 is actually XC6201P332MR

Edit 2: Added PCB layout images. I will add RGB led later. Board dimensions are 49x32mm. With this dimensions we can use seeed or jlcpcb PCB service with 2x3 panelled boards. It means you can buy 60 boards with just 5 dollar (plus shipping :smile:). Also small pcb means cheaper oshpark boards. I will calculate cost of one populated PCB tomorrow.

4 Likes

Good work! :wink:

(I need to get some sleep…) :sleeping:

1 Like

To be safe, you should connect PD2/RXD and PD3/TXD to UART capable pins on the PEX, in case we want to use a serial based bootloader on the hat, as discussed above:

1 Like

@MLXXXp
Oops… I forget that. Thanks :slight_smile:
I see your posts on Arduboy forum. Your suggestions are really great to make stable hardware. If you want to say something about this project, I glad to hear your suggestions.

Wonderful work! I suppose the PEX male connector in PCB will finally be facing downwards. As the PEX female connector in Pokitto is not in the middle of the device, should the PEX male connector be also more near the right edge on the PCB? To make it to look symmetric when connected.