Author Topic: Noob question: STM32 or ATMega32u4 for custom board using QMK  (Read 10541 times)

0 Members and 1 Guest are viewing this topic.

Offline bogomips

  • Thread Starter
  • Posts: 9
Noob question: STM32 or ATMega32u4 for custom board using QMK
« on: Wed, 01 January 2020, 17:02:09 »
Hi

(2 part question)

1:
I've got a bit of experience having built an ergodox with a Teensy2.0 (ATMega32u4), and have started playing around with QMK source.

I see some boards are designed with STM32 micro controllers...

I'm planning a custom board and have been hoping to add the MC to the PCB directly instead of using another Teensy...

Which is better - if I intend to base my firmware off of QMK?
Do you guys have any wisdom to share?
Which MC is easier to work with, less quirks in QMK / toolchain setup / etc?

2:
I'm still a noob when it comes to electronics design and these smaller MCs (though I've done a few projects with ESP MCs and Arduino IDE).

Once I've selected the MC to use (STM32/ATMega32u4) - how do I prep the raw chip to work with the compiled QMK binary? I've read about some bootloaders?
Do I need that to put the MC into USB HID mode?
Where do I get these and how do I load them onto the raw MC? (Do they come from the factory with the bootloader?)
Can I load the bootloader with MC in-situ on the PCB or do I need an external programmer?

Thank you!

Offline Tom_Kazansky

  • Posts: 409
  • Location: Vietnam
  • Oblivion Knight
Re: Noob question: STM32 or ATMega32u4 for custom board using QMK
« Reply #1 on: Thu, 02 January 2020, 03:00:50 »
Hi,
I only have experience with ATMega32u4.

1. if you can use the MC directly, that would be better.
reasons: (in my opinion)
- it would take less space
- Teensy2.0 would interfere with other components (switches, for example)
- easier for you to arrange pins usage (instead of using fixed pins on the Teensy)

2. soldering small SMD components is hard, it requires proper tools and practices.

about the raw chip:
after soldering required components, you must "program" bootloader into it.
On the design, you must make program pins accessible, check this example:
232890-0
connect these pins to a "programmer" and use software to program bootloader into your MCU (the ATMega32u4, which is now soldered on your PCB).
cheapest option for a "programmer" is an Arduino ProMicro (which I'm currently using) and the software is avrdudess (you also need appropriate hex file to program the bootloader)
after you have programmed the bootloader, you can flash keymap into your keyboard via USB with qmk toolbox. (you need hex keymap file for this task)

Offline Applet

  • Posts: 487
  • Location: Sweden
Re: Noob question: STM32 or ATMega32u4 for custom board using QMK
« Reply #2 on: Thu, 02 January 2020, 08:29:22 »
1. Generally, the ATmega is easier and there is more examples of it used in keyboards online, so I'd recommend that. Make sure to select a QMK compatible MCU: https://github.com/qmk/qmk_firmware/blob/master/docs/compatible_microcontrollers.md

2. If you select a MCU with native USB-support, it will have a USB-bootloader (both AVR and ARM), most PCB's you buy come with just the onboard bootloader, no need for external programmer. You set the MCU in bootloader mode (usually with a jumper or button), then flash the QMK firmware using the USB-bootloader that is preprogrammed to the raw chip from factory.

If you intend to make your own firmware or modifications to QMK tho, you'll most likely need a external programmer and a programming/debugging header on the PCB.
« Last Edit: Thu, 02 January 2020, 08:32:02 by Applet »

Offline bogomips

  • Thread Starter
  • Posts: 9
Re: Noob question: STM32 or ATMega32u4 for custom board using QMK
« Reply #3 on: Thu, 02 January 2020, 13:09:29 »
hmmm, thanks guys.

From this, https://deskthority.net/viewtopic.php?t=7608, I can see there is the DFU bootloader which comes from the factory on the atmega32u4. Also some flavors of LUFA.

What confuses me is speak of an "HID bootloader" - https://www.avrfreaks.net/forum/atmega32u4-hid-bootloader

I mean, we want to build a keyboard, so "HID" seems like the right thing...

I'd prefer the do-nothing approach if DFU will work?

Does DFU offer HID option? I guess it must else it would not be, mentioned here on QMK's page?
https://beta.docs.qmk.fm/newbs/newbs_flashing#dfu

Sounds like QMK Toolbox already installed the Windows drivers for DFU:
https://qmk.fm/toolbox/

So I guess all I need to do is grab some 32u4 chips, pop one in a reference design - maybe this one: https://www.pjrc.com/teensy/schematic2.gif

Hook up the USB, and off I go ...

Offline Applet

  • Posts: 487
  • Location: Sweden
Re: Noob question: STM32 or ATMega32u4 for custom board using QMK
« Reply #4 on: Fri, 03 January 2020, 16:53:11 »
I do not know what they mean by HID bootloader, HID is how the device is recogniced when you run your application/firmware. If you flash QMK, it will show up as a HID device.

Yes, the reference design for the teensy is a great start, you can use that, then add the keyboard matrix on the free pins.
« Last Edit: Fri, 03 January 2020, 17:13:01 by Applet »